AmbientMonitor – W5100 client

luca 14/02/2015 0

Some time ago, I published my AmbientMonitor project: a thermometer and hygrometer based on Arduino and an AJAX web interface.

To connect Arduino to the network I chose a shield based on the ENC28J60 chip; Danny Kimbler sent me a sketch that instead uses the official shield (W5100 chip) and the DS18B20 temperature sensor:


I published his sketch in my Github’s repository, let’s describe some code:

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x7D, 0x54 };
byte ip[] = { 10, 150, 41, 3 }; 
byte subnet[] = { 255, 255, 255, 0 };
byte gateway[] = { 10, 150, 41, 254 };

The network configuration (IP address, netmask…) is done at the beginning of the sketch and must be changed accordingly to the particular network you’re connecting the shield to.

OneWire oneWireIndoor(TEMPERATURE_INDOOR);
DallasTemperature sensorIndoor(&oneWireIndoor);

Two libraries are needed to get data from the sensor:

In the example, the sensor is connected to Arduino’s PIN5.

temperatureIndoor = readTemperatureCelsius(sensorIndoor);

The sketch sends the data (JSON format) to the AJAX webpage… the sensor chosen doesn’t provide humidity values, therefore Danny sends the temperature twice…

float readTemperatureCelsius(DallasTemperature sensor) {
 float temperature = sensor.getTempFByIndex(0); 
 return temperature;

The readTemperatureCelsius function leverages some methods of the DallasTemperature library to get the actual temperature from the sensor.

Many thanks to Danny for having sent me his sketch: now you can try my AmbientMonitor project with both the most used ethernet shields for Arduino!

Leave A Response »

This website uses cookies to ensure you get the best experience on our website maggiori informazioni

Questo sito utilizza i cookie per fonire la migliore esperienza di navigazione possibile. Continuando a utilizzare questo sito senza modificare le impostazioni dei cookie o clicchi su "Accetta" permetti al loro utilizzo.