jose.lopez49
Posts: 9
Joined: Fri Apr 10, 2015 3:09 pm

DS18B20 Temperature sensor and Relay activation

Fri Apr 10, 2015 3:24 pm

I am trying to make a thermostat with two DS18B20 temperature sensor and a HL-58S relay. I have connected the temperature sensor parts and they work perfectly, I can see the serials of the sensors in /sys/bus/w1/devices/ and I can consult the temperature with the w1_slave in each sensor. But the problem is once I connected the relay the sensors disappear from the /sys/bus/w1/devices and there is no way to recover them unless you disconnected the relay from the GPIOs and reboot the raspberry. The relay is correctly working when I connected it to the raspberry pi, but the temperature sensor disappears.
What am I doing wrong?

Raspberry specs:
Model A revision 008
Linux raspberrypi 3.18.7+ #755 PREEMPT

Thank you

User avatar
joan
Posts: 14079
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: DS18B20 Temperature sensor and Relay activation

Fri Apr 10, 2015 7:22 pm

Could you post photos or links to photos which show the connections between the sensors and relay and the Pi? A description of the connections may also be useful.

jose.lopez49
Posts: 9
Joined: Fri Apr 10, 2015 3:09 pm

Re: DS18B20 Temperature sensor and Relay activation

Fri Apr 10, 2015 7:30 pm

The connections to the DS18B20 are

Vdd conected to 3.3V GPIO from Raspi
Data connected to the GPIO pin 4
Ground connected to ground GPIO
4.7Kohms pullup resistor between Data and Vdd

The connections to the Relay are.
Vdd conected to gpio pin 5.0V of Raspi
Ground to ground gpio in Raspi
IN 1 connected to gpio pin 17

User avatar
joan
Posts: 14079
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: DS18B20 Temperature sensor and Relay activation

Fri Apr 10, 2015 7:43 pm

That suggests the power supply might be marginal. Have you tried powering the relay from an external source?

jose.lopez49
Posts: 9
Joined: Fri Apr 10, 2015 3:09 pm

Re: DS18B20 Temperature sensor and Relay activation

Fri Apr 10, 2015 7:47 pm

Yes I have supplied the relay with an external supply too. The DS18B20 stops working when I connect the IN1 of the relay (to switch on and off) to any of the gpio pins. Right now I have noticed DS18B20 sometimes are not recognized.

User avatar
joan
Posts: 14079
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: DS18B20 Temperature sensor and Relay activation

Fri Apr 10, 2015 8:23 pm

Every connection you describe seems ok. A photo may be useful.

jose.lopez49
Posts: 9
Joined: Fri Apr 10, 2015 3:09 pm

Re: DS18B20 Temperature sensor and Relay activation

Sat Apr 11, 2015 7:37 am

In this photo I show you the connections.
Right now it is working with temp sensors and the relay, but sometimes the sensors disappear from /sys/bus/w1/devices and sometimes they mark temperature as 0.
Image

User avatar
joan
Posts: 14079
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: DS18B20 Temperature sensor and Relay activation

Sat Apr 11, 2015 7:50 am

DS18B20 coming and going might again be a symptom of a marginal power supply. However I'd check for loose connections first.

jose.lopez49
Posts: 9
Joined: Fri Apr 10, 2015 3:09 pm

Re: DS18B20 Temperature sensor and Relay activation

Sat Apr 11, 2015 9:08 am

But when I disconnected the relay I have the same problem with the temperature sensors, they sometimes disappear. I have checked the connections and they seem to be correct. And sometimes they appear but the showed temperature is 0.

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: DS18B20 Temperature sensor and Relay activation

Sat Apr 11, 2015 11:59 am

Are you sure you have the correct sensors. Some of them are designed to be used as 2 wire devices and are powered trough their data line. Those normally require a special circuit that charges an internal capacitor which provides power during temperature conversion and readout. You need the type that is designed to be separatly powered. The others work if you set the pi pullup, but not always and not reliable. The resistor value between VCC and the dat input is also very critical if you have those wrong types. Sometimes, temperature is read as 85.0 deg. on those as well.

jose.lopez49
Posts: 9
Joined: Fri Apr 10, 2015 3:09 pm

Re: DS18B20 Temperature sensor and Relay activation

Sat Apr 11, 2015 5:37 pm

I bought that sensor
http://m.ebay.es/itm/201318222391?_mwBa ... rvr_id%3D0

I an not completely sure if is the one that needs power trough data line. What can I do to check if is one type or the other?

User avatar
DougieLawson
Posts: 35542
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: DS18B20 Temperature sensor and Relay activation

Sat Apr 11, 2015 7:22 pm

Are you sure that DS18B20 is wired correctly, some of the cheapo Chinese imports have the wires swapped? If it gets hot then the wiring is wrong.
Note: Having anything remotely humorous in your signature is completely banned on this forum. Wear a tinfoil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

jose.lopez49
Posts: 9
Joined: Fri Apr 10, 2015 3:09 pm

Re: DS18B20 Temperature sensor and Relay activation

Sat Apr 11, 2015 11:33 pm

DougieLawson wrote:Are you sure that DS18B20 is wired correctly, some of the cheapo Chinese imports have the wires swapped? If it gets hot then the wiring is wrong.
The sensors are not getting hot and I have read temperature correctly with that configuration several times, but there are times that the sensors are not detected and others that they are detected but the temperatures measured is 0.

User avatar
DougieLawson
Posts: 35542
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: DS18B20 Temperature sensor and Relay activation

Sat Apr 11, 2015 11:47 pm

Have you got a 4K7 resistor to pull it up to 3V3 at the RPi end of the wires?
Note: Having anything remotely humorous in your signature is completely banned on this forum. Wear a tinfoil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

jose.lopez49
Posts: 9
Joined: Fri Apr 10, 2015 3:09 pm

Re: DS18B20 Temperature sensor and Relay activation

Sun Apr 12, 2015 4:20 pm

I have been trying different options and finally I noticed that if I use only one of the sensors it works perfectly but the problem starts when I connect more than one sensor, sometimes both works, sometimes only works one of them and sometimes they don't work. Does anyone know what is happening? I need another resistor or maybe it can't supply more than one sensor?

User avatar
rpdom
Posts: 14742
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: DS18B20 Temperature sensor and Relay activation

Sun Apr 12, 2015 5:02 pm

You only need to one 4.7K resistor at the Pi end. You can connect many sensors to that.

jose.lopez49
Posts: 9
Joined: Fri Apr 10, 2015 3:09 pm

Re: DS18B20 Temperature sensor and Relay activation

Sun Apr 12, 2015 9:13 pm

rpdom wrote:You only need to one 4.7K resistor at the Pi end. You can connect many sensors to that.
Yes I am using just one 4.7K resistor.

Return to “Troubleshooting”