DS18B20 - One Wire Temperature Sensor


#1

Hi Guys,

Has anyone had experience integrating the DS18B20 One Wire Temperature Sensor?

When I plug the sensor into A0 and run the grovepi.temp(0) command it returns the following values :

236.993012731
347.681976479
222.72964291
347.681976479
286.959650935

When I plug the sensor into D8 and run the grovepi.temp(8) command it returns the following values :

0.812724599624
0.915110015576
1.01728008973
0.915110015576
0.915110015576

When using the analogRead command I get different values entirely.

1020
1022


#2

Hi,
The grovepi.Temp() is for this sensor http://www.seeedstudio.com/depot/Grove-Temperature-Sensor-p-774.html so it won’t work with something else.

If you want to support any other sensor, just read the voltage across it using analogRead() and do the conversion in Python to find out the temp value (Please look into the implementation of grovepi.Temp() for more information on this).

-Karan


#3

Hi Karan,

Thanks for your response.

I can understand the code in the GrovePi.py library but I am having difficulty converting the analogRead value from the DS18B20 temperature sensor.

Is it possible that you could you help with the conversion equation?

Thanks in advance


#4

Hi,
I looked up the details about the DS18B20 sensor and it looks like it works on one wire protocol and not Analog Read. The one wire protocol is currently not supported by the GrovePi.

The one wire protocol has it’s own library and here’s a good place to learn more about it http://playground.arduino.cc/Learning/OneWire .

We are not sure, if or when we are going to support these sensors. If you want to integrate this sensor, Arduberry would be a better place to start because you can use the already existing libraries to read the temperature and send the result to the Raspberry Pi via Serial.

Sorry for the confusion.

-Karan


#5

I was experiencing the same issue as I thought that B20 would work like all the other sensors using the analog in pins but I had to use the libraries in ArduBerry and the use serial communication as suggested by Karan. I altered my design and started using simpler thermocouples which are passive temperature sensors to use. It’s working great now. Hope you find an easier way to interface if you’re stuck with the B20.


#6

I am puzzled by this thread. The GrovePi software examples include a temp sensor routine that uses Analog interfaces. In speaking with Grove/Seeed support, the one wire protocol uses Digital, not Analog, interfaces. Either way I get completely screwy readings back from both of my one-wire temp sensors, while my temp / humidity pro give me readings that are reasonable for the room I’m working in.

Are these wild readings a result of one-wire not being supported? Why does the example software use Analog instead of Digital?


#7

I ran further tests and found that (a) swapping which sensor device was in which of the digital ports did not change the reading being returned by that port (i.e. so it’s not likely a sensor problem); (b) removing the sensors entirely and running the same py code gives exactly the same results.

So it sounds like the readings coming back are garbage #s that happen to follow a pattern probably because there’s some protocol running on the 1-wire bus?

Are there plans to support these 1-wire sensors? They’re pretty handy as well as low cost. There’s an alternative thermistor on a card, but for my particular application, the exposed card won’t work.


#8

The temperature sensor example which uses Analog Read is for this particular sensor http://www.seeedstudio.com/wiki/Grove_-_Temperature_Sensor .

GrovePi does not support 1-wire sensors as of now and we don’t have any plans yet for adding the support for these sensors.

You can hack the GrovePi firmware to add the support for these sensor. We’ll help you out as much as possible and if it works well with the GrovePi, then we might even merge the code in our repository.

-Karan


#9

Hi Karan,

Thanks for the link to the correct sensor for the example code. My design would put sensors in environments probably too wet for an exposed board - not submerged, but exposed to rain and constant high humidity air. Thus my plan to use the 1-wire units that are watertight. I will explore the board-mounted sensor further though - no harm in testing.

Hacking the GrovePi firmware is beyond my skills at this juncture. I have some experience with electronics and fairly dated high-level language programming skills that I’ve not used in years and years. I’m teaching myself Python now. Fiddling hardware using both RasPi and Arduino. If I get to the point of taking on the 1-wire firmware, I will open a thread for assistance. I’ve read the protocol docs and am pretty sure I’d need some guidance!!

Thanks,

Robert


#10

OK, first let me say I really like the GrovePi and sensors. They make playing with the Pi pretty easy. However, I am also one of the many who would like to use the DS18B20 sensor with the Pi. And it is also beyond my capability to change the GrovePi firmware.

