Commit 1b4f193c authored by robert.sharp's avatar robert.sharp

Update Main.ino to fix random values bug

parent c95d51a8
...@@ -54,13 +54,17 @@ static const u1_t PROGMEM APPKEY[16] = { 0xEE, 0xB3, 0xA4, 0x83, 0xBF, 0xEC, 0x0 ...@@ -54,13 +54,17 @@ static const u1_t PROGMEM APPKEY[16] = { 0xEE, 0xB3, 0xA4, 0x83, 0xBF, 0xEC, 0x0
void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);} void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);}
static int mydata = -1; static int mydata = -1;
uint8_t testData[2];
AirQualitySensor sensor(A0); AirQualitySensor sensor(A0);
static byte payload[2];
static osjob_t sendjob; static osjob_t sendjob;
// Schedule TX every this many seconds (might become longer due to duty // Schedule TX every this many seconds (might become longer due to duty
// cycle limitations). // cycle limitations).
const unsigned TX_INTERVAL = 60; const unsigned TX_INTERVAL = 20;
// Pin mapping // Pin mapping
const lmic_pinmap lmic_pins = { const lmic_pinmap lmic_pins = {
...@@ -143,7 +147,7 @@ void onEvent (ev_t ev) { ...@@ -143,7 +147,7 @@ void onEvent (ev_t ev) {
void do_send(osjob_t* j){ void do_send(osjob_t* j){
//Update mydata to be the current value of the sensor //Update mydata to be the current value of the sensor
mydata = sensor.getValue(); mydata = sensor.getValue();
testData[0] = mydata;
//test the sensor is working //test the sensor is working
Serial.print("Sensor value: "); Serial.print("Sensor value: ");
Serial.println(sensor.getValue()); Serial.println(sensor.getValue());
...@@ -153,7 +157,7 @@ void do_send(osjob_t* j){ ...@@ -153,7 +157,7 @@ void do_send(osjob_t* j){
Serial.println(F("OP_TXRXPEND, not sending")); Serial.println(F("OP_TXRXPEND, not sending"));
} else { } else {
// Prepare upstream data transmission at the next possible time. // Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0); LMIC_setTxData2(1, testData, sizeof(testData)-1, 0);
Serial.println(F("Packet queued")); Serial.println(F("Packet queued"));
} }
// Next TX is scheduled after TX_COMPLETE event. // Next TX is scheduled after TX_COMPLETE event.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment