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

    DLight keeps giving max value

    PRODUCTS
    1
    1
    215
    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.
    • A
      amateur58
      last edited by amateur58

      I have a brand new DLight. I used the M5Stack example code but all I get is the max value of the sensor, even when I cover the sensor. I tried all 6 modes. I also searched the internet but couldn't find any solution. I added a counter to the example. Here is my code:

      #include <M5Atom.h>
      #include <M5_DLight.h>
      
      M5_DLight sensor;
      uint16_t lux;
      uint16_t counter = 0;
      
      void setup() {
          M5.begin(true, true, true);
          Serial.println("Sensor begin.....");
          sensor.begin();
      
          // CONTINUOUSLY_H_RESOLUTION_MODE
          // CONTINUOUSLY_H_RESOLUTION_MODE2
          // CONTINUOUSLY_L_RESOLUTION_MODE
          // ONE_TIME_H_RESOLUTION_MODE
          // ONE_TIME_H_RESOLUTION_MODE2
          // ONE_TIME_L_RESOLUTION_MODE
          sensor.setMode(CONTINUOUSLY_H_RESOLUTION_MODE);
      }
      
      void loop() {
          M5.dis.fillpix(0x00ff00);
          lux = sensor.getLUX();
          Serial.printf("lux: %d\n", lux);
          counter = counter + 1;
          Serial.printf("Counter: %d\n", counter);
          delay(200);
      }
      

      This is the only output I get:

      Counter: 32
      lux: 65535
      Counter: 33
      lux: 65535
      Counter: 34
      lux: 65535
      Counter: 35
      lux: 65535
      Counter: 36
      lux: 65535
      Counter: 37
      

      Does anyone have an idea what I'm doing wrong?

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