Ralph once again you have come to my rescue. I have been banging my head on the wall trying to run four temperature controlled relays with one Arduino in my greenhouse. Your explanation was clear and concise. Thank you !!!!
Glad to help, David. Coincidentally I have just used three DS18b20s in my workshop's Smart Heater Controller although on separate microcontrollers. There's a lightweight library if you only use a single DS18b20 per pin by Rob Tillaart github.com/RobTillaart/DS18B20_RT
Ralph, I like how you asked us (the viewers) to learn the "hard way" rather than get the library. You pulled the datasheet and dove into. That is a way to teach electronics and programming. I applaud your style and encourage you for more. Thank you for the video.
Glad you like both the video and the methodology! Of course, there are many times when it would be too cumbersome to do it 'the hard way' so a library is essential but I always try and show what's going on behind the scenes too. Thanks for posting.
Ralph, thanks for taking the time to go that one step further down to interrogate the sensor. I think we all get frustrated by libraries sometimes. Videos like this will give confidence to open up the library and poke around. You touched on parasitic power. This is worthy of expansion if you ever take us down into the low voltage
Here is the multisensor code using the DallaTemperature library - RSB did not seem to include it in the comments - sorry for not adding any code comments ------------------------------------------------------------------------------------------------------------------------------- //Temperature Sensore read #include ; #include ; #define sensorCount 2 #define ONE_WIRE_BUS 11 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature tempSensors(&oneWire); void setup() { Serial.begin (9600); tempSensors.begin(); } void loop() { tempSensors.requestTemperatures(); for (int cnt=0; cnt < sensorCount; cnt++) { Serial.println("Sensor " + String(cnt) + ": " + tempSensors.getTempCByIndex(cnt)); } delay (1000); }
Hi Geoff, I've checked this, and the code and other scripts were in a comment (which I've now pinned) but I've also moved all that info to the video description too, so others can find it. Thanks for pointing out that it did not seem attached to the video stuff.
great lesson! now how do i do i turns on a remote led when a certain temp. is reached and turns off the led when the temp. decreases to a certain level. thanks.
You just read the temperature from the DS18B20 and use a simple 'if' statement to control the output on your chosen GPIO pin. Assuming you have interrogated the DS18B20 for the current temperature and have already defined your led pin you might do something like this: if (temp> 20) { digitalWrite(ledPin, HIGH); // LED on } else { digitalWrite(ledPin, LOW); // LED off } Remember to protect the Arduino from excessive current flow by including a 150 ohm resistor from the GPIO pin to the LED.
Hi Robert, I've had to move the files today as Dropbox has changed the way files are shared, very annoying (for us both!). The new links are in the video description, please do let me know if you have trouble accessing them. Thanks for bringing this to my attention.
Ralph once again you have come to my rescue. I have been banging my head on the wall trying to run four temperature controlled relays with one Arduino in my greenhouse. Your explanation was clear and concise. Thank you !!!!
Glad to help, David. Coincidentally I have just used three DS18b20s in my workshop's Smart Heater Controller although on separate microcontrollers. There's a lightweight library if you only use a single DS18b20 per pin by Rob Tillaart github.com/RobTillaart/DS18B20_RT
Ralph, I like how you asked us (the viewers) to learn the "hard way" rather than get the library. You pulled the datasheet and dove into. That is a way to teach electronics and programming. I applaud your style and encourage you for more. Thank you for the video.
Glad you like both the video and the methodology! Of course, there are many times when it would be too cumbersome to do it 'the hard way' so a library is essential but I always try and show what's going on behind the scenes too. Thanks for posting.
Ralph, thanks for taking the time to go that one step further down to interrogate the sensor. I think we all get frustrated by libraries sometimes. Videos like this will give confidence to open up the library and poke around. You touched on parasitic power. This is worthy of expansion if you ever take us down into the low voltage
I'll certainly consider such a video on LV, it's on my backlog (which grows daily!). Thanks for posting.
Works a treat and so easy
Glad you found it useful, Geoff.
Here is the multisensor code using the DallaTemperature library - RSB did not seem to include it in the comments - sorry for not adding any code comments
-------------------------------------------------------------------------------------------------------------------------------
//Temperature Sensore read
#include ;
#include ;
#define sensorCount 2
#define ONE_WIRE_BUS 11
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature tempSensors(&oneWire);
void setup() {
Serial.begin (9600);
tempSensors.begin();
}
void loop() {
tempSensors.requestTemperatures();
for (int cnt=0; cnt < sensorCount; cnt++) {
Serial.println("Sensor " + String(cnt) + ": " + tempSensors.getTempCByIndex(cnt));
}
delay (1000);
}
Hi Geoff, I've checked this, and the code and other scripts were in a comment (which I've now pinned) but I've also moved all that info to the video description too, so others can find it. Thanks for pointing out that it did not seem attached to the video stuff.
great lesson! now how do i do i turns on a remote led when a certain temp. is reached and turns off the led when the temp. decreases to a certain level. thanks.
You just read the temperature from the DS18B20 and use a simple 'if' statement to control the output on your chosen GPIO pin. Assuming you have interrogated the DS18B20 for the current temperature and have already defined your led pin you might do something like this:
if (temp> 20) {
digitalWrite(ledPin, HIGH); // LED on
}
else {
digitalWrite(ledPin, LOW); // LED off
}
Remember to protect the Arduino from excessive current flow by including a 150 ohm resistor from the GPIO pin to the LED.
Is this code still available? Dropbox can't find it. Thank you!
Hi Robert, I've had to move the files today as Dropbox has changed the way files are shared, very annoying (for us both!). The new links are in the video description, please do let me know if you have trouble accessing them. Thanks for bringing this to my attention.
Thank you!
The unique 64-bit number in the DS18B20 is not its address it is the serial number, it's address I think is 0x28
Thank you for your feedback, Graham Gillett, noted and appreciated!
Doesn't really explain how it "finds" the sensors
The library abstracts that away. Which is why I don't like using libraries (initially).