🤖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

    Scheduled Pinned Locked Moved PRODUCTS
    1 Posts 1 Posters 902 Views
    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 Offline
      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

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post