Distance sensors with the Lopy (ultra sonic, IR etc) and input voltage



  • Hello,

    I have various distance sensors lying around (ultrasonic and IR are my favourites), but I have always used them in conjunction with arduino boards. I've noticed that the maximum input voltage on the digital pins on the lopy seem to be 3.3v. Correct me if I'm wrong, please.

    Is there any way to connect a 5v digital output to the lopy without having to deal with series resistors or other voltage rectifying methods? I sure hope so.

    Thanks
    Søren



  • @soren
    simpy use BSS138 to level shifting or bigger model 2N7000



  • @soren
    Many of the Arduino 5V devices will work on 3V3!

    If not, you could run them on 5V, BUT:
    Use a voltage divider (NOT series resistor) on the 5V outputs that connect to a 3V3 level input.
    3V3 is USUALLY enough to register as HIGH on a 5V device.

    Interfaces like I2C (IIC) and SPI are trickier, as they pull the pin LOW (against a pull-up): Use a level shifter!



  • @soren
    I'm afraid you'll need logical level adapters to connect 5V sensors, as you correctly found out the LoPy is not 5V tolerant, you must use 3.3V levels.

    But in most cases it's quite simple and there are many ready made options like the TI TXS0108E or MOSFET based adapters.



Pycom on Twitter