The DS18B20 library is very simple to use, just one line to check the temperature on the sensor:
#define ONEWIREBUS 9 // define the pin connected to the 18B20+ Dline
void setup()
{
Serial.begin(9600);
pinMode(8,OUTPUT);
digitalWrite(8,HIGH); // pin 8 is used to power the 18B20 ( +Vcc )
pinMode(10,OUTPUT);
digitalWrite(10,LOW); // pin 10 is used to power the 18B20 ( GND )
}
void loop()
{
TEMPERATURE t;
if (DS18B20.read(ONEWIREBUS, SKIPROM, RES9BIT, &t))
{
if (t.sign) Serial.printf("-");
else Serial.printf("+");
Serial.printf("%d",t.integer);
Serial.printf(".%d",t.fraction);
Serial.printf("\n\r");
}
}
Now it's time to connect the DS18B20 and the zigbee shield to have a wireless temperature sensor !!
Front view
1 comment:
Wow, great article, I really appreciate your thought process and having it explained properly, thank you! I really like this post.
Post a Comment