1

I have a Sunfounder temperature sensor module and a Raspberry Pi 2 Model B. I want to use this to create a temperature logger, but nothing is working as I expected it too.

The temperature sensor has an analogue and a digital output. Using a voltmeter I've found that the analogue output puts out a voltage between 0 and 3.5V which I suppose can be converted into the temperature -- I'll worry about that when I need to. However, I now no that the Pi does not have an analogue in - it read only 3.5V or 0V on the GPIO inputs.

My understanding is limited, but my question is: how can I read the digital signal from this module? On the GPIO inputs I can read the pin and get 1 or 0, but how can I convert this into the voltage (and then the temperature).

My only idea the digital output is outputting some signal which can be decoded, but I'm completely stuck as to how.

Any advice is appreciated.

1
  • 1
    en.wikipedia.org/wiki/Analog-to-digital_converter From glancing at the product description ("The threshold of temperature detection can be adjusted by rotating the potentiometer. When the temperature exceeds the threshold, D0 outputs low and the corresponding LED will light up..."), I do not think the digital output is intended for reading temperature, just triggering an alarm -- e.g., if you wanted to hook it up using it just for that purpose and did not care about the exact temp, you could not bother with the analog out.
    – goldilocks
    Commented Jun 6, 2016 at 17:05

1 Answer 1

4

The digital output you will get will either be 0 or 1 depending on the level you set with the trimming potentiometer (the blue and white thing). It can be used to detect, based on the trim pot, the difference between a value of 'hot' and a value of 'cold'. Above the level you set, I believe you'll get a 1. Below, you will get a 0. You will be unable to tell what the actual temperature is at any time except when the value turns from 0 to 1.

If you want to read the actual temperature, you will need an Analog-to-Digital converter chip such as the MCP3008. You will then need to perform calculations based on the range the sensor can read according to the value you read. The easiest way IMHO to get an MCP3008 (or other A2D chip) working is to use GPIO Zero (http://gpiozero.readthedocs.io/). A good tutorial on reading temperature (though it's a different sensor) is over at RasPi.TV (http://raspi.tv/2016/using-mcp3008-to-measure-temperature-with-gpio-zero-and-raspio-pro-hat).

1
  • 1
    I've managed to get the ADC working and can read the voltage thanks to your pointers. I now need to understand how to convert that into a temperature, cheers.
    – Greg
    Commented Jun 8, 2016 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.