Enable Remote Calibration
This commit is contained in:
parent
36963daac6
commit
ac60546eab
2 changed files with 27 additions and 10 deletions
|
@ -52,7 +52,7 @@ uint8_t SENSAIRS8::getSensorData(char *payload, uint8_t startbyte) {
|
|||
void SENSAIRS8::calibrate(void) {
|
||||
pinMode(calpin, OUTPUT);
|
||||
digitalWrite(calpin, LOW);
|
||||
delay(5000);
|
||||
delay(6000);
|
||||
digitalWrite(calpin, HIGH);
|
||||
pinMode(calpin, INPUT_PULLUP);
|
||||
}
|
||||
|
|
17
src/main.cpp
17
src/main.cpp
|
@ -157,6 +157,15 @@ void onEvent(ev_t ev) {
|
|||
// Check for Downlink
|
||||
DEBUG_PRINTLN("LoRa Packet Sent");
|
||||
WS2812B_BLINK(1,0,127,0,1000);
|
||||
if ((int)LMIC.dataLen > 0) {
|
||||
// Check for Downlinks
|
||||
// Function based in Ports:
|
||||
// Port 1
|
||||
// Set Sending Interval
|
||||
// Port 2
|
||||
// Do Calibration
|
||||
switch((uint8_t)LMIC.frame[LMIC.dataBeg-1]) {
|
||||
case 1:
|
||||
if ((int)LMIC.dataLen == 2) {
|
||||
// We got a Packet with the right size - lets assemble it into a uint16_t
|
||||
DEBUG_PRINTLN("Received Downlink")
|
||||
|
@ -167,6 +176,14 @@ void onEvent(ev_t ev) {
|
|||
EEPROM.put(ADDR_SLP, tmpslp);
|
||||
WS2812B_BLINK(1,0,0,127,250);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (uint8_t i=0; i<NUM_SENSORS; i++)
|
||||
sensors[i]->calibrate();
|
||||
BLINK_LED(3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Got to sleep for specified Time
|
||||
DEBUG_PRINTLN("Going to Sleep");
|
||||
|
|
Loading…
Reference in a new issue