Nanode / twitter blink example

Here are some notes on my adventures trying to make an ethernet connected Nanode that blinks when certain words are mentioned on twitter. I was working with Mac OS X and there were a few gotchas, so I’ve mentioned them here so I don’t forget and in case anything is useful to anyone else. There’s an exciting video of the resulting beast here featuring the acrylic case from the excellent and fast SKPang. The code (an unholy mixture of C++ and Processing) is here. I was coming at this as someone who’d previously only got blinking and similar going on a Arduino Duemilanove.

Getting the Nanode working

  • Buy a Nanode (ethernet Arduinos are also available, I chose a Nanode because it was recommended to me, also their support is very good and it arrived very quickly. I think in retrospect it’s a bit hard to use for a real novice like me, though I enjoyed finding out…). I got a prebuilt Nanode RFX (which has a Hope RF shield and a microSD slot). You need to also buy a Programming Adaptor, which you need in order to talk to a Nanode as the USB programming interface isn’t built in.
  • Download the Arduino IDE
  • Install the FTDI driver (see this comment, which helped me out a lot) – installing it will restart your computer. This is a different driver to the one you use with a standard Arduino – see the Arduino guide if you’re not using a Nanode
  • Open the blink Arduino example (under file -> examples -> Basic, or here) and change the output to 6
  • Connect the Nanode to the Mac using the FTDI cable using a USB cable
  • In the IDE, set the port to the new driver and the board to ‘Arduino Duemilanove with ATMega 328’
  • Compile and run the Blink example on the Nanode
  • The default LED on the Nanode should blink
  • Celebrate

Connecting up Ethernet

  • Install Ethernet Library -> cd ~/Documents/Arduino; mkdir libraries
  • Download EtherCard library and unzip it in this directory
  • Restart the Arduino IDE and you should see sketch / import library – a new library (not Ethernet but EtherCard at the bottom)
  • Start a new sketch
  • Next I copied and pasted this WebClient example from EtherCard into a new file, and that formed the basis of my code.
  • Click on sketch / import library – and import EtherCard – and it puts some import statements at the top
  • Add this at the top: #include <stdint.h>
  • Connect it to an ethernet connection (e.g. I shared airport to ethernet connection on my mac)

The one problem I had was that it appeared to work intermittently, or once per restart of the board. I think this must have been some sort of race condition. Anyway, I solved it by adding a tiny wait after these two lines:

void loop () {


 delay(100); //<--  add this.


If you look then at the serial monitor (button with the little magnifing glass on the top right of the Arduino IDE), you should see some results. Click restart on the Nanode if not. It takes a while to get the IP address.

A couple of useful links:

5 thoughts on “Nanode / twitter blink example

  1. Wonderful! Riveting video 🙂

    I’m a bit jealous you’ve got it together to do some hardware hacking, feeling very left behind. Not having hands-on makes it more difficult to think about this stuff, and it does sound fun…

    btw, any idea offhand how much more effort/cost it would be to use a wireless connection?

  2. Thanks for posting the writeup, now I can keep some notes here.

    I tried getting this running again (after a few weeks without time to play), and got stuck. I got confused about the two USB cables, plus which way up the adaptor for one of them went. And somehow started the Arduino IDE app on my OSX laptop when it wasn’t properly connected. What rescued me: restarting the IDE after getting the cables right. After doing so, I had two more devices in /dev/ (tty.SLAB_USBtoUART and cu.SLAB_USBtoUART). I don’t know the difference yet but /dev/tty.SLAB_USBtoUART worked and I can send my slightly modified Blink2 happily to the device. Here it is for good measure. Oh, also remember that the serial monitor needs to be met to match the serial speed chosen in the code.

    int i, l, ontime;

    void setup() {
    // initialize the digital pin as an output (our LED…)
    pinMode(6, OUTPUT);
    i = 10;
    l = 1000; // not 800; dies at i=81
    Serial.println(“Hello World, this is Blink2.”);

    void on() {
    digitalWrite(6, HIGH); // set the LED on
    void off() {
    digitalWrite(6, LOW); // set the LED off

    void loop() {
    ontime = 10 * i;
    delay(l – ontime);

    if (i < 100) { i = i + 1; }
    else { i = 10; }

    And for completeness, here's link for that XMPP proxy/wrapper I made using node.js:

  3. Trying the ethernet bit, I’m consistently getting

    DHCP failed

    (with repeated restarts of nanode, and trying ‘net by OSX Internet Sharing or by plugging it into an independent ethernet port)

    Last time I tried, I ended up watching dns messages via Wireshark on the OSX machine; and I also tried some other arduino ethernet libraries. Not sure what to try now, maybe bypassing the dns bit?

  4. Meanwhile, elsewhere on the Internet:


    21:56 danbri: hi folks. I’m following libby’s nanode/ethercard recipe here – – but get stuck with ‘DHCP failed’ each time
    21:56 danbri: i’m trying to run
    21:56 danbri: could someone advise on how i’d bypass dns by hardcoding ip numeric address? I don’t know the APIs….
    22:05 natm: danbri: have a look at ether.hisip and ether.hisport
    22:06 danbri: great, that gives me useful looking search results … thanks natm 🙂

Comments are closed.