ADC sensors on external PSU

  • Im trying to read values from a few sensors that require 5V to work, so i know i cannot power them directly from my lopy4 board.

    Ive tryed 2 setups:
    -sensors connected to a 5v 2A usb adaptor, and the Lopy4 on an expansion board connected to another diferent usb adaptor. Sensors are only connected to the lopy4 trough the ADC pins.

    -sensors and lopy4 powered trough same usb adaptor (lopy4 powered trough Vin and Ground).

    In the first scenario, the sensors output is correct (read from multimeter) however when trying to read on Lopy4 it reads as 0v

    In the second scenario, the lopy can read values correctly but the values the sensors are outputting are wayy off scale (like 3 volts higuer)

    Obviously im doing something wrong, just not sure what?

    Also, is there a diference from powering the lopy from usb and from Vin?

    Best regards

  • @robert-hh said in ADC sensors on external PSU:

    @Alephus Connecting the sensor to the input should not raise the voltage measure at that connection. So it must be something else in the set-up.

    after a while i did a few more tests and found something:

    • of all ADC1 pins, all behave properly except P19 and P20 (guess wich 2 i was using)
    • a friend analized my problem as well and detected that those 2 pins where not "floating", and after analazing the datasheet he assumes its because they are the only ones with pullup/pulldown internal resistors.

    So for now i have a solution however i still dont understand is why, after all, they are tecnicaly valid Pins pins in the datasheet

  • @Alephus Connecting the sensor to the input should not raise the voltage measure at that connection. So it must be something else in the set-up.

  • @robert-hh the voltage is as you sayd, basicly 0. (0.06v) i literaly have no idea whats wrong. Is it the sensors? Is it the lopy? Even other pins do the same

  • @robert-hh

    Regarding code, its exactly that since i know im reading up to 2v and normal adc without the attn only reads up to 1,1v

    Regarding volts at the Pin im gonna read it and post here as soon as possible (had to leave for about 1, 2h)

    In my head this situation makes no sense

  • @Alephus What is the voltage at P20, taken with your multimeter, when the sensor is not connected, but the port is configured? It should be almost 0.
    How did you configure P20? It should be something like:

    from machine import ADC
    adc = ADC()
    adc_c ='P20', attn=ADC.ATTN_11DB)

    You may also try other Pins in the range P13 up to P20

  • @robert-hh

    Vin : 5v input (5v @ 2A Usb wall charger)
    GND : Ground (Gnd Usb wall charger)
    P20 : sensor output


    • : 5v input (5v @ 2A Usb wall charger)
    • : Ground (Gnd Usb wall charger)
      Out: connected to P20 on lopy4

  • @Alephus Which pin of the LoPy4 are you using?

  • @robert-hh

    i was using 2 sensores but reduced to just 1 for testing. The sensor is a SEN0219 Co2 sensor. It uses 5v and should output betwen 0 and 2v.

    0,5v is a very accurate reading for the enviorement we are in however having an output of 3,7v when the max is 2V is... wrong.

    Im not sure what im doing wrong.

  • @Alephus In case of two different power supplies you have to connect the GND wires. Otherwise it cannot work. And what you get is the consistent to the second scenario. Which sensor are you using? And where do you get the 0.5V?

  • @robert-hh

    When using the 2 diferent power supplies, i did try with the ground conected betwen the board and the sensors, but again, in that scenario the sensor output jumps from about 0,5V (correct) to about 3,7V (wrong). ![alt text] url)

  • @Alephus Did you connect the GND pins of both LoPy4 and Sensor?

Pycom on Twitter