to test channels
Dependencies: pulga-lorawan-drv Si1133 BME280
Diff: main.cpp
- Revision:
- 59:a4fc1efb1569
- Parent:
- 56:39847849d219
- Child:
- 60:c4f9e9202fb4
--- a/main.cpp Tue Oct 08 14:01:59 2019 +0100 +++ b/main.cpp Tue Dec 10 13:08:45 2019 +0000 @@ -21,9 +21,10 @@ #include "events/EventQueue.h" // Application helpers -#include "DummySensor.h" +//#include "DummySensor.h" #include "trace_helper.h" #include "lora_radio_helper.h" +#include "BME280.h" using namespace events; @@ -53,12 +54,20 @@ /** * Dummy pin for dummy sensor */ -#define PC_9 0 +//#define PC_9 0 /** * Dummy sensor class object */ -DS1820 ds1820(PC_9); +//DS1820 ds1820(PC_9); +BME280 sensor_amb(P0_13, P0_15, 0x77 << 1) ; + +/** + * Sensors Variables + */ + uint32_t lux = 0; + uint32_t amb = 0; + float sensor_get = 0; /** * This event queue is the global event queue for both the @@ -90,6 +99,10 @@ /** * Entry point for application */ + +mbed::DigitalOut _alive_led(P1_13, 1); +mbed::DigitalOut _actuated_led(P1_14,0); + int main(void) { // setup tracing @@ -138,7 +151,8 @@ } printf("\r\n Connection - In Progress ...\r\n"); - + +_actuated_led =1; // make your event queue dispatching events forever ev_queue.dispatch_forever(); @@ -154,18 +168,23 @@ int16_t retcode; int32_t sensor_value; - if (ds1820.begin()) { + /* if (ds1820.begin()) { ds1820.startConversion(); sensor_value = ds1820.read(); printf("\r\n Dummy Sensor Value = %d \r\n", sensor_value); - ds1820.startConversion(); + ds1820.startConversion(); + sensor_value++; + } else { printf("\r\n No sensor found \r\n"); return; - } + }*/ + + sensor_amb.initialize(); + sensor_get = sensor_amb.getTemperature(); - packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %d", - sensor_value); + packet_len = sprintf((char *) tx_buffer, "Temperature Sensor Value is %d", + sensor_get); retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len, MSG_UNCONFIRMED_FLAG); @@ -236,8 +255,11 @@ } break; case TX_TIMEOUT: + printf("\r\n Transmission Error TX_Timeout"); case TX_ERROR: + printf("\r\n Transmission Error TX_Error"); case TX_CRYPTO_ERROR: + printf("\r\n Transmission Error TX_Crypto_Error"); case TX_SCHEDULING_ERROR: printf("\r\n Transmission Error - EventCode = %d \r\n", event); // try again @@ -250,6 +272,7 @@ receive_message(); break; case RX_TIMEOUT: + printf("\r\n Transmission Error RX_Timeout"); case RX_ERROR: printf("\r\n Error in reception - Code = %d \r\n", event); break;