Notifications
Clear all

ESP32 with relay  


R_Hood
(@r_hood)
New Member
Joined: 2 months ago
Posts: 3
Topic starter  

Hi  This is my first query re my first project which is to use a DHT22 sensor to check the temperature.  I am aiming to use it to switch on 12v at a given temp with a relay.  No problem recording the temp or working the relay but if I use them together I get nan readings on the temp.  As soon as I disconnect the relay the temp readings re-appear.

Ive tried various output pins with no success.  Can someone give me some guidance please?


Quote
Centari
(@centari)
Eminent Member
Joined: 1 year ago
Posts: 43
 

@r_hood, nan error is 'not a number' error.  It sounds like something might be interfering with the I2C buss you have set up.  Without visual or hands on, that's my best guess.


ReplyQuote
YurkshireLad
(@yurkshirelad)
Estimable Member
Joined: 1 month ago
Posts: 151
 

Try ignoring the sensor data and manually control the relay in the code. Try to isolate/separate the two and see if you can locate the problem.

 

Edit: Try to work with both separately and it might highlight the problem.


Centari liked
ReplyQuote
R_Hood
(@r_hood)
New Member
Joined: 2 months ago
Posts: 3
Topic starter  

Thanks Centari and Yurkshire Lad

I think I’ve got things sorted now.  Not sure what I did re the ‘nan’ problem but it’s working now - possibly a bad connection?

Re the relay itself I found a fault with it.  It’s an optorelay module and was indicating by the LEDs on the input side that it was responding to input from the ESP32 but I found it needed a good thump to make the output switch over !  I’ll perhaps set it up on the blink program to see if that will loosen it up.

Thanks for your time,  much appreciated


ReplyQuote