Trying to find a simple temp sensor

Hi

I need a simple temp sensor to operate a relay. Its on an ESP32 board.
I wanted to use the DS18B20, as I have some of those. But... the onewire library it uses won't play friends with the DMX and Oled library I am using.

I tried the MCP9700, but the output was basically unusable for some reason... even with multiple sampling.

Any suggestions for other sensors?
Or, anyone have code for using a DS18B20 without needing the onewire library?

Thanks

TMP36 Voltage Output Temperature Sensors

1 Like

Analog Devices (formerly Maxim; manufacturer of DS18B20, et al) publish some "bare metal" code:

It does require some precise timing - maybe that's the root of the conflict with your other libraries...?

Maxim also had (hopefully, AD still have) some app notes on accessing the sensor via UART, which takes the timing burden off the processor. Could probably also be done with SPI...?

There are also bridge chips between 1-Wire and things like I2C...

Try LM35 analog type temperature sensor.

1 Like

The DMX library basically takes up all the timers.
The onewire library crashes into it and nothing works

sounds weird for esp32.
Could you provide the link to the library?

1 Like

I have spent 2 days on this problem with a mate of mine who is FAR better at coding than me.
He can't fix it... so I need to go down a different route

These DMX libraries are VERY temperamental

BME280 is SDA/SCL plus vcc & gnd. gives temp/humidity/baro for ~$10 USD.

An LM35 or LM75 would be a lot cheaper!

Analogue temp sensors (LM35, TMP36) won't work with the crappy A/D of an ESP32.
Go for I2C sensors.
Leo..

2 Likes

A film NTC in resistive divider mode and measuring readings with the support of a measurement filter like the one suggested in this tutorial: Smoothing


Graph of readings without and with smoothing

Same problem as with the analogue sensor.
The zero A/D threshold and non-linearity in the upper region of the A/D of the ESP32 will bite you.
Leo..

1 Like

So why does everybody rave about the ESP32... so far, I ain't all that impressed.

Looking at the BMP280 breakout boards.... the purple ones with 6 pins.
No wonder beginners have trouble getting stuff to work. Three different webpages have 3 differing opinions on what the pins do.

Some say to leave CSB and SDO alone (when using I2C), some have them held high or low and some have them completely the opposite way around.

BMP280 Module Pinout, Interfacing with Arduino, Applications, Datasheet (microcontrollerslab.com)

This says at the top of the page that CSB is held high for I2C. Then at the bottom it contradicts that.

For definitive information, see the datasheet for the sensor itself - note that two different sensors have been mentioned so far:

BMP280: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf

BME280: Humidity Sensor BME280 | Bosch Sensortec

and that would have to be taken in conjunction with the schematic of the particular board.

Having the same colour & same number of pins doesn't guarantee that the boards are actually the same.
Check the schematics.

1. Fig-1 is the I2C Mode connection of BMP280 Breakout board (with Temperature and Pressure Sensors) with ESP32 Board.


Figure-1:

BMP280-Module_Schematic.jpeg
Figure-2:

BMP280PinDiagram
Figur-3:

2. Fig-3 says that for "I2C Mode Connection" the CSB-pin of the Breakout board/Sensor should be at HIGH state which can be achieved by leaving the pin open as it has a pull-up resistor (Fig-2).

3. Fig-3 says that for "I2C Mode Connection" the SDO-pin of the Breakout board/Sensor should be at LOW state for "Slave Address of 0x76" and it can be achieved by leaving the pin open as it has a pull-down resistor (Fig-2). By strapping SDO-pin at HIGH state, another sensor could be run in parallel by assigning 0x77 as the "Slave Address".

Thanks for that. Does the BMP280 library use a clock? I'll have to download it and have a look

There are many libraries to handle BMP280 sensor; but, not all work with all Arduino Boards. Check which one works with ESP32.

What temperature range do you need to operate the relay?

1 Like

and what accuracy & precision of temperature measurement do you need?

Its to turn a heater on (small 5v PTC). Probably at about 2 degrees. Not super accuracy critical