I found a really well done article from the UK here: https://www.samculley.co.uk/raspberry-pi-temperature-monitor/. The design connects the sensor directly to the Pi on GPIO pin4. The supplied Python code in the article takes advantage of the Pi built-in i2c bus. I believe the GrovePi also uses this same method of communicating with the Pi.

Therefore, to help the many who are interested in this, could someone address the following questions:

  1. Is it likely the design in the UK link above could be used with the GrovePi attached, or would the GrovePi need to be removed first?

  2. Couldn’t the GrovePi firmware be (easily?) modified to add basically a i2c mirror function which would essentially replicate the Pi i2c to the selected GrovePi i2c connector? This would allow folks to use code like the UK code with the convenience of the GrovePi connectors. Seems like a win-win for everyone.
    – -- Duane


#11

Hi,
The one wire temp sensor should work like the tutorial says. The sensor does not work with I2C and uses another protocol called 1-wire which does all the communication on a single wire, GPIO 4 on the Pi here. You should be able to use that tutorial or https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing?view=all to make the temperature sensor work.

The GrovePi does not support the sensor right now but the sensor is compatible with the GrovePi http://www.seeedstudio.com/depot/One-Wire-Temperature-Sensor-p-1235.html?cPath=25_27 .

From the looks of it, the sensor would need a lot of work on the Firmware to get it to working with the GrovePi. We don’t have any plans right now to add the functionality on the firmware and the best way for you would be to use the instructions to directly use it with the Raspberry Pi.

-Karan


#12

I don’t get it. If the GrovePi doesn’t support this sensor, why would you sell it like this?


Is it still not supported? It seems to me that you’re missing a waterproof temperature sensor and this one is ideal…


#13

Hey James, how are we selling the GrovePi+? Sorry, I’m not catching what you mean by “why would you sell it like this?”


#14

Not the grovepi+, but the sensor with Grove connector (which is what the link I posted is pointing to). It’s not supported by the grovepi so what’s the point of having the connector…


#15

I think the connector on that can be used with regular Grove products. I thought you implied we implied it was supported on the GrovePi+. I think @Karan was clear that it was not supported.


#16

How about a label or something that says “Not supported by GrovePi” in the store site. That’s easier than having us look through the forum for each sensor we want to buy… I mean, it happened to me, I didn’t check.


#17

Sure, we can ask Seeed to put that up. All the sensors we sell are supported.


#18

Honestly I’m a huge supporter of dexter and grove but i agree this temperature sensor could be much better labeled.

It does not appear to work with the GrovePI+ and it does not appear to work with the Grove shield V2 on the Linkit one board so saying its grove compatible is a bit of a stretch.

These are the only two boards i work with and i now have 8 of the sensors. No doubt some one will figure it out or has (i did try the above but seemingly I’m not a seasoned enough developer, but no joy) and/OR i just have not found it yet (if anyone knows of anything let me know).

But as mentioned i think a much better compatibility statement (it would be short in my experience so far) would be good.


#19

@rv1,
I am really sorry that there was not enough information available on the grove website whether these sensors worked or not with the GrovePi+. Usually all the information about the supported sensors is avialble here. We usually ask people to post about sensors that are not mentioned there on the forums because there are a lot of sensors which we have not written libraries yet and might work with the GrovePi.

Right now these temperature sensors are not supported directly with the GrovePi.

However, we had received these sensors from Seeed which manufactures them and I took a bit of time to test them with the GrovePi. I was not able to get it running directly with the GrovePi but was able to get it working with the Pi. Getting it to work with the GrovePi directly might be a bit difficult though we’ll work on it in the near future.

If you want to get this sensor to work with the Raspberry Pi, you can try out this tutorial. Though the connections would be a bit different. If you look closer to the Grove connector at the end, you’ll see that only 3 metal tabs of the 4 slots at the end are. The one connector which is singled is the Signal line and the other two are Ground and 3.3V. (refer to the picture here)

You should connect the GND and 3.3V to the GND and 3.3V pins on the raspberry pi and the signal to Pin7 or BCM4 on the Pi header (https://pinout.xyz/pinout/pin7_gpio4).

Once it is connected, power the Pi, and try running the commands from the Add OneWire support in the section of the tutorial linked above.

Do let us know if it works for you. We’ll test it on the GrovePi and will keep you posted about that.


#20

Hello,
I just read the discussion and I’m interested if One Wire Temperature Sensor (DS18B20) is ready to plug in the GrovePI. Has anyone fix it?
Thank you!
By the way, connecting the wires as says karan works for me. But I want just to know if it is ready to plug&play.