AmbientMonitor – W5100 client

by luca
0 comment

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!

Related Posts

Leave a Comment

one + six =