DS18b20 Working Example?


#15

Hi @exposure

Glad you got it working!

The DS18B20’s normally do not need any calibration and are usually quite accurate. One thing to note that has come up before is that the Spark core runs warm and can easily warm up a whole breadboard a few degrees.

Try moving the sensor to another breadboard or use longer wires to move it away from the core.


#16

So I am finally playing with the Spark Core for the first time after a year. Before this I just played with tinker and blinked some leds.

Well I just got a DS18B20 temp sensor and thought I would try the library. So I included the one wire library which looks like it is all setup to read the temp from one of these temp sensors.

I hit the verify button but I got a compiler error.

    ../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
 #warning  "Defaulting to Release Build"
  ^
   
In file included from OneWire/OneWire.cpp:131:0:
OneWire/OneWire.h:31:0: warning: "FALSE" redefined [enabled by default]
 #define FALSE 0
 ^
In file included from ../../core-common-lib/CC3000_Host_Driver/cc3000_common.h:38:0,
                 from ../../core-common-lib/SPARK_Firmware_Driver/inc/hw_config.h:35,
                 from ../inc/main.h:37,
                 from ../inc/spark_utilities.h:30,
                 from ../inc/spark_wiring.h:33,
                 from OneWire/OneWire.h:8,
                 from OneWire/OneWire.cpp:131:
../../core-common-lib/CC3000_Host_Driver/data_types.h:53:0: note: this is the location of the previous definition
 #define FALSE         (0)
 ^
In file included from OneWire/OneWire.cpp:131:0:
OneWire/OneWire.h:32:0: warning: "TRUE" redefined [enabled by default]
 #define TRUE  1
 ^
In file included from ../../core-common-lib/CC3000_Host_Driver/cc3000_common.h:38:0,
                 from ../../core-common-lib/SPARK_Firmware_Driver/inc/hw_config.h:35,
                 from ../inc/main.h:37,
                 from ../inc/spark_utilities.h:30,
                 from ../inc/spark_wiring.h:33,
                 from OneWire/OneWire.h:8,
                 from OneWire/OneWire.cpp:131:
../../core-common-lib/CC3000_Host_Driver/data_types.h:57:0: note: this is the location of the previous definition
 #define TRUE          (!FALSE)
 ^
In file included from ../inc/spark_wiring.h:29:0,
                 from ../inc/application.h:29,
                 from readtemp.cpp:2:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
 #warning  "Defaulting to Release Build"
  ^

   
 readtemp.cpp:2:21: fatal error: OneWire.h: No such file or directory
 #include "application.h"
                     ^
   
compilation terminated.
make: *** [readtemp.o] Error 1

So my question is do I have control over the application.h or is there something goofed up with this library? Or am I just doing this completely wrong.


#17

It looks like the version of the library that is being used by the WebIDE is out of date?

The problem is in OneWire.h

#define FALSE 0
#define TRUE  1

These should not be there (and looking through github history last year, they were removed, and still is removed in the latest version.)

The version of the library in github is 1.1.0, but the version in the WebIDE is 1.0.0.

Can anyone that’s familiar with the library shed some light on this?


#18

I got it to compile by changing the include for the onewire.h so that it is now:

#include "OneWire/OneWire.h"

Using this onewire example I am getting an output from the sensor but it is wrong.

ROM = 28 9C 4E DE 6 0 0 5C
  Chip = DS18B20
  Data = 1 1 4B 46 7F FF 1 10 14 FF  CRC=A7
  Temperature = 1200.06 Celsius, 2192.11 Fahrenheit
No more addresses.

So I was reading through this thread and it looks like I should be using the spark-dallas-temperature library but there is no example ds18b20.ino file like exposure has in post #5.


#19

I did figure out how to get the right temp using the spark-Dallas-temperature library. I had to write my own application since there wasn’t an example.

The other issue I had was that I was trying to work on it way to late with my wife continuing to remind me that it was bed time.

Turns out I put the wrong port in for the data pin (on the Dallas example I had to create).


#20

I have been working on getting the examples working in the core+photon port of OneWire and DallasTemperature. The port works but the examples are taking a little longer. So far I have “Multiple” and “Alarm” compiling. Note if you want to try and fork these examples you have to add the Particle-OneWire library through the webIDE. That is import both libraries, then fork either “Alarm.ino” or “Multiple.ino” then include Particle-OneWire library. I will try and get the others up and running soon.

To import a library from GitHub:

  1. Go to the library tab in the WebIDE
  2. click"Contribute Library"
  3. paste the link above
  4. click import (ignore the warning that another user already has a library by this name)
    5)Whala

OneWire library throwing a boatload of errors
#21

Has anyone tried to get the max31850 chips working? I have it working on an Arduino but would like to use my photon. If nobody has worked on this, I’ll give it a try but it will take a while as I’m a little time constrained ATM.


#22

Thanks to everyone for sharing these great resources. I was able to build two wireless thermometers with what you’ve shared. After much testing, I installed one of the thermometers. I’ve mounted the Core in a project box and mounted it to the wall, then routed the DS18b20 into our chest freezer. The Core dutifully reported the temperature down to -14C. The next report showed -127 and that’s all it has shown since. The Core reported reliable temperature readings for over a week in the house. Any ideas as to why it’s doing this in the deep freeze?

Thanks for any ideas!

Brian


#23

My experience with these is that when you are reading -127, you are getting all 1’s back on the read and something in the connections is wrong.

Where did you put the pull-up resistor? At the Core end of the wires?


#24

Thanks for your reply. Yes, the resistor is at the core end.


#25

I haven’t test this after the rename to Particle, but this is my source code for sous vide with Core (am using ds18b20). You can try to drop in the libraries as is, and see if it works.


#26

@Soemarko, your source code works great! I edited out everything I didn’t need for my purpose. The core I have monitoring my deep freezer now reports the actual temperature rather than -127.

I had done quite a bit of searching last night and ran across a thread on the arduino forums by someone that was experiencing the same issues. It does appear it has something to do with the DallasTemperature library. Using yours, everything is working great. Thank you!!

Brian


#27

Could you share your solution?


#28

Nearly one year later - and it seems that little progress has been made along the lines of putting together a simple working example for getting multiple DS18B20s to work with the Photon.


#29

I published a lib that works, its not as clean as using the onewire lib though, but it works :slight_smile:


#30

Hi everyone,

I’ve been trying a lot of the examples from this thread, but nothing is working. Given that all of these examples are years old, can anyone share working code (bonus points for step-by-step and/or the actual concepts behind getting this to work) utilizing the latest libraries available via Particle Build? I am working on OSX, and am pretty lost overall.

Thanks,
-Kenny


#31

Hi Kenny, I’ve used two of them in this project, maybe you’d like to take a look?


#32

Thanks @gusgonnet! This is definitely pointing me in the right direction, as I am planning to use multiple sensors and a relay as well. It’s not compiling for me, but will see what I can do.


#33

sorry to hear that. Make sure you add the libraries included on top of the ino via the BUILD IDE, if you are using it:

#include "Particle-OneWire.h"
#include "DS18B20.h"
#include "NCD4Relay.h"

#include "elapsedMillis.h"
#include "FiniteStateMachine.h"

It could be that the oneWire lib will be added by the DS18b20, according to Libs 2.0.
good luck!
Gustavo.


#34

@gusgonnet Thanks again. The double import re: OneWire was the culprit.

I’m now able to log the temp read events to the Particle console, but the value(s) are not updating, so will need to double check my connections.

Very helpful code!