Giter VIP home page Giter VIP logo

adafruit_veml7700's Introduction

Adafruit_VEML7700 Build Status

This is the Adafruit VEML7700 Lux sensor library

Tested and works great with the Adafruit VEML7700 Breakout Board

This chip uses I2C to communicate, 2 pins are required to interface

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Written by Kevin Townsend/Limor Fried for Adafruit Industries.
BSD license, check license.txt for more information All text above must be included in any redistribution

adafruit_veml7700's People

Contributors

brentru avatar caternuson avatar evaherrada avatar jgromes avatar julianiolo avatar ladyada avatar siddacious avatar theofficialmrblah avatar tyeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_veml7700's Issues

Delay introduced when reading sensor from v1.2.0 to v2.0.1

  • Arduino board: Adafruit Metro M4

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.16

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):
    I am using two adafruit VEML7700 breakouts through an adafruit TCA9548A mulitplexer to track light as a function on my robot. I updated to the latest version of the library v2.0.1 and this caused massive delays in my main loop (on the order of 800ms). Reverting back to version v1.2.0 the delays disappeared and the code functioned normally. I went into the header and cpp and compared them for the new and old library and a new function has been introduced readWait() which calls 'delay()' every time the readlux() function is called. I would suggest removing the use of delay() as it does not allow the user to manage their own timing and essentially bricks the main board when 'readlux()' is called. The previous version of the sensor code allowed the main control loop of my robot to manage other tasks while waiting for the integration time of the light sensor (e.g. running the PIDs controlling the motor speed).

Gain and Integration Time Not Changing

  • Board: Espressif ESP32-S2

  • Arduino IDE version: 1.8.13

I'm trying to run the sample sketch, and I'm just getting 0s for all the values. I noticed that even when I change the gain and integration time with setGain() and setIntegrationTime(), the values printed out by getGain() and getIntegrationTime() are always 1 for the gain and 100ms for the integration time.

readLux() will return -1 for NOWAIT options

The logic change in #22 is flawed. The switch statement for VEML_LUX_NORMAL_NOWAIT and VEML_LUX_CORRECTED_NOWAIT will always return -1 instead of actually performing and ALS reading.

See commit comment:
aadc65f#comments

Test sketch:

#include "Adafruit_VEML7700.h"

Adafruit_VEML7700 veml = Adafruit_VEML7700();

void setup() {
  Serial.begin(9600);
  while (!Serial) { delay(10); }
  
  Serial.println("Adafruit VEML7700 Test");

  if (!veml.begin()) {
    Serial.println("Sensor not found");
    while (1);
  }
  Serial.println("Sensor found");

  Serial.print("lux = "); Serial.println(veml.readLux(VEML_LUX_NORMAL_NOWAIT));
  Serial.print("lux = "); Serial.println(veml.readLux(VEML_LUX_CORRECTED_NOWAIT));
  Serial.print("lux = "); Serial.println(veml.readLux(VEML_LUX_NORMAL));
  Serial.print("lux = "); Serial.println(veml.readLux(VEML_LUX_CORRECTED));
  Serial.print("lux = "); Serial.println(veml.readLux(VEML_LUX_AUTO));
}

void loop() {
}

Result:
Screenshot from 2023-06-23 08-57-40

Reading value stuck

Reading the lux value (veml.readLux(VEML_LUX_AUTO)) gets stuck if the sensor is not available.
Is there a solution for this?

I had also the problem with AutoLux after night i get the value 0lx also when the sun is shining.

Bug in example code

I could not get the veml7700_test example code to work. I found the first few lines of the Setup as follows:

