This program connects to the The Things Network backend in OTAA Mode. It logs sensor values from a BME 280 to the backend. Tried adding support for Grove GPS using SerialGPS library but it is not working - conflicting with mbed-rtos, so it commented. Deep Sleep for mDot implemented BUT avoiding reprogramming of the mDot config is NOT working.
Dependencies: BME280 SerialGPS libmDot mbed-rtos mbed
main.cpp
- Committer:
- AshuJoshi
- Date:
- 2016-07-03
- Revision:
- 1:36e336869699
- Parent:
- 0:3ec6a7645098
- Child:
- 2:866a72c3c3bf
File content as of revision 1:36e336869699:
/******************************************************
* A Program to interface the Grove Base Shielf V2
* to the mDot UDK.
* Additionally sample code to compress the data
* for use with LPWANs such as LoRa
*****************************************************/
#include "mbed.h"
#include <math.h>
#include "BME280.h"
// mDot UDK Specific
// MDot Pinout: https://developer.mbed.org/platforms/MTS-mDot-F411/#pinout-diagram
// Uncomment this line if using a full sized UDK2.0 instead of a Micro UDK
#define UDK2 1
#ifdef UDK2
DigitalOut led(LED1);
#else
DigitalOut led(XBEE_RSSI);
#endif
//BME280 sensor(I2C_SDA, I2C_SCL)
// MDot UDK - I2C_SDA and I2C_SCL connected to PC_9/PA_*
BME280 b280(PC_9, PA_8);
// Globals
Ticker tick;
// Function Declarations
void endLessTestLoop();
void setUpLEDBlink();
void blink();
void readandprintBME280();
/*****************************************************
* MAIN
*****************************************************/
int main(){
// Simple Test Functions, "Hello World on UDK
setUpLEDBlink();
endLessTestLoop();
return 0;
}
/*****************************************************
* Sensor Functions
****************************************************/
void readandprintBME280() {
printf("%2.2f degC, %04.2f hPa, %2.2f %%\n", b280.getTemperature(), b280.getPressure(), b280.getHumidity());
}
/*****************************************************
* FUNCTIONS for Simple Testing
****************************************************/
void setUpLEDBlink(){
// configure the Ticker to blink the LED on 500ms interval
tick.attach(&blink, 0.5);
}
void endLessTestLoop() {
while(true) {
// printf("Hello world!\r\n");
printf("BME280 Sensor: \n");
readandprintBME280();
wait(5);
}
}
// Callback function to change LED state
void blink() {
led = !led;
}