i would like to read a high value for my gpio pin as right now my input value to the pi is reading from a digital sensor either 0v(low) or 0.9v(high). however i do know that 0.9v is too low to allow the gpio to know that it is actually a high value

is there any software coding where i can reduce the input value of the pin lower so that 0.9v is a high and 0v is a low without hardware implementation?

my code here is:

import RPI.GPIO as GPIO
from time import sleep


while True:
    input_value = GPIO.input(18)
    print str(input_value) +"v"

3 Answers 3


No. The Pi's logic level (3.3V) is determined by its hardware, and isn't settable using software. Your only options would be to find a suitable logic level converter, or to use a different sensor with 3.3V logic.

  • ok thanks, just wanted confirmation on the possibility of software implementation.
    – Joseph Ng
    Commented Aug 26, 2016 at 8:26

The sensor voltage 0.85V should be enough to turn on a transistor. Search for "simple transistor switch" or see e.g. http://www.circuitsgallery.com/2012/02/transistor-act-as-switch-working-and.html (In this particular picture remove the LED and connect the RPi input to the collector)

A circuit like this with almost any NPN transitor would probably be sufficient. When your sensor output is high the transistor will turn on, which will pull the RPi input low. The RPi input should be set to either have a pull-up resistor or none, setting a pull-down resistor would confuse things.

If your sensor output-hi voltage is lower than 0.65 V (the threshold for turning on a silicon transistor) it may be possible to locate an NPN germanium transistor such as an NTE101 or 2N1306 with a threshold of 0.3-0.4V or so. For voltages lower than that a "rail-to-rail" comparator chip might be required. This takes slightly more wiring; see e.g. TLV3701IP at Digikey or TI.com (a circuit is on page 1 of the specs).


You could use an analog pin readout, pi does not come with a analog to digital converter so you need to get one.

Use an external ADC like this one https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi/overview

and then you can write your code kind of like this

if analog signal is < .85vDC then do nothing elif analog signal is > than 9.5vDC do something.

Good luck

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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