void setup() {
while (!Serial) { delay(10); }
Serial.begin(115200);
Serial.println("Adafruit VEML7700 Test");
......

When I run the sketch the serial monitor shows nothing. I see that the while(!Serial) comes before the Serial.begin so as far as I understand it the while statement is looking for a serial input before Serial is initialized. I can't see this ever working so I swapped those lines and everything works.

"Adafruit Unified Sensor" missing from the 'depends' statement in 'library.properties' file

Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

  • Do not use GitHub issues for troubleshooting projects and issues. Instead use
    the forums at http://forums.adafruit.com to ask questions and troubleshoot why
    something isn't working as expected. In many cases the problem is a common issue
    that you will more quickly receive help from the forum community. GitHub issues
    are meant for known defects in the code. If you don't know if there is a defect
    in the code then start with troubleshooting on the forum first.

  • If following a tutorial or guide be sure you didn't miss a step. Carefully
    check all of the steps and commands to run have been followed. Consult the
    forum if you're unsure or have questions about steps in a guide/tutorial.

  • For Arduino projects check these very common issues to ensure they don't apply:

    • For uploading sketches or communicating with the board make sure you're using
      a USB data cable and not a USB charge-only cable. It is sometimes
      very hard to tell the difference between a data and charge cable! Try using the
      cable with other devices or swapping to another cable to confirm it is not
      the problem.

    • Be sure you are supplying adequate power to the board. Check the specs of
      your board and plug in an external power supply. In many cases just
      plugging a board into your computer is not enough to power it and other
      peripherals.

    • Double check all soldering joints and connections. Flakey connections
      cause many mysterious problems. See the guide to excellent soldering for examples of good solder joints.

    • Ensure you are using an official Arduino or Adafruit board. We can't
      guarantee a clone board will have the same functionality and work as expected
      with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

  • Arduino board: INSERT ARDUINO BOARD NAME/TYPE HERE
    ESP8266

  • Arduino IDE version (found in Arduino -> About Arduino menu): INSERT ARDUINO
    VERSION HERE

    N/A, using platformio

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

During compile, errors result from omission of the "Adafruit Unified Sensor" library, because it is missing from the 'depends' statement in this repo's 'library.properties' file

Auto Lux gets stuck in dark conditions

  • Arduino board: Adafruit QT Py ESP32-S2

  • Arduino IDE version (found in Arduino -> About Arduino menu): 2.0.3, running ESPHome

  • List the steps to reproduce the problem below:

In this code I am trying to poll a VEML7700 every 15 seconds, to send back the "auto lux" value.

This works well, until the sensor is no longer exposed to any light. Once the light level drops to 0, the auto lux function will not return anything until the sensor is re-exposed to light

For example, if you cover the sensor with a cup, the auto lux function will start, but it will not return a value until you pick up the cup. In my case this blocks the entire system and the ESP device shuts down... until you pick up the cup.

The cup is just an example, I noticed this when all of my sensors started going offline at night

#include "esphome.h"
#include "Adafruit_VEML7700.h"

class VEML7700 : public PollingComponent, public Sensor {
    public:
    Adafruit_VEML7700 veml;
    
    VEML7700() : PollingComponent(15000) {}

    float get_setup_priority() const override { return esphome::setup_priority::DATA; }

    void setup() override {
        Serial.begin(115200);
        while (!Serial) { delay(10); }
        Serial.println("Adafruit VEML7700 Auto Lux Test");

        if (!veml.begin()) {
            Serial.println("Sensor not found");
            while (1);
        }
        Serial.println("Sensor found");
    }

    void update() override {

 // When light level drops to 0, Serial will print the first statement,
// but the second will not come until the sensor is re-exposed to light.
// If I remove "VEML_LUX_AUTO", the value is always returned immediately

        Serial.println("Calculating Auto Lux...");
        float lux = veml.readLux(VEML_LUX_AUTO);
        Serial.print("Lux = "); Serial.println(lux);

        publish_state(lux);
        
    }

};

Here is the serial output, with notes added when the sensor was covered and re-exposed to light:

[D][api:102]: Accepted ::FFFF:10.0.1.3
Calculating Auto Lux...
Lux = 5.70
[D][sensor:127]: 'VEML7700': Sending state 5.70240 lux with 0 decimals of accuracy
Calculating Auto Lux...
Lux = 5.82
[D][sensor:127]: 'VEML7700': Sending state 5.81760 lux with 0 decimals of accuracy
**  Sensor Covered
Calculating Auto Lux...
Lux = 0.00
[D][sensor:127]: 'VEML7700': Sending state 0.00000 lux with 0 decimals of accuracy
Calculating Auto Lux...
[Disconnected]
**   Wait 5 Minutes
**   Uncover Sensor
[Connected]
Sensor found
[C][wifi:037]: Setting up WiFi...
Calculating Auto Lux...
[Disconnected]
[Connected]
Adafruit VEML7700 Auto Lux Test
Sensor found
[C][wifi:037]: Setting up WiFi...
Calculating Auto Lux...
Lux = 5.47
[D][sensor:127]: 'VEML7700': Sending state 5.47200 lux with 0 decimals of accuracy

And here are serial logs from a different device (generic esp32 dev board), when covered it says there is a problem with the loop task:

E (62139) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (62139) task_wdt:  - loopTask (CPU 1)
E (62139) task_wdt: Tasks currently running:
E (62139) task_wdt: CPU 0: IDLE
E (62139) task_wdt: CPU 1: IDLE
E (62139) task_wdt: Aborting.

abort() was called at PC 0x400efae5 on core 0


Backtrace:0x40083aa5:0x3ffbea4c |<-CORRUPTED




ELF file SHA256: 0000000000000000

ESP32 Compile Issues

Output log from a runner:

/home/runner/Arduino/libraries/Adafruit_VEML7700_Library/Adafruit_VEML7700.cpp: In member function 'float Adafruit_VEML7700::readLux(luxMethod)':
  /home/runner/Arduino/libraries/Adafruit_VEML7[70](https://github.com/adafruit/Adafruit_Wippersnapper_Arduino/actions/runs/3234897613/jobs/5298588942#step:8:71)0_Library/Adafruit_VEML7700.cpp:94:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
       wait = false;
       ~~~~~^~~~~~~
  /home/runner/Arduino/libraries/Adafruit_VEML7700_Library/Adafruit_VEML7700.cpp:95:3: note: here
     case VEML_LUX_NORMAL:
     ^~~~
  /home/runner/Arduino/libraries/Adafruit_VEML7700_Library/Adafruit_VEML7700.cpp:98:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
       wait = false;
       ~~~~~^~~~~~~
  /home/runner/Arduino/libraries/Adafruit_VEML[77](https://github.com/adafruit/Adafruit_Wippersnapper_Arduino/actions/runs/3234897613/jobs/5298588942#step:8:78)00_Library/Adafruit_VEML7700.cpp:99:3: note: here
     case VEML_LUX_CORRECTED:
     ^~~~

When I tried to build the sample app, it requires Adafruit_i2cDevice.h and Adafruit_I2cregister.h . These files are not found by the compiler. I checked on my machine, and no files of these names exist anywhere on my machine. There is not such file in the library, nor is there another library that has a name like this. The only places I could find the names in a github search were in the header files for Adafruit_VEML7700 sources that do a #include. Something is missing here.

Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

  • Do not use GitHub issues for troubleshooting projects and issues. Instead use
    the forums at http://forums.adafruit.com to ask questions and troubleshoot why
    something isn't working as expected. In many cases the problem is a common issue
    that you will more quickly receive help from the forum community. GitHub issues
    are meant for known defects in the code. If you don't know if there is a defect
    in the code then start with troubleshooting on the forum first.

  • If following a tutorial or guide be sure you didn't miss a step. Carefully
    check all of the steps and commands to run have been followed. Consult the
    forum if you're unsure or have questions about steps in a guide/tutorial.

  • For Arduino projects check these very common issues to ensure they don't apply:

    • For uploading sketches or communicating with the board make sure you're using
      a USB data cable and not a USB charge-only cable. It is sometimes
      very hard to tell the difference between a data and charge cable! Try using the
      cable with other devices or swapping to another cable to confirm it is not
      the problem.

    • Be sure you are supplying adequate power to the board. Check the specs of
      your board and plug in an external power supply. In many cases just
      plugging a board into your computer is not enough to power it and other
      peripherals.

    • Double check all soldering joints and connections. Flakey connections
      cause many mysterious problems. See the guide to excellent soldering for examples of good solder joints.

    • Ensure you are using an official Arduino or Adafruit board. We can't
      guarantee a clone board will have the same functionality and work as expected
      with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

  • Arduino board: INSERT ARDUINO BOARD NAME/TYPE HERE

  • Arduino IDE version (found in Arduino -> About Arduino menu): INSERT ARDUINO
    VERSION HERE

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.