henryhunt
Posts: 17
Joined: Sat Aug 27, 2016 11:31 am

Reading output from sensor with a separate power supply

Thu Apr 12, 2018 11:09 am

I am familiar with sensors like the DS18B20 that have a positive and negative wire, as well as a data wire. This makes sense, since no matter whether the current goes through the data or ground wire, it always ends up at the same point (ground) in the same circuit. However, I now have a sunshine sensor that operates on its own 12V power supply, and has a single data wire that is outputs either 5V to indicate sunny or 0V to indicate not sunny. I wish to read that output on a Raspberry Pi, and it has confused me thinking about it.

I know about common ground, where all circuits paths will eventually return to the same ground at some point. I have started by connecting the single data/output wire to an arduino (since I do not yet have the resistors for a voltage divider to make the 5V readable by the 3.3V RPi pins), setting that pin to input and reading it. This did not work, and flicked lots 0s and 1s (not just 0s, since there was no sun) on the serial output.

Am I approaching this the right way? I was also confused with how common ground would work with an arduino, which is battery powered, so therefore never reaches the same ground as the separate 12V supply for the sensor. Any advice is greatly appreciated.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5346
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Reading output from sensor with a separate power supply

Thu Apr 12, 2018 4:32 pm

henryhunt wrote:
Thu Apr 12, 2018 11:09 am
I am familiar with sensors like the DS18B20 that have a positive and negative wire, as well as a data wire. This makes sense, since no matter whether the current goes through the data or ground wire, it always ends up at the same point (ground) in the same circuit. However, I now have a sunshine sensor that operates on its own 12V power supply, and has a single data wire that is outputs either 5V to indicate sunny or 0V to indicate not sunny. I wish to read that output on a Raspberry Pi, and it has confused me thinking about it.
I know about common ground, where all circuits paths will eventually return to the same ground at some point. I have started by connecting the single data/output wire to an arduino (since I do not yet have the resistors for a voltage divider to make the 5V readable by the 3.3V RPi pins), setting that pin to input and reading it. This did not work, and flicked lots 0s and 1s (not just 0s, since there was no sun) on the serial output.
Am I approaching this the right way? I was also confused with how common ground would work with an arduino, which is battery powered, so therefore never reaches the same ground as the separate 12V supply for the sensor. Any advice is greatly appreciated.
W.r.t. "Am I approaching this the right way?" - probably not - "Ground" as in AC mains earth/ground and "G(rou)nd" as in signal ground or the "0V" supply rail are not the same thing. You need two connections - the data signal connection (level-shifted via a potential divider for a Pi) and the 0V line to be commoned/connected with the 0V/Gnd connection of the arduino or Pi. (I'd draw you a diagram but that's tricky here - it may help you to look at some of the circuit schematics within my webpages)
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

henryhunt
Posts: 17
Joined: Sat Aug 27, 2016 11:31 am

Re: Reading output from sensor with a separate power supply

Thu Apr 12, 2018 7:44 pm

@FTrevorGowen Your response was very helpful, thank you. If I understand you correctly, the single 5V output line needs to converge with the negative wire of the separate 12V power supply after being read by the RPi, so it feeds back and completes the circuit.

I have just had another look at the sensor control board and realised that the pin next to the output pin on the terminal block labelled "Com" actually stands for common ground (not "Communication" like I thought it did). This makes sense because it means that I have to read the value of the 5V output line, and then route that current back to the sensor control board, through its Com pin, which will then find its way back to negative line of the power supply.

One question I now have is how do I read the value of the pin, then route the current out and into the com port? If I make no effort to do this then I imagine the current from the read pin will just go into the ground of the RPi, and not back to the original 12V power supply and it won't work.

To help understand, I managed to find this document: http://measuringtheweather.com/wp-conte ... t-v1.2.pdf. If you look at the circuit diagram at the bottom of page 4, that it what I am trying to create. With "Logger" being the RPi, my question is effectively 'how do I complete the link out of the logger, to after the resistor? Won't the current be "swallowed" by the raspberry pi instead of being sent back out to the ciruit?

Return to “Interfacing (DSI, CSI, I2C, etc.)”