Navigation

    LILYGO

    • Register
    • Login
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    ReadAnalog GPIO12

    Technical Discussion
    gpio t4
    2
    2
    310
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      Castanog last edited by

      I have started using the Lilygo T-Display-s3, and in my application I connected GPIO12 to measure an analog voltage between 0 and 3Vdc.
      I should be pretty straight forward, I set the PinMode for GPIO12 as INPUT and used the ReadAnalog function with the GPIO12 pin (12)....

      However, for some reason it does not read the voltage at all....
      GPIO12 is supposed to share operation with the ADC2 CH1, is there any setup that is required, that I'm not familiar with?

      1 Reply Last reply Reply Quote 0
      • teastain2
        teastain2 last edited by

        Hi! I used this code, just now to read the battery voltage from GPIO4.
        Do not to declare Input as INPUT mode

        top of the sketch:
        #define analogPin 4 //the built in battery voltage test point
        float val = 1.23; //a test number to check if I'm getting a real value

        in "setup"
        Serial.begin(115200); // be sure to set USB CDC On Boot: "Enabled"

        The entire test loop:
        void loop() {
        val = analogRead(analogPin); // read the input pin
        Serial.println(val/1000); // testing value
        delay(1000);
        }

        That's it...I'm getting 2.94VDC.
        The ESP32 has terrible ADC capabilities, so this is it!

        I also have a LilyGO T-Display S3 support page on GitHub here:
        https://github.com/teastainGit/LilyGO-T-display-S3-setup-and-examples
        lots of goodies
        -Terry

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB | Contributors