I had put the Arduino stuff on the back burner for awhile, concentrating on some web development work but I needed to track temperature at work and attempt to catch the air conditioning in the act of malfunctioning. I decided to finish my porting the temperature controller I made in 2010 with the Arduino / Ethernet shield to the London Hackspace – Nanode-5, all with pretty good results.

If you look closely you will see a TMP-421 temperature sensor board installed on the analog header, as outlined by Liquidware and ModernDevice, the vendor of this little breakout board. It utilizes the I2C port which occupies two of the analog I/O and the other two are used as power and ground. In this configuration it is possible to power down the chip for purposes of a reset or something, but this functionality is not used here.
The accompanying sketch and php scripts on github basically do the following.
- Initialize the ethernet chip
- Initialize the I2C bus and the TMP-421 chip
- Read the temperature every 5 seconds
- Push the temperature to a waiting mySQL database every 60 seconds
- ???
- PROFIT!
I want to add a rudimentary thermostat and relay driver, and a simple webpage to read the temperature on demand and set the thermostat setpoint. So keep an eye on this blog and github for updates to the code. The final feature list will be…
- Temperature reporting and databasing (DONE)
- Temperature graphing (DONE)
- Simple hysteresis thermostat (IN PROGRESS)
- Webserver to display current temp.
- Webserver sets setpoint, persistantly through PROGMEM
Oh, I mentioned graphing…. as always click to display the latest graph…

I will release the graphing code later when I have added some functionality and cleaned it up a bit. But if you want to play with graphing in your own, this is based on the Flot package. It’s a little old now, but I am hesitant to change, it works! But there is better out there and I’ll eventually get around to evaluating them.
And finally, to get this working on your server, first you will need a webhost with PHP and mySQL. There are many packages out there, look around. Then you will have to change the following lines of code,
In nanode_temperature.pde, between lines 45 to 60 change these parameters to match your setup
//**************************************
//**** BEGIN USER DEFINED VARIABLES ****
//**************************************
#define POST_RATE 60000 // rate to post to the db milliseconds (60 seconds)
#define UPDATE_RATE 5000 // rate to read the RSSI milliseconds (5 seconds)
#define TIME_OUT 30000 // time to wait for a response from internet (30 seconds)
float setpoint = 70.00; // default setpoint upon first use
float differential = 2.50; // differential
char HOSTNAME[] PROGMEM = “hostname.com”; // hostname of a shared hosting server here
static byte hisip[] = {***,***,***,***}; // ipaddress of the server here
#define HTTPPATH “/somewhere/nanode_temperature.php” // path to the PHP script
#define DATABASE “nanode_temperature” // database name
#define TABLE “node1″ // table name
//**********************************
//*** END USER DEFINED VARIABLES ***
//**********************************
Also between lines 77 to 80, change this to your network scheme…
#else
static byte myip[] = {192,168,2,202}; // modify these addresses to match
static byte gwip[] = {192,168,2,1}; // your local network scheme.
#endif
And finally in line 260, change the following line to reflect the path to your php script,
ether.browseUrl(PSTR("/path/nanode_temperature.php"), paramString, HOSTNAME, my_result_cb);
In php.db, you must put your database credentials in there, and the database name you chose above,
$host = localhost;
$user = username;
$password = password;
$database = databasename;
Thats it! That should get you going with the functionality provided. I’ll probably be adding more fields to the table, with on/off times, setpoints and the like, but I will write the php script such that it automatically adds them to your existing database, to make things simple.