🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5Stack Reflective IR Sensor Always Reads 0

    General
    2
    4
    572
    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.
    • S
      shinshin8
      last edited by

      Issue: M5Stack Reflective IR Sensor Always Reads 0

      Environment:

      Device:M5Stack Basic
      Board: LilyGO T-Display (ESP32-D0WDQ6-V3)
      Sensor Module: M5Stack Reflective IR
      Development Environment:
      Arduino IDE (ESP32 board configuration)
      M5Unified library
      Wiring:
      VCC → 5V (or 3.3V)
      GND → GND
      Analog OUT → GPIO36 (VP)
      Digital OUT → GPIO26
      Problem:
      The M5Stack Reflective IR sensor is connected properly, but when reading the analog value using analogRead(36), the result is always 0 and does not change.

      What I Have Tried:

      Checked Serial Monitor Output (Baud Rate: 115200 bps)

      Used Serial.println(analogRead(36));
      The value remains 0 at all times.
      Tested with Hand in Front of Sensor

      Expected the analog value (0-4095) to change.
      No change in the output.
      Checked Sensor Wiring

      VCC is correctly connected to 5V (or 3.3V).
      GND is properly connected to GND.
      Analog OUT is connected to GPIO36 (ESP32 ADC pin).
      The wiring appears to be correct.
      Measured Voltage with Multimeter

      VCC-GND voltage: 5V (or 3.3V) → OK
      Analog OUT-GND voltage: 0V → No change even when hand is placed in front of the sensor.
      Tried a Minimal Test Code:

      void setup() {
      Serial.begin(115200);
      analogReadResolution(12); // Set ADC to 12-bit
      pinMode(36, INPUT);
      }

      void loop() {
      int analogValue = analogRead(36);
      Serial.println(analogValue);
      delay(500);
      }
      Still always reads 0.
      Checked Digital Output (GPIO26)

      Used digitalRead(26), but the output remains LOW at all times.
      Seems like the sensor is not responding at all.
      Tested on Another ESP32 Board (M5Stack Basic)

      Same issue: Analog OUT remains 0 at all times.
      Possible Causes:

      Sensor might be defective since Analog OUT is always 0V.
      ESP32 ADC issue, but tested on another board with the same result.
      Incorrect voltage supply, but tested with both 5V and 3.3V without any difference.
      Questions:

      Is it normal for the M5Stack Reflective IR sensor's Analog OUT to stay at 0V?
      If adjusting the sensitivity (potentiometer) does not change the output, could this indicate a defective sensor?
      Are there any additional debugging steps I should try?
      I would appreciate any insights from anyone who has experience with this sensor. Thank you!

      teastainT 1 Reply Last reply Reply Quote 0
      • teastainT
        teastain @shinshin8
        last edited by teastain

        @shinshin8 said in M5Stack Reflective IR Sensor Always Reads 0:

        Board: LilyGO T-Display (ESP32-D0WDQ6-V3)

        What do you mean 'Board: LilyGO T-Display (ESP32-D0WDQ6-V3)'
        What version of Arduino IDE are you using?
        Are you using this example:
        https://github.com/m5stack/M5Unit-ReflectiveIR/blob/main/examples/detect.ino

        Later edit:
        Is the IR LED turned on?
        You can use a phone camera to observe near IR.
        Have you tried adjusting the sensitivity trim pot full scale, CW, CCW?
        Your hand may not reflect enough IR.
        The output is active low, so you should see 0Vdc when a reflective object is in the path. ADC 0Vdc as well.
        Screenshot 2025-02-10 at 3.45.54 PM.png

        Cheers, Terry!

        100% M5Stack addict with several drawers full of product!

        S 1 Reply Last reply Reply Quote 0
        • S
          shinshin8 @teastain
          last edited by shinshin8

          @teastain
          I followed your instructions and set the board to M5Core, installed the CH9102_VCP_SER_Windows.exe driver, but the port still displays as "LilyGO T-Display".

          I also checked the IR LED using the iPhone 13 mini front camera, but I couldn’t see any infrared light.

          Do you have any suggestions for further troubleshooting?

          22e8c480-2155-4749-a9d9-a019e851bcc9-image.png

          teastainT 1 Reply Last reply Reply Quote 0
          • teastainT
            teastain @shinshin8
            last edited by teastain

            @shinshin8 You must ignore that the Arduino IDE reports lilygo boards and select your own Core from the drop down. The IDE is just trying to be helpful, but is always wrong, just ignore it and select the correct board from the drop down list in the little window here:1600.jpg

            Also questions:
            Are you using this example:
            https://github.com/m5stack/M5Unit-ReflectiveIR/blob/main/examples/detect.ino?

            Have you tried adjusting the sensitivity trim pot full scale, CW, CCW?

            Your hand may not reflect enough IR.

            The output is active low, so you should see 0Vdc when a reflective object is in the path. ADC will output 0 digital, Off as well.

            Cheers, Terry!

            100% M5Stack addict with several drawers full of product!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post