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 * MAX44009.cpp
mitea1 0:f2815503561f 3 *
mitea1 0:f2815503561f 4 * Created on: 18.05.2016
mitea1 0:f2815503561f 5 * Author: Adrian
mitea1 0:f2815503561f 6 */
mitea1 0:f2815503561f 7
mitea1 0:f2815503561f 8 #include "MAX44009.h"
mitea1 0:f2815503561f 9
mitea1 0:f2815503561f 10 MAX44009::MAX44009(I2C_RT* i2c) {
mitea1 0:f2815503561f 11 // TODO Auto-generated constructor stub
mitea1 0:f2815503561f 12 setI2CRT(i2c);
mitea1 0:f2815503561f 13 this->config = new MAX44009Config();
mitea1 0:f2815503561f 14 }
mitea1 0:f2815503561f 15
mitea1 0:f2815503561f 16 MAX44009::~MAX44009() {
mitea1 0:f2815503561f 17 // TODO Auto-generated destructor stub
mitea1 0:f2815503561f 18 }
mitea1 0:f2815503561f 19
mitea1 0:f2815503561f 20 void MAX44009::init(MAX44009_MODE desiredMode){
mitea1 0:f2815503561f 21 config->build(desiredMode);
mitea1 0:f2815503561f 22 setIntegrationTime();
mitea1 0:f2815503561f 23 setContinousMode();
mitea1 0:f2815503561f 24 configureInterrupts();
mitea1 0:f2815503561f 25 setUpperThreshold();
mitea1 0:f2815503561f 26 setLowerThreshold();
mitea1 0:f2815503561f 27 }
mitea1 0:f2815503561f 28
mitea1 0:f2815503561f 29 float MAX44009::getLux(){
mitea1 0:f2815503561f 30 uint8_t registerData[2];
mitea1 0:f2815503561f 31
mitea1 0:f2815503561f 32 i2c->read_RT(MAX44009_ADRESS,MAX44009_LUX_H_L_BYTE,true,registerData,2);
mitea1 0:f2815503561f 33
mitea1 0:f2815503561f 34 uint8_t exponent = (registerData[0] >> 4) & 0xF;
mitea1 0:f2815503561f 35 uint8_t mantissa = registerData[0] & 0xF;
mitea1 0:f2815503561f 36
mitea1 0:f2815503561f 37 return calculateLux(mantissa,exponent);
mitea1 0:f2815503561f 38
mitea1 0:f2815503561f 39
mitea1 0:f2815503561f 40 }
mitea1 0:f2815503561f 41
mitea1 0:f2815503561f 42 float MAX44009::calculateLux(uint8_t mantissa, uint8_t exponent){
mitea1 0:f2815503561f 43 return pow(2.0,exponent) * mantissa * 0.72;
mitea1 0:f2815503561f 44 }
mitea1 0:f2815503561f 45
mitea1 0:f2815503561f 46 void MAX44009::setIntegrationTime(){
mitea1 0:f2815503561f 47 uint8_t registerValue = config->getIntegrationTime();
mitea1 0:f2815503561f 48 i2c->write_RT(MAX44009_ADRESS,MAX44009_CONFIG,false,&registerValue,1);
mitea1 0:f2815503561f 49 }
mitea1 0:f2815503561f 50
mitea1 0:f2815503561f 51 void MAX44009::setContinousMode(){
mitea1 0:f2815503561f 52 uint8_t registerValue = (config->getContinousMode()) << 7;
mitea1 0:f2815503561f 53 i2c->write_RT(MAX44009_ADRESS,MAX44009_CONFIG,false,&registerValue,1);
mitea1 0:f2815503561f 54 }
mitea1 0:f2815503561f 55
mitea1 0:f2815503561f 56 void MAX44009::setManualConfig(){
mitea1 0:f2815503561f 57 uint8_t registerValue = (config->getManualConfig()) << 6;
mitea1 0:f2815503561f 58 i2c->write_RT(MAX44009_ADRESS,MAX44009_CONFIG,false,&registerValue,1);
mitea1 0:f2815503561f 59 }
mitea1 0:f2815503561f 60
mitea1 0:f2815503561f 61 void MAX44009::configureInterrupts(){
mitea1 0:f2815503561f 62 uint8_t registerValue = config->getInterruptEnable();
mitea1 0:f2815503561f 63 i2c->write_RT(MAX44009_ADRESS,MAX44009_INT_ENABLE,false,&registerValue,1);
mitea1 0:f2815503561f 64 }
mitea1 0:f2815503561f 65
mitea1 0:f2815503561f 66 void MAX44009::setUpperThreshold(){
mitea1 0:f2815503561f 67 uint8_t registerValue = config->getUpperThreshold();
mitea1 0:f2815503561f 68 i2c->write_RT(MAX44009_ADRESS,MAX44009_TH_UPPER,false,&registerValue,1);
mitea1 0:f2815503561f 69 }
mitea1 0:f2815503561f 70
mitea1 0:f2815503561f 71 void MAX44009::setLowerThreshold(){
mitea1 0:f2815503561f 72 uint8_t registerValue = config->getLowerThreshold();
mitea1 0:f2815503561f 73 i2c->write_RT(MAX44009_ADRESS,MAX44009_TH_LOWER,false,&registerValue,1);
mitea1 0:f2815503561f 74 }
mitea1 0:f2815503561f 75
mitea1 0:f2815503561f 76 void MAX44009::setI2CRT(I2C_RT* i2c){
mitea1 0:f2815503561f 77 this->i2c = i2c;
mitea1 0:f2815503561f 78 }