Using DS18B20 or DS18S20 with Moteino

Started by hexibot43, December 06, 2013, 02:02:23 AM

damonb

Here is the code for my temperature logging node (using JeeNode μC hardware).
All the magic is done by the libraries:
JeeLib (http://jeelabs.net/pub/docs/jeelib/) and
OneWire (http://www.pjrc.com/teensy/td_libs_OneWire.html)

Much credit due especially to Jean-Claude Wippler for his excellent site http://jeelabs.org/. It is a gold mine if you are just starting out with this stuff.

john k2ox

Just thinking.  The size of the resistor has little to do with battery drain.  The block diagram indicates the resistor simply slows the current that charges an internal capacitor.  Once the cap charges, no further current flows into it.  That is, until it flows out to power the chip while it's output is low.

The higher the resistance the longer to recharge, but total energy used is the same.  Too high an 'R' limits how soon you can measure temp a second time.  Too small and the chip can't pull it to a logic low.

damonb

This is a bit bizarre but I just stumbled across this thread from 5 years ago while googling for something else. Unfortunately I never saw the replies and hence have never answered.
Apologies everyone!

My DS18B20 sketch is now attached.
It uses JeeNode not Moteino libraries, but you should be able to get the general idea. (Incidentally you can use the JeeLib library with Moteino hardware - at least I have, YMMV) The JeeLib scheduler class is the magic sauce, allowing different events to be scheduled to be triggered on each pass through loop().