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 16:58:23 2018 +0000
Revision:
9:c4e378f4801d
Parent:
7:87cbeafdba06
[MOD]initial commit for flowsensor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mitea1 0:f2815503561f 1 /*
mitea1 0:f2815503561f 2 * Application.h
mitea1 0:f2815503561f 3 *
mitea1 0:f2815503561f 4 * Created on: Jun 3, 2016
mitea1 0:f2815503561f 5 * Author: Adrian
mitea1 0:f2815503561f 6 */
mitea1 0:f2815503561f 7
mitea1 0:f2815503561f 8 #include "ApplicationConfig.h"
mitea1 0:f2815503561f 9 #include "mbed.h"
mitea1 0:f2815503561f 10 #include "rtos.h"
mitea1 0:f2815503561f 11 #include "I2C_RT.h"
mitea1 0:f2815503561f 12 #include "MAX44009.h"
mitea1 0:f2815503561f 13 #include "BME280.h"
mitea1 0:f2815503561f 14 #include "MPU9250.h"
mitea1 0:f2815503561f 15 #include "SI1143.h"
mitea1 0:f2815503561f 16 #include "uBlox.h"
mitea1 9:c4e378f4801d 17 #include "FlowMeter.h"
mitea1 0:f2815503561f 18 #include "mDot.h"
mitea1 0:f2815503561f 19 #include "TaskLight.h"
mitea1 0:f2815503561f 20 #include "TaskTemperature.h"
mitea1 0:f2815503561f 21 #include "TaskHumidity.h"
mitea1 0:f2815503561f 22 #include "TaskPressure.h"
mitea1 0:f2815503561f 23 #include "TaskAcceleration.h"
mitea1 0:f2815503561f 24 #include "TaskGyroscope.h"
mitea1 0:f2815503561f 25 #include "TaskTesla.h"
mitea1 0:f2815503561f 26 #include "TaskProximity.h"
mitea1 0:f2815503561f 27 #include "TaskGPS.h"
mitea1 9:c4e378f4801d 28 #include "TaskFlowMeter.h"
mitea1 0:f2815503561f 29 #include "TaskLoRaMeasurement.h"
mitea1 0:f2815503561f 30 #include "TaskDatahandler.h"
mitea1 0:f2815503561f 31 #include "main.h"
mitea1 9:c4e378f4801d 32 #include "LoRa.h"
mitea1 0:f2815503561f 33
mitea1 0:f2815503561f 34 #ifndef SENSORHANDLER_H_
mitea1 0:f2815503561f 35 #define SENSORHANDLER_H_
mitea1 0:f2815503561f 36
mitea1 0:f2815503561f 37 class Application {
mitea1 0:f2815503561f 38 public:
mitea1 0:f2815503561f 39 Application();
mitea1 0:f2815503561f 40 virtual ~Application();
mitea1 0:f2815503561f 41
mitea1 0:f2815503561f 42 /**
mitea1 0:f2815503561f 43 * @brief Start the Application in the desired Mode
mitea1 0:f2815503561f 44 * @return
mitea1 0:f2815503561f 45 */
mitea1 0:f2815503561f 46 void init(APPLICATION_MODE desiredMode);
mitea1 0:f2815503561f 47
mitea1 0:f2815503561f 48 private:
mitea1 0:f2815503561f 49 RawSerial* uart;
mitea1 0:f2815503561f 50 RawSerial* debugSerial;
mitea1 0:f2815503561f 51 I2C_RT* i2c_rt;
mitea1 9:c4e378f4801d 52 InterruptIn* pulseInput;
mitea1 0:f2815503561f 53 mDot* dot;
mitea1 0:f2815503561f 54 LoRa* lora;
mitea1 0:f2815503561f 55
mitea1 0:f2815503561f 56 TaskLight* taskLight;
mitea1 0:f2815503561f 57 TaskTemperature* taskTemperature;
mitea1 0:f2815503561f 58 TaskPressure* taskPressure;
mitea1 0:f2815503561f 59 TaskHumidity* taskHumidity;
mitea1 0:f2815503561f 60 TaskAcceleration* taskAcceleration;
mitea1 0:f2815503561f 61 TaskGyroscope* taskGyroscope;
mitea1 0:f2815503561f 62 TaskTesla* taskTesla;
mitea1 0:f2815503561f 63 TaskProximity* taskProximity;
mitea1 0:f2815503561f 64 TaskGPS* taskGps;
mitea1 9:c4e378f4801d 65 TaskFlowMeter* taskFlowMeter;
mitea1 0:f2815503561f 66 TaskLoRaMeasurement* taskLoRaMeasurement;
mitea1 0:f2815503561f 67 TaskDatahandler* taskDataHandler;
mitea1 0:f2815503561f 68
mitea1 0:f2815503561f 69 rtos::Mutex* mutexI2C;
mitea1 0:f2815503561f 70 rtos::Mutex* mutexUART1;
mitea1 0:f2815503561f 71 rtos::Mutex mutexBME280;
mitea1 0:f2815503561f 72 rtos::Mutex mutexMAX44009;
mitea1 0:f2815503561f 73 rtos::Mutex mutexMPU9250;
mitea1 0:f2815503561f 74 rtos::Mutex mutexSi4103;
mitea1 0:f2815503561f 75 rtos::Mutex mutexUBlox;
mitea1 9:c4e378f4801d 76 rtos::Mutex* mutexFlowMeter;
mitea1 0:f2815503561f 77 rtos::Mutex* mutexLoRa;
mitea1 0:f2815503561f 78
mitea1 0:f2815503561f 79 Queue<MAX44009Message,LIGHT_QUEUE_LENGHT> queueLight;
mitea1 0:f2815503561f 80 Queue<BME280TemperatureMessage,TEMPERATURE_QUEUE_LENGHT> queueTemperature;
mitea1 0:f2815503561f 81 Queue<BME280PressureMessage,PRESSURE_QUEUE_LENGHT> queuePressure;
mitea1 0:f2815503561f 82 Queue<BME280HumidityMessage,HUMIDITY_QUEUE_LENGHT> queueHumidity;
mitea1 0:f2815503561f 83 Queue<MPU9250AccelerationMessage,ACCELERATION_QUEUE_LENGHT> queueAcceleration;
mitea1 0:f2815503561f 84 Queue<MPU9250GyroscopeMessage,GYROSCOPE_QUEUE_LENGHT> queueGyro;
mitea1 0:f2815503561f 85 Queue<MPU9250TeslaMessage,TESLA_QUEUE_LENGHT> queueTesla;
mitea1 0:f2815503561f 86 Queue<SI1143ProximityMessage,PROXIMITY_QUEUE_LENGHT> queueProximity;
mitea1 0:f2815503561f 87 Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT> queueGps;
mitea1 9:c4e378f4801d 88 Queue<FlowMeterMessage,FLOWMETER_QUEUE_LENGTH> queueFlowMeter;
mitea1 0:f2815503561f 89 Queue<LoRaMeasurementMessage,LORA_MEASUREMENT_QUEUE_LENGHT> queueLoRaMeasurements;
mitea1 0:f2815503561f 90 Queue<CommandMessage,COMMAND_QUEUE_LENGHT> queueCommands;
mitea1 0:f2815503561f 91
mitea1 0:f2815503561f 92 QueueBundle queueBundle;
mitea1 0:f2815503561f 93
mitea1 0:f2815503561f 94 uBlox* gpsSensor;
mitea1 0:f2815503561f 95 MAX44009* max44009;
mitea1 0:f2815503561f 96 BME280* bme280;
mitea1 0:f2815503561f 97 MPU9250* mpu9250;
mitea1 0:f2815503561f 98 SI1143* si1143;
mitea1 9:c4e378f4801d 99 FlowMeter* flowMeter;
mitea1 0:f2815503561f 100
mitea1 0:f2815503561f 101 ApplicationConfig* config;
mitea1 0:f2815503561f 102
mitea1 0:f2815503561f 103 /**
mitea1 0:f2815503561f 104 * @brief Initializes all Interfaces such as I2C, UART and a Debug Serial via USB
mitea1 0:f2815503561f 105 */
mitea1 0:f2815503561f 106 void initInterfaces();
mitea1 0:f2815503561f 107
mitea1 0:f2815503561f 108 /**
mitea1 0:f2815503561f 109 * @brief Initializes (builds) all Sensors in their specific modes
mitea1 0:f2815503561f 110 */
mitea1 0:f2815503561f 111 void initSensors();
mitea1 0:f2815503561f 112
mitea1 0:f2815503561f 113 /**
mitea1 0:f2815503561f 114 * @brief Initializes (builds) all Tasks so that they are ready to run
mitea1 0:f2815503561f 115 */
mitea1 0:f2815503561f 116 void initTasks();
mitea1 0:f2815503561f 117
mitea1 0:f2815503561f 118 /**
mitea1 0:f2815503561f 119 * @brief Initializes (builds) all Mutexes so that they are ready to be used
mitea1 0:f2815503561f 120 */
mitea1 0:f2815503561f 121 void initMutexes();
mitea1 0:f2815503561f 122
mitea1 0:f2815503561f 123 /**
mitea1 0:f2815503561f 124 * @brief Initializes (builds) the ApplicationConfig which contains information about
mitea1 0:f2815503561f 125 * which Task has to be run and how the sensors have to be configured
mitea1 0:f2815503561f 126 */
mitea1 0:f2815503561f 127 void initApplicationConfig();
mitea1 0:f2815503561f 128
mitea1 0:f2815503561f 129 /**
mitea1 1:fe242f3e341b 130 * @brief Initializes (builds) the QueueBundle
mitea1 1:fe242f3e341b 131 */
mitea1 1:fe242f3e341b 132 void initQueueBundle();
mitea1 1:fe242f3e341b 133
mitea1 1:fe242f3e341b 134 /**
mitea1 0:f2815503561f 135 * @brief Stops all tasks that are currently running. Used to define a defined state to start the application
mitea1 0:f2815503561f 136 * in a new mode or when using a transition between two application modes it is neccessary to stop all task before
mitea1 0:f2815503561f 137 * starting them again
mitea1 0:f2815503561f 138 */
mitea1 0:f2815503561f 139 void stopAllRunningSensorTasks();
mitea1 0:f2815503561f 140
mitea1 0:f2815503561f 141 /**
mitea1 0:f2815503561f 142 * @brief Starts all task which are allowed to run by the Application Config
mitea1 0:f2815503561f 143 */
mitea1 0:f2815503561f 144 void startRunnableSensorTasks();
mitea1 0:f2815503561f 145
mitea1 0:f2815503561f 146 /**
mitea1 0:f2815503561f 147 * @brief Configures and builds the sensors according to they SensorMode specific parameters
mitea1 0:f2815503561f 148 */
mitea1 0:f2815503561f 149 void configureSensors();
mitea1 0:f2815503561f 150
mitea1 0:f2815503561f 151 /**
mitea1 0:f2815503561f 152 * @brief Configures and builds the LoRa Device according to its Mode specific parameters
mitea1 0:f2815503561f 153 */
mitea1 0:f2815503561f 154 void configureLora();
mitea1 0:f2815503561f 155
mitea1 0:f2815503561f 156 };
mitea1 0:f2815503561f 157
mitea1 0:f2815503561f 158 #endif /* APPLICATION_H_ */