Giter Club home page Giter Club logo

adafruit_veml6070's Introduction

Adafruit VEML6070 Library Build StatusDocumentation

This is a library for the Adafruit VEML6070 UV sensor breakout:

Check out the links above for our tutorials and wiring diagrams. This chip uses I2C to communicate

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

Written by Limor Fried/Ladyada for Adafruit Industries. MIT license, all text above must be included in any redistribution

adafruit_veml6070's People

Contributors

deanm1278 avatar evaherrada avatar hoffmannjan avatar ladyada avatar siddacious avatar tdicola avatar tyeth avatar

Stargazers

 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  avatar  avatar

adafruit_veml6070's Issues

Infrequent power-up to unresponsive state

I've found that infrequently, the VEML 6070 configuration register initializes to a state where the ACK feature is enabled and triggered, making it unresponsive to normal initialization and read commands. Usually, the device's configuration register maintains its last state, especially if the power supply is not interrupted, so this really doesn't happen often; yet it is guaranteed to happen if the device is used in e.g. a datalogging application where sensor power is removed on a periodic schedule.

I plan to provide a unit test case revealing the bug in a fork of the git repo, and then to submit a pull request for edits to the library that fix this bug by always reading from the Alert Response Address (ARA) before initialization.

Please let me know if you are amenable to accepting these proposed edits based on the information above, and any process/documentation standards you'd like me to follow in providing the test case. Thanks!

VEML6070 causes I2C lockup after power cycle

  • Arduino board: Uno
  • Arduino IDE version: 1.8.5
  • Steps to reproduce:

If you run the sketch below, the code will hang on the second loop iteration at uv.begin(VEML6070_HALF_T);
If you uncomment the uv.clearAck() then it will hang there.
If you comment out the lines that power-down the breakout & I2C bus, then the loop runs indefinitely as expected.
The putative problem is the Wire library getting into a wait loop for a bad bus condition to clear. Why the bad bus condition is created is unknown, since the bus is clear at the start of communication.

#include <Wire.h>
#include <Adafruit_VEML6070.h>

// Pin assignments
#define POWER_PIN (11)  // VIN pin on VEML breakout board
#define ACK_PIN   (13)     // Note blue LED will turn *off* if ACK is set

Adafruit_VEML6070 uv = Adafruit_VEML6070();

void setup() {
  Serial.begin(115200);
  Serial.println("VEML6070 Test to Reveal Bug");
  
  pinMode(POWER_PIN, OUTPUT);
  digitalWrite(POWER_PIN, LOW);
  
  digitalWrite(ACK_PIN, INPUT_PULLUP);  // ACK is open-drain

}

bool testAck() {
  bool ack = (digitalRead(ACK_PIN) == LOW);
  if (ack) { Serial.println("ACK is set (low)"); Serial.flush(); }
}

bool i2c_ready(){
  bool ready = (digitalRead(SDA) == HIGH) && (digitalRead(SCL) == HIGH);
  if (!ready) { Serial.println("I2C bus locked"); Serial.flush(); }
  return ready;
}

void loop() {
  // Power DOWN the VEML 6070, and drive the I2C bus
  // to ground to ensure the sensor is actually power-cycled
  digitalWrite(POWER_PIN, LOW);
  pinMode(SDA, OUTPUT);
  digitalWrite(SDA, LOW);
  pinMode(SCL, OUTPUT);
  digitalWrite(SCL, LOW);
  pinMode(SDA, INPUT);
  pinMode(SCL, INPUT);
  delay(100);
  
  
  // Power up and initialize the VEML 6070
  digitalWrite(POWER_PIN, HIGH);
  Wire.begin();
  delay(1000);  // For device to power up

  i2c_ready();
  testAck();
  //if (uv.clearAck()) { Serial.println("Ack was set"); Serial.flush(); }
  i2c_ready();

  Serial.print("init.. "); Serial.flush();
  uv.begin(VEML6070_HALF_T);
  Serial.println("done");

  // Attempt to read the UV value after allowing for measurement delay
  Serial.print("UV: ");
  uint16_t value = uv.readUV();
  Serial.println(value);
}

Problem with uv.begin(VEML6070_x_T);

Setting the integration time doesn't seem to make an effect on the output value.
changing VEML6070_1_T -> VEML6070_2_T should yield in doubling of the output, but it doesn't in my case.

Tested against a simple code which changes the Integration Time every time it's uploaded...

#include <Wire.h>

#define VEML6070_ADDR_ARA       (0x18 >> 1)
#define VEML6070_ADDR_CMD       (0x70 >> 1)
#define VEML6070_ADDR_DATA_LSB  (0x71 >> 1)
#define VEML6070_ADDR_DATA_MSB  (0x73 >> 1)

// VEML6070 command register bits
#define VEML6070_CMD_WDM        0x02
#define VEML6070_CMD_SD         0x01
#define VEML6070_CMD_IT_0_5T    0x00
#define VEML6070_CMD_IT_1T      0x04
#define VEML6070_CMD_IT_2T      0x08
#define VEML6070_CMD_IT_4T      0x0C
#define VEML6070_CMD_DEFAULT (VEML6070_CMD_WDM | VEML6070_CMD_IT_1T)

byte cmd = VEML6070_CMD_DEFAULT;

void setup()
{
  
  Serial.begin(9600); 
  while(!Serial);
  Serial.println(cmd,BIN);

  Wire.begin(); 
  Wire.requestFrom(VEML6070_ADDR_ARA,1);

  Wire.beginTransmission(VEML6070_ADDR_CMD);
  Wire.write(cmd);
  Serial.println(Wire.endTransmission());

  
}

void loop()
{
  uint8_t X0,X1;
  
  Wire.requestFrom(0x39,1); 
  X0 = Wire.read(); 
  
  Wire.requestFrom(0x38,1);  
  X1 = Wire.read();   
  
  Wire.endTransmission();
  
  Serial.print("X0= ");
  Serial.print(X0);
  Serial.print("   X1= ");
  Serial.println(X1);
  
  delay(500);
}

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.