diff --git a/.DS_Store b/.DS_Store index 2458362..7ea09bc 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..df712af --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +.pio +.vscode +.vs_code \ No newline at end of file diff --git a/2.Sensors/BMP180Example/BMP180Example.ino b/2.Sensors/BMP180Example/BMP180Example.ino deleted file mode 100644 index aa233e3..0000000 --- a/2.Sensors/BMP180Example/BMP180Example.ino +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @brief Uses the built in Mama Duck with a BMP180 sensor - * - * @date 2020-09-21 - * - * @copyright Copyright (c) 2020 - * - */ -#include -#include -#include - -// Setup BMP180 -#include -Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085); - -#ifdef SERIAL_PORT_USBVIRTUAL -#define Serial SERIAL_PORT_USBVIRTUAL -#endif - -// create a built-in mama duck -MamaDuck duck; - -auto timer = timer_create_default(); -const int INTERVAL_MS = 60000; - -void setup() { - // We are using a hardcoded device id here, but it should be retrieved or - // given during the device provisioning then converted to a byte vector to - // setup the duck NOTE: The Device ID must be exactly 8 bytes otherwise it - // will get rejected - std::string deviceId("MAMA0001"); - std::vector devId; - devId.insert(devId.end(), deviceId.begin(), deviceId.end()); - - // Use the default setup provided by the SDK - duck.setupWithDefaults(devId); - Serial.println("MAMA-DUCK...READY!"); - - // BMP setup - if (!bmp.begin()) { - /* There was a problem detecting the BMP085 ... check your connections */ - Serial.print( - "Ooops, no BMP085 detected ... Check your wiring or I2C ADDR!"); - while (1) - ; - } else { - Serial.println("BMP on"); - } - - // initialize the timer. The timer thread runs separately from the main loop - // and will trigger sending a counter message. - timer.every(INTERVAL_MS, runSensor); -} - -void loop() { - timer.tick(); - // Use the default run(). The Mama duck is designed to also forward data it - // receives from other ducks, across the network. It has a basic routing - // mechanism built-in to prevent messages from hoping endlessly. - duck.run(); -} - -bool runSensor(void*) { - float T, P; - - bmp.getTemperature(&T); - Serial.println(T); - bmp.getPressure(&P); - Serial.println(P); - - String sensorVal = String(T) + "/" + String(P); - - duck.sendData(topics::bmp180, sensorVal); - - return true; -} diff --git a/2.Sensors/BMP180Example/platformio.ini b/2.Sensors/BMP180Example/platformio.ini deleted file mode 100644 index f407eb8..0000000 --- a/2.Sensors/BMP180Example/platformio.ini +++ /dev/null @@ -1,26 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[platformio] -src_dir = . - -[env:heltec_wifi_lora_32_V2] -platform = espressif32 -board = heltec_wifi_lora_32_V2 -framework = arduino -monitor_speed = 115200 -monitor_filters = time - -lib_deps = - https://github.com/Call-for-Code/ClusterDuck-Protocol - adafruit/Adafruit BMP085 Library - -; uncomment for OTA update -; upload_port = duck.local diff --git a/2.Sensors/BMP280Example/BMP280Example.ino b/2.Sensors/BMP280Example/BMP280Example.ino deleted file mode 100644 index fe2b11a..0000000 --- a/2.Sensors/BMP280Example/BMP280Example.ino +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @brief Uses the built in Mama Duck with a BMP280 sensor - * - * @date 2020-09-21 - * - * @copyright Copyright (c) 2020 - * - */ - -#include -#include -#include - -#ifdef SERIAL_PORT_USBVIRTUAL -#define Serial SERIAL_PORT_USBVIRTUAL -#endif - -// Setup BMP280 -#include -Adafruit_BMP280 bmp; - -// create a built-in mama duck -MamaDuck duck; - -auto timer = timer_create_default(); -const int INTERVAL_MS = 60000; - - -void setup() { - // We are using a hardcoded device id here, but it should be retrieved or - // given during the device provisioning then converted to a byte vector to - // setup the duck NOTE: The Device ID must be exactly 8 bytes otherwise it - // will get rejected - std::string deviceId("MAMA0001"); - std::vector devId; - devId.insert(devId.end(), deviceId.begin(), deviceId.end()); - - // Use the default setup provided by the SDK - duck.setupWithDefaults(devId); - Serial.println("MAMA-DUCK...READY!"); - - //BMp setup - if(!bmp.begin()) - { - /* There was a problem detecting the BMP085 ... check your connections */ - Serial.print("Ooops, no BMP208 detected ... Check your wiring or I2C ADDR!"); - while(1); - } - - // initialize the timer. The timer thread runs separately from the main loop - // and will trigger sending a counter message. - timer.every(INTERVAL_MS, runSensor); -} - -void loop() { - timer.tick(); - // Use the default run(). The Mama duck is designed to also forward data it receives - // from other ducks, across the network. It has a basic routing mechanism built-in - // to prevent messages from hoping endlessly. - duck.run(); -} - -bool runSensor(void *) { - float T,P; - - T = bmp.readTemperature(); - Serial.println(T); - P = bmp.readPressure(); - Serial.println(P); - - String sensorVal = "Temp: " + String(T) + " Pres: " + String(P); //Store Data - - duck.sendData(topics::bmp280, sensorVal); - - return true; -} diff --git a/2.Sensors/BMP280Example/libraries.txt b/2.Sensors/BMP280Example/libraries.txt deleted file mode 100644 index 3aa3fde..0000000 --- a/2.Sensors/BMP280Example/libraries.txt +++ /dev/null @@ -1 +0,0 @@ -Adafruit BMP280 Library \ No newline at end of file diff --git a/2.Sensors/BMP280Example/platformio.ini b/2.Sensors/BMP280Example/platformio.ini deleted file mode 100644 index 86e8042..0000000 --- a/2.Sensors/BMP280Example/platformio.ini +++ /dev/null @@ -1,26 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[platformio] -src_dir = . - -[env:heltec_wifi_lora_32_V2] -platform = espressif32 -board = heltec_wifi_lora_32_V2 -framework = arduino -monitor_speed = 115200 -monitor_filters = time - -lib_deps = - https://github.com/Call-for-Code/ClusterDuck-Protocol - adafruit/Adafruit BMP280 Library - -; uncomment for OTA update -; upload_port = duck.local diff --git a/2.Sensors/DHT11Example/DHT11Example.ino b/2.Sensors/DHT11Example/DHT11Example.ino deleted file mode 100644 index b34d67b..0000000 --- a/2.Sensors/DHT11Example/DHT11Example.ino +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @brief Uses the built in Mama Duck with a DHT11 sensor - * - * @date 2020-09-21 - * - * @copyright Copyright (c) 2020 - * - */ - -#include -#include -#include - -#ifdef SERIAL_PORT_USBVIRTUAL -#define Serial SERIAL_PORT_USBVIRTUAL -#endif - -// Setup DHT11 -#include -#define DHTTYPE DHT11 -#define DHTPIN 4 -#define TIMEOUT 5000 -DHT dht(DHTPIN, DHTTYPE); - -// create a built-in mama duck -MamaDuck duck; - -auto timer = timer_create_default(); -const int INTERVAL_MS = 10000; - -void setup() { - // We are using a hardcoded device id here, but it should be retrieved or - // given during the device provisioning then converted to a byte vector to - // set up the duck NOTE: The Device ID must be exactly 8 bytes otherwise it - // will get rejected - std::string deviceId("MAMA0001"); - std::vector devId; - devId.insert(devId.end(), deviceId.begin(), deviceId.end()); - - // Use the default setup provided by the SDK - duck.setupWithDefaults(devId); - Serial.println("MAMA-DUCK...READY!"); - - // initialize the timer. The timer thread runs separately from the main loop - // and will trigger sending a counter message. - timer.every(INTERVAL_MS, runSensor); -} - -void loop() { - timer.tick(); - // Use the default run(). The Mama duck is designed to also forward data it receives - // from other ducks, across the network. It has a basic routing mechanism built-in - // to prevent messages from hoping endlessly. - duck.run(); -} - -bool runSensor(void *) { - - String sensorVal = "Temp: "; - sensorVal += dht.readTemperature(); - sensorVal += "Humidity: "; - sensorVal += dht.readHumidity(); - - Serial.println(sensorVal); - - duck.sendData(topics::dht11, sensorVal); - - return true; -} diff --git a/2.Sensors/DHT11Example/libraries.txt b/2.Sensors/DHT11Example/libraries.txt deleted file mode 100644 index 4095d92..0000000 --- a/2.Sensors/DHT11Example/libraries.txt +++ /dev/null @@ -1 +0,0 @@ -DHT sensor library diff --git a/2.Sensors/DHT11Example/platformio.ini b/2.Sensors/DHT11Example/platformio.ini deleted file mode 100644 index f6f71b1..0000000 --- a/2.Sensors/DHT11Example/platformio.ini +++ /dev/null @@ -1,26 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[platformio] -src_dir = . - -[env:heltec_wifi_lora_32_V2] -platform = espressif32 -board = heltec_wifi_lora_32_V2 -framework = arduino -monitor_speed = 115200 -monitor_filters = time - -lib_deps = - https://github.com/Call-for-Code/ClusterDuck-Protocol - adafruit/DHT sensor library - -; uncomment for OTA update -; upload_port = duck.local diff --git a/2.Sensors/DustSensorExample/DustSensorExample.ino b/2.Sensors/DustSensorExample/DustSensorExample.ino deleted file mode 100644 index 0620261..0000000 --- a/2.Sensors/DustSensorExample/DustSensorExample.ino +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @brief Uses the built in Mama Duck with a GP2YDustSensor - * - * @date 2020-09-21 - * - * @copyright Copyright (c) 2020 - * - */ - -#include -#include -#include - -#ifdef SERIAL_PORT_USBVIRTUAL -#define Serial SERIAL_PORT_USBVIRTUAL -#endif - -// Include for DustSensor -#include - -const uint8_t SHARP_LED_PIN = 22; // Sharp Dust/particle sensor Led Pin -const uint8_t SHARP_VO_PIN = 0; // Sharp Dust/particle analog out pin used for reading - -GP2YDustSensor dustSensor(GP2YDustSensorType::GP2Y1010AU0F, SHARP_LED_PIN, SHARP_VO_PIN); - -// create a built-in mama duck -MamaDuck duck; - -auto timer = timer_create_default(); -const int INTERVAL_MS = 60000; -char message[32]; -int counter = 1; - -void setup() { - // We are using a hardcoded device id here, but it should be retrieved or - // given during the device provisioning then converted to a byte vector to - // setup the duck NOTE: The Device ID must be exactly 8 bytes otherwise it - // will get rejected - std::string deviceId("MAMA0001"); - std::vector devId; - devId.insert(devId.end(), deviceId.begin(), deviceId.end()); - - // Use the default setup provided by the SDK - duck.setupWithDefaults(devId); - Serial.println("MAMA-DUCK...READY!"); - - // Dust sensor - dustSensor.begin(); - - // initialize the timer. The timer thread runs separately from the main loop - // and will trigger sending a counter message. - timer.every(INTERVAL_MS, runSensor); -} - -void loop() { - timer.tick(); - // Use the default run(). The Mama duck is designed to also forward data it receives - // from other ducks, across the network. It has a basic routing mechanism built-in - // to prevent messages from hoping endlessly. - duck.run(); -} - -bool runSensor(void *) { - - //Dust sensor - String sensorVal = "Current dust concentration: " + dustSensor.getDustDensity(); - sensorVal += " ug/m3"; - - duck.sendData(topics::gp2y, sensorVal); - - return true; -} diff --git a/2.Sensors/DustSensorExample/libraries.txt b/2.Sensors/DustSensorExample/libraries.txt deleted file mode 100644 index 44ad969..0000000 --- a/2.Sensors/DustSensorExample/libraries.txt +++ /dev/null @@ -1 +0,0 @@ -Sharp GP2Y Dust Sensor diff --git a/2.Sensors/DustSensorExample/platformio.ini b/2.Sensors/DustSensorExample/platformio.ini deleted file mode 100644 index d80f7bb..0000000 --- a/2.Sensors/DustSensorExample/platformio.ini +++ /dev/null @@ -1,26 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[platformio] -src_dir = . - -[env:heltec_wifi_lora_32_V2] -platform = espressif32 -board = heltec_wifi_lora_32_V2 -framework = arduino -monitor_speed = 115200 -monitor_filters = time - -lib_deps = - https://github.com/Call-for-Code/ClusterDuck-Protocol - luciansabo/Sharp GP2Y Dust Sensor - -; uncomment for OTA update -; upload_port = duck.local diff --git a/2.Sensors/MQ7Example/MQ7Example.ino b/2.Sensors/MQ7Example/MQ7Example.ino deleted file mode 100644 index 533ff65..0000000 --- a/2.Sensors/MQ7Example/MQ7Example.ino +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file MQ7Example.ino - * @brief Uses the built in Mama Duck with a MQ7 sensor attached - * - * @date 2020-09-21 - * - * @copyright Copyright (c) 2020 - * - */ - -#include -#include -#include - -#ifdef SERIAL_PORT_USBVIRTUAL - #define Serial SERIAL_PORT_USBVIRTUAL -#endif - -// Include the MQ7 library -#include - -//Definitions -#define placa "Heltec WiFi LoRa 32(V2)" -#define Voltage_Resolution 5 -#define pin A0 //Analog input 0 of your arduino -#define type "MQ-7" //MQ7 -#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO -#define RatioMQ7CleanAir 27.5 //RS / R0 = 27.5 ppm -#define PWMPin 5 // Pin connected to mosfet - -//Declare Sensor -MQUnifiedsensor MQ7(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type); - - -// create a built-in mama duck -MamaDuck duck; - -auto timer = timer_create_default(); -const int INTERVAL_MS = 60000; -char message[32]; -int counter = 1; - -void setup() { - // We are using a hardcoded device id here, but it should be retrieved or - // given during the device provisioning then converted to a byte vector to - // setup the duck NOTE: The Device ID must be exactly 8 bytes otherwise it - // will get rejected - std::string deviceId("MAMA0001"); - std::vector devId; - devId.insert(devId.end(), deviceId.begin(), deviceId.end()); - - // Use the default setup provided by the SDK - duck.setupWithDefaults(devId); - Serial.println("MAMA-DUCK...READY!"); - - //Set math model to calculate the PPM concentration and the value of constants - MQ7.setRegressionMethod(1); //_PPM = a*ratio^b - MQ7.setA(99.042); MQ7.setB(-1.518); // Configurate the ecuation values to get CO concentration - - // init the sensor - /***************************** MQInicializar********************************* - Input: pin, type - Output: - Remarks: This function create the sensor object. - *****************************************************************************/ - MQ7.init(); - /***************************** MQ CAlibration ******************************/ - // Explanation: - // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated - // and now is on clean air (Calibration conditions), and it will setup R0 value. - // We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino - // This routine not need to execute to every restart, you can load your R0 if you know the value - // Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor - Serial.print("Calibrating please wait."); - float calcR0 = 0; - for (int i = 1; i<=10; i ++) { - MQ7.update(); // Update data, the arduino will be read the voltage on the analog pin - calcR0 += MQ7.calibrate(RatioMQ7CleanAir); - Serial.print("."); - } - MQ7.setR0(calcR0/10); - Serial.println(" done!."); - - if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} - if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} - /***************************** MQ CAlibration ******************************/ - MQ7.serialDebug(true); - - // initialize the timer. The timer thread runs separately from the main loop - // and will trigger sending a counter message. - timer.every(INTERVAL_MS, runSensor); -} - -void loop() { - timer.tick(); - // Use the default run(). The Mama duck is designed to also forward data it receives - // from other ducks, across the network. It has a basic routing mechanism built-in - // to prevent messages from hoping endlessly. - duck.run(); -} - -bool runSensor(void *) { - MQ7.update(); // Update data, the arduino will be read the voltage on the analog pin - MQ7.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup - MQ7.serialDebug(); // Will print the table on the serial port - - float sensorRead = MQ7.readSensor(); - String sensorVal = String(sensorRead); - - duck.sendData(topics::mq7, sensorVal); - return true; -} - diff --git a/2.Sensors/MQ7Example/libraries.txt b/2.Sensors/MQ7Example/libraries.txt deleted file mode 100644 index be06075..0000000 --- a/2.Sensors/MQ7Example/libraries.txt +++ /dev/null @@ -1 +0,0 @@ -MQUnifiedsensor diff --git a/2.Sensors/MQ7Example/platformio.ini b/2.Sensors/MQ7Example/platformio.ini deleted file mode 100644 index 6c9a5aa..0000000 --- a/2.Sensors/MQ7Example/platformio.ini +++ /dev/null @@ -1,26 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[platformio] -src_dir = . - -[env:heltec_wifi_lora_32_V2] -platform = espressif32 -board = heltec_wifi_lora_32_V2 -framework = arduino -monitor_speed = 115200 -monitor_filters = time - -lib_deps = - https://github.com/Call-for-Code/ClusterDuck-Protocol - miguel5612/MQUnifiedsensor - -; uncomment for OTA update -; upload_port = duck.local diff --git a/2.Sensors/WS2812Example/platformio.ini b/2.Sensors/WS2812Example/platformio.ini deleted file mode 100644 index a2b59e8..0000000 --- a/2.Sensors/WS2812Example/platformio.ini +++ /dev/null @@ -1,26 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[platformio] -src_dir = . - -[env:heltec_wifi_lora_32_V2] -platform = espressif32 -board = heltec_wifi_lora_32_V2 -framework = arduino -monitor_speed = 115200 -monitor_filters = time - -lib_deps = - https://github.com/Call-for-Code/ClusterDuck-Protocol - fastled/FastLED - -; uncomment for OTA update -; upload_port = duck.local diff --git a/3.TTGO-TBeam/.DS_Store b/3.TTGO-TBeam/.DS_Store deleted file mode 100644 index 2cc2c56..0000000 Binary files a/3.TTGO-TBeam/.DS_Store and /dev/null differ diff --git a/6.Ble-Duck-App/Ble-Duck-App/Ble-Duck-App.ino b/6.Ble-Duck-App/Ble-Duck-App/Ble-Duck-App.ino deleted file mode 100644 index 5823b56..0000000 --- a/6.Ble-Duck-App/Ble-Duck-App/Ble-Duck-App.ino +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file Ble-Duck-App.ino - * @brief Uses the built in Mama Duck with BLE functionality - * - * @date 2020-09-21 - * - * @copyright Copyright (c) 2020 - * - */ - -#include - -#ifdef SERIAL_PORT_USBVIRTUAL -#define Serial SERIAL_PORT_USBVIRTUAL -#endif - - -#include "BluetoothSerial.h" -#include -#include -#include - -#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) -#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it -#endif - -BluetoothSerial SerialBT; - -// create a built-in mama duck -MamaDuck duck; - -char message[32]; -int counter = 1; - -void setup() { - // We are using a hardcoded device id here, but it should be retrieved or - // given during the device provisioning then converted to a byte vector to - // setup the duck NOTE: The Device ID must be exactly 8 bytes otherwise it - // will get rejected - std::string deviceId("MAMA0001"); - std::vector devId; - devId.insert(devId.end(), deviceId.begin(), deviceId.end()); - duck.setDeviceId(devId); - - duck.setupSerial(); - duck.setupRadio(); - - Serial.println("MAMA-DUCK...READY!"); - - // Bluetooth display name - // This is what will be displyed in you Bluetooth settings - SerialBT.begin("MamaDuck1"); - Serial.println("The device started, now you can pair it with bluetooth!"); - -} - -void loop() { - - if (SerialBT.available()) { - String text = SerialBT.readString(); - Serial.println(text); - duck.sendData(topics::status, text); - delay(10); - } - - duck.run(); -} - diff --git a/6.Ble-Duck-App/Ble-Duck-App/platformio.ini b/6.Ble-Duck-App/Ble-Duck-App/platformio.ini deleted file mode 100644 index c74d6e8..0000000 --- a/6.Ble-Duck-App/Ble-Duck-App/platformio.ini +++ /dev/null @@ -1,25 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[platformio] -src_dir = . - -[env:heltec_wifi_lora_32_V2] -platform = espressif32 -board = heltec_wifi_lora_32_V2 -framework = arduino -monitor_speed = 115200 -monitor_filters = time - -lib_deps = - https://github.com/Call-for-Code/ClusterDuck-Protocol - -; uncomment for OTA update -; upload_port = duck.local diff --git a/4.Custom-Papa/PaPi-DMS-Lite-Examples/Serial-PaPiDuckExample/Serial-PaPiDuckExample.ino b/Custom-Papa/PaPi-DMS-Lite-Examples/Serial-PaPiDuckExample/Serial-PaPiDuckExample.ino similarity index 100% rename from 4.Custom-Papa/PaPi-DMS-Lite-Examples/Serial-PaPiDuckExample/Serial-PaPiDuckExample.ino rename to Custom-Papa/PaPi-DMS-Lite-Examples/Serial-PaPiDuckExample/Serial-PaPiDuckExample.ino diff --git a/4.Custom-Papa/Papa-DishDuck-WiFi/Papa-DishDuck-WiFi.ino b/Custom-Papa/Papa-DishDuck-WiFi/Papa-DishDuck-WiFi.ino similarity index 100% rename from 4.Custom-Papa/Papa-DishDuck-WiFi/Papa-DishDuck-WiFi.ino rename to Custom-Papa/Papa-DishDuck-WiFi/Papa-DishDuck-WiFi.ino diff --git a/4.Custom-Papa/Papa-DishDuck-WiFi/README.md b/Custom-Papa/Papa-DishDuck-WiFi/README.md similarity index 100% rename from 4.Custom-Papa/Papa-DishDuck-WiFi/README.md rename to Custom-Papa/Papa-DishDuck-WiFi/README.md diff --git a/4.Custom-Papa/Papa-DishDuck-WiFi/libraries.txt b/Custom-Papa/Papa-DishDuck-WiFi/libraries.txt similarity index 100% rename from 4.Custom-Papa/Papa-DishDuck-WiFi/libraries.txt rename to Custom-Papa/Papa-DishDuck-WiFi/libraries.txt diff --git a/4.Custom-Papa/Papa-DishDuck-WiFi/platformio.ini b/Custom-Papa/Papa-DishDuck-WiFi/platformio.ini similarity index 100% rename from 4.Custom-Papa/Papa-DishDuck-WiFi/platformio.ini rename to Custom-Papa/Papa-DishDuck-WiFi/platformio.ini diff --git a/4.Custom-Papa/Papa-DishDuck/Papa-DishDuck.ino b/Custom-Papa/Papa-DishDuck/Papa-DishDuck.ino similarity index 100% rename from 4.Custom-Papa/Papa-DishDuck/Papa-DishDuck.ino rename to Custom-Papa/Papa-DishDuck/Papa-DishDuck.ino diff --git a/4.Custom-Papa/Papa-DishDuck/README.md b/Custom-Papa/Papa-DishDuck/README.md similarity index 100% rename from 4.Custom-Papa/Papa-DishDuck/README.md rename to Custom-Papa/Papa-DishDuck/README.md diff --git a/4.Custom-Papa/Papa-DishDuck/libraries.txt b/Custom-Papa/Papa-DishDuck/libraries.txt similarity index 100% rename from 4.Custom-Papa/Papa-DishDuck/libraries.txt rename to Custom-Papa/Papa-DishDuck/libraries.txt diff --git a/4.Custom-Papa/Papa-DishDuck/platformio.ini b/Custom-Papa/Papa-DishDuck/platformio.ini similarity index 100% rename from 4.Custom-Papa/Papa-DishDuck/platformio.ini rename to Custom-Papa/Papa-DishDuck/platformio.ini diff --git a/4.Custom-Papa/Papa-Downtime-Counter/Papa-Downtime-Counter.ino b/Custom-Papa/Papa-Downtime-Counter/Papa-Downtime-Counter.ino similarity index 100% rename from 4.Custom-Papa/Papa-Downtime-Counter/Papa-Downtime-Counter.ino rename to Custom-Papa/Papa-Downtime-Counter/Papa-Downtime-Counter.ino diff --git a/4.Custom-Papa/Papa-Downtime-Counter/libraries.txt b/Custom-Papa/Papa-Downtime-Counter/libraries.txt similarity index 100% rename from 4.Custom-Papa/Papa-Downtime-Counter/libraries.txt rename to Custom-Papa/Papa-Downtime-Counter/libraries.txt diff --git a/4.Custom-Papa/Papa-Downtime-Counter/platformio.ini b/Custom-Papa/Papa-Downtime-Counter/platformio.ini similarity index 100% rename from 4.Custom-Papa/Papa-Downtime-Counter/platformio.ini rename to Custom-Papa/Papa-Downtime-Counter/platformio.ini diff --git a/4.Custom-Papa/PapiDuck-DMS-Lite-Serial-Example/PapiDuck-DMS-Lite-Serial-Example.ino b/Custom-Papa/PapiDuck-DMS-Lite-Serial-Example/PapiDuck-DMS-Lite-Serial-Example.ino similarity index 100% rename from 4.Custom-Papa/PapiDuck-DMS-Lite-Serial-Example/PapiDuck-DMS-Lite-Serial-Example.ino rename to Custom-Papa/PapiDuck-DMS-Lite-Serial-Example/PapiDuck-DMS-Lite-Serial-Example.ino diff --git a/4.Custom-Papa/PapiDuck-DMS-Lite-Serial-Example/platformio.ini b/Custom-Papa/PapiDuck-DMS-Lite-Serial-Example/platformio.ini similarity index 100% rename from 4.Custom-Papa/PapiDuck-DMS-Lite-Serial-Example/platformio.ini rename to Custom-Papa/PapiDuck-DMS-Lite-Serial-Example/platformio.ini diff --git a/4.Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/PapiDuck-DMS-Lite-WiFi-Example.ino b/Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/PapiDuck-DMS-Lite-WiFi-Example.ino similarity index 100% rename from 4.Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/PapiDuck-DMS-Lite-WiFi-Example.ino rename to Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/PapiDuck-DMS-Lite-WiFi-Example.ino diff --git a/4.Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/libraries.txt b/Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/libraries.txt similarity index 100% rename from 4.Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/libraries.txt rename to Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/libraries.txt diff --git a/4.Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/platformio.ini b/Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/platformio.ini similarity index 100% rename from 4.Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/platformio.ini rename to Custom-Papa/PapiDuck-DMS-Lite-WiFi-Example/platformio.ini diff --git a/5.Encryption/DecryptionPapaDuck/DecryptionPapaDuck.ino b/Encryption/DecryptionPapaDuck/DecryptionPapaDuck.ino similarity index 100% rename from 5.Encryption/DecryptionPapaDuck/DecryptionPapaDuck.ino rename to Encryption/DecryptionPapaDuck/DecryptionPapaDuck.ino diff --git a/5.Encryption/DecryptionPapaDuck/libraries.txt b/Encryption/DecryptionPapaDuck/libraries.txt similarity index 100% rename from 5.Encryption/DecryptionPapaDuck/libraries.txt rename to Encryption/DecryptionPapaDuck/libraries.txt diff --git a/5.Encryption/DecryptionPapaDuck/platformio.ini b/Encryption/DecryptionPapaDuck/platformio.ini similarity index 100% rename from 5.Encryption/DecryptionPapaDuck/platformio.ini rename to Encryption/DecryptionPapaDuck/platformio.ini diff --git a/5.Encryption/MamaDecrypt/MamaDecrypt.ino b/Encryption/MamaDecrypt/MamaDecrypt.ino similarity index 100% rename from 5.Encryption/MamaDecrypt/MamaDecrypt.ino rename to Encryption/MamaDecrypt/MamaDecrypt.ino diff --git a/5.Encryption/MamaDecrypt/platformio.ini b/Encryption/MamaDecrypt/platformio.ini similarity index 100% rename from 5.Encryption/MamaDecrypt/platformio.ini rename to Encryption/MamaDecrypt/platformio.ini diff --git a/README.md b/README.md index f59193c..2e7396b 100644 --- a/README.md +++ b/README.md @@ -2,36 +2,29 @@ These are few examples to show how someone can build on top of the ClusterDuck Protocol. It works using the master branch of the ClusterDuck Protocol firmware. -## 2. Sensors +## Sensors +These sensors are tested and confirmed that it works by CDP. #### BMP180Example The BMP180 example is a custom MamaDuck that will send sensor data from the BMP 180 (Temperature, Pressure, Altitude) if integrated with the . -#### BMP280Example -The BMP280 example is a custom Mama that will send sensor data from the BMP 280 (Temperature, Pressure, Humidity) inside its own payload into the mesh. - -#### DHT11Example -The DHT example is a custom Mama that will send sensor data from the DHT11 (Temperature and Humidity) inside its own payload into the mesh. - -#### DustSensorExample -The DustSensor example is a custom mama that will send sensor data from a Dust Sensor inside its own payload into the mesh. - -#### MQ7Example -The MQ7 example is a custom mama that will send sensor data from the MQ7 Gas sensor (Carbon Monoxide) inside its own payload into the mesh. - #### WS2812Example The WS2812 example is a Mama Duck, which also brings some light to the world by incorporating some WS2812 LEDs via the FastLED library. -## 3. TTGO T-Beam +## TTGO T-Beam If you have a TTGO T-Beam you can use these custom examples for it. -#### GPS +#### TBeam-GPS-Example This example is a MamaDuck, that uses using TinyGPS++ to get and send GPS data with the GPS topic based on the set timer. -#### Telemetry +#### TBeam-Telemetry-Example Using the TTGO's hardware we can collect all different kinds of live board information such as: onboard temperature, battery voltage (if 18650 installed), and charging. -## 4. Custom Papa +#### TBeam-AXP-Example + +#### TBeam-Sleep-Example + +## Custom Papa #### PaPa-DishDuck and PaPa-DishDuck-WiFi The papa Iridium Example is built to have an extra Iridium Satelite Backhaul when WiFi breakes down. @@ -40,7 +33,7 @@ The papa Iridium Example is built to have an extra Iridium Satelite Backhaul whe This custom PapaDuck keeps track of when it loses access to the internet and for how long. ### PaPi-DMS-Lite-Examples -https://github.com/Project-Owl/dms-lite-docker +[Link to DMS Lite](https://github.com/Project-Owl/dms-lite-docker) #### PapiDuck-Serial-Example The Serial Papi Example is a custom papa that will print the incoming data into the Serial Monitor for the PAPI to read. @@ -48,12 +41,11 @@ The Serial Papi Example is a custom papa that will print the incoming data into #### PapiDuck-WiFi-Example The WiFi Papi Example is a custom papa that will send the incoming data into the Papi. -## 5. Encryption -You can enable encryption. CDP comes with default settings, but set your own IV and AES256 key when in use. +## Encryption +You can enable encryption. CDP comes with default settings, but set your own IV and AES256 key when in use. **NOTE** It is not secure since the keys are hardcoded in the firmware. This is a work in progress. #### DecryptionPapa Decryption is a very fast operation and using this example your messages will be decrypted before sending to the cloud. Remember to set IV and AES256 key to be the same as what you use on other devices. -## 6. Ble-Duck-App -The BLE example is a custom mama that will accept data from the Duck App over bluetooth. -https://github.com/Project-Owl/DuckApp \ No newline at end of file +#### MamaDecrypt +A custom mama example that uses AES256 to encrypt the messages it generates and relays it. Any message it receives from the network, it can decrypt it. \ No newline at end of file diff --git a/Sensors/BMP180Example/BMP180Example.ino b/Sensors/BMP180Example/BMP180Example.ino new file mode 100644 index 0000000..09d8bbf --- /dev/null +++ b/Sensors/BMP180Example/BMP180Example.ino @@ -0,0 +1,127 @@ +/** + * @brief Uses the built in Mama Duck with a DHT11 amd BMP180 sensor + * + * @date 2024-06-14 + * + * @copyright Copyright (c) 2020 + * + */ + +#include +#include +#include + +#ifdef SERIAL_PORT_USBVIRTUAL +#define Serial SERIAL_PORT_USBVIRTUAL +#endif + +// Setup BMP180 +#include +Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085); + +bool sendData(std::vector message); +bool runSensor(void *); + +// create a built-in mama duck +MamaDuck duck; + +auto timer = timer_create_default(); +const int INTERVAL_MS = 10000; + +int counter = 1; +bool setupOK = false; + +void setup() { + + // The Device ID must be exactly 8 bytes otherwise it will get rejected + std::string deviceId("MAMABMP1"); + std::vector devId; + devId.insert(devId.end(), deviceId.begin(), deviceId.end()); + if (duck.setupWithDefaults(devId) != DUCK_ERR_NONE) { + Serial.println("[MAMA] Failed to setup MamaDuck"); + return; + } + + // BMP setup + if (!bmp.begin()) { + /* There was a problem detecting the BMP085 ... check your connections */ + Serial.print( + "Ooops, no BMP085 detected ... Check your wiring or I2C ADDR!"); + while (1) + ; + } else { + Serial.println("BMP on"); + } + + // initialize the timer. The timer will trigger sending a counter message. + timer.every(INTERVAL_MS, runSensor); + + setupOK = true; + Serial.println("[MAMA] Setup OK!"); +} + +void loop() { + timer.tick(); + // Use the default run(). The Mama duck is designed to also forward data it receives + // from other ducks, across the network. It has a basic routing mechanism built-in + // to prevent messages from hoping endlessly. + duck.run(); +} + +std::vector stringToByteVector(const String& str) { + std::vector byteVec; + byteVec.reserve(str.length()); + + for (unsigned int i = 0; i < str.length(); ++i) { + byteVec.push_back(static_cast(str[i])); + } + + return byteVec; +} + +bool runSensor(void *) { + bool result; + + String bmp = getBMP(); + + String message = String("Counter:")+String(counter)+" "+bmp; + + result = sendData(stringToByteVector(message)); + if (result) { + Serial.println("[MAMA] runSensor ok."); + } else { + Serial.println("[MAMA] runSensor failed."); + } + + return result; +} + +String getBMP() { + float T, P; + + bmp.getTemperature(&T); + Serial.print("[SENSOR]: Temperature: "); + Serial.println(T); + + bmp.getPressure(&P); + Serial.print("[SENSOR]: Pressure: "); + Serial.println(P); + + String sensorVal = "Temp:" + String(T) + " Pres:" + String(P); + + return sensorVal; +} + +bool sendData(std::vector message) { + bool sentOk = false; + + int err = duck.sendData(topics::sensor, message); + if (err == DUCK_ERR_NONE) { + counter++; + sentOk = true; + } + if (!sentOk) { + Serial.println("[MAMA] Failed to send data. error = " + String(err)); + } + return sentOk; +} \ No newline at end of file diff --git a/2.Sensors/BMP180Example/libraries.txt b/Sensors/BMP180Example/libraries.txt similarity index 100% rename from 2.Sensors/BMP180Example/libraries.txt rename to Sensors/BMP180Example/libraries.txt diff --git a/Sensors/BMP180Example/platformio.ini b/Sensors/BMP180Example/platformio.ini new file mode 100644 index 0000000..a71234f --- /dev/null +++ b/Sensors/BMP180Example/platformio.ini @@ -0,0 +1,158 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + + +; Some useful platformio CLI commands to build and uplaod the example code. + +; using the released CDP library +; platformio run -e prod_heltec_wifi_lora_32_V3 -t upload + +; using the local CDP library +; platformio run -e local_heltec_wifi_lora_32_V3 -t upload + + +[platformio] + src_dir = . +;; uncomment the line below to build for your board + + default_envs = local_heltec_wifi_lora_32_V3 +; default_envs = local_heltec_wifi_lora_32_V3 +; default_envs = local_heltec_wifi_lora_32_V2 +; default_envs = local_ttgo_t_beam + +; default_envs = prod_heltec_wifi_lora_32_V3 +; default_envs = prod_heltec_wifi_lora_32_V2 +; default_envs = prod_ttgo_t_beam + +description = MamaDuck CDP examples + +[env] + lib_deps = + WIRE + SPI + contrem/arduino-timer@^3.0.1 + adafruit/Adafruit BMP085 Unified@^1.1.0 + ; adafruit/Adafruit Unified Sensor@^1.1.14 + +[env:esp32] + lib_deps = + +[env:local_cdp] + lib_deps = symlink://../../../ ; local CDP library + +[env:release_cdp] + lib_deps = + https://github.com/ClusterDuck-Protocol/ClusterDuck-Protocol/archive/refs/tags/4.2.0.zip + + +; ------------------------------------------------------------------------------------------------------- +; ---- PRODUCTION ENVIRONMENTS +; ------------------------------------------------------------------------------------------------------- + + +; PRODUCTION HELTEC_WIFI_LORA_32_V2 +[env:prod_heltec_wifi_lora_32_V2] + platform = espressif32 + board = heltec_wifi_lora_32_V2 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + adafruit/Adafruit BMP085 Unified@^1.1.0 + +; PRODUCTION HELTEC_WIFI_LORA_32_V3 +[env:prod_heltec_wifi_lora_32_V3] + platform = espressif32 + board = heltec_wifi_lora_32_V3 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + adafruit/Adafruit BMP085 Unified@^1.1.0 + +; PRODUCTION LILYGO_T_BEAM_SX1262 +[env:prod_lilygo_t_beam_sx1262] + platform = espressif32 + board = ttgo-t-beam + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + adafruit/Adafruit BMP085 Unified@^1.1.0 + +; PRODUCTION TTGO_LORA32_V1 +[env:prod_ttgo_lora32_v1] + platform = espressif32 + board = ttgo-lora32-v1 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + adafruit/Adafruit BMP085 Unified@^1.1.0 + +; ------------------------------------------------------------------------------------------------------- +; ---- LOCAL ENVIRONMENTS +; ------------------------------------------------------------------------------------------------------- + +; LOCAL HELTEC_WIFI_LORA_32_V2 +[env:local_heltec_wifi_lora_32_V2] + platform = espressif32 + board = heltec_wifi_lora_32_V2 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + adafruit/Adafruit BMP085 Unified@^1.1.0 + +; LOCAL HELTEC_WIFI_LORA_32_V3 +[env:local_heltec_wifi_lora_32_V3] + platform = espressif32 + board = heltec_wifi_lora_32_V3 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + adafruit/Adafruit BMP085 Unified@^1.1.0 + +; LOCAL LILYGO_T_BEAM_SX1262 +[env:local_lilygo_t_beam_sx1262] + platform = espressif32 + board = ttgo-t-beam + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + adafruit/Adafruit BMP085 Unified@^1.1.0 + +; LOCAL TTGO_LORA32_V1 +[env:local_ttgo_lora32_v1] + platform = espressif32 + board = ttgo-lora32-v1 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + adafruit/Adafruit BMP085 Unified@^1.1.0 \ No newline at end of file diff --git a/2.Sensors/WS2812Example/WS2812Example.ino b/Sensors/WS2812Example/WS2812Example.ino similarity index 100% rename from 2.Sensors/WS2812Example/WS2812Example.ino rename to Sensors/WS2812Example/WS2812Example.ino diff --git a/2.Sensors/WS2812Example/libraries.txt b/Sensors/WS2812Example/libraries.txt similarity index 100% rename from 2.Sensors/WS2812Example/libraries.txt rename to Sensors/WS2812Example/libraries.txt diff --git a/Sensors/WS2812Example/platformio.ini b/Sensors/WS2812Example/platformio.ini new file mode 100644 index 0000000..dd00466 --- /dev/null +++ b/Sensors/WS2812Example/platformio.ini @@ -0,0 +1,165 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + + +; Some useful platformio CLI commands to build and uplaod the example code. + +; using the released CDP library +; platformio run -e prod_heltec_wifi_lora_32_V3 -t upload + +; using the local CDP library +; platformio run -e local_heltec_wifi_lora_32_V3 -t upload + + +[platformio] + src_dir = . +;; uncomment the line below to build for your board + + default_envs = local_heltec_wifi_lora_32_V3 +; default_envs = local_heltec_wifi_lora_32_V3 +; default_envs = local_heltec_wifi_lora_32_V2 +; default_envs = local_ttgo_t_beam + +; default_envs = prod_heltec_wifi_lora_32_V3 +; default_envs = prod_heltec_wifi_lora_32_V2 +; default_envs = prod_ttgo_t_beam + +description = MamaDuck CDP examples + +[env] + lib_deps = + WIRE + SPI + contrem/arduino-timer@^3.0.1 + FastLED/FastLED@^3.6.0 + +[env:esp32] + lib_deps = + +[env:local_cdp] + lib_deps = symlink://../../../ ; local CDP library + +[env:release_cdp] + lib_deps = + https://github.com/ClusterDuck-Protocol/ClusterDuck-Protocol/archive/refs/tags/4.2.0.zip + + +; ------------------------------------------------------------------------------------------------------- +; ---- PRODUCTION ENVIRONMENTS +; ------------------------------------------------------------------------------------------------------- + + +; PRODUCTION HELTEC_WIFI_LORA_32_V2 +[env:prod_heltec_wifi_lora_32_V2] + platform = espressif32 + board = heltec_wifi_lora_32_V2 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + contrem/arduino-timer@^3.0.1 + FastLED/FastLED@^3.6.0 + +; PRODUCTION HELTEC_WIFI_LORA_32_V3 +[env:prod_heltec_wifi_lora_32_V3] + platform = espressif32 + board = heltec_wifi_lora_32_V3 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + contrem/arduino-timer@^3.0.1 + FastLED/FastLED@^3.6.0 + +; PRODUCTION LILYGO_T_BEAM_SX1262 +[env:prod_lilygo_t_beam_sx1262] + platform = espressif32 + board = ttgo-t-beam + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + contrem/arduino-timer@^3.0.1 + FastLED/FastLED@^3.6.0 + +; PRODUCTION TTGO_LORA32_V1 +[env:prod_ttgo_lora32_v1] + platform = espressif32 + board = ttgo-lora32-v1 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + contrem/arduino-timer@^3.0.1 + FastLED/FastLED@^3.6.0 + +; ------------------------------------------------------------------------------------------------------- +; ---- LOCAL ENVIRONMENTS +; ------------------------------------------------------------------------------------------------------- + +; LOCAL HELTEC_WIFI_LORA_32_V2 +[env:local_heltec_wifi_lora_32_V2] + platform = espressif32 + board = heltec_wifi_lora_32_V2 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + contrem/arduino-timer@^3.0.1 + FastLED/FastLED@^3.6.0 + +; LOCAL HELTEC_WIFI_LORA_32_V3 +[env:local_heltec_wifi_lora_32_V3] + platform = espressif32 + board = heltec_wifi_lora_32_V3 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + contrem/arduino-timer@^3.0.1 + FastLED/FastLED@^3.6.0 + +; LOCAL LILYGO_T_BEAM_SX1262 +[env:local_lilygo_t_beam_sx1262] + platform = espressif32 + board = ttgo-t-beam + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + contrem/arduino-timer@^3.0.1 + FastLED/FastLED@^3.6.0 + +; LOCAL TTGO_LORA32_V1 +[env:local_ttgo_lora32_v1] + platform = espressif32 + board = ttgo-lora32-v1 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + contrem/arduino-timer@^3.0.1 + FastLED/FastLED@^3.6.0 \ No newline at end of file diff --git a/3.TTGO-TBeam/TBeam-AXP-Example/TBeam-AXP-Example.ino b/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX126/TBeam-AXP-Example.ino similarity index 100% rename from 3.TTGO-TBeam/TBeam-AXP-Example/TBeam-AXP-Example.ino rename to TTGO-TBeam/TBeam-AXP-Example/TBeam-SX126/TBeam-AXP-Example.ino diff --git a/3.TTGO-TBeam/TBeam-AXP-Example/libraries.txt b/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX126/libraries.txt similarity index 100% rename from 3.TTGO-TBeam/TBeam-AXP-Example/libraries.txt rename to TTGO-TBeam/TBeam-AXP-Example/TBeam-SX126/libraries.txt diff --git a/3.TTGO-TBeam/TBeam-AXP-Example/platformio.ini b/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX126/platformio.ini similarity index 100% rename from 3.TTGO-TBeam/TBeam-AXP-Example/platformio.ini rename to TTGO-TBeam/TBeam-AXP-Example/TBeam-SX126/platformio.ini diff --git a/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX127/TBeam-AXP-Example.ino b/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX127/TBeam-AXP-Example.ino new file mode 100644 index 0000000..a7ba0ba --- /dev/null +++ b/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX127/TBeam-AXP-Example.ino @@ -0,0 +1,119 @@ +/** + * @file TBeam-AXP-Example.ino + * @brief Uses the built in Mama Duck with some customizations. + * + * This example is a Mama Duck for the TTGO T-Beam that provides feedback and status on the battery and charging of the duck. + * + * @date 2020-11-10 + * + * @copyright Copyright (c) 2020 + * + */ + +#include +#include "arduino-timer.h" +#include +#include + +#ifdef SERIAL_PORT_USBVIRTUAL +#define Serial SERIAL_PORT_USBVIRTUAL +#endif + +// AXP setup +#include +#include + +AXP20X_Class axp; + +const uint8_t i2c_sda = 21; +const uint8_t i2c_scl = 22; + + +DuckDisplay* display = NULL; + + +// Set device ID between "" +String deviceId = "MAMA001"; +MamaDuck duck; + +auto timer = timer_create_default(); +const int INTERVAL_MS = 60000; +char message[32]; +int counter = 1; + +void setup() { + // We are using a hardcoded device id here, but it should be retrieved or + // given during the device provisioning then converted to a byte vector to + // setup the duck NOTE: The Device ID must be exactly 8 bytes otherwise it + // will get rejected + std::string deviceId("MAMA0001"); + std::vector devId; + devId.insert(devId.end(), deviceId.begin(), deviceId.end()); + + // Use the default setup provided by the SDK + duck.setupWithDefaults(devId); + Serial.println("MAMA-DUCK...READY!"); + + // initialize the timer. The timer thread runs separately from the main loop + // and will trigger sending a counter message. + timer.every(INTERVAL_MS, runSensor); + + Wire.begin(i2c_sda, i2c_scl); + + int ret = axp.begin(Wire, AXP192_SLAVE_ADDRESS); + + if (ret == AXP_FAIL) { + Serial.println("AXP Power begin failed"); + while (1); + } +} + +void loop() { + timer.tick(); + // Use the default run(). The Mama duck is designed to also forward data it receives + // from other ducks, across the network. It has a basic routing mechanism built-in + // to prevent messages from hoping endlessly. + duck.run(); + + +} + +bool runSensor(void *) { + + +float isCharging = axp.isChargeing(); +boolean isFullyCharged = axp.isChargingDoneIRQ(); +float batteryVoltage = axp.getBattVoltage(); +float batteryDischarge = axp.getAcinCurrent(); +float getTemp = axp.getTemp(); +int battPercentage = axp.getBattPercentage(); + + Serial.println("--- T-BEAM Power Information ---"); + Serial.print("Duck charging (1 = Yes): "); + Serial.println(isCharging); + Serial.print("Fully Charged: "); + Serial.println(isFullyCharged); + Serial.print("Battery Voltage: "); + Serial.println(batteryVoltage); + Serial.print("Battery Discharge: "); + Serial.println(batteryDischarge); + Serial.print("Board Temperature: "); + Serial.println(getTemp); + Serial.print("battery Percentage: "); + Serial.println(battPercentage); + + + String sensorVal = + "Charging: " + + String(isCharging) ; + " BattFull: " + + String(isFullyCharged)+ + " Voltage " + + String(batteryVoltage) ; + " Temp: " + + String(getTemp); + + + duck.sendData(topics::sensor, sensorVal); + return true; +} diff --git a/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX127/libraries.txt b/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX127/libraries.txt new file mode 100644 index 0000000..cd2a7ea --- /dev/null +++ b/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX127/libraries.txt @@ -0,0 +1 @@ +AXP202X_Library \ No newline at end of file diff --git a/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX127/platformio.ini b/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX127/platformio.ini new file mode 100644 index 0000000..e403bc3 --- /dev/null +++ b/TTGO-TBeam/TBeam-AXP-Example/TBeam-SX127/platformio.ini @@ -0,0 +1,186 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + + +; Some useful platformio CLI commands to build and uplaod the example code. + +; using the released CDP library +; platformio run -e prod_heltec_wifi_lora_32_V3 -t upload + +; using the local CDP library +; platformio run -e local_heltec_wifi_lora_32_V3 -t upload + + +[platformio] + src_dir = . +;; uncomment the line below to build for your board + + default_envs = local_heltec_wifi_lora_32_V3 +; default_envs = local_heltec_wifi_lora_32_V3 +; default_envs = local_heltec_wifi_lora_32_V2 +; default_envs = local_ttgo_t_beam + +; default_envs = prod_heltec_wifi_lora_32_V3 +; default_envs = prod_heltec_wifi_lora_32_V2 +; default_envs = prod_ttgo_t_beam + +description = DuckLink CDP examples + +[env] + lib_deps = + WIRE + SPI + contrem/arduino-timer@^3.0.1 + bblanchon/ArduinoJson@^7.0.3 + adafruit/DHT sensor library@^1.4.1 + adafruit/Adafruit BMP085 Unified@^1.1.0 + adafruit/Adafruit Unified Sensor@^1.1.14 + +[env:esp32] + lib_deps = + ARDUINOOTA + +[env:local_cdp] + lib_deps = ../../../ ; local CDP library + +[env:release_cdp] + lib_deps = + https://github.com/ClusterDuck-Protocol/ClusterDuck-Protocol ; CDP from master branch + + +; ------------------------------------------------------------------------------------------------------- +; ---- PRODUCTION ENVIRONMENTS +; ------------------------------------------------------------------------------------------------------- + + +; PRODUCTION HELTEC_WIFI_LORA_32_V2 +[env:prod_heltec_wifi_lora_32_V2] + platform = espressif32 + board = heltec_wifi_lora_32_V2 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + +; PRODUCTION HELTEC_WIFI_LORA_32_V3 +[env:prod_heltec_wifi_lora_32_V3] + platform = espressif32 + board = heltec_wifi_lora_32_V3 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + +; PRODUCTION LILYGO_T_BEAM_SX1262 +[env:prod_lilygo_t_beam_sx1262] + platform = espressif32 + board = ttgo-t-beam + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + adafruit/Adafruit BMP085 Unified@^1.1.0 + adafruit/Adafruit Unified Sensor@^1.1.14 + +; PRODUCTION TTGO_LORA32_V1 +[env:prod_ttgo_lora32_v1] + platform = espressif32 + board = ttgo-lora32-v1 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:release_cdp.lib_deps} + adafruit/DHT sensor library@^1.4.1 + adafruit/Adafruit BMP085 Unified@^1.1.0 + adafruit/Adafruit Unified Sensor@^1.1.14 + +; PRODUCTION CUBECELL_BOARD_V2 +[env:prod_cubecell_board_v2] + platform = https://github.com/HelTecAutomation/heltec-cubecell.git + board = cubecell_board_v2 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + build_flags = + -DCubeCell_Board + lib_ignore = + ESP Async WebServer + lib_deps = + ${env:release_cdp.lib_deps} + +; ------------------------------------------------------------------------------------------------------- +; ---- LOCAL ENVIRONMENTS +; ------------------------------------------------------------------------------------------------------- + +; LOCAL HELTEC_WIFI_LORA_32_V2 +[env:local_heltec_wifi_lora_32_V2] + platform = espressif32 + board = heltec_wifi_lora_32_V2 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + +; LOCAL HELTEC_WIFI_LORA_32_V3 +[env:local_heltec_wifi_lora_32_V3] + platform = espressif32 + board = heltec_wifi_lora_32_V3 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + +; LOCAL LILYGO_T_BEAM_SX1262 +[env:local_lilygo_t_beam_sx1262] + platform = espressif32 + board = ttgo-t-beam + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + +; LOCAL TTGO_LORA32_V1 +[env:local_ttgo_lora32_v1] + platform = espressif32 + board = ttgo-lora32-v1 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + lib_deps = + ${env:esp32.lib_deps} + ${env:local_cdp.lib_deps} + +; LOCAL CUBECELL_BOARD_V2 +[env:local_cubecell_board_v2] + platform = https://github.com/HelTecAutomation/heltec-cubecell.git + board = cubecell_board_v2 + framework = arduino + monitor_speed = 115200 + monitor_filters = time + build_flags = + -DCubeCell_Board + lib_ignore = + ESP Async WebServer + lib_deps = + ${env:local_cdp.lib_deps} \ No newline at end of file diff --git a/3.TTGO-TBeam/TBeam-GPS-Example/TBeam-GPS-Example.ino b/TTGO-TBeam/TBeam-GPS-Example/TBeam-GPS-Example.ino similarity index 100% rename from 3.TTGO-TBeam/TBeam-GPS-Example/TBeam-GPS-Example.ino rename to TTGO-TBeam/TBeam-GPS-Example/TBeam-GPS-Example.ino diff --git a/3.TTGO-TBeam/TBeam-GPS-Example/libraries.txt b/TTGO-TBeam/TBeam-GPS-Example/libraries.txt similarity index 100% rename from 3.TTGO-TBeam/TBeam-GPS-Example/libraries.txt rename to TTGO-TBeam/TBeam-GPS-Example/libraries.txt diff --git a/3.TTGO-TBeam/TBeam-GPS-Example/platformio.ini b/TTGO-TBeam/TBeam-GPS-Example/platformio.ini similarity index 100% rename from 3.TTGO-TBeam/TBeam-GPS-Example/platformio.ini rename to TTGO-TBeam/TBeam-GPS-Example/platformio.ini diff --git a/3.TTGO-TBeam/TBeam-Sleep/.gitignore b/TTGO-TBeam/TBeam-Sleep/.gitignore similarity index 100% rename from 3.TTGO-TBeam/TBeam-Sleep/.gitignore rename to TTGO-TBeam/TBeam-Sleep/.gitignore diff --git a/3.TTGO-TBeam/TBeam-Sleep/.vscode/extensions.json b/TTGO-TBeam/TBeam-Sleep/.vscode/extensions.json similarity index 100% rename from 3.TTGO-TBeam/TBeam-Sleep/.vscode/extensions.json rename to TTGO-TBeam/TBeam-Sleep/.vscode/extensions.json diff --git a/3.TTGO-TBeam/TBeam-Telemetry/TBeam-Telemetry.ino b/TTGO-TBeam/TBeam-Telemetry/TBeam-Telemetry.ino similarity index 100% rename from 3.TTGO-TBeam/TBeam-Telemetry/TBeam-Telemetry.ino rename to TTGO-TBeam/TBeam-Telemetry/TBeam-Telemetry.ino diff --git a/3.TTGO-TBeam/TBeam-Telemetry/libraries.txt b/TTGO-TBeam/TBeam-Telemetry/libraries.txt similarity index 100% rename from 3.TTGO-TBeam/TBeam-Telemetry/libraries.txt rename to TTGO-TBeam/TBeam-Telemetry/libraries.txt diff --git a/3.TTGO-TBeam/TBeam-Telemetry/platformio.ini b/TTGO-TBeam/TBeam-Telemetry/platformio.ini similarity index 100% rename from 3.TTGO-TBeam/TBeam-Telemetry/platformio.ini rename to TTGO-TBeam/TBeam-Telemetry/platformio.ini