A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

Dependencies:   mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MAX44009.h Source File

MAX44009.h

Go to the documentation of this file.
00001 /**
00002  * @file MAX44009.h
00003  *
00004  * @author Adrian
00005  * @date 16.05.2016
00006  */
00007 
00008 #include <stdint.h>
00009 #include <math.h>
00010 #include "I2C_RT.h "
00011 #include "MAX44009Config.h "
00012 
00013 #ifndef APP_MAX44009_H_
00014 #define APP_MAX44009_H_
00015 
00016 #define MAX44009_ADRESS         0b10010100
00017 #define MAX44009_CONFIG         0x02
00018 #define MAX44009_LUX_H_BYTE     0x03
00019 #define MAX44009_LUX_L_BYTE     0x04
00020 #define MAX44009_LUX_H_L_BYTE   0x0304
00021 
00022 #define MAX44009_INT_ENABLE     0x01
00023 #define MAX44009_TH_UPPER       0x05
00024 #define MAX44009_TH_LOWER       0x06
00025 
00026 /**
00027  * @class MAX44009
00028  * @brief Provides Functionality to control  the MAX44009 Sensor on the Sensbert
00029  */
00030 class MAX44009 {
00031 public:
00032     MAX44009(I2C_RT*);
00033     virtual ~MAX44009();
00034 
00035     /**
00036      * @brief Initializes the MAX44009 according to the desired MAX44009_MODE
00037      * @param desiredMode the desired Mode depending on which the MAX44009 has to be
00038      * configured
00039      */
00040     void init(MAX44009_MODE desiredMode);
00041 
00042     /**
00043      * @brief Returns the actual lux values that has been measured by the sensor
00044      * @return
00045      */
00046     float getLux();
00047 
00048 private:
00049     I2C_RT* i2c;
00050     MAX44009Config* config;
00051 
00052     /**
00053      * @brief Calculates the lux value according to the mantissa and exponent whose have been read
00054      * from the sensor registers. Calculation is documented in the Datasheet of MAX44009
00055      * @param mantissa  read mantissa from Sensor register
00056      * @param exponent  read exponent from Sensor register
00057      * @return
00058      */
00059     float calculateLux(uint8_t mantissa,uint8_t exponent);
00060 
00061     /**
00062      * @brief Set the integration time for Lux Measurements internally of the MAX44009
00063      * according to its MAX44009Config
00064      */
00065     void setIntegrationTime();
00066 
00067     /**
00068      * @brief Set the MAX44009 lux measurements ContinousMode internally of the MAX44009
00069      * according to its MAX44009Config
00070      */
00071     void setContinousMode();
00072 
00073     /**
00074      * @brief Set the MAX44009 lux measurements ManualConfig internally of the MAX44009
00075      * according to its MAX44009Config
00076      */
00077     void setManualConfig();
00078 
00079     /**
00080      * @brief Set the I2C device that communicates with MAX44009
00081      * @param i2c i2c device that communicates with MAX44009
00082      */
00083     void setI2CRT(I2C_RT* i2c);
00084 
00085 
00086     /**
00087      * @brief Configure MAX44009 interrupts internally
00088      * according to its MAX44009Config
00089      */
00090     void configureInterrupts();
00091 
00092     /**
00093      * @brief Configure MAX44009 upper Lux Threshold that triggers an Interrupt
00094      * according to its MAX44009Config
00095      */
00096     void setUpperThreshold();
00097 
00098     /**
00099      * @brief Configure MAX44009 lower Lux Threshold that triggers an Interrupt
00100      * according to its MAX44009Config
00101      */
00102     void setLowerThreshold();
00103 };
00104 
00105 #endif /* APP_MAX44009_H_ */