Using the Raspi as an Ethernet shield

[Alexandre] wanted to set up a web-based temperature logger with his Arduino, but found the Arduino Ethernet shield a little finicky. Since his Raspberry pi was just delivered, he figured he could use the Raspi as an Ethernet shield with just a little bit of coding.

After [Alexandre] set up his Arduino to send a thermocouple through the USB, the only thing left to do was to add node.js to the Raspi’s Debian installation. Every five minutes, the Arduino wakes up, takes a temperature reading, and sends it over to the Raspberry pi. From there, it’s easy parse the Arduino’s JSON output and serve it up on the web.

In the end, [Alexandre] successfully set up his Raspberry pi as an Ethernet shield to serve a web page displaying the current temperature (don’t F5 that link, btw). One interesting thing we have to point out is the cost of setting up this online temperature logger: the Arduino Ethernet shield sells for $45 USD, while the Raspberry pi is available for $35. Yes, it’s actually less expensive to use a Raspberry pi as an Ethernet shield than the current Arduino offerings. There you have it, just in case you were still on the fence about this whole Raspi thing.

47 thoughts on “Using the Raspi as an Ethernet shield

    1. You cannot buy a Raspberry Pi at the moment, they are on a HUGE waiting list and only when you are on top of the list you will receive a special code to access the store and order one…

      1. This is why the Raspberry Pi is such a turn off. As if the proprietary Broadcom chip wasn’t bad enough, the Raspberry Pi “foundation” could not have done a worse job on execution. Why does anyone need a UK-based foundation to distribute these devices which are all made in china? With that model, nobody will get their boards for the hyped price (or even close) in a reasonable amount of time.

        The allwinner devices are a lot more sensible. Made in china, sold by chinese (by normal channels) and for reasonable prices (never $25 or $35, but those prices are a marketing gimic). Nobody cares if these devices are not marked to some nonexistent “hacker community”, schools, or 3rd world countries. BTW, what country plays the biggest role in African development? You guessed it, China. The Raspberry Pi foundation is based more on hubris than practical thinking.

      1. @ Fozz, Pat

        I must have gotten on the lists earlier than I realized then. I received mine, through Newark (it was shipped from KS, not from overseas) about two weeks ago.

    1. If I were a Raspi, I would be able to read sensors. It looks like he could have not had female connectors to plug into the Raspi’s io’s. Or maybe he just didn’t think about it?

      1. There’s a “shield” on the stocks for the RPi with ADC/DAC called the “Gertboard”.

        The good thing or snag about the RPi is it’s so cheap and easy to do stuff with that you end up using it for tasks that could be said to be beneath it. I’m using mine as a print server at the moment due to a small accident involving a child, my old print server, and a can of fizzy drink. It took about 15 minutes to rig and works perfectly. The RPi is actually cheaper than the replacement USB->ethernet server, though this may just be the thieving nature of my fellow Brits.

        Don’t hold your breath for an RPi though – The software is a bit rough at the moment and doesn’t make best use of the GPU yet, amongst many other rough edges. It’s getting better pretty fast though.

    2. ADC chips are cheap and easy to use. I know Linear has some pretty cheap and capable ones out there that use SPI, while Maxim sells some that are a bit more expensive that use I2C. Both will give you better resolution than the onboard ADC on the Arduino. You can even daisy chain them for more channels.

  1. Most likely he uses the analogue in on the Arduino, ras pi only has digital inputs.

    Does scream out for a real IO sheild for the RasPi, should dominate the Arduino then.

    1. They are turning up honest, just allow around two months for them to arrive.

      I’ve now received two:
      Ordered 29th Feb, shipped 4th May.
      Ordered 27th of April, shipped 20th of June.

    2. Been there, done that: it doesn’t work!

      As soon as you attach the non USB-compliant USB-AVR device, the TL-WR703N is spitting USB error before even enumerating it :)

      Unless you really have it working?

        1. @rasz: Well maybe I am doing something wrong, but a mouse, a keyboard and a memory stick are working fine on the TL-WR703N, and not the AVR-USB ATTiny, which is working fine on my Linux laptop PC.

          Did you used diodes, LEDs or Zeners for the +5V/+3V3 drop?

  2. reeeally? cheaper? looks like eventually the arduino(IDE) will soon be centered(reworked but hopefully backwards compat) around the raspi.
    i think its safe to say at that point raspi will add dedicated analouge in and dedicated PWM out chips, or again, a shield.

    who knows, maybe arduino(IDE) will soon grow to include all (modern) uC’s like a modern version of SDCC
    (if im right, SDCC did all the popular uC’s of it’s day, just no built in uploader…)

    1. You speak as if software development magically happens merely because cheap hardware exists.

      Even if someone does support the Pi in the Arduino IDE (a pretty big “if”), that project would exist only as a fork or 3rd party add-on. The Arduino developers never publish the official IDE with support for any 3rd party boards, but they (try to) make an architecture which makes 3rd party boards possible.

    2. Not a chance.

      To take advantage of all the features on a really complex ARM chip like on the Pi, you really need Linux, drivers, and of course the closed-source binary code from Broadcom.

      You could still emulate an Arduino in Linux, or provide some Arduino-like environment. And it would run faster than a real Arduino. But not with absolute real-time response, and that is a fundamental difference that will break some code and hardware interfacing techniques.

      Also, consider that you can get a bare AVR chip in DIP package, slap it on a breadboard, and load the Arduino firmware. Then add a Microchip Ethernet IC, also in DIP. A few support components and you have Arduino with Ethernet on a breadboard for under $10. The Arduino and Pi still have their own niches.

      No need to complicate the Pi with extra features like analog and PWM, which may or may not be used, and will increase the size and base price. That can easily be added by the user, even without a shield; wire jumpers work just fine. There is an Arduino shield adapter in the works though. And the Arduino and Pi can work together to combine their abilities, as demonstrated in this article.

      Arduino has been ported to some Microchip and simple ARM uC’s. Which is good. But personally, I hope Arduino doesn’t evolve to providing a Linux target environment. I’m fundamentally opposed to renaming existing things for marketing purposes. It’s bad enough Arduino already has a significant number of people calling C programming “wiring”. If Linux folks start calling it that too, I’ll certainly go postal.

    3. I seriously doubt the Arduino team would change architecture, and I doubt RaspPi team will fork Arduino IDE.

      But I dont doubt someone else will get Arduino bootlader emulated on Pi… Which as already noted won’t run identically.

  3. Using an entire Arduino is already a waste by itself (I use it to program my chips, then I make stand-alone board) but this is terrible; at least components-wise: the webpage is really nice and the project’s quite cool.
    Please, consider replacing your Arduino with a digital temperature sensor or I2C ADC + your current sensor.

    1. Who cares about how many components you use? The only two things that matter are the cost and power. Here, the raspi is cheaper, but it’s also *ludicrously* higher in power. The Ethernet shield is less than 1W, and the raspi is more like 3-3.5W.

      Not to mention that the raspi likely has a much, much longer time to initialize after power-on, so conserving power by periodically shutting down isn’t all that helpful.

      1. 3.5W is not a trivial amount of power. It is trivial if you’ve got wall power, and you only have one of them. It’s not trivial if you don’t, or have a bunch – and the RasPi doesn’t do POE, so unless you feel like running 5V to your device, 3.5W just to get Ethernet is a big power suck.

        And no, ‘ludicrous’ isn’t crazy. Heck, the Arduino’s ethernet shield – at ~1W – is fairly crazy for Ethernet connectivity on its own. 3.5W just to add Ethernet is insane.

  4. Buy the Raspi from farnell in the UK and I assume any element14 store elsewhere.

    Since the Raspi has GPIO exposed you’d hope it’d be possible to just code for it now.

  5. Oh my. Can’t we ever have a discussion about the Raspberry Pi without fighting about it’s meaning?

    Let’s at least be organized about it!

    Issue 1: That Raspberry Pi sure is cheap, but I can’t gosh darn find it anywhere!

    Answer: It’s assumed that they’re going to make more considering that there’s a virtual “line around the block” for them. Be patient and stop whining. The “blogosphere” was a huge echo chamber for this product about a year before it was launched. You had your chance and you should learn to have realistic expectations. They likely won’t be cranking these out steadily until another year or so (if that).

    Issue 2: I think the Raspberry Pi will be a great tool for getting young people involved with computer science, applied mathematics, etc.!

    Answer: Let’s be real for a moment. The majority of the buyers (model B only, right now) seem to be from first-world countries. Here computers are very accessible already, so this is pretty much just a hobbyist’s toy for the time being. It won’t spark a revolution over here, but it should be making people question what it really means to “engineer” software in a world where there are fewer and fewer consequences for what I like to call “bad grammar” in programming caused by ignorance (brought to you by cheap computers); e.g. “Why bother learning C and assembly for AVR or PIC, when I can blink an LED in a scripted language on a Raspberry Pi?”

    Issue 3: The Pi will never get the Linux support it deserves without full documentation.

    Answer: This is simply not true. The BCM2835 datasheet has been out for almost 5 months now and while it’s abbreviated, it enough to build your own Linux kernel, write custom drivers for the peripherals onboard, and more. It’s very educational stuff. It’s not the whole enchilada, but then again, the core of the Raspberry Pi community wasn’t disillusioned by this product in the way the “blogosphere” was.

    Feel free to append my list (or correct it!) with common misunderstandings or plain stupid stuff you’ve heard about this thing. I figure I might at well say things out of my ass while everyone else is too.

  6. Not sure what addon the pi would need to rival an arduino, perhaps, a breakout board with an arduino on it….

    There is an add-on board coming, called gertboard, it uses an atmega328 chip, shock, horror, they really are adding an arduino to a pi, who would’ve ever imagined that ;) you could just add an spi io analog expander to the pi but really, why reinvent the wheel if you don’t need to?

    Lastly, I think there has already been some work on wiring pi, don’t think it’s in the IDE yet but it certainly has the look of arduino coding to it, as well as you being able to code in C for it, you can also bash script it too.

  7. If I have to do the same project, I’d think of it in reverse. Instead of thinking of Raspberry Pi as arduino’s ethernet shield, I’d think of Arduino as the raspberry pi’s sensor measurement platform. Let the Pi do the logic (like waiting for 5 seconds and then querying the arduino for sensor data), not the other way around. In other words, make the arduino logic dumb, and putting the logic of your application in the Pi. Advantage? The Pi is easier to code in, you can do a lot more, and you relegate to arduino what it does best — be the low-level guy.

  8. im glad my faulty opingion was met with real information. thank you. i stand corrected.

    … but its still a great price on an SBC you can program without cracking(reverse engineering) anything first :)

    1. This reminds me of an old usenet wisdom: If you want to gain more knowledge on a particular topic, just post a strongly worded, but wrong opinion, then start looking for replies that starts with the word “actually”. LOL.

  9. It is useless. Use limited device with real cost about $60. Plewase don’t forget about shipping and taxes.
    TP-link WR703N cost $22 and have WiFi (PandaWill, eBay, AlyExpress, etc) with shipping.
    ENC28J60 modules cost $10 (eBay) with shipping.

  10. At this point isn’t this just a Raspberry Pi with an Arduino attached?

    We already did that ages ago.

    and I’m sure I’m not the only one.

    With regards to the Arduino IDE we had that all going working and pushing code to an Arduino from the ‘Pi and was demonstrating it to the masses at the Derby Mini-maker fare.

    Let’s start making stuff with the HW rather than saying it will be good when they all sort it !!

  11. interesting to read these old “Raspi suks! will never be popular! comments. 12 months later, my employer has bought over 750 of them and we have plans to quadruple that in the next quarter, all running Raspian. I initially ordered one personally, curious to see what the fuss was all about. I’m now on my tenth, all going strong doing jobs around the home. Haven’t used any arduino kit since then and I was *hardcore* ATmega. RasPisare now made in UK, with double initial ram for the same price :/ it seems I was a fool to doubt and criticise them

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s