Sunday, January 29, 2012

Step Five: Interfacing with the Ethernet Shield

In order to get up and running with the ethernet shield, we can use an example sketch that ships with Arduino 1.0.


The TwitterClient example is most useful for a number of reasons:
1) The sketch behaves as a client (rather than a server which would be more difficult to configure)
2) A regular polling period of 5 minutes is written out of the box.

You can find this source code and documentation on the official arduino.cc website. A special thanks to Tom Igoe for writing the original!


With a hardcoded mac address and IP, my linksys router picked up the arduino and I could see recent tweets right away. Sometimes, I had to reset the arduino (using the on-board reset button) in order to have the router recognize the device. If you are having trouble, I would experiment with resetting the Arduino, and maybe even integrating DHCP.

In future posts, we will make some light modifications to this sketch to better suit our purposes:
1) Swap the api.twitter.com hostnames with our app engine hostname.
2) Pass a payload of temperature and humidity data in the query string.

TLDR;

Use the example TwitterClient example that ships with Arduino 1.0 - it's really great and only requires minor adjustments for this project.

No comments:

Post a Comment