GY-63_MS5611/libraries/Max44009
2021-04-25 19:56:44 +02:00
..
.github/workflows update libs 2021-04-07 13:31:22 +02:00
examples 2021-01-29 2021-01-29 12:31:58 +01:00
test 2021-01-29 2021-01-29 12:31:58 +01:00
.arduino-ci.yml 2021-01-29 2021-01-29 12:31:58 +01:00
keywords.txt 2021-01-29 2021-01-29 12:31:58 +01:00
library.json 2021-01-29 2021-01-29 12:31:58 +01:00
library.properties 2021-01-29 2021-01-29 12:31:58 +01:00
LICENSE 2021-01-29 2021-01-29 12:31:58 +01:00
max44009.cpp 2021-01-29 2021-01-29 12:31:58 +01:00
Max44009.h 2021-01-29 2021-01-29 12:31:58 +01:00
readme.md update libs 2021-04-25 19:56:44 +02:00

Arduino CI License: MIT GitHub release

MAX44009 I2C LUX sensor

Library for MAX44009 / GY-49 I2C lux sensor

Description

a.k.a. GY-49

The MAX44009 ambient light sensor is an I2C sensor, that has a 22 bit dynamic range from 0.045 lux to 188,000 lux.

Schema breakout max44009 / GY-49

//  breakout MAX44009 / GY-49
//
//      +--------+
//  VCC |o       |
//  GND |o       |
//  SCL |o      o| ADDRESS
//  SDA |o      o| -INT
//      +--------+
//
// ADDRESS:
// 0 = 0x4A
// 1 = 0x4B
//
// INT:
// Connect the INT pin to an pull up resistor
// 0 = interrupt
// 1 = no interrupt
// connect to an LED or an interrupt pin of an Arduino
//

Interface

  • enum class Boolean { True, False } enum class to prevent bool to be implicitly casted to int

Constructor

  • Max44009(address, dataPin, clockPin) dataPin, clockPin for ESP32, ESP8266
  • Max44009(address, begin = Boolean::True)
  • Max44009(begin = Boolean::True)
  • void configure(address, TwoWire *wire, begin = Boolean::True) Change I2C interface and address
  • bool isConnected() device available on I2C bus.

Basic

  • float getLux() read the sensor.
  • int getError() returns last error.

Configure thresholds

check datasheet for details

  • void setHighThreshold(float)
  • float getHighThreshold(void)
  • void setLowThreshold(float)
  • float getLowThreshold(void)
  • void setThresholdTimer(uint8_t) 2 seems practical minimum
  • uint8_t getThresholdTimer() returns

Configure interrupts

check datasheet for details

  • void enableInterrupt()
  • void disableInterrupt()
  • bool interruptEnabled()
  • uint8_t getInterruptStatus()

Configure flags

check datasheet for details

  • void setConfiguration(uint8_t)
  • uint8_t getConfiguration()

Configure sample mode

check datasheet for details

  • void setAutomaticMode()
  • void setContinuousMode() uses more power
  • void clrContinuousMode() uses less power
  • void setManualMode(uint8_t CDR, uint8_t TIM)
  • int getIntegrationTime() returns time in milliseconds
    CDR = Current Divisor Ratio
    CDR = 1 ==> only 1/8th is measured

    TIM = Time Integration Measurement (table)
    000  800ms
    001  400ms
    010  200ms
    011  100ms
    100   50ms       manual only
    101   25ms       manual only
    110   12.5ms     manual only
    111    6.25ms    manual only

Examples

Max44009\examples\max44009_test01

  • use for e.g. UNO (use voltage convertor!)

Max44009\examples\max44009_test02

  • will not compile for UNO
  • use for e.g. ESP32

Notes

Please be aware this is a 3.3 Volt device so it should not be connected to an Arduino or other 5 Volt device directly. Use a level convertor to solve this.

Do not forget to connect the address pin as you cannot read the sensor in a reliable way. As the line will float it will sometimes have the right address and sometimes not. (been there ;)