#include #include #include #include "ArduinoLowPower.h" // +++++++++++++++++++++++++++++ DHT22 +++++++++++++++++++++++++++++ #include #define DHT_PIN 13 #define DHT_TYPE DHT22 float DHT_temperature, humidity, temperature; bool DHT_temp_reading_failed, DHT_hum_reading_failed; DHT dht(DHT_PIN, DHT_TYPE); // +++++++++++++++++++++++++++++ BMP388 +++++++++++++++++++++++++++++ #include #include #include "Adafruit_BMP3XX.h" Adafruit_BMP3XX bmp; // Configuration used: I2C float BMP_temperature, pressure; bool BMP_reading_failed; // ++++++++++++++++++++++++++++ CONTACT SENSOR +++++++++++++++++++++++++++ #define CONTACT_SENSOR_PIN 11 unsigned short door_state; volatile int door_openings = 0; // ++++++++++++++++++++++++++++ BATTERY TENSION +++++++++++++++++++++++++++ #define BATTERY_PIN 9 float battery_tension; // ++++++++++++++++++++ DEEPSLEEP ++++++++++++++++++ #define MILLIS_IN_HOUR 3600000 #define MILLIS_IN_MINUTE 60000 #define SECS_IN_HOUR 3600 #include RTCZero rtc_sleep; // Sleep cycles parameters int TX_interval = 100; // SECS_IN_HOUR / 20; // DEPLOY - 1/2 ore int sleep_subperiod = 50; //TX_interval / 18; int time_between_join_requests = 60; bool send_flag = false, sleep_flag = false; int sleep_cycles_done = 0; // ++++++++++++++++++++++++ LoRa PARAMETERS ++++++++++++++++++++++++ static const u1_t PROGMEM APPEUI[8] = {APPEUI}; static const u1_t PROGMEM DEVEUI[8] = {DEVEUI}; static const u1_t PROGMEM APPKEY[16] = {APPKEY}; void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);} void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);} void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);} static uint8_t payload[10]; static osjob_t sendjob; // Pin mapping for Adafruit Feather M0 LoRa const lmic_pinmap lmic_pins = { .nss = 8, .rxtx = LMIC_UNUSED_PIN, //.rst = 4, .rst = LMIC_UNUSED_PIN, .dio = {3, 6, LMIC_UNUSED_PIN}, .rxtx_rx_active = 0, .rssi_cal = 8, // LBT cal for the Adafruit Feather M0 LoRa, in dB .spi_freq = 8000000, };