Archive

Archive for March, 2009

Linking Arduino to the outside world.

March 15th, 2009

I had a mission for this weekend. My mission was to have my Arduino talking to a website posting some information which I could then import in to Wordpress using a custom plugin. This was going to be a bit of a mission as I had not used the ethershield for Arduino before and I’ve not done any PHP programming for some years.

I started off on Saturday with getting my Arduino up and running, only to find that my Dallas DS18B20 thermometer no longer appears to work. After checking out the Maplin web site and a quick visit to Bardwell’s on London Road, Sheffield I gave up on the idea of obtaining a new one that day. The temperature part of the project would just have to wait so for now I’m just posting a bit of static data.

The Dallas DS18B20, Ethershield and LCD keypad that I used for my project can all be purchased from http://www.nuelectronics.com/

The Ethershield is a wired ethernet shield for the Arduino. It comes with the necessary library to get it working along with some excellent examples for ping, webserver and web client functionality.

I used the web client example to post information to a VMWare Ubuntu machine I have running on my local network with Apache, PHP and Wordpress installed.

Once I had the Arduino posting some information, the next step was to write some PHP code to accept the data and write this to a file which I could then use as a log of information. The log would contain many lines. Each line holds the date, time and data which I have posted from the Arduino.

PHP Code

PHP Code

Once I had the file being generated I decided that the next thing to do would be to introduce the LCD Shield so that I could watch what the Arduino was doing in the different stages of posting and when the next post would be.  Nuelectronics came to the rescue with the LCD Keypad shield. Just like with the ethershield, using the LCD keypad is made simple to use with the library that can be downloaded from the website. In no time at all I had the LCD displaying what the little device was doing.

The link to the sketch code that I used can be downloaded from here.

The code is not currently working for the thermometer reading as when I un-comment the code in the GetTemperature function the sketch stops working. If I comment it out it starts to work again. This is without even calling the function. If anyone can tell me why this would be happening I would be most gratefull.

The next stage of this project is to build a plugin for Wordpress to be able to read the data file and display this information on my Wordpress page. A couple of things are needed in order to be able to do this. 1) I need to work out how to define a gateway IP address for the ethershield to be able to post out to my live website and 2) I need to get hold of a new DS18B20 thermometer. In the meantime I’ll start to look at building the plugin for Wordpress.

As soon as I have the pictures of the hardware set up from my phone I’ll post these along with an update on where I have got to.

Also, if anyone can think of a neat project with Arduino I’d love to here from you and let’s see if we can put something together. One of the things I would like to do in the future is to drive some motors which I’ll recycle from some old floppy drives, hard disk and CD drives which I have lying around.

admin Arduino , , , , ,