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

Simple circuit to read output from sensor with separate power supply not working

Mon Apr 16, 2018 12:34 pm

I have a sunshine duration sensor from Instromet, which operates on its own 12V power supply. It produces a 5V output signal as long as it is sunny (and 0V otherwise). I'm having trouble understanding how to connect this to the Pi and read its 5V output.

The circuit I currently have can be seen in the diagram here: https://1drv.ms/u/s!AhMZRFFD7BsbgtkFxjBWf530_5oWkQ

A photo of my voltage divider can be seen here (all resistors are 10K, so 2 are used to make 20K in one half of the divider. The diode is a 3.3V zener diode. Black wire is 5V sensor output, purple is 3.3V and goes to Pi for reading, grey goes to Pi ground): https://1drv.ms/u/s!AhMZRFFD7BsbgtkI-0mgk-KPkEnpHA

This is the Python code I'm using to read the GPIO pin:

Code: Select all

import RPi.GPIO as gpio
import time

gpio.setmode(gpio.BCM)
gpio.setup(17, gpio.IN, pull_up_down = gpio.PUD_DOWN)

while True:
    print(gpio.input(17))
    time.sleep(1)
It just prints out zeros, even when it is sunny (the sensor has an LED indicator on it so I know when it is sunny and a 1 should be printed)

I'd really appreciate some help as I've been trying for over a week to get this to work and have run out of ideas now. Thanks!

scotty101
Posts: 3811
Joined: Fri Jun 08, 2012 6:03 pm

Re: Simple circuit to read output from sensor with separate power supply not working

Mon Apr 16, 2018 12:53 pm

You need a ground connection between your sensor and the Pi.
Voltages are relative to a ground and if your two devices don't share a ground potential, you will likely get a false reading.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

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

Re: Simple circuit to read output from sensor with separate power supply not working

Mon Apr 16, 2018 1:02 pm

@scotty101 The sensor has a 'Com' input for common ground. If I cut the ground wire from the raspberry pi power supply and wire it into the Com input, would that work? So the 5V power to the raspberry pi would still be coming from its own power supply, but the ground of it would go to the 'Com' on the sensor, and out of the ground for the sensor.

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