1

I'm trying to make a thermostat controlled by my Raspberry Pi 4. It has a touchscreen, which covers the first 13 pins on both sides (pins 1-26). I obviously need to attach a temperature sensor (DS18B20). While I have access to a few grounds, all the voltage pins (1, 2, 4) are used by the touchscreen.

My question: Can I set a free GPIO pin to HIGH to use as VCC on my DS18B20?

2
  • 1
    I am 99% sure that the touch screen HAT does NOT need all 26 pins. I am 99% sure that you can steal one of the 26 pins that the touch screen occupied but left idle, collecting dust. Let me know if you do know a little bit of DIY skills, including hand soldering, and wish to know a couple of ways to steal an unused GPIO pin for DS18B20. Cheers.
    – tlfong01
    Feb 1 '21 at 2:46
  • 1
    why don't you connect to one of the voltage pins? ... it is unclear why you don't want to connect multiple wires to a pin
    – jsotola
    Feb 1 '21 at 7:16
0

"Can I set another GPIO pin to HIGH to use as VCC on my DS18B20"

In general NO.
The GPIO pins can only supply 3.3V at a maximum of 16mA (total 50mA for whole system).

You could use a GPIO pin if this satisfies the requirements of the device.

3
  • OK. I was hoping not to have to solder on to a voltage pin, but that may be required.
    – pkSML
    Feb 1 '21 at 0:38
  • 1
    @pkSML I am not familiar to the DS18B20, you should consult the datasheet. 1 wire devices generally use little current so you should give it a try - you won't damage anything.
    – Milliways
    Feb 1 '21 at 0:52
  • 1
    Quick look at the data sheet says 3-5.5V and pulls about 4mA, so I dont see any reason you couldnt do that. Be aware though, that the voltage output from the pin and the min voltage needed by the sensor are getting pretty close together, so there is a chance you will see intermittent issues if either are not quite to spec.
    – Chad G
    Feb 1 '21 at 16:31
0

Thanks for the help guys.

I consulted the datasheet at https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf and set my GPIO pin high with the command: raspi-gpio set 26 op pn dh.

$ cat w1_slave
5e 01 55 05 7f a5 81 66 2c : crc=2c YES
5e 01 55 05 7f a5 81 66 2c t=21875

Success!

Edit: Since I'm using custom pins for the 1-wire interface, here's what I added to my /boot/config.txt file:

dtoverlay=w1-gpio,gpiopin=19

Source: https://www.waveshare.com/wiki/Raspberry_Pi_Tutorial_Series:_1-Wire_DS18B20_Sensor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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