ST_Anything: OneWire DS18B20 Temperature Probe for Aquarium Control

arduino
temperature
thingshield

(Gnomesoup) #1

Thank you to @ogiewon for the ST_Anything library. I am very new to Arduino and fairly new to coding so your examples and library have been a huge help so far.

My end goal is to create a simple aquarium controller with an Arduino mega that will handle the lights, check temperature and eventually monitor ph and other stats of a small 5 gallon tank. I want to use SmartThings to send the information to the cloud and allow me to make setting adjustments.

I have a DS18B20 temperature probe that I am using to check the water temperature. The probe uses the 1-Wire Protocol which I’ve gotten to work successfully using the OneWire library. I have been able to use the sendSmartString() function in the loop to send the temperature to smartthings. While this works, it is not very elegant as I can not control how often it sends information and I think it conflicts with how other messages are being sent. I believe the right way to go about adding the probe would be to create a library similar to ST_Anything_temperaturehumidity used for the DHT22 sensor so I can control the polling interval and offset.

Does anyone have any suggestions on where to start with creating a library for 1-Wire devices that is compatible with the ST_Anything library?


(sidjohn1) #2

The Fibaro Z-Wave Door/Window Sensor natively supports the DS18B20 temperature probe, just uncomment the temp lines in the devicetype and your good to go.


(Dan) #3

@gnomesoup

I actually have a friend who is using the DS18B20 temperature sensor in a Home Brew application to monitory temperature. He is using it in conjunction with ST_Anything. If I find some time, I’ll try to get his work integrated into my main GitHub repository.

How many DS18B20 temperature probes do you think you need from the one Arduino? One should be pretty simple. If you want to daisy-chain a bunch of them together, things get a little more complicated.

Dan


(Gnomesoup) #4

I’m only looking for the one at this point. Thanks so much!


(Gnomesoup) #5

@ogiewon

If it helps I took a stab at creating the library myself. I’m sure you will roll your eyes when you see what I have done but the “getData” function has the meat of what is needed for pulling info from the sensor. The thing I can’t figure out is how to call the OneWire class from within the ST_Anything library. You seem to be a wizard when it comes to calling libraries from another library.


(Dan) #6

@gnomesoup

I have finished adding in support for the Dallas Semiconductor DS18B20 OneWire Temperature Sensor to the ST_Aything library.

You’ll need to grab three new libraries and a new example sketch from my GitHub Repository at https://github.com/DanielOgorchock/ST_Anything/tree/master/Arduino.

The three new libraries are:

  1. DallasTemperature (copy to your libraries folder)

  2. OneWire (copy to your libraries folder)

  3. ST_Anything_DS18B20_Temperature (copy to your libraries folder)

The new sketch is:

  1. ST_Anything_DS18B20_Temperature.ino (copy to your sketches folder)

Let me know how it works for you. Please read the comments near the top of PS__DS18B20_Temperature.h or PS_DS18B20_Temperature.cpp for descriptions of what each parameter is used for in the constructor in your setup() routine of the sketch.

By default this new library will report out in Fahrenheit, but you can simply change the “false” to “true” if you’d prefer Celsius. Also, I chose 10bit resolution for the DS18B20 temperature calculation. 10bits seem to provide decent resolution while not taking too much time. You can tweak this as well if desired with values of 9, 10, 11, or 12 bits allowed. These changes would be done in the SKETCH’s setup() routine if desired as shown below:

static st::PS_DS18B20_Temperature sensor1(F("temperature"), 120, 0, PIN_DS18B20_Temperature, false, 10);

Dan


(Gnomesoup) #7

That was amazingly fast. Thank you. I was able to add the sensor very easily and it is working perfectly!