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

LoRa-Sensornode Firmware for Multitech mDot

A multifunctional and modular Firmware for Multitech's mDot which provides a widerange of functionality for several Sensors. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

/media/uploads/mitea1/logo-lora-600x370.png /media/uploads/mitea1/mt_mdot_family_642px.png

Supported Sensors

Idea

The Firmware has some predefined Application Modes running different Tasks(Measurements). Each mode can be used in a different Scenario. Application_Modes define which sensors are used, how often they aquire data and how often the data has to be sent via LoRa. Lets say you just want to measure the Light then you choose an Application_Mode (or define one) that only runs TaskLight for light measurement. As a standard all measurements are taken every second and sent via LoRa but you can change that interval depending on your usage Scenario

Committer:
mitea1
Date:
Fri Nov 02 17:01:02 2018 +0000
Revision:
10:4051c38bf73f
Parent:
0:f2815503561f
wtf

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mitea1 0:f2815503561f 1 /**
mitea1 0:f2815503561f 2 * @file MAX44009.h
mitea1 0:f2815503561f 3 *
mitea1 0:f2815503561f 4 * @author Adrian
mitea1 0:f2815503561f 5 * @date 16.05.2016
mitea1 0:f2815503561f 6 */
mitea1 0:f2815503561f 7
mitea1 0:f2815503561f 8 #include <stdint.h>
mitea1 0:f2815503561f 9 #include <math.h>
mitea1 0:f2815503561f 10 #include "I2C_RT.h"
mitea1 0:f2815503561f 11 #include "MAX44009Config.h"
mitea1 0:f2815503561f 12
mitea1 0:f2815503561f 13 #ifndef APP_MAX44009_H_
mitea1 0:f2815503561f 14 #define APP_MAX44009_H_
mitea1 0:f2815503561f 15
mitea1 0:f2815503561f 16 #define MAX44009_ADRESS 0b10010100
mitea1 0:f2815503561f 17 #define MAX44009_CONFIG 0x02
mitea1 0:f2815503561f 18 #define MAX44009_LUX_H_BYTE 0x03
mitea1 0:f2815503561f 19 #define MAX44009_LUX_L_BYTE 0x04
mitea1 0:f2815503561f 20 #define MAX44009_LUX_H_L_BYTE 0x0304
mitea1 0:f2815503561f 21
mitea1 0:f2815503561f 22 #define MAX44009_INT_ENABLE 0x01
mitea1 0:f2815503561f 23 #define MAX44009_TH_UPPER 0x05
mitea1 0:f2815503561f 24 #define MAX44009_TH_LOWER 0x06
mitea1 0:f2815503561f 25
mitea1 0:f2815503561f 26 /**
mitea1 0:f2815503561f 27 * @class MAX44009
mitea1 0:f2815503561f 28 * @brief Provides Functionality to control the MAX44009 Sensor on the Sensbert
mitea1 0:f2815503561f 29 */
mitea1 0:f2815503561f 30 class MAX44009 {
mitea1 0:f2815503561f 31 public:
mitea1 0:f2815503561f 32 MAX44009(I2C_RT*);
mitea1 0:f2815503561f 33 virtual ~MAX44009();
mitea1 0:f2815503561f 34
mitea1 0:f2815503561f 35 /**
mitea1 0:f2815503561f 36 * @brief Initializes the MAX44009 according to the desired MAX44009_MODE
mitea1 0:f2815503561f 37 * @param desiredMode the desired Mode depending on which the MAX44009 has to be
mitea1 0:f2815503561f 38 * configured
mitea1 0:f2815503561f 39 */
mitea1 0:f2815503561f 40 void init(MAX44009_MODE desiredMode);
mitea1 0:f2815503561f 41
mitea1 0:f2815503561f 42 /**
mitea1 0:f2815503561f 43 * @brief Returns the actual lux values that has been measured by the sensor
mitea1 0:f2815503561f 44 * @return
mitea1 0:f2815503561f 45 */
mitea1 0:f2815503561f 46 float getLux();
mitea1 0:f2815503561f 47
mitea1 0:f2815503561f 48 private:
mitea1 0:f2815503561f 49 I2C_RT* i2c;
mitea1 0:f2815503561f 50 MAX44009Config* config;
mitea1 0:f2815503561f 51
mitea1 0:f2815503561f 52 /**
mitea1 0:f2815503561f 53 * @brief Calculates the lux value according to the mantissa and exponent whose have been read
mitea1 0:f2815503561f 54 * from the sensor registers. Calculation is documented in the Datasheet of MAX44009
mitea1 0:f2815503561f 55 * @param mantissa read mantissa from Sensor register
mitea1 0:f2815503561f 56 * @param exponent read exponent from Sensor register
mitea1 0:f2815503561f 57 * @return
mitea1 0:f2815503561f 58 */
mitea1 0:f2815503561f 59 float calculateLux(uint8_t mantissa,uint8_t exponent);
mitea1 0:f2815503561f 60
mitea1 0:f2815503561f 61 /**
mitea1 0:f2815503561f 62 * @brief Set the integration time for Lux Measurements internally of the MAX44009
mitea1 0:f2815503561f 63 * according to its MAX44009Config
mitea1 0:f2815503561f 64 */
mitea1 0:f2815503561f 65 void setIntegrationTime();
mitea1 0:f2815503561f 66
mitea1 0:f2815503561f 67 /**
mitea1 0:f2815503561f 68 * @brief Set the MAX44009 lux measurements ContinousMode internally of the MAX44009
mitea1 0:f2815503561f 69 * according to its MAX44009Config
mitea1 0:f2815503561f 70 */
mitea1 0:f2815503561f 71 void setContinousMode();
mitea1 0:f2815503561f 72
mitea1 0:f2815503561f 73 /**
mitea1 0:f2815503561f 74 * @brief Set the MAX44009 lux measurements ManualConfig internally of the MAX44009
mitea1 0:f2815503561f 75 * according to its MAX44009Config
mitea1 0:f2815503561f 76 */
mitea1 0:f2815503561f 77 void setManualConfig();
mitea1 0:f2815503561f 78
mitea1 0:f2815503561f 79 /**
mitea1 0:f2815503561f 80 * @brief Set the I2C device that communicates with MAX44009
mitea1 0:f2815503561f 81 * @param i2c i2c device that communicates with MAX44009
mitea1 0:f2815503561f 82 */
mitea1 0:f2815503561f 83 void setI2CRT(I2C_RT* i2c);
mitea1 0:f2815503561f 84
mitea1 0:f2815503561f 85
mitea1 0:f2815503561f 86 /**
mitea1 0:f2815503561f 87 * @brief Configure MAX44009 interrupts internally
mitea1 0:f2815503561f 88 * according to its MAX44009Config
mitea1 0:f2815503561f 89 */
mitea1 0:f2815503561f 90 void configureInterrupts();
mitea1 0:f2815503561f 91
mitea1 0:f2815503561f 92 /**
mitea1 0:f2815503561f 93 * @brief Configure MAX44009 upper Lux Threshold that triggers an Interrupt
mitea1 0:f2815503561f 94 * according to its MAX44009Config
mitea1 0:f2815503561f 95 */
mitea1 0:f2815503561f 96 void setUpperThreshold();
mitea1 0:f2815503561f 97
mitea1 0:f2815503561f 98 /**
mitea1 0:f2815503561f 99 * @brief Configure MAX44009 lower Lux Threshold that triggers an Interrupt
mitea1 0:f2815503561f 100 * according to its MAX44009Config
mitea1 0:f2815503561f 101 */
mitea1 0:f2815503561f 102 void setLowerThreshold();
mitea1 0:f2815503561f 103 };
mitea1 0:f2815503561f 104
mitea1 0:f2815503561f 105 #endif /* APP_MAX44009_H_ */