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.
Supported Sensors
- MAX44009 (Lux Measurment) http://www.ebay.ie/itm/MAX44009-Ambient-Light-Sensor-Module-for-Arduino-with-4P-Pin-Header-/381676089124?hash=item58ddaaef24:g:-ecAAOSwzJ5XZm5E
- BME280 (Temperature, Pressure and Humdity Measurment) At the moment there are some known problem using this. https://www.adafruit.com/product/2652 https://www.amazon.com/Diymall-Pressure-Temperature-Sensor-Arduino/dp/B0118XCKTG
- MPU9250 (Acceleration, Gyroscope and Magnetometer) http://www.watterott.com/de/9-DOF-IMU-Module-With-MPU-9250
- Si1143 (Proximity up to 50cm) https://moderndevice.com/product/si1143-proximity-sensors/
- uBlox M8Q (GPS Position) http://www.dx.com/de/p/gygpsv3-m8n-u-blox-neo-m8n-001-flight-controller-gps-module-blue-394557#.V4lFW-uLRhE
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
app/SI1143.cpp
- Committer:
- mitea1
- Date:
- 2016-07-06
- Revision:
- 0:f2815503561f
File content as of revision 0:f2815503561f:
/* * SI1143.cpp * * Created on: Jun 2, 2016 * Author: Adrian */ #include "SI1143.h" SI1143::SI1143(I2C_RT* i2c) { this->i2c = i2c; this->config = new SI1143Config(); } void SI1143::init(SI1143_MODE desiredMode){ config->build(desiredMode); restart(); } void SI1143::restart() { command(SI1143_RESET); osDelay(30); uint8_t writeValue; // Setting up LED Power to full writeValue = SI1143_HW_KEY_VAL0; i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_HW_KEY,false,&writeValue,1); writeValue = config->getLed1Voltage(); i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_PS_LED21,false,&writeValue,1); writeValue = 0x0A; i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_PS_LED3,false,&writeValue,1); writeValue = SI1143_ALS_IR_TASK + SI1143_ALS_VIS_TASK + SI1143_PS1_TASK + SI1143_PS2_TASK + SI1143_PS3_TASK; i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_PARAM_WR,false,&writeValue,1); command(SI1143_PARAM_SET + (SI1143_CHLIST & 0x1F)); writeValue = 0x04; i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_PARAM_WR,false,&writeValue,1); command(SI1143_PARAM_SET + (SI1143_PS_ADC_MISC & 0x1F)); i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_INT_CFG,false,0,1); i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_IRQ_ENABLE,false,0,1); i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_IRQ_MODE1,false,0,1); i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_IRQ_MODE2,false,0,1); } // void SI1143::command(uint8_t cmd) { uint8_t val; i2c->read_RT((SI1143_IR_ADDRESS<<1),SI1143_RESPONSE,false,&val,1); osDelay(100); while(val!=0) { i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_COMMAND,false,SI1143_NOP,1); osDelay(10); i2c->read_RT((SI1143_IR_ADDRESS<<1),SI1143_RESPONSE,false,&val,1); } do{ i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_COMMAND,false,&cmd,1); osDelay(10); if(cmd==SI1143_RESET){ break; } osDelay(10); i2c->read_RT((SI1143_IR_ADDRESS<<1),SI1143_RESPONSE,false,&val,1); }while(val==0); } int SI1143::getProximity(int numberOfMeasurements) // Read the data for the first LED { uint8_t lowByte; uint8_t highByte; int stack = 0; int proximity = 0; command(SI1143_PSALS_FORCE); for(int r=numberOfMeasurements; r>0; r=r-1) { i2c->read_RT((SI1143_IR_ADDRESS<<1),SI1143_PS1_DATA0,false,&lowByte,1); i2c->read_RT((SI1143_IR_ADDRESS<<1),SI1143_PS1_DATA1,false,&highByte,1); stack = stack + (highByte * 256) + lowByte; } proximity = stack / numberOfMeasurements; return proximity; } int SI1143::getAmbientLight(int numberOfMeasurements) // Read the data for ambient light { uint8_t lowByte; uint8_t highByte; int stack = 0; int ambientLight = 0; command(SI1143_PSALS_FORCE); for(int r=numberOfMeasurements; r>0; r=r-1) { i2c->read_RT((SI1143_IR_ADDRESS<<1),SI1143_ALS_VIS_DATA0,false,&lowByte,1); i2c->read_RT((SI1143_IR_ADDRESS<<1),SI1143_ALS_VIS_DATA1,false,&highByte,1); stack = stack + (highByte * 256) + lowByte; } ambientLight = stack / numberOfMeasurements; return ambientLight; } int SI1143::getInfraRedLight(int numberOfMeasurements) // Read the data for infrared light { uint8_t lowByte; uint8_t highByte; int stack = 0; int infraRedLight = 0; command(SI1143_PSALS_FORCE); for(int r=numberOfMeasurements; r>0; r=r-1) { i2c->read_RT((SI1143_IR_ADDRESS<<1),SI1143_ALS_IR_DATA0,false,&lowByte,1); i2c->read_RT((SI1143_IR_ADDRESS<<1),SI1143_ALS_IR_DATA1,false,&highByte,1); stack = stack + (highByte * 256) + lowByte; } infraRedLight = stack / numberOfMeasurements; return infraRedLight; } void SI1143::configureInterrupts(){ uint8_t interruptEnableValue = config->getInterruptEnable(); i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_IRQ_ENABLE,false,0,1); } void SI1143::setProximitySensing1Threshold(){ uint8_t thresholdLowByte = (config->getProximitySensing1Threshold()) & 0xFF; uint8_t thresholdHighByte = (config->getProximitySensing1Threshold()) >> 8; i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_PS1_TH0,false,&thresholdLowByte,1); i2c->write_RT((SI1143_IR_ADDRESS<<1),SI1143_PS1_TH1,false,&thresholdHighByte,1); }