From 9cab67e8719515b63f1a79e122528319f6318e1d Mon Sep 17 00:00:00 2001 From: pasatsanduadrian Date: Tue, 17 Dec 2019 16:00:12 +0200 Subject: [PATCH 1/8] Create GAS_WiFi this is an updated version for Gas Board equipped with 8 sensors --- .../IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi | 494 ++++++++++++++++++ 1 file changed, 494 insertions(+) create mode 100644 projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi diff --git a/projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi b/projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi new file mode 100644 index 00000000..762779c3 --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi @@ -0,0 +1,494 @@ +/* + * ------------ [Ga_v30_01] - Temperature, Humidty and Pressure -------------- + * + * Explanation: This example read the temperature, humidity and + * pressure values from BME280 sensor + * + * Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L. + * http://www.libelium.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Version: 3.0 + * Design: David Gascón + * Implementation: Ahmad Saad +*/ + +// Library include +#include +#include +#include + +// choose socket (SELECT USER'S SOCKET) +/////////////////////////////////////// +uint8_t socket = SOCKET0; +/////////////////////////////////////// + + +// choose URL settings +/////////////////////////////////////// +char type[] = "http"; +char host[] = "82.78.81.171"; +char port[] = "80"; +/////////////////////////////////////// + +uint8_t error; +uint8_t status; +unsigned long previous; + + + +#define NUM_OF_POINTS 3 + +//********************************************************************************* +// O2 Sensor must be connected in SOCKET1 +//********************************************************************************* +O2SensorClass O2Sensor(SOCKET_1); + +// Percentage values of Oxygen +#define POINT1_PERCENTAGE 0.0 +#define POINT2_PERCENTAGE 5.0 +// Calibration Voltage Obtained during calibration process (in mV) +#define POINT1_VOLTAGE 0.35 +#define POINT2_VOLTAGE 2.0 + +float concentrations_o2[] = {POINT1_PERCENTAGE, POINT2_PERCENTAGE}; +float voltages_o2[] = {POINT1_VOLTAGE, POINT2_VOLTAGE}; + + +//********************************************************************************* +// CO2 Sensor must be connected physically in SOCKET2 +//********************************************************************************* +CO2SensorClass CO2Sensor(SOCKET_2); + +// Concentratios used in calibration process +#define POINT1_PPM_CO2 350.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_CO2 1000.0 // PPM VALUE +#define POINT3_PPM_CO2 3000.0 // PPM VALUE + +// Calibration vVoltages obtained during calibration process +#define POINT1_VOLT_CO2 0.300 +#define POINT2_VOLT_CO2 0.350 +#define POINT3_VOLT_CO2 0.380 + +float concentrations_co2[] = {POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2}; +float voltages_co2[] = {POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2}; + + +//********************************************************************************* +// NO2 Sensor must be connected physically in SOCKET3 +//********************************************************************************* +NO2SensorClass NO2Sensor(SOCKET_3); + +// Concentratios used in calibration process +#define POINT1_PPM_NO2 10.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_NO2 50.0 // PPM VALUE +#define POINT3_PPM_NO2 100.0 // PPM VALUE + +// Calibration voltages obtained during calibration process (in KOHMs) +#define POINT1_RES_NO2 45.25 // <-- Rs at normal concentration in air +#define POINT2_RES_NO2 25.50 +#define POINT3_RES_NO2 3.55 + +float concentrations_no2[] = {POINT1_PPM_NO2, POINT2_PPM_NO2, POINT3_PPM_NO2}; +float voltages_no2[] = {POINT1_RES_NO2, POINT2_RES_NO2, POINT3_RES_NO2}; + +//********************************************************************************* +// CO Sensor must be connected physically in SOCKET_4 +//********************************************************************************* +COSensorClass COSensor(SOCKET_4); + +// Concentratios used in calibration process +#define POINT1_PPM_CO 100.0 // <--- Ro value at this concentration +#define POINT2_PPM_CO 300.0 // +#define POINT3_PPM_CO 1000.0 // + +// Calibration resistances obtained during calibration process +#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. +#define POINT2_RES_CO 40.665 // +#define POINT3_RES_CO 20.300 // + +float concentrations_co[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO }; +float resValues_co[] = { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO }; +//********************************************************************************* +// VOC Sensor must be connected physically in SOCKET5 +//********************************************************************************* +VOCSensorClass VOCSensor(SOCKET_5); + +// Concentratios used in calibration process (PPM VALUE) +#define POINT1_PPM_VOC 100.0 // <--- Ro value at this concentration +#define POINT2_PPM_VOC 300.0 +#define POINT3_PPM_VOC 1000.0 + +// Calibration resistances obtained during calibration process +#define POINT1_RES_VOC 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. +#define POINT2_RES_VOC 40.665 // +#define POINT3_RES_VOC 20.300 // + +float concentrations[] = { POINT1_PPM_VOC, POINT2_PPM_VOC, POINT3_PPM_VOC }; +float resValues[] = { POINT1_RES_VOC, POINT2_RES_VOC, POINT3_RES_VOC }; + + +//********************************************************************************* +// LPG Sensor can be connected in SOCKET6 AND SOCKET7 +//********************************************************************************* +LPGSensorClass LPGSensor(SOCKET_6); ; // <---- SOCKET7 Class used + +// Concentratios used in calibration process +#define POINT1_PPM_LPG 10.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_LPG 50.0 // PPM VALUE +#define POINT3_PPM_LPG 100.0 // PPM VALUE + +// Calibration voltages obtained during calibration process (in KOHMs) +#define POINT1_RES_LPG 45.25 // <-- Rs at normal concentration in air +#define POINT2_RES_LPG 25.50 +#define POINT3_RES_LPG 3.55 + +float concentrations_lps[] = {POINT1_PPM_LPG, POINT2_PPM_LPG, POINT3_PPM_LPG}; +float voltages_lps[] = {POINT1_RES_LPG, POINT2_RES_LPG, POINT3_RES_LPG}; + +//********************************************************************************* +// Solvent Vapors Sensor must be connected physically in SOCKET_6 or SOCKET_7 +//********************************************************************************* +SVSensorClass SVSensor(SOCKET_7); + +// Concentratios used in calibration process +#define POINT1_PPM_SV 10.0 // <-- Normal concentration in air +#define POINT2_PPM_SV 50.0 +#define POINT3_PPM_SV 100.0 + +// Calibration voltages obtained during calibration process (in KOHMs) +#define POINT1_RES_SV 45.25 // <-- Rs at normal concentration in air +#define POINT2_RES_SV 25.50 +#define POINT3_RES_SV 3.55 + +float concentrations_sv[] = { POINT1_PPM_SV, POINT2_PPM_SV, POINT3_PPM_SV }; +float voltages_sv[] = { POINT1_RES_SV, POINT2_RES_SV, POINT3_RES_SV }; + +//********************************************************************************* +// BME280 Definitions +//********************************************************************************* +#include + +float temperature; // Stores the temperature in ºC +float humidity; // Stores the realitve humidity in %RH +float pressure; // Stores the pressure in Pa + +//********************************************************************************* + + +char node_ID[] = "BEIA_GAS1"; //ex GAS_WiFi + +void setup() +{ + // Configure the calibration values + O2Sensor.setCalibrationPoints(voltages_o2, concentrations_o2); + // Configure the calibration values + CO2Sensor.setCalibrationPoints(voltages_co2, concentrations_co2, NUM_OF_POINTS); + // Configure the calibration values + NO2Sensor.setCalibrationPoints(voltages_no2, concentrations_no2, NUM_OF_POINTS); + // Configure the calibration values + VOCSensor.setCalibrationPoints(resValues, concentrations, NUM_OF_POINTS); + // Configure the calibration values + LPGSensor.setCalibrationPoints(voltages_lps, concentrations_lps, NUM_OF_POINTS); + // Calculate the slope and the intersection of the logarithmic function + COSensor.setCalibrationPoints(resValues_co, concentrations_co, NUM_OF_POINTS); + // Calculate the slope and the intersection of the logarithmic function + SVSensor.setCalibrationPoints(voltages_sv, concentrations_sv, NUM_OF_POINTS); + + USB.ON(); + USB.println(F("Frame")); + + // Set the Waspmote ID + frame.setID(node_ID); + + /////////////////////////////////////////// + // 1. Turn on the board + /////////////////////////////////////////// + + //Power gases board and wait for stabilization and sensor response time + Gases.ON(); +} + +void loop() +{ + // get actual time + previous = millis(); + ////////////////////////////////////////////////// + // 1. Switch ON + ////////////////////////////////////////////////// + error = WIFI_PRO.ON(socket); + + if (error == 0) + { + USB.println(F("WiFi switched ON")); + } + else + { + USB.println(F("WiFi did not initialize correctly")); + } + ////////////////////////////////////////////////// + // 2. Join AP + ////////////////////////////////////////////////// + // check connectivity + status = WIFI_PRO.isConnected(); + + // check if module is connected + if (status == true) + { + USB.print(F("WiFi is connected OK")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + + ////////////////////////////////////////////////////////////////////// + // 2. Read Sensors + ////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////// + // 2.1 Read Temperature, Humidity and Pressure Sensor (BME280) + ////////////////////////////////////////////////////////////////////// + + // Read enviromental variables + temperature = Gases.getTemperature(); + humidity = Gases.getHumidity(); + pressure = Gases.getPressure(); + + ////////////////////////////////////////////////////////////////////// + // 2.2 Read O2 Sensor - Connected in SOCKET1 + ////////////////////////////////////////////////////////////////////// + O2Sensor.ON(); + delay(1000); + // O2 Sensor does not need power suplly + float O2Vol = O2Sensor.readVoltage(); + delay(100); + // Read the concentration value in % + float O2Val = O2Sensor.readConcentration(); + O2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.3 Read CO2 Sensor - Connected in SOCKET2 + ////////////////////////////////////////////////////////////////////// + CO2Sensor.ON(); + delay(1000); + // PPM value of CO2 + // Voltage value of the sensor + float CO2Vol = CO2Sensor.readVoltage(); + // PPM value of CO2 + float CO2PPM = CO2Sensor.readConcentration(); + CO2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.4 Read NO2 Sensor - Connected in SOCKET3 + ////////////////////////////////////////////////////////////////////// + NO2Sensor.ON(); + delay(1000); + // PPM value of NO2 + float NO2Vol = NO2Sensor.readVoltage(); // Voltage value of the sensor + float NO2Res = NO2Sensor.readResistance(); // Resistance of the sensor + float NO2PPM = NO2Sensor.readConcentration(); // PPM value of NO2 + NO2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.4 Read VOC Sensor - Connected in SOCKET5 + ////////////////////////////////////////////////////////////////////// + VOCSensor.ON(); + delay(1000); + // PPM value of VOC + float VOCVol = VOCSensor.readVoltage(); // Voltage value of the sensor + float VOCRes = VOCSensor.readResistance(); // Resistance of the sensor + float VOCPPM = VOCSensor.readConcentration(); // PPM value of VOC + VOCSensor.OFF(); + + // 2.5 Read LPG Sensor - Connected in SOCKET7 + ////////////////////////////////////////////////////////////////////// + LPGSensor.ON(); + delay(1000); + // PPM value of CH4 + float LPGVol = LPGSensor.readVoltage(); // Voltage value of the sensor + float LPGRes = LPGSensor.readResistance(); // Resistance of the sensor + float LPGPPM = LPGSensor.readConcentration(); // PPM value of LPGfloat LPGPPM = LPGSensor.readConcentration(); + LPGSensor.OFF(); + + // 2.6 Read LPG Sensor - Connected in SOCKET6 + ////////////////////////////////////////////////////////////////////// + COSensor.ON(); + // PPM value of CO + delay(1000); + float COVol = COSensor.readVoltage(); // Voltage value of the sensor + float CORes = COSensor.readResistance(); // Resistance of the sensor + float COPPM = COSensor.readConcentration(); // PPM value of CO + COSensor.OFF(); + + // 2.7 Read SV Sensor - Connected in SOCKET7 + ////////////////////////////////////////////////////////////////////// + SVSensor.ON(); + // PPM value of SV + float SVVol = SVSensor.readVoltage(); // Voltage value of the sensor + float SVRes = SVSensor.readResistance(); // Resistance of the sensor + float SVPPM = SVSensor.readConcentration(); // PPM value of Solvent Vapor sensor + SVSensor.OFF(); + + + /////////////////print of results////////////////////////// + // O2 Sensor does not need power suplly + USB.print(F("O2 concentration Estimated: ")); + USB.print(O2Vol); + USB.print(F(" mV | ")); + + USB.print(F(" O2 concentration Estimated: ")); + USB.print(O2Val); + USB.println(F(" %")); + + // Print of the results + USB.print(F("NO2 Sensor Voltage: ")); + USB.print(NO2Vol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" NO2 Sensor Resistance: ")); + USB.print(NO2Res); + USB.print(F(" Ohms |")); + + // Print of the results + USB.print(F(" NO2 concentration Estimated: ")); + USB.print(NO2PPM); + USB.println(F(" PPM")); + + + // Print of the results + USB.print(F("CO Sensor Voltage: ")); + USB.print(COVol); + USB.print(F(" mV |")); + + // Print of the results + USB.print(F(" CO Sensor Resistance: ")); + USB.print(CORes); + USB.print(F(" Ohms |")); + + USB.print(F(" CO concentration Estimated: ")); + USB.print(COPPM); + USB.println(F(" ppm")); + + // Print of the results + USB.print(F("CO2 Sensor Voltage: ")); + USB.print(CO2Vol); + USB.print(F("volts |")); + + USB.print(F(" CO2 concentration estimated: ")); + USB.print(CO2PPM); + USB.println(F(" ppm")); + + // Print of the results + USB.print(F("VOC Sensor Voltage: ")); + USB.print(VOCVol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" VOC Sensor Resistance: ")); + USB.print(VOCRes); + USB.print(F(" Ohms |")); + + USB.print(F(" VOC concentration Estimated: ")); + USB.print(VOCPPM); + USB.println(F(" ppm")); + + // Print of the results + USB.print(F("Solvent Vapors Sensor Voltage: ")); + USB.print(SVVol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" Solvent Vapors Sensor Resistance: ")); + USB.print(SVRes); + USB.print(F(" Ohms |")); + + // Print of the results + USB.print(F(" Solvent Vapors concentration Estimated: ")); + USB.print(SVPPM); + USB.println(F(" PPM")); + + // Print of the results + USB.print(F("LPG Sensor Voltage: ")); + USB.print(LPGVol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" LPG Sensor Resistance: ")); + USB.print(LPGRes); + USB.print(F(" Ohms |")); + + USB.print(F(" LPG concentration Estimated: ")); + USB.print(LPGPPM); + USB.println(F(" ppm")); + + // 3. Create ASCII frame + /////////////////////////////////////////// + + // Create new frame (ASCII) + frame.createFrame(BINARY, node_ID); + // Add Oxygen voltage value + frame.addSensor(SENSOR_GASES_O2, O2Val); + // Add CO2 PPM value + frame.addSensor(SENSOR_GASES_CO2, CO2PPM); + // Add NO2 PPM value + frame.addSensor(SENSOR_GASES_NO2, NO2PPM); + // Add VOC PPM value + frame.addSensor(SENSOR_GASES_VOC, VOCPPM); + // Add LPG PPM value + frame.addSensor(SENSOR_GASES_LPG, LPGPPM); + // Add CO PPM value + frame.addSensor(SENSOR_GASES_CO, COPPM); + // Add SV PPM value + frame.addSensor(SENSOR_GASES_SV, SVPPM); + // Add BAT level value + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + // Show the frame + frame.showFrame(); + + + // 3.2. Send Frame to Meshlium + /////////////////////////////// + + // http frame + error = WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); + + // check response + if (error == 0) + { + USB.println(F("HTTP OK")); + USB.print(F("HTTP Time from OFF state (ms):")); + USB.println(millis()-previous); + } + else + { + USB.println(F("Error calling 'getURL' function")); + WIFI_PRO.printErrorCode(); + } + } + else + { + USB.print(F("WiFi is connected ERROR")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + } + ////////////////////////////////////////////////// + // 3. Switch OFF + ////////////////////////////////////////////////// + WIFI_PRO.OFF(socket); + USB.println(F("WiFi switched OFF\n\n")); +// Go to deepsleep + // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm + USB.println(F("Go to deepsleep --- After 10 seconds, Waspmote wakes up thanks to the RTC Alarm")); + PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); +} From 242642af27c3de3a4b357e231d5e75cd31b2eab7 Mon Sep 17 00:00:00 2001 From: pasatsanduadrian Date: Tue, 17 Dec 2019 16:15:40 +0200 Subject: [PATCH 2/8] Update GAS_WiFi --- .../IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi b/projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi index 762779c3..a32bb7e1 100644 --- a/projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi +++ b/projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi @@ -490,5 +490,22 @@ void loop() // Go to deepsleep // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm USB.println(F("Go to deepsleep --- After 10 seconds, Waspmote wakes up thanks to the RTC Alarm")); - PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); + //PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); + // USB.ON(); + //USB.println(F("\nwake up")); + + // After wake up check interruption source + //if( intFlag & RTC_INT ) + // { + // clear interruption flag + // intFlag &= ~(RTC_INT); + + // USB.println(F("---------------------")); + //USB.println(F("RTC INT captured")); + //USB.println(F("---------------------")); + Utils.blinkLEDs(300); + Utils.blinkLEDs(300); + Utils.blinkLEDs(300); + // } + delay (10000); } From c9da40c7342c89c3e2e85110fdb5c84e1316d1fd Mon Sep 17 00:00:00 2001 From: pasatsanduadrian Date: Tue, 17 Dec 2019 16:16:27 +0200 Subject: [PATCH 3/8] Update GAS_WiFi used delay deep sleep function doesn t work From 114f58df91027c3d5c98dc330dc7f9154788a31a Mon Sep 17 00:00:00 2001 From: pasatsanduadrian Date: Wed, 15 Jan 2020 12:52:27 +0200 Subject: [PATCH 4/8] Create BEIA GAS 2 --- projects/IoTBoardCode/Waspmote/BEIA GAS 2 | 549 ++++++++++++++++++++++ 1 file changed, 549 insertions(+) create mode 100644 projects/IoTBoardCode/Waspmote/BEIA GAS 2 diff --git a/projects/IoTBoardCode/Waspmote/BEIA GAS 2 b/projects/IoTBoardCode/Waspmote/BEIA GAS 2 new file mode 100644 index 00000000..ac247cb2 --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/BEIA GAS 2 @@ -0,0 +1,549 @@ +/* + * ------------ [Ga_v30_01] - Temperature, Humidty and Pressure -------------- + * + * Explanation: This example read the temperature, humidity and + * pressure values from BME280 sensor + * + * Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L. + * http://www.libelium.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Version: 3.0 + * Design: David Gascón + * Implementation: Ahmad Saad +*/ + +// Library include +#include +#include +#include + +// choose socket (SELECT USER'S SOCKET) +/////////////////////////////////////// +uint8_t socket = SOCKET0; +/////////////////////////////////////// + + +// choose URL settings +/////////////////////////////////////// +char type[] = "http"; +char host[] = "82.78.81.171"; +char port[] = "80"; +/////////////////////////////////////// + +uint8_t error; +uint8_t status; +unsigned long previous; + + + +#define NUM_OF_POINTS 3 + +//********************************************************************************* +// O2 Sensor must be connected in SOCKET1 +//********************************************************************************* +O2SensorClass O2Sensor(SOCKET_1); + +// Percentage values of Oxygen +#define POINT1_PERCENTAGE 0.0 +#define POINT2_PERCENTAGE 5.0 +// Calibration Voltage Obtained during calibration process (in mV) +#define POINT1_VOLTAGE 0.35 +#define POINT2_VOLTAGE 2.0 + +float concentrations_o2[] = {POINT1_PERCENTAGE, POINT2_PERCENTAGE}; +float voltages_o2[] = {POINT1_VOLTAGE, POINT2_VOLTAGE}; + + +//********************************************************************************* +// CO2 Sensor must be connected physically in SOCKET2 +//********************************************************************************* +CO2SensorClass CO2Sensor(SOCKET_2); + +// Concentratios used in calibration process +#define POINT1_PPM_CO2 350.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_CO2 1000.0 // PPM VALUE +#define POINT3_PPM_CO2 3000.0 // PPM VALUE + +// Calibration vVoltages obtained during calibration process +#define POINT1_VOLT_CO2 0.300 +#define POINT2_VOLT_CO2 0.350 +#define POINT3_VOLT_CO2 0.380 + +float concentrations_co2[] = {POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2}; +float voltages_co2[] = {POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2}; + + +//********************************************************************************* +// NO2 Sensor must be connected physically in SOCKET3 +//********************************************************************************* +NO2SensorClass NO2Sensor(SOCKET_3); + +// Concentratios used in calibration process +#define POINT1_PPM_NO2 10.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_NO2 50.0 // PPM VALUE +#define POINT3_PPM_NO2 100.0 // PPM VALUE + +// Calibration voltages obtained during calibration process (in KOHMs) +#define POINT1_RES_NO2 45.25 // <-- Rs at normal concentration in air +#define POINT2_RES_NO2 25.50 +#define POINT3_RES_NO2 3.55 + +float concentrations_no2[] = {POINT1_PPM_NO2, POINT2_PPM_NO2, POINT3_PPM_NO2}; +float voltages_no2[] = {POINT1_RES_NO2, POINT2_RES_NO2, POINT3_RES_NO2}; + +//********************************************************************************* +// CO Sensor must be connected physically in SOCKET_4 +//********************************************************************************* +//COSensorClass COSensor(SOCKET_4); + +// Concentratios used in calibration process +//#define POINT1_PPM_CO 100.0 // <--- Ro value at this concentration +//#define POINT2_PPM_CO 300.0 // +//#define POINT3_PPM_CO 1000.0 // + +// Calibration resistances obtained during calibration process +//#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. +//#define POINT2_RES_CO 40.665 // +//#define POINT3_RES_CO 20.300 // + +//float concentrations_co[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO }; +//float resValues_co[] = { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO }; +//********************************************************************************* +// VOC Sensor must be connected physically in SOCKET5 +//********************************************************************************* +VOCSensorClass VOCSensor(SOCKET_5); + +// Concentratios used in calibration process (PPM VALUE) +#define POINT1_PPM_VOC 100.0 // <--- Ro value at this concentration +#define POINT2_PPM_VOC 300.0 +#define POINT3_PPM_VOC 1000.0 + +// Calibration resistances obtained during calibration process +#define POINT1_RES_VOC 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. +#define POINT2_RES_VOC 40.665 // +#define POINT3_RES_VOC 20.300 // + +float concentrations[] = { POINT1_PPM_VOC, POINT2_PPM_VOC, POINT3_PPM_VOC }; +float resValues[] = { POINT1_RES_VOC, POINT2_RES_VOC, POINT3_RES_VOC }; + + +//********************************************************************************* +// LPG Sensor can be connected in SOCKET6 AND SOCKET7 +//********************************************************************************* +LPGSensorClass LPGSensor(SOCKET_6); ; // <---- SOCKET7 Class used + +// Concentratios used in calibration process +#define POINT1_PPM_LPG 10.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_LPG 50.0 // PPM VALUE +#define POINT3_PPM_LPG 100.0 // PPM VALUE + +// Calibration voltages obtained during calibration process (in KOHMs) +#define POINT1_RES_LPG 45.25 // <-- Rs at normal concentration in air +#define POINT2_RES_LPG 25.50 +#define POINT3_RES_LPG 3.55 + +float concentrations_lps[] = {POINT1_PPM_LPG, POINT2_PPM_LPG, POINT3_PPM_LPG}; +float voltages_lps[] = {POINT1_RES_LPG, POINT2_RES_LPG, POINT3_RES_LPG}; + +//********************************************************************************* +// Solvent Vapors Sensor / APP1 must be connected physically in SOCKET_6 or SOCKET_7 +//********************************************************************************* +APSensorClass APPSensor(SOCKET_7); // + + +//SVSensorClass SVSensor(SOCKET_7); + +// Concentratios used in calibration process +//#define POINT1_PPM_SV 10.0 // <-- Normal concentration in air +//#define POINT2_PPM_SV 50.0 +//#define POINT3_PPM_SV 100.0 + +// Calibration voltages obtained during calibration process (in KOHMs) +//#define POINT1_RES_SV 45.25 // <-- Rs at normal concentration in air +//#define POINT2_RES_SV 25.50 +//#define POINT3_RES_SV 3.55 + +//float concentrations_sv[] = { POINT1_PPM_SV, POINT2_PPM_SV, POINT3_PPM_SV }; +//float voltages_sv[] = { POINT1_RES_SV, POINT2_RES_SV, POINT3_RES_SV }; + +//********************************************************************************* +// BME280 Definitions +//********************************************************************************* +#include + +float temperature; // Stores the temperature in ºC +float humidity; // Stores the realitve humidity in %RH +float pressure; // Stores the pressure in Pa + +//********************************************************************************* + + +char node_ID[] = "BEIA_GAS2"; //ex GAS_WiFi + +void setup() +{ + // Configure the calibration values + O2Sensor.setCalibrationPoints(voltages_o2, concentrations_o2); + // Configure the calibration values + //CO2Sensor.setCalibrationPoints(voltages_co2, concentrations_co2, NUM_OF_POINTS); + // Configure the calibration values + NO2Sensor.setCalibrationPoints(voltages_no2, concentrations_no2, NUM_OF_POINTS); + // Configure the calibration values + VOCSensor.setCalibrationPoints(resValues, concentrations, NUM_OF_POINTS); + // Configure the calibration values + LPGSensor.setCalibrationPoints(voltages_lps, concentrations_lps, NUM_OF_POINTS); + // Calculate the slope and the intersection of the logarithmic function + //COSensor.setCalibrationPoints(resValues_co, concentrations_co, NUM_OF_POINTS); + // Calculate the slope and the intersection of the logarithmic function + //SVSensor.setCalibrationPoints(voltages_sv, concentrations_sv, NUM_OF_POINTS); + // Concentratios used in calibration process (in PPM) + APPSensor.concentrations[POINT_1] = 10.0; // <--- Ro value at this concentration + APPSensor.concentrations[POINT_2] = 50.0 ; + APPSensor.concentrations[POINT_3] = 100.0; + // Calibration resistances obtained during calibration process (in Kohms) + APPSensor.values[POINT_1] = 45.25; // <-- Ro Resistance at 100 ppm. Necessary value. + APPSensor.values[POINT_2] = 25.665; + APPSensor.values[POINT_3] = 2.300; + // Define the number of calibration points + APPSensor.numPoints = 3; + // Calculate the slope and the intersection of the logarithmic function + APPSensor.setCalibrationPoints(); + USB.ON(); + USB.println(F("Frame")); + + // Set the Waspmote ID + frame.setID(node_ID); + + /////////////////////////////////////////// + // 1. Turn on the board + /////////////////////////////////////////// + + //Power gases board and wait for stabilization and sensor response time + Gases.ON(); +} + +void loop() +{ + // get actual time + previous = millis(); + ////////////////////////////////////////////////// + // 1. Switch ON + ////////////////////////////////////////////////// + error = WIFI_PRO.ON(socket); + + if (error == 0) + { + USB.println(F("WiFi switched ON")); + } + else + { + USB.println(F("WiFi did not initialize correctly")); + } + ////////////////////////////////////////////////// + // 2. Join AP + ////////////////////////////////////////////////// + // check connectivity + status = WIFI_PRO.isConnected(); + + // check if module is connected + if (status == true) + { + USB.print(F("WiFi is connected OK")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + + ////////////////////////////////////////////////////////////////////// + // 2. Read Sensors + ////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////// + // 2.1 Read Temperature, Humidity and Pressure Sensor (BME280) + ////////////////////////////////////////////////////////////////////// + + // Read enviromental variables + temperature = Gases.getTemperature(); + humidity = Gases.getHumidity(); + pressure = Gases.getPressure(); + + ////////////////////////////////////////////////////////////////////// + // 2.2 Read O2 Sensor - Connected in SOCKET1 + ////////////////////////////////////////////////////////////////////// + O2Sensor.ON(); + delay(1000); + // O2 Sensor does not need power suplly + float O2Vol = O2Sensor.readVoltage(); + delay(100); + // Read the concentration value in % + float O2Val = O2Sensor.readConcentration(); + O2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.3 Read CO2 Sensor - Connected in SOCKET2 + ////////////////////////////////////////////////////////////////////// + //CO2Sensor.ON(); + //delay(1000); + // PPM value of CO2 + // Voltage value of the sensor + //float CO2Vol = CO2Sensor.readVoltage(); + // PPM value of CO2 + //float CO2PPM = CO2Sensor.readConcentration(); + //CO2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.4 Read NO2 Sensor - Connected in SOCKET3 + ////////////////////////////////////////////////////////////////////// + NO2Sensor.ON(); + delay(1000); + // PPM value of NO2 + float NO2Vol = NO2Sensor.readVoltage(); // Voltage value of the sensor + float NO2Res = NO2Sensor.readResistance(); // Resistance of the sensor + float NO2PPM = NO2Sensor.readConcentration(); // PPM value of NO2 + NO2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.4 Read VOC Sensor - Connected in SOCKET5 + ////////////////////////////////////////////////////////////////////// + VOCSensor.ON(); + delay(1000); + // PPM value of VOC + float VOCVol = VOCSensor.readVoltage(); // Voltage value of the sensor + float VOCRes = VOCSensor.readResistance(); // Resistance of the sensor + float VOCPPM = VOCSensor.readConcentration(); // PPM value of VOC + VOCSensor.OFF(); + + // 2.5 Read LPG Sensor - Connected in SOCKET7 + ////////////////////////////////////////////////////////////////////// + LPGSensor.ON(); + delay(1000); + // PPM value of CH4 + float LPGVol = LPGSensor.readVoltage(); // Voltage value of the sensor + float LPGRes = LPGSensor.readResistance(); // Resistance of the sensor + float LPGPPM = LPGSensor.readConcentration(); // PPM value of LPGfloat LPGPPM = LPGSensor.readConcentration(); + LPGSensor.OFF(); + + // 2.6 Read LPG Sensor - Connected in SOCKET6 + ////////////////////////////////////////////////////////////////////// + //COSensor.ON(); + // PPM value of CO + //delay(1000); + //float COVol = COSensor.readVoltage(); // Voltage value of the sensor + //float CORes = COSensor.readResistance(); // Resistance of the sensor + //float COPPM = COSensor.readConcentration(); // PPM value of CO + //COSensor.OFF(); + + // 2.7 Read SV Sensor - Connected in SOCKET7 + ////////////////////////////////////////////////////////////////////// + //SVSensor.ON(); + // PPM value of SV + //float SVVol = SVSensor.readVoltage(); // Voltage value of the sensor + //float SVRes = SVSensor.readResistance(); // Resistance of the sensor + //float SVPPM = SVSensor.readConcentration(); // PPM value of Solvent Vapor sensor + //SVSensor.OFF(); + + // 2.6 Read APP1 Sensor - Connected in SOCKET7 + APPSensor.ON(); + delay(1000); + // PPM value of APP1 + float APPVol = APPSensor.readVoltage(); // Voltage value of the sensor + float APPRes = APPSensor.readResistance(); // Resistance of the sensor + float APP_PPM = APPSensor.readConcentration(); // PPM value of AP1 + + + /////////////////print of results////////////////////////// + // O2 Sensor does not need power suplly + USB.print(F("O2 concentration Estimated: ")); + USB.print(O2Vol); + USB.print(F(" mV | ")); + + USB.print(F(" O2 concentration Estimated: ")); + USB.print(O2Val); + USB.println(F(" %")); + + // Print of the results + USB.print(F("NO2 Sensor Voltage: ")); + USB.print(NO2Vol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" NO2 Sensor Resistance: ")); + USB.print(NO2Res); + USB.print(F(" Ohms |")); + + // Print of the results + USB.print(F(" NO2 concentration Estimated: ")); + USB.print(NO2PPM); + USB.println(F(" PPM")); + + + // Print of the results + // USB.print(F("CO Sensor Voltage: ")); + //USB.print(COVol); + //USB.print(F(" mV |")); + + // Print of the results + //USB.print(F(" CO Sensor Resistance: ")); + //USB.print(CORes); + //USB.print(F(" Ohms |")); + + //USB.print(F(" CO concentration Estimated: ")); + //USB.print(COPPM); + //USB.println(F(" ppm")); + + // Print of the results + //USB.print(F("CO2 Sensor Voltage: ")); + //USB.print(CO2Vol); + //USB.print(F("volts |")); + + //USB.print(F(" CO2 concentration estimated: ")); + //USB.print(CO2PPM); + //USB.println(F(" ppm")); + + // Print of the results + USB.print(F("VOC Sensor Voltage: ")); + USB.print(VOCVol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" VOC Sensor Resistance: ")); + USB.print(VOCRes); + USB.print(F(" Ohms |")); + + USB.print(F(" VOC concentration Estimated: ")); + USB.print(VOCPPM); + USB.println(F(" ppm")); + + // Print of the results + //USB.print(F("Solvent Vapors Sensor Voltage: ")); + //USB.print(SVVol); + //USB.print(F(" V |")); + + // Print of the results + //USB.print(F(" Solvent Vapors Sensor Resistance: ")); + //USB.print(SVRes); + //USB.print(F(" Ohms |")); + + // Print of the results + //USB.print(F(" Solvent Vapors concentration Estimated: ")); + //USB.print(SVPPM); + //USB.println(F(" PPM")); + + // Print of the results + USB.print(F("LPG Sensor Voltage: ")); + USB.print(LPGVol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" LPG Sensor Resistance: ")); + USB.print(LPGRes); + USB.print(F(" Ohms |")); + + USB.print(F(" LPG concentration Estimated: ")); + USB.print(LPGPPM); + USB.println(F(" ppm")); + + // Print of the results + USB.print(F("Air Pollutans Sensor Voltage: ")); + USB.print(APPVol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" Air Pollutans Sensor Resistance: ")); + USB.print(APPRes); + USB.print(F(" Ohms |")); + + USB.print(F(" Air Pollutans concentration Estimated: ")); + USB.print(APP_PPM); + USB.println(F(" ppm")); + + // 3. Create ASCII frame + /////////////////////////////////////////// + + // Create new frame (ASCII) + frame.createFrame(BINARY, node_ID); + // Add Oxygen voltage value + frame.addSensor(SENSOR_GASES_O2, O2Val); + // Add CO2 PPM value + //frame.addSensor(SENSOR_GASES_CO2, CO2PPM); + // Add NO2 PPM value + frame.addSensor(SENSOR_GASES_NO2, NO2PPM); + // Add VOC PPM value + frame.addSensor(SENSOR_GASES_VOC, VOCPPM); + // Add LPG PPM value + frame.addSensor(SENSOR_GASES_LPG, LPGPPM); + // Add CO PPM value + //frame.addSensor(SENSOR_GASES_CO, COPPM); + // Add SV PPM value + //frame.addSensor(SENSOR_GASES_SV, SVPPM); + // Add APP1 PPM value + frame.addSensor(SENSOR_GASES_AP1, APP_PPM); + // Add BAT level value + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + // Show the frame + frame.showFrame(); + + + // 3.2. Send Frame to Meshlium + /////////////////////////////// + + // http frame + error = WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); + + // check response + if (error == 0) + { + USB.println(F("HTTP OK")); + USB.print(F("HTTP Time from OFF state (ms):")); + USB.println(millis()-previous); + } + else + { + USB.println(F("Error calling 'getURL' function")); + WIFI_PRO.printErrorCode(); + } + } + else + { + USB.print(F("WiFi is connected ERROR")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + } + ////////////////////////////////////////////////// + // 3. Switch OFF + ////////////////////////////////////////////////// + WIFI_PRO.OFF(socket); + USB.println(F("WiFi switched OFF\n\n")); +// Go to deepsleep + // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm + USB.println(F("Go to deepsleep --- After 10 seconds, Waspmote wakes up thanks to the RTC Alarm")); + //PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); + // USB.ON(); + //USB.println(F("\nwake up")); + + // After wake up check interruption source + //if( intFlag & RTC_INT ) + // { + // clear interruption flag + // intFlag &= ~(RTC_INT); + + // USB.println(F("---------------------")); + //USB.println(F("RTC INT captured")); + //USB.println(F("---------------------")); + Utils.blinkLEDs(300); + Utils.blinkLEDs(300); + Utils.blinkLEDs(300); + // } + delay (900000); +} From e8af7b47dc9a457af1256dfc56713589e44de56e Mon Sep 17 00:00:00 2001 From: pasatsanduadrian Date: Mon, 6 Jul 2020 15:10:21 +0300 Subject: [PATCH 5/8] added the gist from my git account --- projects/IoTBoardCode/Waspmote/BEIA GAS 2 | 549 ---------------------- 1 file changed, 549 deletions(-) delete mode 100644 projects/IoTBoardCode/Waspmote/BEIA GAS 2 diff --git a/projects/IoTBoardCode/Waspmote/BEIA GAS 2 b/projects/IoTBoardCode/Waspmote/BEIA GAS 2 deleted file mode 100644 index ac247cb2..00000000 --- a/projects/IoTBoardCode/Waspmote/BEIA GAS 2 +++ /dev/null @@ -1,549 +0,0 @@ -/* - * ------------ [Ga_v30_01] - Temperature, Humidty and Pressure -------------- - * - * Explanation: This example read the temperature, humidity and - * pressure values from BME280 sensor - * - * Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L. - * http://www.libelium.com - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Version: 3.0 - * Design: David Gascón - * Implementation: Ahmad Saad -*/ - -// Library include -#include -#include -#include - -// choose socket (SELECT USER'S SOCKET) -/////////////////////////////////////// -uint8_t socket = SOCKET0; -/////////////////////////////////////// - - -// choose URL settings -/////////////////////////////////////// -char type[] = "http"; -char host[] = "82.78.81.171"; -char port[] = "80"; -/////////////////////////////////////// - -uint8_t error; -uint8_t status; -unsigned long previous; - - - -#define NUM_OF_POINTS 3 - -//********************************************************************************* -// O2 Sensor must be connected in SOCKET1 -//********************************************************************************* -O2SensorClass O2Sensor(SOCKET_1); - -// Percentage values of Oxygen -#define POINT1_PERCENTAGE 0.0 -#define POINT2_PERCENTAGE 5.0 -// Calibration Voltage Obtained during calibration process (in mV) -#define POINT1_VOLTAGE 0.35 -#define POINT2_VOLTAGE 2.0 - -float concentrations_o2[] = {POINT1_PERCENTAGE, POINT2_PERCENTAGE}; -float voltages_o2[] = {POINT1_VOLTAGE, POINT2_VOLTAGE}; - - -//********************************************************************************* -// CO2 Sensor must be connected physically in SOCKET2 -//********************************************************************************* -CO2SensorClass CO2Sensor(SOCKET_2); - -// Concentratios used in calibration process -#define POINT1_PPM_CO2 350.0 // PPM VALUE <-- Normal concentration in air -#define POINT2_PPM_CO2 1000.0 // PPM VALUE -#define POINT3_PPM_CO2 3000.0 // PPM VALUE - -// Calibration vVoltages obtained during calibration process -#define POINT1_VOLT_CO2 0.300 -#define POINT2_VOLT_CO2 0.350 -#define POINT3_VOLT_CO2 0.380 - -float concentrations_co2[] = {POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2}; -float voltages_co2[] = {POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2}; - - -//********************************************************************************* -// NO2 Sensor must be connected physically in SOCKET3 -//********************************************************************************* -NO2SensorClass NO2Sensor(SOCKET_3); - -// Concentratios used in calibration process -#define POINT1_PPM_NO2 10.0 // PPM VALUE <-- Normal concentration in air -#define POINT2_PPM_NO2 50.0 // PPM VALUE -#define POINT3_PPM_NO2 100.0 // PPM VALUE - -// Calibration voltages obtained during calibration process (in KOHMs) -#define POINT1_RES_NO2 45.25 // <-- Rs at normal concentration in air -#define POINT2_RES_NO2 25.50 -#define POINT3_RES_NO2 3.55 - -float concentrations_no2[] = {POINT1_PPM_NO2, POINT2_PPM_NO2, POINT3_PPM_NO2}; -float voltages_no2[] = {POINT1_RES_NO2, POINT2_RES_NO2, POINT3_RES_NO2}; - -//********************************************************************************* -// CO Sensor must be connected physically in SOCKET_4 -//********************************************************************************* -//COSensorClass COSensor(SOCKET_4); - -// Concentratios used in calibration process -//#define POINT1_PPM_CO 100.0 // <--- Ro value at this concentration -//#define POINT2_PPM_CO 300.0 // -//#define POINT3_PPM_CO 1000.0 // - -// Calibration resistances obtained during calibration process -//#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. -//#define POINT2_RES_CO 40.665 // -//#define POINT3_RES_CO 20.300 // - -//float concentrations_co[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO }; -//float resValues_co[] = { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO }; -//********************************************************************************* -// VOC Sensor must be connected physically in SOCKET5 -//********************************************************************************* -VOCSensorClass VOCSensor(SOCKET_5); - -// Concentratios used in calibration process (PPM VALUE) -#define POINT1_PPM_VOC 100.0 // <--- Ro value at this concentration -#define POINT2_PPM_VOC 300.0 -#define POINT3_PPM_VOC 1000.0 - -// Calibration resistances obtained during calibration process -#define POINT1_RES_VOC 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. -#define POINT2_RES_VOC 40.665 // -#define POINT3_RES_VOC 20.300 // - -float concentrations[] = { POINT1_PPM_VOC, POINT2_PPM_VOC, POINT3_PPM_VOC }; -float resValues[] = { POINT1_RES_VOC, POINT2_RES_VOC, POINT3_RES_VOC }; - - -//********************************************************************************* -// LPG Sensor can be connected in SOCKET6 AND SOCKET7 -//********************************************************************************* -LPGSensorClass LPGSensor(SOCKET_6); ; // <---- SOCKET7 Class used - -// Concentratios used in calibration process -#define POINT1_PPM_LPG 10.0 // PPM VALUE <-- Normal concentration in air -#define POINT2_PPM_LPG 50.0 // PPM VALUE -#define POINT3_PPM_LPG 100.0 // PPM VALUE - -// Calibration voltages obtained during calibration process (in KOHMs) -#define POINT1_RES_LPG 45.25 // <-- Rs at normal concentration in air -#define POINT2_RES_LPG 25.50 -#define POINT3_RES_LPG 3.55 - -float concentrations_lps[] = {POINT1_PPM_LPG, POINT2_PPM_LPG, POINT3_PPM_LPG}; -float voltages_lps[] = {POINT1_RES_LPG, POINT2_RES_LPG, POINT3_RES_LPG}; - -//********************************************************************************* -// Solvent Vapors Sensor / APP1 must be connected physically in SOCKET_6 or SOCKET_7 -//********************************************************************************* -APSensorClass APPSensor(SOCKET_7); // - - -//SVSensorClass SVSensor(SOCKET_7); - -// Concentratios used in calibration process -//#define POINT1_PPM_SV 10.0 // <-- Normal concentration in air -//#define POINT2_PPM_SV 50.0 -//#define POINT3_PPM_SV 100.0 - -// Calibration voltages obtained during calibration process (in KOHMs) -//#define POINT1_RES_SV 45.25 // <-- Rs at normal concentration in air -//#define POINT2_RES_SV 25.50 -//#define POINT3_RES_SV 3.55 - -//float concentrations_sv[] = { POINT1_PPM_SV, POINT2_PPM_SV, POINT3_PPM_SV }; -//float voltages_sv[] = { POINT1_RES_SV, POINT2_RES_SV, POINT3_RES_SV }; - -//********************************************************************************* -// BME280 Definitions -//********************************************************************************* -#include - -float temperature; // Stores the temperature in ºC -float humidity; // Stores the realitve humidity in %RH -float pressure; // Stores the pressure in Pa - -//********************************************************************************* - - -char node_ID[] = "BEIA_GAS2"; //ex GAS_WiFi - -void setup() -{ - // Configure the calibration values - O2Sensor.setCalibrationPoints(voltages_o2, concentrations_o2); - // Configure the calibration values - //CO2Sensor.setCalibrationPoints(voltages_co2, concentrations_co2, NUM_OF_POINTS); - // Configure the calibration values - NO2Sensor.setCalibrationPoints(voltages_no2, concentrations_no2, NUM_OF_POINTS); - // Configure the calibration values - VOCSensor.setCalibrationPoints(resValues, concentrations, NUM_OF_POINTS); - // Configure the calibration values - LPGSensor.setCalibrationPoints(voltages_lps, concentrations_lps, NUM_OF_POINTS); - // Calculate the slope and the intersection of the logarithmic function - //COSensor.setCalibrationPoints(resValues_co, concentrations_co, NUM_OF_POINTS); - // Calculate the slope and the intersection of the logarithmic function - //SVSensor.setCalibrationPoints(voltages_sv, concentrations_sv, NUM_OF_POINTS); - // Concentratios used in calibration process (in PPM) - APPSensor.concentrations[POINT_1] = 10.0; // <--- Ro value at this concentration - APPSensor.concentrations[POINT_2] = 50.0 ; - APPSensor.concentrations[POINT_3] = 100.0; - // Calibration resistances obtained during calibration process (in Kohms) - APPSensor.values[POINT_1] = 45.25; // <-- Ro Resistance at 100 ppm. Necessary value. - APPSensor.values[POINT_2] = 25.665; - APPSensor.values[POINT_3] = 2.300; - // Define the number of calibration points - APPSensor.numPoints = 3; - // Calculate the slope and the intersection of the logarithmic function - APPSensor.setCalibrationPoints(); - USB.ON(); - USB.println(F("Frame")); - - // Set the Waspmote ID - frame.setID(node_ID); - - /////////////////////////////////////////// - // 1. Turn on the board - /////////////////////////////////////////// - - //Power gases board and wait for stabilization and sensor response time - Gases.ON(); -} - -void loop() -{ - // get actual time - previous = millis(); - ////////////////////////////////////////////////// - // 1. Switch ON - ////////////////////////////////////////////////// - error = WIFI_PRO.ON(socket); - - if (error == 0) - { - USB.println(F("WiFi switched ON")); - } - else - { - USB.println(F("WiFi did not initialize correctly")); - } - ////////////////////////////////////////////////// - // 2. Join AP - ////////////////////////////////////////////////// - // check connectivity - status = WIFI_PRO.isConnected(); - - // check if module is connected - if (status == true) - { - USB.print(F("WiFi is connected OK")); - USB.print(F(" Time(ms):")); - USB.println(millis()-previous); - - ////////////////////////////////////////////////////////////////////// - // 2. Read Sensors - ////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////// - // 2.1 Read Temperature, Humidity and Pressure Sensor (BME280) - ////////////////////////////////////////////////////////////////////// - - // Read enviromental variables - temperature = Gases.getTemperature(); - humidity = Gases.getHumidity(); - pressure = Gases.getPressure(); - - ////////////////////////////////////////////////////////////////////// - // 2.2 Read O2 Sensor - Connected in SOCKET1 - ////////////////////////////////////////////////////////////////////// - O2Sensor.ON(); - delay(1000); - // O2 Sensor does not need power suplly - float O2Vol = O2Sensor.readVoltage(); - delay(100); - // Read the concentration value in % - float O2Val = O2Sensor.readConcentration(); - O2Sensor.OFF(); - - ////////////////////////////////////////////////////////////////////// - // 2.3 Read CO2 Sensor - Connected in SOCKET2 - ////////////////////////////////////////////////////////////////////// - //CO2Sensor.ON(); - //delay(1000); - // PPM value of CO2 - // Voltage value of the sensor - //float CO2Vol = CO2Sensor.readVoltage(); - // PPM value of CO2 - //float CO2PPM = CO2Sensor.readConcentration(); - //CO2Sensor.OFF(); - - ////////////////////////////////////////////////////////////////////// - // 2.4 Read NO2 Sensor - Connected in SOCKET3 - ////////////////////////////////////////////////////////////////////// - NO2Sensor.ON(); - delay(1000); - // PPM value of NO2 - float NO2Vol = NO2Sensor.readVoltage(); // Voltage value of the sensor - float NO2Res = NO2Sensor.readResistance(); // Resistance of the sensor - float NO2PPM = NO2Sensor.readConcentration(); // PPM value of NO2 - NO2Sensor.OFF(); - - ////////////////////////////////////////////////////////////////////// - // 2.4 Read VOC Sensor - Connected in SOCKET5 - ////////////////////////////////////////////////////////////////////// - VOCSensor.ON(); - delay(1000); - // PPM value of VOC - float VOCVol = VOCSensor.readVoltage(); // Voltage value of the sensor - float VOCRes = VOCSensor.readResistance(); // Resistance of the sensor - float VOCPPM = VOCSensor.readConcentration(); // PPM value of VOC - VOCSensor.OFF(); - - // 2.5 Read LPG Sensor - Connected in SOCKET7 - ////////////////////////////////////////////////////////////////////// - LPGSensor.ON(); - delay(1000); - // PPM value of CH4 - float LPGVol = LPGSensor.readVoltage(); // Voltage value of the sensor - float LPGRes = LPGSensor.readResistance(); // Resistance of the sensor - float LPGPPM = LPGSensor.readConcentration(); // PPM value of LPGfloat LPGPPM = LPGSensor.readConcentration(); - LPGSensor.OFF(); - - // 2.6 Read LPG Sensor - Connected in SOCKET6 - ////////////////////////////////////////////////////////////////////// - //COSensor.ON(); - // PPM value of CO - //delay(1000); - //float COVol = COSensor.readVoltage(); // Voltage value of the sensor - //float CORes = COSensor.readResistance(); // Resistance of the sensor - //float COPPM = COSensor.readConcentration(); // PPM value of CO - //COSensor.OFF(); - - // 2.7 Read SV Sensor - Connected in SOCKET7 - ////////////////////////////////////////////////////////////////////// - //SVSensor.ON(); - // PPM value of SV - //float SVVol = SVSensor.readVoltage(); // Voltage value of the sensor - //float SVRes = SVSensor.readResistance(); // Resistance of the sensor - //float SVPPM = SVSensor.readConcentration(); // PPM value of Solvent Vapor sensor - //SVSensor.OFF(); - - // 2.6 Read APP1 Sensor - Connected in SOCKET7 - APPSensor.ON(); - delay(1000); - // PPM value of APP1 - float APPVol = APPSensor.readVoltage(); // Voltage value of the sensor - float APPRes = APPSensor.readResistance(); // Resistance of the sensor - float APP_PPM = APPSensor.readConcentration(); // PPM value of AP1 - - - /////////////////print of results////////////////////////// - // O2 Sensor does not need power suplly - USB.print(F("O2 concentration Estimated: ")); - USB.print(O2Vol); - USB.print(F(" mV | ")); - - USB.print(F(" O2 concentration Estimated: ")); - USB.print(O2Val); - USB.println(F(" %")); - - // Print of the results - USB.print(F("NO2 Sensor Voltage: ")); - USB.print(NO2Vol); - USB.print(F(" V |")); - - // Print of the results - USB.print(F(" NO2 Sensor Resistance: ")); - USB.print(NO2Res); - USB.print(F(" Ohms |")); - - // Print of the results - USB.print(F(" NO2 concentration Estimated: ")); - USB.print(NO2PPM); - USB.println(F(" PPM")); - - - // Print of the results - // USB.print(F("CO Sensor Voltage: ")); - //USB.print(COVol); - //USB.print(F(" mV |")); - - // Print of the results - //USB.print(F(" CO Sensor Resistance: ")); - //USB.print(CORes); - //USB.print(F(" Ohms |")); - - //USB.print(F(" CO concentration Estimated: ")); - //USB.print(COPPM); - //USB.println(F(" ppm")); - - // Print of the results - //USB.print(F("CO2 Sensor Voltage: ")); - //USB.print(CO2Vol); - //USB.print(F("volts |")); - - //USB.print(F(" CO2 concentration estimated: ")); - //USB.print(CO2PPM); - //USB.println(F(" ppm")); - - // Print of the results - USB.print(F("VOC Sensor Voltage: ")); - USB.print(VOCVol); - USB.print(F(" V |")); - - // Print of the results - USB.print(F(" VOC Sensor Resistance: ")); - USB.print(VOCRes); - USB.print(F(" Ohms |")); - - USB.print(F(" VOC concentration Estimated: ")); - USB.print(VOCPPM); - USB.println(F(" ppm")); - - // Print of the results - //USB.print(F("Solvent Vapors Sensor Voltage: ")); - //USB.print(SVVol); - //USB.print(F(" V |")); - - // Print of the results - //USB.print(F(" Solvent Vapors Sensor Resistance: ")); - //USB.print(SVRes); - //USB.print(F(" Ohms |")); - - // Print of the results - //USB.print(F(" Solvent Vapors concentration Estimated: ")); - //USB.print(SVPPM); - //USB.println(F(" PPM")); - - // Print of the results - USB.print(F("LPG Sensor Voltage: ")); - USB.print(LPGVol); - USB.print(F(" V |")); - - // Print of the results - USB.print(F(" LPG Sensor Resistance: ")); - USB.print(LPGRes); - USB.print(F(" Ohms |")); - - USB.print(F(" LPG concentration Estimated: ")); - USB.print(LPGPPM); - USB.println(F(" ppm")); - - // Print of the results - USB.print(F("Air Pollutans Sensor Voltage: ")); - USB.print(APPVol); - USB.print(F(" V |")); - - // Print of the results - USB.print(F(" Air Pollutans Sensor Resistance: ")); - USB.print(APPRes); - USB.print(F(" Ohms |")); - - USB.print(F(" Air Pollutans concentration Estimated: ")); - USB.print(APP_PPM); - USB.println(F(" ppm")); - - // 3. Create ASCII frame - /////////////////////////////////////////// - - // Create new frame (ASCII) - frame.createFrame(BINARY, node_ID); - // Add Oxygen voltage value - frame.addSensor(SENSOR_GASES_O2, O2Val); - // Add CO2 PPM value - //frame.addSensor(SENSOR_GASES_CO2, CO2PPM); - // Add NO2 PPM value - frame.addSensor(SENSOR_GASES_NO2, NO2PPM); - // Add VOC PPM value - frame.addSensor(SENSOR_GASES_VOC, VOCPPM); - // Add LPG PPM value - frame.addSensor(SENSOR_GASES_LPG, LPGPPM); - // Add CO PPM value - //frame.addSensor(SENSOR_GASES_CO, COPPM); - // Add SV PPM value - //frame.addSensor(SENSOR_GASES_SV, SVPPM); - // Add APP1 PPM value - frame.addSensor(SENSOR_GASES_AP1, APP_PPM); - // Add BAT level value - frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); - // Show the frame - frame.showFrame(); - - - // 3.2. Send Frame to Meshlium - /////////////////////////////// - - // http frame - error = WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); - - // check response - if (error == 0) - { - USB.println(F("HTTP OK")); - USB.print(F("HTTP Time from OFF state (ms):")); - USB.println(millis()-previous); - } - else - { - USB.println(F("Error calling 'getURL' function")); - WIFI_PRO.printErrorCode(); - } - } - else - { - USB.print(F("WiFi is connected ERROR")); - USB.print(F(" Time(ms):")); - USB.println(millis()-previous); - } - ////////////////////////////////////////////////// - // 3. Switch OFF - ////////////////////////////////////////////////// - WIFI_PRO.OFF(socket); - USB.println(F("WiFi switched OFF\n\n")); -// Go to deepsleep - // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm - USB.println(F("Go to deepsleep --- After 10 seconds, Waspmote wakes up thanks to the RTC Alarm")); - //PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); - // USB.ON(); - //USB.println(F("\nwake up")); - - // After wake up check interruption source - //if( intFlag & RTC_INT ) - // { - // clear interruption flag - // intFlag &= ~(RTC_INT); - - // USB.println(F("---------------------")); - //USB.println(F("RTC INT captured")); - //USB.println(F("---------------------")); - Utils.blinkLEDs(300); - Utils.blinkLEDs(300); - Utils.blinkLEDs(300); - // } - delay (900000); -} From 0ff26a6c5ce806e771929656e89c950bea73eac5 Mon Sep 17 00:00:00 2001 From: pasatsanduadrian Date: Mon, 6 Jul 2020 15:58:14 +0300 Subject: [PATCH 6/8] am editat waspmotes codes --- .../IoTBoardCode/Waspmote/GAS_WiFi4/main.ino | 206 ---- .../Waspmote/RADIATION_Board/README.md | 3 - .../Waspmote/ALRO MySQL/Alro_Libelium.sql | 8 + .../Waspmote/Gases Board BEIA GAS1/BEIA_GAS1 | 608 ++++++++++ .../Waspmote/RPI model/Model RPI code | 28 + .../Waspmote/Radiation1/Radiation 1[WiFi] | 187 +++ .../Radiation2 XBEE/radiation board 2} | 396 +++--- .../Waspmote/SCP/GAS PRO - custom code | 287 +++++ .../Waspmote/SEP 3G Altfactor/gistfile1.txt | 310 +++++ .../Waspmote/Waspmote/SEP FARM/Custom SCP | 404 +++++++ .../Waspmote/SEP1 XBEE Altfactor/xBEE_SEP1 | 371 ++++++ .../Waspmote/Smart Water/Smart Water code | 314 +++++ .../Waspmote Gases Board/BEIA GAS 2} | 1060 +++++++++-------- .../Waspmote/Waspmote/Waspmote XBEE/XBEE01 | 200 ++++ 14 files changed, 3464 insertions(+), 918 deletions(-) delete mode 100644 projects/IoTBoardCode/Waspmote/GAS_WiFi4/main.ino delete mode 100644 projects/IoTBoardCode/Waspmote/RADIATION_Board/README.md create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/ALRO MySQL/Alro_Libelium.sql create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/Gases Board BEIA GAS1/BEIA_GAS1 create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/RPI model/Model RPI code create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation 1[WiFi] rename projects/IoTBoardCode/Waspmote/{RADIATION_Board/main.ino => Waspmote/Radiation2 XBEE/radiation board 2} (93%) create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/SCP/GAS PRO - custom code create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/SEP 3G Altfactor/gistfile1.txt create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/SEP FARM/Custom SCP create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/SEP1 XBEE Altfactor/xBEE_SEP1 create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/Smart Water/Smart Water code rename projects/IoTBoardCode/Waspmote/{GAS_WiFi4/GAS_WiFi => Waspmote/Waspmote Gases Board/BEIA GAS 2} (75%) create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/Waspmote XBEE/XBEE01 diff --git a/projects/IoTBoardCode/Waspmote/GAS_WiFi4/main.ino b/projects/IoTBoardCode/Waspmote/GAS_WiFi4/main.ino deleted file mode 100644 index 56abf542..00000000 --- a/projects/IoTBoardCode/Waspmote/GAS_WiFi4/main.ino +++ /dev/null @@ -1,206 +0,0 @@ -#include -#include -#include - -// choose socket (SELECT USER'S SOCKET) -/////////////////////////////////////// -uint8_t socket = SOCKET0; -/////////////////////////////////////// - -// choose URL settings -/////////////////////////////////////// -char type[] = "http"; -char host[] = "82.78.81.171"; -char port[] = "80"; -/////////////////////////////////////// -uint8_t error; -uint8_t status; -unsigned long previous; - -// CO Sensor must be connected physically in SOCKET_2 -CO2SensorClass CO2Sensor(SOCKET_2); - -// VOC Sensor must be connected in SOCKET_5 -VOCSensorClass VOCSensor(SOCKET_5); - -// Concentratios used in calibration process -#define POINT1_PPM_VOC 100.0 // <--- Ro value at this concentration -#define POINT2_PPM_VOC 300.0 -#define POINT3_PPM_VOC 1000.0 -// Calibration resistances obtained during calibration process -#define POINT1_RES_VOC 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. -#define POINT2_RES_VOC 40.665 // -#define POINT3_RES_VOC 20.300 // - -// Concentratios used in calibration process (PPM Values) -#define POINT1_PPM_CO2 350.0 // <-- Normal concentration in air -#define POINT2_PPM_CO2 1000.0 -#define POINT3_PPM_CO2 3000.0 - -// Calibration vVoltages obtained during calibration process (Volts) -#define POINT1_VOLT_CO2 0.300 -#define POINT2_VOLT_CO2 0.350 -#define POINT3_VOLT_CO2 0.380 - -// Define the number of calibration points -#define numPoints 3 - -float temperature; // Stores the temperature in ºC -float humidity; // Stores the realitve humidity in %RH -float pressure; // Stores the pressure in Pa - -float VOCconcentrations[] = {POINT1_PPM_VOC, POINT2_PPM_VOC, POINT3_PPM_VOC}; -float VOCresValues[] = {POINT1_RES_VOC, POINT2_RES_VOC, POINT3_RES_VOC}; - -float concentrations[] = {POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2}; -float voltages[] = {POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2}; - -// define the Waspmote ID -char node_ID[] = "GAS_WiFi4"; - -// 2. Read sensors -////////////////////////////////////////// -// Turn on the sensor board -void setup() { - USB.println(F("Start program")); - - CO2Sensor.setCalibrationPoints(voltages, concentrations, numPoints); - // Calculate the slope and the intersection of the logarithmic function - VOCSensor.setCalibrationPoints(VOCresValues, VOCconcentrations, numPoints); - - // turn on gas and sensors - Gases.ON(); - delay(100); - CO2Sensor.ON(); - VOCSensor.ON(); - // APPSensor.ON(); -} - -void loop() { - - // get actual time - previous = millis(); - - ////////////////////////////////////////////////// - // 1. Switch ON - ////////////////////////////////////////////////// - error = WIFI_PRO.ON(socket); - - if (error == 0) { - USB.println(F("WiFi switched ON")); - } else { - USB.println(F("WiFi did not initialize correctly")); - } - - ////////////////////////////////////////////////// - // 2. Join AP - ////////////////////////////////////////////////// - - // check connectivity - status = WIFI_PRO.isConnected(); - - // check if module is connected - if (status == true) { - USB.print(F("WiFi is connected OK")); - USB.print(F(" Time(ms):")); - USB.println(millis() - previous); - - // Read the concentration value - temperature = Gases.getTemperature(); - humidity = Gases.getHumidity(); - pressure = Gases.getPressure(); - - float CO2Vol = CO2Sensor.readVoltage(); - float CO2PPM = CO2Sensor.readConcentration(); - float vocVol = VOCSensor.readVoltage(); - float vocRes = VOCSensor.readResistance(vocVol); // Resistance of the senso - float vocPPM = VOCSensor.readConcentration(vocRes); // PPM value of VOC - - // Print of the results - USB.print(F(" Temperature: ")); - USB.print(temperature); - USB.println(F(" Celsius Degrees |")); - - USB.print(F(" Humidity : ")); - USB.print(humidity); - USB.println(F(" %RH")); - - USB.print(F(" Pressure : ")); - USB.print(pressure); - USB.println(F(" Pa")); - - USB.print(F("CO2 Sensor Voltage: ")); - USB.print(CO2Vol); - USB.print(F("volts |")); - - USB.print(F(" VOC Sensor Voltage: ")); - USB.print(vocVol); - USB.println(F(" V |")); - - USB.print(F(" VOC Sensor Resistance: ")); - USB.print(vocRes); - USB.println(F(" Ohms |")); - - USB.print(F(" CO2 concentration estimated: ")); - USB.print(CO2PPM); - USB.println(F(" ppm")); - - USB.print(F(" VOC concentration Estimated: ")); - USB.print(vocPPM); - USB.println(F(" ppm")); - - USB.println(); - - /////////////////////////////////////////// - // 3. Create BINARY frame - /////////////////////////////////////////// - frame.createFrame(BINARY, node_ID); - - frame.addSensor(SENSOR_GASES_TC, Gases.getTemperature()); - - frame.addSensor(SENSOR_GASES_HUM, Gases.getHumidity()); - - frame.addSensor(SENSOR_GASES_PRES, Gases.getPressure()); - - frame.addSensor(SENSOR_GASES_CO2, CO2PPM); - - frame.addSensor(SENSOR_GASES_VOC, VOCSensor.readConcentration(vocRes)); - - frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); - - /////////////////////////////// - // 3.1. Create a new Frame - /////////////////////////////// - // print frame - frame.showFrame(); - /////////////////////////////// - // 3.2. Send Frame to Meshlium - /////////////////////////////// - - // http frame - error = WIFI_PRO.sendFrameToMeshlium(type, host, port, frame.buffer, - frame.length); - - // check response - if (error == 0) { - USB.println(F("HTTP OK")); - - USB.print(F("HTTP Time from OFF state (ms):")); - USB.println(millis() - previous); - } else { - USB.println(F("Error calling 'getURL' function")); - WIFI_PRO.printErrorCode(); - } - } else { - USB.print(F("WiFi is connected ERROR")); - USB.print(F(" Time(ms):")); - USB.println(millis() - previous); - } - - ////////////////////////////////////////////////// - // 3. Switch OFF - ////////////////////////////////////////////////// - WIFI_PRO.OFF(socket); - USB.println(F("WiFi switched OFF\n\n")); - delay(900000); -} diff --git a/projects/IoTBoardCode/Waspmote/RADIATION_Board/README.md b/projects/IoTBoardCode/Waspmote/RADIATION_Board/README.md deleted file mode 100644 index 4c02a1a2..00000000 --- a/projects/IoTBoardCode/Waspmote/RADIATION_Board/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Arduino code for sending data from Waspmote + Radiation Board to Meshlium using XBee comunication. - -Libelium + XBee tutorial: diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/ALRO MySQL/Alro_Libelium.sql b/projects/IoTBoardCode/Waspmote/Waspmote/ALRO MySQL/Alro_Libelium.sql new file mode 100644 index 00000000..a7ec4acb --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/ALRO MySQL/Alro_Libelium.sql @@ -0,0 +1,8 @@ +# Date row +SELECT timestamp, id_wasp, sensor, value FROM sensorParser WHERE timestamp >= '2018-07-16' and (id_wasp in ("SCP1", "SCP2", "SCP4")) and (sensor in ("TC", "PRES", "HUM", "PM1", "PM10", "PM2_5")) + +# Medii orare +SELECT DATE(timestamp) as "ZI", HOUR(timestamp) as "ORA", id_wasp, sensor, count(*) as "Numar_valori", avg(value) as "Medie orara" FROM sensorParser WHERE timestamp >= '2018-07-16' and (id_wasp in ("SCP1", "SCP2", "SCP4")) and (sensor in ("TC", "PRES", "HUM", "PM1", "PM10", "PM2_5")) group by DATE(timestamp), HOUR(timestamp), id_wasp, sensor order by DATE(timestamp), id_wasp, sensor, HOUR(timestamp) + +# Medii zilnice +SELECT DATE(timestamp) as "ZI", id_wasp, sensor, count(*) as "Numar_valori", avg(value) as "Medie Zilnica" FROM sensorParser WHERE timestamp >= '2018-07-16' and (id_wasp in ("SCP1", "SCP2", "SCP4")) and (sensor in ("TC", "PRES", "HUM", "PM1", "PM10", "PM2_5")) group by DATE(timestamp), id_wasp, sensor order by DATE(timestamp), id_wasp, sensor diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Gases Board BEIA GAS1/BEIA_GAS1 b/projects/IoTBoardCode/Waspmote/Waspmote/Gases Board BEIA GAS1/BEIA_GAS1 new file mode 100644 index 00000000..179df631 --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/Gases Board BEIA GAS1/BEIA_GAS1 @@ -0,0 +1,608 @@ +/* + * ------------ [Ga_v30_01] - Temperature, Humidty and Pressure -------------- + * + * Explanation: This example read the temperature, humidity and + * pressure values from BME280 sensor + * + * Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L. + * http://www.libelium.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Version: 3.0 + * Design: David Gascón + * Implementation: Ahmad Saad +*/ + +// Library include +#include +#include +#include +#include "WaspFrameConstantsv15.h" + +// choose socket (SELECT USER'S SOCKET) +/////////////////////////////////////// +uint8_t socket = SOCKET0; +/////////////////////////////////////// + + +// choose URL settings +/////////////////////////////////////// +char type[] = "http"; +char host[] = "82.78.81.178"; +char port[] = "80"; +/////////////////////////////////////// + +uint8_t error; +uint8_t status; +unsigned long previous; + +float VOLT; +uint16_t CHRG; + +#define NUM_OF_POINTS 3 + +//********************************************************************************* +// O2 Sensor must be connected in SOCKET1 +//********************************************************************************* +O2SensorClass O2Sensor(SOCKET_1); + +// Percentage values of Oxygen +#define POINT1_PERCENTAGE 0.0 +#define POINT2_PERCENTAGE 5.0 +// Calibration Voltage Obtained during calibration process (in mV) +#define POINT1_VOLTAGE 0.35 +#define POINT2_VOLTAGE 2.0 + +float concentrations_o2[] = {POINT1_PERCENTAGE, POINT2_PERCENTAGE}; +float voltages_o2[] = {POINT1_VOLTAGE, POINT2_VOLTAGE}; + + +//********************************************************************************* +// CO2 Sensor must be connected physically in SOCKET2 +//********************************************************************************* +CO2SensorClass CO2Sensor(SOCKET_2); + +// Concentratios used in calibration process +#define POINT1_PPM_CO2 350.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_CO2 1000.0 // PPM VALUE +#define POINT3_PPM_CO2 3000.0 // PPM VALUE + +// Calibration vVoltages obtained during calibration process +#define POINT1_VOLT_CO2 0.300 +#define POINT2_VOLT_CO2 0.350 +#define POINT3_VOLT_CO2 0.380 + +float concentrations_co2[] = {POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2}; +float voltages_co2[] = {POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2}; + + +//********************************************************************************* +// NO2 Sensor must be connected physically in SOCKET3 +//********************************************************************************* +NO2SensorClass NO2Sensor(SOCKET_3); + +// Concentratios used in calibration process +#define POINT1_PPM_NO2 10.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_NO2 50.0 // PPM VALUE +#define POINT3_PPM_NO2 100.0 // PPM VALUE + +// Calibration voltages obtained during calibration process (in KOHMs) +#define POINT1_RES_NO2 45.25 // <-- Rs at normal concentration in air +#define POINT2_RES_NO2 25.50 +#define POINT3_RES_NO2 3.55 + +float concentrations_no2[] = {POINT1_PPM_NO2, POINT2_PPM_NO2, POINT3_PPM_NO2}; +float voltages_no2[] = {POINT1_RES_NO2, POINT2_RES_NO2, POINT3_RES_NO2}; + +//********************************************************************************* +// CO Sensor must be connected physically in SOCKET_4 +//********************************************************************************* +COSensorClass COSensor(SOCKET_4); + +// Concentratios used in calibration process +#define POINT1_PPM_CO 100.0 // <--- Ro value at this concentration +#define POINT2_PPM_CO 300.0 // +#define POINT3_PPM_CO 1000.0 // + +// Calibration resistances obtained during calibration process +#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. +#define POINT2_RES_CO 40.665 // +#define POINT3_RES_CO 20.300 // + +float concentrations_co[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO }; +float resValues_co[] = { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO }; +//********************************************************************************* +// VOC Sensor must be connected physically in SOCKET5 +//********************************************************************************* +VOCSensorClass VOCSensor(SOCKET_5); + +// Concentratios used in calibration process (PPM VALUE) +#define POINT1_PPM_VOC 100.0 // <--- Ro value at this concentration +#define POINT2_PPM_VOC 300.0 +#define POINT3_PPM_VOC 1000.0 + +// Calibration resistances obtained during calibration process +#define POINT1_RES_VOC 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. +#define POINT2_RES_VOC 40.665 // +#define POINT3_RES_VOC 20.300 // + +float concentrations[] = { POINT1_PPM_VOC, POINT2_PPM_VOC, POINT3_PPM_VOC }; +float resValues[] = { POINT1_RES_VOC, POINT2_RES_VOC, POINT3_RES_VOC }; + + +//********************************************************************************* +// LPG Sensor can be connected in SOCKET6 AND SOCKET7 +//********************************************************************************* +LPGSensorClass LPGSensor(SOCKET_6); ; // <---- SOCKET7 Class used + +// Concentratios used in calibration process +#define POINT1_PPM_LPG 10.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_LPG 50.0 // PPM VALUE +#define POINT3_PPM_LPG 100.0 // PPM VALUE + +// Calibration voltages obtained during calibration process (in KOHMs) +#define POINT1_RES_LPG 45.25 // <-- Rs at normal concentration in air +#define POINT2_RES_LPG 25.50 +#define POINT3_RES_LPG 3.55 + +float concentrations_lps[] = {POINT1_PPM_LPG, POINT2_PPM_LPG, POINT3_PPM_LPG}; +float voltages_lps[] = {POINT1_RES_LPG, POINT2_RES_LPG, POINT3_RES_LPG}; + +//********************************************************************************* +// Solvent Vapors Sensor / APP1 must be connected physically in SOCKET_6 or SOCKET_7 +//********************************************************************************* +//APSensorClass APPSensor(SOCKET_7); // + + +SVSensorClass SVSensor(SOCKET_7); + +// Concentratios used in calibration process +#define POINT1_PPM_SV 10.0 // <-- Normal concentration in air +#define POINT2_PPM_SV 50.0 +#define POINT3_PPM_SV 100.0 + +// Calibration voltages obtained during calibration process (in KOHMs) +#define POINT1_RES_SV 45.25 // <-- Rs at normal concentration in air +#define POINT2_RES_SV 25.50 +#define POINT3_RES_SV 3.55 + +float concentrations_sv[] = { POINT1_PPM_SV, POINT2_PPM_SV, POINT3_PPM_SV }; +float voltages_sv[] = { POINT1_RES_SV, POINT2_RES_SV, POINT3_RES_SV }; + +//********************************************************************************* +// BME280 Definitions +//********************************************************************************* +#include + +float temperature; // Stores the temperature in ºC +float humidity; // Stores the realitve humidity in %RH +float pressure; // Stores the pressure in Pa + +//********************************************************************************* + + +char node_ID[] = "BEIA_GAS1"; //ex GAS_WiFi + +void setup() +{ + // Configure the calibration values + O2Sensor.setCalibrationPoints(voltages_o2, concentrations_o2); + // Configure the calibration values + CO2Sensor.setCalibrationPoints(voltages_co2, concentrations_co2, NUM_OF_POINTS); + // Configure the calibration values + NO2Sensor.setCalibrationPoints(voltages_no2, concentrations_no2, NUM_OF_POINTS); + // Configure the calibration values + VOCSensor.setCalibrationPoints(resValues, concentrations, NUM_OF_POINTS); + // Configure the calibration values + LPGSensor.setCalibrationPoints(voltages_lps, concentrations_lps, NUM_OF_POINTS); + // Calculate the slope and the intersection of the logarithmic function + COSensor.setCalibrationPoints(resValues_co, concentrations_co, NUM_OF_POINTS); + // Calculate the slope and the intersection of the logarithmic function + SVSensor.setCalibrationPoints(voltages_sv, concentrations_sv, NUM_OF_POINTS); + // Concentratios used in calibration process (in PPM) + /*APPSensor.concentrations[POINT_1] = 10.0; // <--- Ro value at this concentration + APPSensor.concentrations[POINT_2] = 50.0 ; + APPSensor.concentrations[POINT_3] = 100.0; + // Calibration resistances obtained during calibration process (in Kohms) + APPSensor.values[POINT_1] = 45.25; // <-- Ro Resistance at 100 ppm. Necessary value. + APPSensor.values[POINT_2] = 25.665; + APPSensor.values[POINT_3] = 2.300; + // Define the number of calibration points + APPSensor.numPoints = 3; + // Calculate the slope and the intersection of the logarithmic function + APPSensor.setCalibrationPoints(); */ + USB.ON(); + USB.println(F("Frame Gases_Board")); + USB.println(F("Sensors used:")); + USB.println(F("- SOCKET_1: O2 sensor")); + USB.println(F("- SOCKET_2: CO2 sensor)")); + USB.println(F("- SOCKET_3: NO2 sensor")); + USB.println(F("- SOCKET_4: CO sensor")); + USB.println(F("- SOCKET_5: VOC sensor")); + USB.println(F("- SOCKET_6: LPG sensor")); + USB.println(F("- SOCKET_7: APP1 / SV [1] sensor")); + USB.println(F("- SOCKET_8: BME280 sensor (temperature, humidity & pressure")); + + // Set the Waspmote ID + frame.setID(node_ID); + + /////////////////////////////////////////// + // 1. Turn on the board + /////////////////////////////////////////// + + //Power gases board and wait for stabilization and sensor response time + Gases.ON(); +} + +void loop() +{ + // get actual time + previous = millis(); + ////////////////////////////////////////////////// + // 1. Switch ON + ////////////////////////////////////////////////// + error = WIFI_PRO.ON(socket); + + if (error == 0) + { + USB.println(F("WiFi switched ON")); + } + else + { + USB.println(F("WiFi did not initialize correctly")); + } + ////////////////////////////////////////////////// + // 2. Join AP + ////////////////////////////////////////////////// + // check connectivity + status = WIFI_PRO.isConnected(); + + // check if module is connected + if (status == true) + { + USB.print(F("WiFi is connected OK")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + + ////////////////////////////////////////////////////////////////////// + // 2. Read Sensors + ////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////// + // 2.1 Read Temperature, Humidity and Pressure Sensor (BME280) + ////////////////////////////////////////////////////////////////////// + + // Read enviromental variables + temperature = Gases.getTemperature(); + humidity = Gases.getHumidity(); + pressure = Gases.getPressure(); + + VOLT = PWR.getBatteryVolts(); + // CHRG = PWR.getBatteryCurrent(); + ////////////////////////////////////////////////////////////////////// + // 2.2 Read O2 Sensor - Connected in SOCKET1 + ////////////////////////////////////////////////////////////////////// + O2Sensor.ON(); + delay(1000); + // O2 Sensor does not need power suplly + float O2Vol = O2Sensor.readVoltage(); + delay(100); + // Read the concentration value in % + float O2Val = O2Sensor.readConcentration(); + O2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.3 Read CO2 Sensor - Connected in SOCKET2 + ////////////////////////////////////////////////////////////////////// + CO2Sensor.ON(); + delay(1000); + // PPM value of CO2 + // Voltage value of the sensor + float CO2Vol = CO2Sensor.readVoltage(); + // PPM value of CO2 + float CO2PPM = CO2Sensor.readConcentration(); + CO2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.4 Read NO2 Sensor - Connected in SOCKET3 + ////////////////////////////////////////////////////////////////////// + NO2Sensor.ON(); + delay(1000); + // PPM value of NO2 + float NO2Vol = NO2Sensor.readVoltage(); // Voltage value of the sensor + float NO2Res = NO2Sensor.readResistance(); // Resistance of the sensor + float NO2PPM = NO2Sensor.readConcentration(); // PPM value of NO2 + NO2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.4 Read VOC Sensor - Connected in SOCKET5 + ////////////////////////////////////////////////////////////////////// + VOCSensor.ON(); + delay(1000); + // PPM value of VOC + float VOCVol = VOCSensor.readVoltage(); // Voltage value of the sensor + float VOCRes = VOCSensor.readResistance(); // Resistance of the sensor + float VOCPPM = VOCSensor.readConcentration(); // PPM value of VOC + VOCSensor.OFF(); + + // 2.5 Read LPG Sensor - Connected in SOCKET7 + ////////////////////////////////////////////////////////////////////// + LPGSensor.ON(); + delay(1000); + // PPM value of CH4 + float LPGVol = LPGSensor.readVoltage(); // Voltage value of the sensor + float LPGRes = LPGSensor.readResistance(); // Resistance of the sensor + float LPGPPM = LPGSensor.readConcentration(); // PPM value of LPGfloat LPGPPM = LPGSensor.readConcentration(); + LPGSensor.OFF(); + + // 2.6 Read LPG Sensor - Connected in SOCKET6 + ////////////////////////////////////////////////////////////////////// + COSensor.ON(); + // PPM value of CO + delay(1000); + float COVol = COSensor.readVoltage(); // Voltage value of the sensor + float CORes = COSensor.readResistance(); // Resistance of the sensor + float COPPM = COSensor.readConcentration(); // PPM value of CO + COSensor.OFF(); + + // 2.7 Read SV Sensor - Connected in SOCKET7 + ////////////////////////////////////////////////////////////////////// + SVSensor.ON(); + // PPM value of SV + float SVVol = SVSensor.readVoltage(); // Voltage value of the sensor + float SVRes = SVSensor.readResistance(); // Resistance of the sensor + float SVPPM = SVSensor.readConcentration(); // PPM value of Solvent Vapor sensor + //SVSensor.OFF(); + + /* + // 2.6 Read APP1 Sensor - Connected in SOCKET7 + APPSensor.ON(); + delay(1000); + // PPM value of APP1 + float APPVol = APPSensor.readVoltage(); // Voltage value of the sensor + float APPRes = APPSensor.readResistance(); // Resistance of the sensor + float APP_PPM = APPSensor.readConcentration(); // PPM value of AP1 + */ + + // Print of the results + USB.print(F("Temperature: ")); + USB.print(temperature); + USB.println(F(" Celsius Degrees")); + + USB.print(F("Humidity : ")); + USB.print(humidity); + USB.println(F(" %RH")); + + USB.print(F("Pressure : ")); + USB.print(pressure); + USB.println(F(" Pa")); + /////////////////print of results////////////////////////// + // O2 Sensor does not need power suplly + USB.print(F("O2 concentration Estimated: ")); + USB.print(O2Vol); + USB.println(F(" mV")); + + USB.print(F("O2 concentration Estimated: ")); + USB.print(O2Val); + USB.println(F(" %")); + + // Print of the results + USB.print(F("NO2 Sensor Voltage: ")); + USB.print(NO2Vol); + USB.println(F(" V")); + + // Print of the results + USB.print(F("NO2 Sensor Resistance: ")); + USB.print(NO2Res); + USB.println(F(" Ohms")); + + // Print of the results + USB.print(F("NO2 concentration Estimated: ")); + USB.print(NO2PPM); + USB.println(F(" PPM")); + + + // Print of the results + USB.print(F("CO Sensor Voltage: ")); + USB.print(COVol); + USB.print(F(" mV")); + + // Print of the results + USB.print(F("CO Sensor Resistance: ")); + USB.print(CORes); + USB.print(F(" Ohms")); + + USB.print(F("CO concentration Estimated: ")); + USB.print(COPPM); + USB.println(F(" ppm")); + + // Print of the results + USB.print(F("CO2 Sensor Voltage: ")); + USB.print(CO2Vol); + USB.println(F("volts")); + + USB.print(F("CO2 concentration estimated: ")); + USB.print(CO2PPM); + USB.println(F(" ppm")); + + // Print of the results + USB.print(F("VOC Sensor Voltage: ")); + USB.print(VOCVol); + USB.println(F(" V")); + + // Print of the results + USB.print(F("VOC Sensor Resistance: ")); + USB.print(VOCRes); + USB.println(F(" Ohms")); + + USB.print(F("VOC concentration Estimated: ")); + USB.print(VOCPPM); + USB.println(F(" ppm")); + + // Print of the results + USB.print(F("Solvent Vapors Sensor Voltage: ")); + USB.print(SVVol); + USB.println(F(" V")); + + // Print of the results + USB.print(F("Solvent Vapors Sensor Resistance: ")); + USB.print(SVRes); + USB.println(F(" Ohms")); + + // Print of the results + USB.print(F("Solvent Vapors concentration Estimated: ")); + USB.print(SVPPM); + USB.println(F(" PPM")); + + // Print of the results + USB.print(F("LPG Sensor Voltage: ")); + USB.print(LPGVol); + USB.println(F(" V")); + + // Print of the results + USB.print(F("LPG Sensor Resistance: ")); + USB.print(LPGRes); + USB.println(F(" Ohms")); + + USB.print(F("LPG concentration Estimated: ")); + USB.print(LPGPPM); + USB.println(F(" ppm")); +/* + // Print of the results + USB.print(F("Air Pollutans Sensor Voltage: ")); + USB.print(APPVol); + USB.println(F(" V |")); + + // Print of the results + USB.print(F(" Air Pollutans Sensor Resistance: ")); + USB.print(APPRes); + USB.println(F(" Ohms |")); + + USB.print(F(" Air Pollutans concentration Estimated: ")); + USB.print(APP_PPM); + USB.println(F(" ppm")); + */ + + // Show the remaining battery level + USB.print(F("Battery Level: ")); + USB.print(PWR.getBatteryLevel(),DEC); + USB.println(F(" %")); + + // Show the battery Volts + USB.print(F("Battery (Volts): ")); + USB.print(PWR.getBatteryVolts()); + USB.println(F(" V")); + + // Show the battery charging current (only from solar panel) + //USB.print(F("Battery charging current (only from solar panel): ")); + //USB.print(CHRG, DEC); + // USB.println(F(" mA")); + + + // 3. Create ASCII frame + /////////////////////////////////////////// + + // Create new frame (ASCII) + frame.createFrame(BINARY, node_ID); + + //frame.addSensor(SENSOR_TIME, RTC.hour, RTC.minute, RTC.second); + + // Add Oxygen voltage value + frame.addSensor(SENSOR_GASES_O2, O2Val); + // Add CO2 PPM value + //frame.addSensor(SENSOR_GASES_CO2, CO2PPM); + // Add NO2 PPM value + frame.addSensor(SENSOR_GASES_NO2, NO2PPM); + // Add VOC PPM value + frame.addSensor(SENSOR_GASES_VOC, VOCPPM); + // Add LPG PPM value + frame.addSensor(SENSOR_GASES_LPG, LPGPPM); + // Add CO PPM value + frame.addSensor(SENSOR_GASES_CO, COPPM); + // Add SV PPM value + frame.addSensor(SENSOR_GASES_SV, SVPPM); + // Add APP1 PPM value + //frame.addSensor(SENSOR_GASES_AP1, APP_PPM); + // Add BAT level value + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + + + frame.addSensor(SENSOR_GASES_TC, Gases.getTemperature()); + frame.addSensor(SENSOR_GASES_HUM, Gases.getHumidity()); + frame.addSensor(SENSOR_GASES_PRES, Gases.getPressure()); + frame.showFrame(); + + // 3.2. Send Frame to Meshlium + /////////////////////////////// + + // http frame + error = WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); + + // check response + if (error == 0) + { + USB.println(F("HTTP OK")); + USB.print(F("HTTP Time from OFF state (ms):")); + USB.println(millis()-previous); + frame.createFrame(ASCII, node_ID); + frame.addSensor(SENSOR_BAT_VOLT, VOLT); + frame.addSensor(SENSOR_BAT_CURR, CHRG); + WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); + USB.println(F("ASCII FRAME SEND OK")); + } + else + { + USB.println(F("Error calling 'getURL' function")); + WIFI_PRO.printErrorCode(); + } + } + else + { + USB.print(F("WiFi is connected ERROR")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + } + ////////////////////////////////////////////////// + // 3. Switch OFF + ////////////////////////////////////////////////// + WIFI_PRO.OFF(socket); + USB.println(F("WiFi switched OFF\n\n")); + // Go to deepsleep + // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm + USB.println(F("enter deep sleep")); + // Go to sleep disconnecting all switches and modules + // After 10 seconds, Waspmote wakes up thanks to the RTC Alarm + USB.println(RTC.getTime()); + + PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE1,ALL_ON); + USB.ON(); + USB.println(RTC.getTime()); + USB.println(F("\nwake up")); + + // After wake up check interruption source + if( intFlag & RTC_INT ) + { + // clear interruption flag + intFlag &= ~(RTC_INT); + + USB.println(F("---------------------")); + USB.println(F("RTC INT captured")); + USB.println(F("---------------------")); + Utils.blinkLEDs(300); + Utils.blinkLEDs(300); + Utils.blinkLEDs(300); + } + //delay (60000); +} \ No newline at end of file diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/RPI model/Model RPI code b/projects/IoTBoardCode/Waspmote/Waspmote/RPI model/Model RPI code new file mode 100644 index 00000000..124b0aea --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/RPI model/Model RPI code @@ -0,0 +1,28 @@ +from sense_hat import SenseHat +import time +import json +import paho.mqtt.publish as publish +import math + +MQTT_HOST = 'vitalahtbroker.cloud.reply.eu' +MQTT_TOPIC = 'topic/temperature' + +sense = SenseHat() + +while True: + payload_dict = {"Site_ID": "Beia_01", + "Sensor_ID": "Temp_sensehat_01", + "Protoc_Type" : "MQTT", + "Sensor_Name": "Temperature_Sensor", + "Meas_Unit": "C", + "Latitude" : 44.395643, + "Longitude": 26.102910, + "Meas_Timestamp": int(round(time.time())), + "Meas_Value": sense.get_temperature()} + + try: + publish.single(MQTT_TOPIC, qos = 1, hostname = MQTT_HOST, payload = json.dumps(payload_dict), port=80) + except: + time.sleep(0.01) + + time.sleep(600) \ No newline at end of file diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation 1[WiFi] b/projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation 1[WiFi] new file mode 100644 index 00000000..9d7a52f7 --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation 1[WiFi] @@ -0,0 +1,187 @@ +#include +#include +#include + +// citeste accelerometru +// choose socket (SELECT USER'S SOCKET) +uint8_t socket = SOCKET0; +/////////////////////////////////////// +uint8_t status; +int x_acc; +int y_acc; +int z_acc; + + +// choose URL settings +/////////////////////////////////////// +char type[] = "http"; +char host[] = "82.78.81.171"; +char port[] = "80"; +/////////////////////////////////////// + +uint8_t error; +unsigned long previous; + + +char node_ID[] = "RADIATION1"; + +void setup() +{ + USB.println(F("Start program")); + USB.println(F("***************************************")); + USB.println(F("Once the module is set with one or more")); + USB.println(F("AP settings, it attempts to join the AP")); + USB.println(F("automatically once it is powered on")); + USB.println(F("Refer to example 'WIFI_PRO_01' to configure")); + USB.println(F("the WiFi module with proper settings")); + USB.println(F("***************************************")); + + ACC.ON(); + + + // open USB port + USB.ON(); + USB.println(F(" Radiation board sensor example")); + + frame.setID(node_ID); + +} + +void loop() + +{ + // get actual time + previous = millis(); + ////////////////////////////////////////////////// + // 1. Switch ON + ////////////////////////////////////////////////// + error = WIFI_PRO.ON(socket); + + if (error == 0) + { + USB.println(F("WiFi switched ON")); + } + else + { + USB.println(F("WiFi did not initialize correctly")); + } + ////////////////////////////////////////////////// + // 2. Join AP + ////////////////////////////////////////////////// + // check connectivity + status = WIFI_PRO.isConnected(); + + // check if module is connected + if (status == true) + { + USB.print(F("WiFi is connected OK")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + + /////////////////////////////////////////// + // 1. Create ASCII frame + /////////////////////////////////////////// + /////////////////////////////////////////// + //----------Check Register----------------------- + // should always answer 0x32, it is used to check + // the proper functionality of the accelerometer + status = ACC.check(); + + //----------X Value----------------------- + x_acc = ACC.getX(); + + //----------Y Value----------------------- + y_acc = ACC.getY(); + + //----------Z Value----------------------- + z_acc = ACC.getZ(); + + //------------------------------- + + USB.print(F("\n------------------------------\nCheck: 0x")); + USB.println(status, HEX); + USB.println(F("\n \t0X\t0Y\t0Z")); + USB.print(F(" ACC\t")); + USB.print(x_acc, DEC); + USB.print(F("\t")); + USB.print(y_acc, DEC); + USB.print(F("\t")); + USB.println(z_acc, DEC); + + delay(1000); + + // Turn on the board + /////////////////////////////////////////// + RadiationBoard.ON(); + delay(100); + + // create new frame + frame.createFrame(ASCII, node_ID); + + USB.println(F("Measuring radiation")); + float radiation = RadiationBoard.getRadiation(); + float radiationcpm = RadiationBoard.getCPM(5000); + + USB.print(F("radiation[uSv/h]: ")); + USB.println(radiation); + USB.println(); + + + USB.print(F("radiation[cpm]: ")); + USB.println(radiationcpm); + USB.println(); + + + // add frame fields + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + frame.addSensor(SENSOR_RADIATION, radiation); +// frame.addSensor(SENSOR_RADIATION, radiationcpm); + frame.addSensor(SENSOR_ACC, ACC.getX(), ACC.getY(), ACC.getZ()); + + // Power off the board + RadiationBoard.OFF(); + + /////////////////////////////////////////// + // 2. Send packet + /////////////////////////////////////////// + + // Show the frame + frame.showFrame(); + /////////////////////////////// + // 3.2. Send Frame to Meshlium + /////////////////////////////// + + // http frame + error = WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); + + // check response + if (error == 0) + { + USB.println(F("HTTP OK")); + USB.print(F("HTTP Time from OFF state (ms):")); + USB.println(millis()-previous); + } + else + { + USB.println(F("Error calling 'getURL' function")); + WIFI_PRO.printErrorCode(); + } + } + else + { + USB.print(F("WiFi is connected ERROR")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + } + + ////////////////////////////////////////////////// + // 3. Switch OFF + ////////////////////////////////////////////////// + WIFI_PRO.OFF(socket); + USB.println(F("WiFi switched OFF\n\n")); + USB.println(F("Go to deepsleep After 30 minutes, Waspmote wakes up thanks to the RTC Alarm")); + +// Go to deepsleep + // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm + PWR.deepSleep("00:00:00:60", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); +} diff --git a/projects/IoTBoardCode/Waspmote/RADIATION_Board/main.ino b/projects/IoTBoardCode/Waspmote/Waspmote/Radiation2 XBEE/radiation board 2 similarity index 93% rename from projects/IoTBoardCode/Waspmote/RADIATION_Board/main.ino rename to projects/IoTBoardCode/Waspmote/Waspmote/Radiation2 XBEE/radiation board 2 index 3b2bf275..c4270146 100644 --- a/projects/IoTBoardCode/Waspmote/RADIATION_Board/main.ino +++ b/projects/IoTBoardCode/Waspmote/Waspmote/Radiation2 XBEE/radiation board 2 @@ -1,198 +1,198 @@ -#include -#include -#include - - -// PAN (Personal Area Network) Identifier -uint8_t panID[2] = {0xbe,0x1a}; - -// Define Freq Channel to be set: -// Center Frequency = 2.405 + (CH - 11d) * 5 MHz -// Range: 0x0B - 0x1A (XBee) -// Range: 0x0C - 0x17 (XBee-PRO) -uint8_t channel = 0x17; - -// Define the Encryption mode: 1 (enabled) or 0 (disabled) -uint8_t encryptionMode = 0; - -// Define the AES 16-byte Encryption Key -char encryptionKey[] = "Beia123456789012"; - -// Destination MAC address -////////////////////////////////////////// -char RX_ADDRESS[] = "0013A20041678B8C"; -////////////////////////////////////////// - -// Define the Waspmote ID -char WASPMOTE_ID[] = "RADIATION_Board"; - - -// define variable -uint8_t error; - -// messure every 10 minutes -unsigned long delay_interval = 600000; - - -void setup() -{ - // open USB port - USB.ON(); - - USB.println(F("-------------------------------")); - USB.println(F("Configure XBee 802.15.4")); - USB.println(F("-------------------------------")); - - // init XBee - xbee802.ON(); - - delay(1000); - - - ///////////////////////////////////// - // 1. set channel - ///////////////////////////////////// - xbee802.setChannel( channel ); - - // check at commmand execution flag - if( xbee802.error_AT == 0 ) - { - USB.print(F("1. Channel set OK to: 0x")); - USB.printHex( xbee802.channel ); - USB.println(); - } - else - { - USB.println(F("1. Error calling 'setChannel()'")); - } - - - ///////////////////////////////////// - // 2. set PANID - ///////////////////////////////////// - xbee802.setPAN( panID ); - - // check the AT commmand execution flag - if( xbee802.error_AT == 0 ) - { - USB.print(F("2. PAN ID set OK to: 0x")); - USB.printHex( xbee802.PAN_ID[0] ); - USB.printHex( xbee802.PAN_ID[1] ); - USB.println(); - } - else - { - USB.println(F("2. Error calling 'setPAN()'")); - } - - ///////////////////////////////////// - // 3. set encryption mode (1:enable; 0:disable) - ///////////////////////////////////// - xbee802.setEncryptionMode( encryptionMode ); - - // check the AT commmand execution flag - if( xbee802.error_AT == 0 ) - { - USB.print(F("3. AES encryption configured (1:enabled; 0:disabled):")); - USB.println( xbee802.encryptMode, DEC ); - } - else - { - USB.println(F("3. Error calling 'setEncryptionMode()'")); - } - - ///////////////////////////////////// - // 4. set encryption key - ///////////////////////////////////// - xbee802.setLinkKey( encryptionKey ); - - // check the AT commmand execution flag - if( xbee802.error_AT == 0 ) - { - USB.println(F("4. AES encryption key set OK")); - } - else - { - USB.println(F("4. Error calling 'setLinkKey()'")); - } - - ///////////////////////////////////// - // 5. write values to XBee module memory - ///////////////////////////////////// - xbee802.writeValues(); - - // check the AT commmand execution flag - if( xbee802.error_AT == 0 ) - { - USB.println(F("5. Changes stored OK")); - } - else - { - USB.println(F("5. Error calling 'writeValues()'")); - } - - - USB.println(F("-------------------------------")); - - RadiationBoard.ON(); -} - - - -void loop() -{ - /////////////////////////////////////////// - // 1. Create ASCII frame - /////////////////////////////////////////// - - // create new frame - frame.createFrame(ASCII, WASPMOTE_ID); - - USB.println(F("Measuring radiation")); - float radiation = RadiationBoard.getRadiation(); - - USB.print(F("radiation[uSv/h]: ")); - USB.println(radiation); - USB.println(); - - - - // add frame fields - frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); - frame.addSensor(SENSOR_RADIATION, radiation); - - - /////////////////////////////////////////// - // 2. Send packet - /////////////////////////////////////////// - - USB.println(F("sending...")); - // send XBee packet - error = xbee802.send( RX_ADDRESS, frame.buffer, frame.length ); - - // check TX flag - if( error == 0 ) - { - USB.println(F("send ok")); - - // blink green LED - Utils.blinkGreenLED(); - - } - else - { - USB.println(F("send error")); - - // blink red LED - Utils.blinkRedLED(); - } - - USB.println(F("-------------------------------")); - USB.print(F("Going to sleep for ")); - USB.print(delay_interval / 1000); - USB.println(F(" secounds.")); - USB.println(F("-------------------------------")); - - // sleep - delay(delay_interval); -} +#include +#include +#include + + +// PAN (Personal Area Network) Identifier +uint8_t panID[2] = {0xbe,0x1a}; + +// Define Freq Channel to be set: +// Center Frequency = 2.405 + (CH - 11d) * 5 MHz +// Range: 0x0B - 0x1A (XBee) +// Range: 0x0C - 0x17 (XBee-PRO) +uint8_t channel = 0x16; + +// Define the Encryption mode: 1 (enabled) or 0 (disabled) +uint8_t encryptionMode = 0; + +// Define the AES 16-byte Encryption Key +char encryptionKey[] = "Beia123456789012"; + +// Destination MAC address +////////////////////////////////////////// +char RX_ADDRESS[] = "0013A20041678B8C"; +////////////////////////////////////////// + +// Define the Waspmote ID +char WASPMOTE_ID[] = "RADIATION_Board2"; + + +// define variable +uint8_t error; + +// messure every 10 minutes +unsigned long delay_interval = 6000; + + +void setup() +{ + // open USB port + USB.ON(); + + USB.println(F("-------------------------------")); + USB.println(F("Configure XBee 802.15.4")); + USB.println(F("-------------------------------")); + + // init XBee + xbee802.ON(); + + delay(1000); + + + ///////////////////////////////////// + // 1. set channel + ///////////////////////////////////// + xbee802.setChannel( channel ); + + // check at commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.print(F("1. Channel set OK to: 0x")); + USB.printHex( xbee802.channel ); + USB.println(); + } + else + { + USB.println(F("1. Error calling 'setChannel()'")); + } + + + ///////////////////////////////////// + // 2. set PANID + ///////////////////////////////////// + xbee802.setPAN( panID ); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.print(F("2. PAN ID set OK to: 0x")); + USB.printHex( xbee802.PAN_ID[0] ); + USB.printHex( xbee802.PAN_ID[1] ); + USB.println(); + } + else + { + USB.println(F("2. Error calling 'setPAN()'")); + } + + ///////////////////////////////////// + // 3. set encryption mode (1:enable; 0:disable) + ///////////////////////////////////// + xbee802.setEncryptionMode( encryptionMode ); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.print(F("3. AES encryption configured (1:enabled; 0:disabled):")); + USB.println( xbee802.encryptMode, DEC ); + } + else + { + USB.println(F("3. Error calling 'setEncryptionMode()'")); + } + + ///////////////////////////////////// + // 4. set encryption key + ///////////////////////////////////// + xbee802.setLinkKey( encryptionKey ); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.println(F("4. AES encryption key set OK")); + } + else + { + USB.println(F("4. Error calling 'setLinkKey()'")); + } + + ///////////////////////////////////// + // 5. write values to XBee module memory + ///////////////////////////////////// + xbee802.writeValues(); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.println(F("5. Changes stored OK")); + } + else + { + USB.println(F("5. Error calling 'writeValues()'")); + } + + + USB.println(F("-------------------------------")); + + RadiationBoard.ON(); +} + + + +void loop() +{ + /////////////////////////////////////////// + // 1. Create ASCII frame + /////////////////////////////////////////// + + // create new frame + frame.createFrame(ASCII, WASPMOTE_ID); + + USB.println(F("Measuring radiation")); + float radiation = RadiationBoard.getRadiation(); + + USB.print(F("radiation[uSv/h]: ")); + USB.println(radiation); + USB.println(); + + + + // add frame fields + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + frame.addSensor(SENSOR_RADIATION, radiation); + + + /////////////////////////////////////////// + // 2. Send packet + /////////////////////////////////////////// + + USB.println(F("sending...")); + // send XBee packet + error = xbee802.send( RX_ADDRESS, frame.buffer, frame.length ); + + // check TX flag + if( error == 0 ) + { + USB.println(F("send ok")); + + // blink green LED + Utils.blinkGreenLED(); + + } + else + { + USB.println(F("send error")); + + // blink red LED + Utils.blinkRedLED(); + } + + USB.println(F("-------------------------------")); + USB.print(F("Going to sleep for ")); + USB.print(delay_interval / 1000); + USB.println(F(" secounds.")); + USB.println(F("-------------------------------")); + + // sleep + delay(delay_interval); +} \ No newline at end of file diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/SCP/GAS PRO - custom code b/projects/IoTBoardCode/Waspmote/Waspmote/SCP/GAS PRO - custom code new file mode 100644 index 00000000..35eaded3 --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/SCP/GAS PRO - custom code @@ -0,0 +1,287 @@ +/* + * ------------ [GP_v30_08] - Frame Class Utility -------------- + * + * Explanation: This is the basic code to create a frame with some + * Gases Pro Sensor Board sensors + * + * Copyright (C) 2019 Libelium Comunicaciones Distribuidas S.L. + * http://www.libelium.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Version: 3.2 + * Design: David Gascón + * Implementation: Alejandro Gállego + */ + +#include +#include +//#include +#include +#include "WaspFrameConstantsv15.h" + + +// choose socket (SELECT USER'S SOCKET) +/////////////////////////////////////// +uint8_t socket = SOCKET0; +/////////////////////////////////////// + + +// choose URL settings +/////////////////////////////////////// +char type[] = "http"; +char host[] = "82.78.81.171"; +char port[] = "80"; +/////////////////////////////////////// + +uint8_t error; +uint8_t status; +unsigned long previous; + +float VOLT; +uint16_t CHRG; + + +Gas O3(SOCKET_4); +Gas SO2(SOCKET_6); +Gas NO2(SOCKET_2); + + +float temperature; +float humidity; +float pressure; + +float concO3; +float concSO2; +float concNO2; + + +char node_ID[] = "TELMONAER2"; + + +void setup() +{ + USB.ON(); + USB.println(F("Frame Utility Example for Gases Pro Sensor Board")); + + // Set the Waspmote ID + frame.setID(node_ID); + USB.println(F("Frame Gases_Pro_Board")); + USB.println(F("Sensors used:")); + USB.println(F("- SOCKET_1: sensor")); + USB.println(F("- SOCKET_2: NO2 sensor)")); + USB.println(F("- SOCKET_3: sensor")); + USB.println(F("- SOCKET_4: O3 sensor")); + USB.println(F("- SOCKET_5: sensor")); + USB.println(F("- SOCKET_6: SO2 sensor")); + USB.println(F("- SOCKET_7: sensor")); + USB.println(F("- SOCKET_8: BME280 sensor (temperature, humidity & pressure")); +} + +void loop() +{ + // get actual time + previous = millis(); + ////////////////////////////////////////////////// + // 1. Switch ON + ////////////////////////////////////////////////// + error = WIFI_PRO.ON(socket); + + if (error == 0) + { + USB.println(F("WiFi switched ON")); + } + else + { + USB.println(F("WiFi did not initialize correctly")); + } + ////////////////////////////////////////////////// + // 2. Join AP + ////////////////////////////////////////////////// + // check connectivity + status = WIFI_PRO.isConnected(); + + // check if module is connected + if (status == true) + { + USB.print(F("WiFi is connected OK")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + + /////////////////////////////////////////// + // 1. Turn on sensors and wait + /////////////////////////////////////////// + + //Power on gas sensors + O3.ON(); + SO2.ON(); + NO2.ON(); + + // Sensors need time to warm up and get a response from gas + // To reduce the battery consumption, use deepSleep instead delay + // After 2 minutes, Waspmote wakes up thanks to the RTC Alarm + PWR.deepSleep("00:00:02:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON); + + + /////////////////////////////////////////// + // 2. Read sensors + /////////////////////////////////////////// + + // Read the sensors and compensate with the temperature internally + concO3 = O3.getConc(); + concSO2 = SO2.getConc(); + concNO2 = NO2.getConc(); + + // Read enviromental variables + temperature = NO2.getTemp(); + humidity = NO2.getHumidity(); + pressure = NO2.getPressure(); + + VOLT = PWR.getBatteryVolts(); + + /////////////////////////////////////////// + // 3. Turn off the sensors + /////////////////////////////////////////// + + //Power off sensors + O3.OFF(); + SO2.OFF(); + NO2.OFF(); + + // Print of the results + USB.print(F("Temperature: ")); + USB.print(temperature); + USB.println(F(" Celsius Degrees")); + + USB.print(F("Humidity : ")); + USB.print(humidity); + USB.println(F(" %RH")); + + USB.print(F("Pressure : ")); + USB.print(pressure); + USB.println(F(" Pa")); + + // Print of the results + USB.print(F("NO2 concentration : ")); + USB.print(concNO2); + USB.println(F(" PPM")); + + // Print of the results + USB.print(F("SO2 concentration : ")); + USB.print(concSO2); + USB.println(F(" PPM")); + + // Print of the results + USB.print(F("O3 concentration : ")); + USB.print(concO3); + USB.println(F(" PPM")); + + // Show the remaining battery level + USB.print(F("Battery Level: ")); + USB.print(PWR.getBatteryLevel(),DEC); + USB.println(F(" %")); + + // Show the battery Volts + USB.print(F("Battery (Volts): ")); + USB.print(PWR.getBatteryVolts()); + USB.println(F(" V")); + + /////////////////////////////////////////// + // 5. Create ASCII frame + /////////////////////////////////////////// + + // Create new frame (ASCII) + frame.createFrame(BINARY); + + // Add temperature + frame.addSensor(SENSOR_GASES_PRO_TC, temperature); + // Add humidity + frame.addSensor(SENSOR_GASES_PRO_HUM, humidity); + // Add pressure value + frame.addSensor(SENSOR_GASES_PRO_PRES, pressure); + // Add O3 value + frame.addSensor(SENSOR_GASES_PRO_O3, concO3); + // Add NO value + frame.addSensor(SENSOR_GASES_PRO_SO2, concSO2); + // Add NO2 value + frame.addSensor(SENSOR_GASES_PRO_NO2, concNO2); + + // Show the frame + frame.showFrame(); + + + // 3.2. Send Frame to Meshlium + /////////////////////////////// + + // http frame + error = WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); + + // check response + if (error == 0) + { + USB.println(F("HTTP OK")); + USB.print(F("HTTP Time from OFF state (ms):")); + USB.println(millis()-previous); + + frame.createFrame(ASCII, node_ID); + frame.addSensor(SENSOR_BAT_VOLT, VOLT); + frame.addSensor(SENSOR_BAT_CURR, CHRG); + WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); + USB.println(F("ASCII FRAME SEND OK")); + + } + else + { + USB.println(F("Error calling 'getURL' function")); + WIFI_PRO.printErrorCode(); + } + } + else + { + USB.print(F("WiFi is connected ERROR")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + } + ////////////////////////////////////////////////// + // 3. Switch OFF + ////////////////////////////////////////////////// + WIFI_PRO.OFF(socket); + USB.println(F("WiFi switched OFF\n\n")); + // Go to deepsleep + // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm + USB.println(F("enter deep sleep")); + // Go to sleep disconnecting all switches and modules + // After 10 seconds, Waspmote wakes up thanks to the RTC Alarm + USB.println(RTC.getTime()); + + PWR.deepSleep("00:00:18:10",RTC_OFFSET,RTC_ALM1_MODE1,ALL_ON); + USB.ON(); + USB.println(RTC.getTime()); + USB.println(F("\nwake up")); + + // After wake up check interruption source + if( intFlag & RTC_INT ) + { + // clear interruption flag + intFlag &= ~(RTC_INT); + + USB.println(F("---------------------")); + USB.println(F("RTC INT captured")); + USB.println(F("---------------------")); + Utils.blinkLEDs(300); + Utils.blinkLEDs(300); + Utils.blinkLEDs(300); + } + //delay (60000); +} \ No newline at end of file diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/SEP 3G Altfactor/gistfile1.txt b/projects/IoTBoardCode/Waspmote/Waspmote/SEP 3G Altfactor/gistfile1.txt new file mode 100644 index 00000000..2e368941 --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/SEP 3G Altfactor/gistfile1.txt @@ -0,0 +1,310 @@ +/* + * --------------- 3G_15b - Sending a frame to Meshlium --------------- + * + * Explanation: This example shows how to send frame to Meshlium + * + * Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L. + * http://www.libelium.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Version: 1.4 + * Design: David Gascón + * Implementation: Alejandro Gállego + */ + +#include +#include "Wasp3G.h" +#include + + +char url[] = "82.78.81.171"; +int port = 80; + +char apn[] = "live.vodafone.com"; +char login[] = "live"; +char password[] = "vodafone"; + +int8_t answer; +char moteID[] = "SEP2"; + +char GPS_data[250]; +int GPS_status = 0; +int GPS_fix = 0; +int GPRS_status = 0; + +//Gas CO2(SOCKET_B); +Gas H2(SOCKET_3); +Gas CO(SOCKET_4); +//Gas O2(SOCKET_4); +//Gas NO(SOCKET_5); +Gas NO2(SOCKET_6); + +float temperature; +float humidity; +float pressure; +//float concCO2; +float concCO; +float concH2; +//float concO2; +//float concNO; +float concNO2; + +void setup() +{ + USB.println(F("USB port started...")); + + USB.println(F("---******************************************************************************---")); + USB.println(F("GET method to the libelium's test url with frame...")); + USB.println(F("You can use this php to test the HTTP connection of the module.")); + USB.println(F("The php returns the parameters that the user sends with the URL.")); + USB.println(F("In this case the RTC time and the battery level.")); + USB.println(F("---******************************************************************************---")); + + // 1. sets operator parameters + _3G.set_APN(apn, login, password); + // And shows them + _3G.show_APN(); + USB.println(F("---******************************************************************************---")); + // Set the Waspmote ID + frame.setID(moteID); + // 2. activates the 3G+GPS module: + answer = _3G.ON(); + if ((answer == 1) || (answer == -3)) + { + + USB.println(F("3G+GPS module ready...")); + + // 3. starts the GPS: + USB.println(F("Starting in stand-alone mode")); + GPS_status = _3G.startGPS(); + if (GPS_status == 1) + { + USB.println(F("GPS started")); + } + else + { + USB.println(F("GPS NOT started")); + } + + } + else + { + // Problem with the communication with the 3G+GPS module + USB.println(F("3G+GPS module not started")); + } + +} + +void loop() +{ + + // 2. activates the 3G module: + answer = _3G.ON(); + if ((answer == 1) || (answer == -3)) + { + USB.println(F("3G + GPS module ready...")); +/* + // 3. set pin code: + USB.println(F("Setting PIN code...")); + // **** must be substituted by the SIM code + if (_3G.setPIN("****") == 1) + { + USB.println(F("PIN code accepted")); + } + else + { + USB.println(F("PIN code incorrect")); + } +*/ + // 4. wait for connection to the network: + answer = _3G.check(180); + if (answer == 1) + { + USB.println(F("3G module connected to the network...")); + USB.println(F("Power on sensors...")); + // CO2.ON(); + CO.ON(); + H2.ON(); + // O2.ON(); + // NO.ON(); + NO2.ON(); + // Sensors need time to warm up and get a response from gas + // To reduce the battery consumption, use deepSleep instead delay + // After 2 minutes, Waspmote wakes up thanks to the RTC Alarm + USB.println(F("Deep sleep 2 minutes to heat time sensors ...")); + + // PWR.deepSleep("00:00:02:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON); + USB.println(F("Power on, reading sensors ...")); + + // Read the CO sensor and compensate with the temperature internally + concCO = CO.getConc(); + // Read the O3 sensor and compensate with the temperature internally + concH2 = H2.getConc(); + // Read the O2 sensor and compensate with the temperature internally + // concO2 = O2.getConc(); + // Read the NO sensor and compensate with the temperature internally + // concNO = NO.getConc(); + // Read the NO2 sensor and compensate with the temperature internally + concNO2 = NO2.getConc(); + + // Read enviromental variables + temperature = CO.getTemp(); + humidity = CO.getHumidity(); + pressure = CO.getPressure(); + + //Power off sensors + //CO2.OFF(); + CO.OFF(); + H2.OFF(); + //O2.OFF(); + // NO.OFF(); + NO2.OFF(); + + memset(GPS_data, '\0', sizeof(GPS_data)); + // 5. checks the status of the GPS + if ((GPS_status == 1) && (_3G.getGPSinfo() == 1)) + { + GPS_fix = 1; + Utils.setLED(LED0, LED_ON); + // when it's available, shows it + USB.print(F("Latitude (degrees):")); + USB.println(_3G.convert2Degrees(_3G.latitude)); + USB.print(F("Longitude (degrees):")); + USB.println(_3G.convert2Degrees(_3G.longitude)); + USB.print(F("Speed over the ground")); + USB.println(_3G.speedOG); + USB.print(F("Course over the ground:")); + USB.println(_3G.course); + USB.print(F("altitude (m):")); + USB.println(_3G.altitude); + + /* // 6a. add GPS data + // add GPS position field + snprintf(GPS_data, sizeof(GPS_data), "GET /demo_sim908.php?%svisor=false&latitude=%s&longitude=%s&altitude=%s&time=20%c%c%c%c%c%c%s&satellites=7&speedOTG=%s&course=%s HTTP/1.1\r\nHost: %s\r\nContent-Length: 0\r\n\r\n", + url, + _3G.latitude, + _3G.longitude, + _3G.altitude, + _3G.date[4], _3G.date[5], _3G.date[2], _3G.date[3], _3G.date[0], _3G.date[1], _3G.UTC_time, + _3G.speedOG, + _3G.course, + url); + + USB.print(F("Data string: ")); + */ + USB.println(GPS_data); + } + else if((GPS_status == 1) && (_3G.getGPSinfo() != 1)) + { + GPS_fix = 0; + Utils.setLED(LED0, LED_OFF); + // 6c. add not GPS fixed string + USB.println(F("GPS not fixed")); + } + else + { + GPS_fix = 0; + Utils.setLED(LED0, LED_OFF); + // 6d. add not GPS started string + USB.println(F("GPS not started. Restarting")); + GPS_status = _3G.startGPS(); + } + + // switch on RTC + RTC.ON(); + // Create new frame (ASCII) + frame.createFrame(BINARY); + // set frame fields (Time from RTC) + frame.addSensor(SENSOR_TIME, RTC.getTime()); + // set frame fields (Battery sensor - uint8_t) + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + // Add temperature + frame.addSensor(SENSOR_GP_TC, temperature); + // Add humidity + frame.addSensor(SENSOR_GP_HUM, humidity); + // Add pressure value + frame.addSensor(SENSOR_GP_PRES, pressure); + // Add CO2 value + //frame.addSensor(SENSOR_GP_CO2, concCO2); + // Add CO value + frame.addSensor(SENSOR_GP_CO, concCO); + // Add O3 value + frame.addSensor(SENSOR_GP_H2, concH2); + // Add O2 value + // frame.addSensor(SENSOR_GP_O2, concO2); + // Add NO value + // frame.addSensor(SENSOR_GP_NO, concNO); + // Add NO2 value + frame.addSensor(SENSOR_GP_NO2, concNO2); + + // 7a. add GPS data + // add GPS position field + frame.addSensor(SENSOR_GPS, _3G.convert2Degrees(_3G.latitude), _3G.convert2Degrees(_3G.longitude)); + // add GPS speed over the ground field + frame.addSensor(SENSOR_SPEED, _3G.speedOG); + // add GPS course over the ground field + frame.addSensor(SENSOR_COURSE, _3G.course); + // add GPS altitude field + frame.addSensor(SENSOR_ALTITUDE, _3G.altitude); + + // show Frame + frame.showFrame(); + // switch off RTC + RTC.OFF(); + + // 5. Sends the frame to Meshlium with GET + USB.print(F("Sending the frame to Meshlium with GET method...")); + + answer = _3G.sendHTTPframe( url, port, frame.buffer, frame.length, GET); + + // Checks the answer + if ( answer == 1) + { + USB.println(F("Done")); + USB.println(_3G.buffer_3G); + } + else if (answer < -14) + { + USB.print(F("Failed. Error code: ")); + USB.println(answer, DEC); + USB.print(F("CME error code: ")); + USB.println(_3G.CME_CMS_code, DEC); + } + else + { + USB.print(F("Failed. Error code: ")); + USB.println(answer, DEC); + } + } + else + { + USB.println(F("3G module cannot connect to the network...")); + } + } + else + { + // Problem with the communication with the 3G module + USB.println(F("3G module not started")); + } + + // 7. powers off the 3G module + _3G.OFF(); + + USB.println(F("Sleeping...")); + + // 8. sleeps one hour + PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); + +} \ No newline at end of file diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/SEP FARM/Custom SCP b/projects/IoTBoardCode/Waspmote/Waspmote/SEP FARM/Custom SCP new file mode 100644 index 00000000..849afb58 --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/SEP FARM/Custom SCP @@ -0,0 +1,404 @@ +/* + ------------ [SCP_v30_09] - Frame Class Utility -------------- + + Explanation: This is the basic code to create a frame with some + Smart Cities Pro Sensor Board sensors + + Copyright (C) 2018 Libelium Comunicaciones Distribuidas S.L. + http://www.libelium.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Version: 3.3 + Design: David Gascón + Implementation: Alejandro Gállego +*/ +#include +#include +#include +#include +#include "WaspFrameConstantsv15.h" + + +// APN settings +/////////////////////////////////////// +char apn[] = ""; +char login[] = ""; +char password[] = ""; +/////////////////////////////////////// + +// SERVER settings +/////////////////////////////////////// +char host[] = "82.78.81.178"; +uint16_t port = 80; +/////////////////////////////////////// + +// define the Waspmote ID +int error; + +/* + Define objects for sensors + Imagine we have a P&S! with the next sensors: + - SOCKET_A: BME280 sensor (temperature, humidity & pressure) + - SOCKET_B: Electrochemical gas sensor (O3) + - SOCKET_C: Electrochemical gas sensor (NO2) + - SOCKET_D: Particle matter sensor (dust) + - SOCKET_E: Luxes sensor + - SOCKET_F: Pellistor sensor (CO2) +*/ +bmeCitiesSensor bme(SOCKET_E); +//luxesCitiesSensor luxes(SOCKET_A); +ultrasoundCitiesSensor ultrasound(SOCKET_A); +Gas sensor_ch4(SOCKET_B); +Gas sensor_h2s(SOCKET_C); +Gas sensor_nh3(SOCKET_F); + + +// define vars for sensor values +float temperature; +float humidity; +float pressure; +//uint32_t luminosity; +uint16_t range; + + +float concentration_ch4; +float concentration_h2s; +float concentration_nh3; +//int OPC_status; +//int OPC_measure; + +float VOLT; +uint16_t CHRG; +char moteID[] = "FARM"; +uint8_t connection_status; +void setup() +{ + USB.ON(); + USB.println(F("Frame Utility Example for Cities Pro Board")); + USB.println(F("Sensors used:")); + USB.println(F("- SOCKET_A: Ultrasound sensor")); + USB.println(F("- SOCKET_E: BME280 sensor (temperature, humidity & pressure)")); + USB.println(F("- SOCKET_B: Electrochemical gas sensor (CH4)")); + USB.println(F("- SOCKET_C: Electrochemical gas sensor (H2S)")); + // USB.println(F("- SOCKET_D: Particle matter sensor (dust)")); + // USB.println(F("- SOCKET_E: Luxes sensor")); + USB.println(F("- SOCKET_F: Electrochemical sensor (NH3)")); + + // Set the Waspmote ID + frame.setID(moteID); + + ////////////////////////////////////////////////// + // 1. sets operator parameters + ////////////////////////////////////////////////// + _4G.set_APN(apn, login, password); + + ////////////////////////////////////////////////// + // 2. Show APN settings via USB port + ////////////////////////////////////////////////// + _4G.show_APN(); + + + /////////////////////////////////////////// + // 1. Turn ON the Smart Water sensor board + /////////////////////////////////////////// +} + + +void loop() +{ + + //////////////////////////////////////////////// + // 2. Create new frame + //////////////////////////////////////////////// + + RTC.ON(); + RTC.getTime(); + + /////////////////////////////////////////// + // 1. Read BME and luxes sensors + /////////////////////////////////////////// + + // switch off all gas sensors for better performance + sensor_ch4.OFF(); + sensor_h2s.OFF(); + sensor_nh3.OFF(); + + // switch on BME sensor + // read temperature, humidity and pressure + // switch off BME sensor + bme.ON(); + temperature = bme.getTemperature(); + humidity = bme.getHumidity(); + pressure = bme.getPressure(); + bme.OFF(); + + // switch on luxes sensor + // read luminosity + // switch off luxes sensor + //luxes.ON(); + // luminosity = luxes.getLuminosity(); + // luxes.OFF(); + + ultrasound.ON(); + // switch on all gas sensor again + sensor_ch4.ON(); + sensor_h2s.ON(); + sensor_nh3.ON(); + + + /////////////////////////////////////////// + // 2. Wait heating time + /////////////////////////////////////////// + + // Sensors need time to warm up and get a response from gas + // To reduce the battery consumption, use deepSleep instead delay + // After 2 minutes, Waspmote wakes up thanks to the RTC Alarm + USB.println(RTC.getTime()); + USB.println(F("Enter deep sleep mode to wait for sensors heating time...")); + PWR.deepSleep("00:00:02:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON); + USB.ON(); + USB.println(RTC.getTime()); + USB.println(F("wake up!!\r\n")); + + + /////////////////////////////////////////// + // 3. Read gas sensors + /////////////////////////////////////////// + + // Read the sensors and compensate with the temperature internally + concentration_ch4 = sensor_ch4.getConc(temperature); + concentration_h2s = sensor_h2s.getConc(temperature); + concentration_nh3 = sensor_nh3.getConc(temperature); + + // Read the ultrasound sensor + range = ultrasound.getDistance(); + // switch off CO2 sensor + // Pellistor and NDIR sensors must be switched off after + // reading because they present a high power consumption + //sensor_co2.OFF(); + + // switch off all gas sensor again + sensor_ch4.OFF(); + sensor_h2s.OFF(); + sensor_nh3.OFF(); + /////////////////////////////////////////// + ultrasound.OFF(); + + /////////////////////////////////////////// + // 4. Read particle matter sensor + /////////////////////////////////////////// +/* + // Turn on the particle matter sensor + OPC_status = PM.ON(); + if (OPC_status == 1) + { + USB.println(F("Particle sensor started")); + } + else + { + USB.println(F("Error starting the particle sensor")); + } + + // Get measurement from the particle matter sensor + if (OPC_status == 1) + { + // Power the fan and the laser and perform a measure of 5 seconds + OPC_measure = PM.getPM(5000, 5000); + } + + PM.OFF(); +*/ + + VOLT = PWR.getBatteryVolts(); + CHRG = PWR.getBatteryCurrent(); + /////////////////////////////////////////// + // 5. Print sensor values + /////////////////////////////////////////// + + USB.println(F("***********************************************")); + USB.print(F("SOCKET_E -- > Temperature : ")); + USB.printFloat(temperature, 2); + USB.println(F(" Celsius degrees")); + USB.print(F("SOCKET_E -- > Humidity : ")); + USB.printFloat(humidity, 2); + USB.println(F(" % ")); + USB.print(F("SOCKET_E -- > Pressure : ")); + USB.printFloat(pressure, 2); + USB.println(F(" Pa")); + USB.print(F("SOCKET_B -- > CH4 concentration : ")); + USB.printFloat(concentration_ch4, 3); + USB.println(F(" ppm")); + USB.print(F("SOCKET_C -- > H2S concentration : ")); + USB.printFloat(concentration_h2s, 3); + USB.println(F(" ppm")); + USB.print(F("SOCKET_F -- > NH3 concentration : ")); + USB.printFloat(concentration_nh3, 3); + USB.println(F(" ppm")); + USB.print(F("SOCKET_A -- > Distance : ")); + USB.print(range); + USB.println(F(" cm")); + // Show the remaining battery level + USB.print(F("Battery Level: ")); + USB.print(PWR.getBatteryLevel(),DEC); + USB.println(F(" %")); + // Show the battery Volts + USB.print(F("Battery (Volts): ")); + USB.print(PWR.getBatteryVolts()); + USB.println(F(" V")); + // Show the battery charging current (only from solar panel) + USB.print(F("Battery charging current (only from solar panel): ")); + USB.print(CHRG, DEC); + USB.println(F(" mA")); + USB.println(F("***********************************************")); + +/* + // check answer + if (OPC_measure == 1) + { + USB.print(F("SOCKET_D -- > PM 1 : ")); + USB.printFloat(PM._PM1, 3); + USB.println(F(" ug / m3")); + USB.print(F("SOCKET_D -- > PM 2.5 : ")); + USB.printFloat(PM._PM2_5, 3); + USB.println(F(" ug / m3")); + USB.print(F("SOCKET_D -- > PM 10 : ")); + USB.printFloat(PM._PM10, 3); + USB.println(F(" ug / m3")); + } + else + { + USB.print(F("SOCKET_D -- > Error performing the measure. Error code : ")); + USB.println(OPC_measure, DEC); + } +*/ + //USB.print(F("SOCKET_E -- > Luminosity : ")); + // USB.print(luminosity); + //USB.println(F(" luxes")); + + + + + /////////////////////////////////////////// + // 6. Create ASCII frame + /////////////////////////////////////////// + + // Create new frame (ASCII) + frame.createFrame(ASCII); + + // Add sensor values + frame.addSensor(SENSOR_CITIES_PRO_TC, temperature); + frame.addSensor(SENSOR_CITIES_PRO_HUM, humidity); + frame.addSensor(SENSOR_CITIES_PRO_PRES, pressure); + frame.addSensor(SENSOR_CITIES_PRO_CH4, concentration_ch4); + frame.addSensor(SENSOR_CITIES_PRO_H2S, concentration_h2s); + frame.addSensor(SENSOR_CITIES_PRO_NH3, concentration_nh3); + frame.addSensor(SENSOR_CITIES_PRO_US, range); + // frame.addSensor(SENSOR_CITIES_PRO_LUXES, luminosity); + //frame.addSensor(SENSOR_CITIES_PRO_PM1, PM._PM1); + // frame.addSensor(SENSOR_CITIES_PRO_PM2_5, PM._PM2_5); + // frame.addSensor(SENSOR_CITIES_PRO_PM10, PM._PM10); + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + //frame.addSensor(SENSOR_RSSI, _4G.getRSSI()); + frame.addSensor(SENSOR_BAT_VOLT, VOLT); + frame.addSensor(SENSOR_BAT_CURR, CHRG); + + // Show the frame + frame.showFrame(); + + ////////////////////////////////////////////////// + // 1. Switch ON + ////////////////////////////////////////////////// + error = _4G.ON(); + + if (error == 0) + { + USB.println(F("1. 4G module ready...")); + + connection_status = _4G.checkDataConnection(30); + + if (connection_status == 0) + { + USB.println(F("1.1. Module connected to network")); + + // delay for network parameters stabilization + delay(5000); + + ////////////////////////////////////////////// + // 1.2. Get RSSI + ////////////////////////////////////////////// + error = _4G.getRSSI(); + if (error == 0) + { + USB.print(F("1.2. RSSI: ")); + USB.print(_4G._rssi, DEC); + USB.println(F(" dBm")); + } + else + { + USB.println(F("1.2. Error calling 'getRSSI' function")); + } + } + //////////////////////////////////////////////// + // 3. Send to Meshlium + //////////////////////////////////////////////// + USB.print(F("Sending the frame...")); + error = _4G.sendFrameToMeshlium( host, port, frame.buffer, frame.length); + + // check the answer + if ( error == 0) + { + USB.print(F("Done. HTTP code: ")); + USB.println(_4G._httpCode); + USB.print("Server response: "); + USB.println(_4G._buffer, _4G._length); + //frame.createFrame(ASCII); + //frame.addSensor(SENSOR_BAT_VOLT, VOLT); + // frame.addSensor(SENSOR_BAT_CURR, CHRG); + // _4G.sendFrameToMeshlium( host, port, frame.buffer, frame.length); + // USB.println(F("ASCII FRAME SEND OK")); + } + else + { + USB.print(F("Failed. Error code: ")); + USB.println(error, DEC); + } + } + else + { + // Problem with the communication with the 4G module + USB.println(F("4G module not started")); + USB.print(F("Error code: ")); + USB.println(error, DEC); + } + + + //////////////////////////////////////////////// + // 4. Powers off the 4G module + //////////////////////////////////////////////// + USB.println(F("4. Switch OFF 4G module")); + _4G.OFF(); + + /////////////////////////////////////////// + // 7. Sleep + /////////////////////////////////////////// + + // Go to deepsleep + // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm + USB.println(F("Enter deep sleep mode")); + PWR.deepSleep("00:00:15:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON); + USB.ON(); + USB.println(F("wake up!!")); + +} \ No newline at end of file diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/SEP1 XBEE Altfactor/xBEE_SEP1 b/projects/IoTBoardCode/Waspmote/Waspmote/SEP1 XBEE Altfactor/xBEE_SEP1 new file mode 100644 index 00000000..0c8e8c0f --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/SEP1 XBEE Altfactor/xBEE_SEP1 @@ -0,0 +1,371 @@ +#include +#include +#include +#include + +// PAN (Personal Area Network) Identifier +uint8_t panID[2] = {0x20,0x07}; + +// Define Freq Channel to be set: +// Center Frequency = 2.405 + (CH - 11d) * 5 MHz +// Range: 0x0B - 0x1A (XBee) +// Range: 0x0C - 0x17 (XBee-PRO) +uint8_t channel = 0x0C; + +// Define the Encryption mode: 1 (enabled) or 0 (disabled) +uint8_t encryptionMode = 1; + +// Define the AES 16-byte Encryption Key +char encryptionKey[] = "libelium2015MVXB"; + +// Destination MAC address +////////////////////////////////////////// +char RX_ADDRESS[] = "0013A20040D878D1"; +////////////////////////////////////////// + +// Define the Waspmote ID +char NODE_ID[] = "SEP1"; + + +// define variable +uint8_t error; + +// messure every 10 minutes +unsigned long delay_interval = 900000; + +//Gas CO2(SOCKET_B); +Gas CO(SOCKET_F); +Gas O3(SOCKET_A); +//Gas O2(SOCKET_4); +//Gas NO(SOCKET_5); +Gas NO2(SOCKET_B); + +float temperature; +float humidity; +float pressure; +//float concCO2; +float concCO; +float concO3; +//float concO2; +//float concNO; +float concNO2; + +char info_string[61]; +int status; +int measure; + + + + +void setup() +{ + // open USB port + USB.ON(); + + USB.println(F("-------------------------------")); + USB.println(F("Configure XBee 802.15.4")); + USB.println(F("-------------------------------")); + + // init XBee + xbee802.ON(); + + delay(1000); + + + ///////////////////////////////////// + // 1. set channel + ///////////////////////////////////// + xbee802.setChannel( channel ); + + // check at commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.print(F("1. Channel set OK to: 0x")); + USB.printHex( xbee802.channel ); + USB.println(); + } + else + { + USB.println(F("1. Error calling 'setChannel()'")); + } + + + ///////////////////////////////////// + // 2. set PANID + ///////////////////////////////////// + xbee802.setPAN( panID ); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.print(F("2. PAN ID set OK to: 0x")); + USB.printHex( xbee802.PAN_ID[0] ); + USB.printHex( xbee802.PAN_ID[1] ); + USB.println(); + } + else + { + USB.println(F("2. Error calling 'setPAN()'")); + } + + ///////////////////////////////////// + // 3. set encryption mode (1:enable; 0:disable) + ///////////////////////////////////// + xbee802.setEncryptionMode( encryptionMode ); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.print(F("3. AES encryption configured (1:enabled; 0:disabled):")); + USB.println( xbee802.encryptMode, DEC ); + } + else + { + USB.println(F("3. Error calling 'setEncryptionMode()'")); + } + + ///////////////////////////////////// + // 4. set encryption key + ///////////////////////////////////// + xbee802.setLinkKey( encryptionKey ); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.println(F("4. AES encryption key set OK")); + } + else + { + USB.println(F("4. Error calling 'setLinkKey()'")); + } + + ///////////////////////////////////// + // 5. write values to XBee module memory + ///////////////////////////////////// + xbee802.writeValues(); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.println(F("5. Changes stored OK")); + } + else + { + USB.println(F("5. Error calling 'writeValues()'")); + } + + + USB.println(F("-------------------------------")); + + +//pm +USB.ON(); + USB.println(F("Frame Utility Example for Gases Pro Sensor Board")); + + // Set the Waspmote ID + USB.println(F("Particle Matter Sensor example")); + // Set the Waspmote ID + frame.setID(NODE_ID); + + status = OPC_N2.ON(); + if (status == 1) + { + status = OPC_N2.getInfoString(info_string); + if (status == 1) + { + USB.println(F("Information string extracted:")); + USB.println(info_string); + + } + else + { + USB.println(F("Error reading the particle sensor")); + } + + OPC_N2.OFF(); + } + else + { + USB.println(F("Error starting the particle sensor")); + } + +} + + + +void loop() +{ + + /////////////////////////////////////////// + // 1. Turn on sensors and wait + /////////////////////////////////////////// + // Power on the OPC_N2 sensor. + // If the gases PRO board is off, turn it on automatically. + status = OPC_N2.ON(); + if (status == 1) + { + USB.println(F("Particle sensor started")); + + } + else + { + USB.println(F("Error starting the particle sensor")); + } + + /////////////////////////////////////////// + // 2. Read sensors + /////////////////////////////////////////// + + if (status == 1) + { + // Power the fan and the laser and perform a measure of 5 seconds + measure = OPC_N2.getPM(10000); + if (measure == 1) + { + USB.println(F("Measure performed")); + USB.print(F("PM 1: ")); + USB.print(OPC_N2._PM1); + USB.println(F(" ug/m3")); + USB.print(F("PM 2.5: ")); + USB.print(OPC_N2._PM2_5); + USB.println(F(" ug/m3")); + USB.print(F("PM 10: ")); + USB.print(OPC_N2._PM10); + USB.println(F(" ug/m3")); + + } + else + { + USB.print(F("Error performing the measure. Error code:")); + USB.println(measure, DEC); + } + } + +OPC_N2.OFF(); + + delay(15000); + /////////////////////////////////////////// + // 3. Turn off the sensors + /////////////////////////////////////////// + + // Power off the OPC_N2 sensor. If there aren't other sensors powered, + // turn off the board automatically + //Power on sensors + // CO2.ON(); + CO.ON(); + O3.ON(); + // O2.ON(); + // NO.ON(); + NO2.ON(); + + // Sensors need time to warm up and get a response from gas + // To reduce the battery consumption, use deepSleep instead delay + // After 2 minutes, Waspmote wakes up thanks to the RTC Alarm + PWR.deepSleep("00:00:02:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON); + + + /////////////////////////////////////////// + // 2. Read sensors + /////////////////////////////////////////// + + // Read the CO2 sensor and compensate with the temperature internally + // concCO2 = CO2.getConc(); + // Read the CO sensor and compensate with the temperature internally + concCO = CO.getConc(); + // Read the O3 sensor and compensate with the temperature internally + concO3 = O3.getConc(); + // Read the O2 sensor and compensate with the temperature internally +// concO2 = O2.getConc(); + // Read the NO sensor and compensate with the temperature internally + // concNO = NO.getConc(); + // Read the NO2 sensor and compensate with the temperature internally + concNO2 = NO2.getConc(); + + // Read enviromental variables + temperature = CO.getTemp(); + humidity = CO.getHumidity(); + pressure = CO.getPressure(); + + /////////////////////////////////////////// + // 3. Turn off the sensors + /////////////////////////////////////////// + + //Power off sensors + //CO2.OFF(); + CO.OFF(); +O3.OFF(); + // O2.OFF(); + // NO.OFF(); +NO2.OFF(); + + /////////////////////////////////////////// + // 1. Create ASCII frame + /////////////////////////////////////////// + + // create new frame + frame.createFrame(BINARY, NODE_ID); + + + // add frame fields + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + // Add temperature + frame.addSensor(SENSOR_GP_TC, temperature); + // Add humidity + frame.addSensor(SENSOR_GP_HUM, humidity); + // Add pressure value + frame.addSensor(SENSOR_GP_PRES, pressure); + // Add CO2 value +// frame.addSensor(SENSOR_GP_CO2, concCO2); + // Add CO value + frame.addSensor(SENSOR_GP_CO, concCO); + // Add O3 value +frame.addSensor(SENSOR_GP_O3, concO3); + // Add O2 value + // frame.addSensor(SENSOR_GP_O2, concO2); + // Add NO value + // frame.addSensor(SENSOR_GP_NO, concNO); + // Add NO2 value +frame.addSensor(SENSOR_GP_NO2, concNO2); +// Add PM 1 + frame.addSensor(SENSOR_OPC_PM1,OPC_N2._PM1); + // Add PM 2.5 + frame.addSensor(SENSOR_OPC_PM2_5,OPC_N2._PM2_5); + // Add PM 10 + frame.addSensor(SENSOR_OPC_PM10,OPC_N2._PM10); + // Show the frame + frame.showFrame(); + + /////////////////////////////////////////// + // 2. Send packet + /////////////////////////////////////////// + + USB.println(F("sending...")); + // send XBee packet + error = xbee802.send( RX_ADDRESS, frame.buffer, frame.length ); + + // check TX flag + if( error == 0 ) + { + USB.println(F("send ok")); + + // blink green LED + Utils.blinkGreenLED(); + + } + else + { + USB.println(F("send error")); + + // blink red LED + Utils.blinkRedLED(); + } + + USB.println(F("-------------------------------")); + USB.print(F("Going to sleep for ")); + USB.print(delay_interval / 1000); + USB.println(F(" secounds.")); + USB.println(F("-------------------------------")); + + // sleep + delay(delay_interval); +} \ No newline at end of file diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Smart Water/Smart Water code b/projects/IoTBoardCode/Waspmote/Waspmote/Smart Water/Smart Water code new file mode 100644 index 00000000..23c364d0 --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/Smart Water/Smart Water code @@ -0,0 +1,314 @@ +/* + --------------- 4G_08 - Send frames to Meshlium --------------- + + Explanation: This example shows how to use HTTP requests to send + Waspmote frames from Waspmote to Meshlium. Therefore, the Meshlium + will be able to parse the sensor data and inset it into the database + + NOTE: This example is valid for Meshlium Manager System versions + prior to v4.0.9 which only supports HTTPS. + + Copyright (C) 2018 Libelium Comunicaciones Distribuidas S.L. + http://www.libelium.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . + + Version: 3.0 + Design: David Gascón + Implementation: Alejandro Gállego +*/ + +#include +#include +#include +#include "WaspFrameConstantsv15.h" + +// APN settings +/////////////////////////////////////// +char apn[] = "net"; +char login[] = ""; +char password[] = ""; +/////////////////////////////////////// + +// SERVER settings +/////////////////////////////////////// +char host[] = "82.78.81.178"; +uint16_t port = 80; +/////////////////////////////////////// + +// define the Waspmote ID +char moteID[] = "SW1"; +int error; + + +// This variable will store the temperature value +float temp; +float VOLT; + +float value_orp; +float value_orp_calculated; + +float value_do; +float value_do_calculated; + +float pHVol; +float pHValue; + +float ECRes; +float ECValue; + +// Temperature at which calibration was carried out +#define cal_temp 27.3 +// Offset obtained from sensor calibration +#define calibration_offset 0.018 +// Calibration of the sensor in normal air +#define air_calibration 2.517 +// Calibration of the sensor under 0% solution +#define zero_calibration 0.0 + +// Calibration values +#define cal_point_10 1.94 +#define cal_point_7 2.050 +#define cal_point_4 2.1165 + +// Value 1 used to calibrate the sensor +#define point1_cond 10500 +// Value 2 used to calibrate the sensor +#define point2_cond 40000 + +// Point 1 of the calibration +#define point1_cal 197.00 +// Point 2 of the calibration +#define point2_cal 150.00 + + +ORPClass ORPSensor; +DOClass DOSensor; +pHClass pHSensor; +conductivityClass ConductivitySensor; +pt1000Class TemperatureSensor; + + +uint16_t CHRG; +// Create an instance of the class + + +void setup() +{ + USB.ON(); + USB.println(F("Start program")); + + // set the Waspmote ID + frame.setID(moteID); + + // Configure the calibration values + pHSensor.setCalibrationPoints(cal_point_10, cal_point_7, cal_point_4, cal_temp); + DOSensor.setCalibrationPoints(air_calibration, zero_calibration); + ConductivitySensor.setCalibrationPoints(point1_cond, point1_cal, point2_cond, point2_cal); + + + ////////////////////////////////////////////////// + // 1. sets operator parameters + ////////////////////////////////////////////////// + _4G.set_APN(apn, login, password); + + ////////////////////////////////////////////////// + // 2. Show APN settings via USB port + ////////////////////////////////////////////////// + _4G.show_APN(); + + USB.println(F("This is a Smart Water data frame...")); + + /////////////////////////////////////////// + // 1. Turn ON the Smart Water sensor board + /////////////////////////////////////////// + +} + + + +void loop() +{ + ////////////////////////////////////////////////// + // 1. Switch ON + ////////////////////////////////////////////////// + error = _4G.ON(); + + if (error == 0) + { + USB.println(F("1. 4G module ready...")); + + + //////////////////////////////////////////////// + // 2. Create new frame + //////////////////////////////////////////////// + + RTC.ON(); + RTC.getTime(); + + Water.ON(); + delay(2000); + + /////////////////////////////////////////// + // 2. read the sensors + /////////////////////////////////////////// + + // Reading of the Temperature sensor + temp = TemperatureSensor.readTemperature(); + VOLT = PWR.getBatteryVolts(); + CHRG = PWR.getBatteryCurrent(); + + // Reading of the ORP sensor + value_orp = ORPSensor.readORP(); + // Apply the calibration offset + value_orp_calculated = value_orp - calibration_offset; + // Reading of the ORP sensor + value_do = DOSensor.readDO(); + // Conversion from volts into dissolved oxygen percentage + value_do_calculated = DOSensor.DOConversion(value_do); + // Read the ph sensor (voltage value) + pHVol = pHSensor.readpH(); + // Read the temperature sensor + // Convert the value read with the information obtained in calibration + pHValue = pHSensor.pHConversion(pHVol, temp); + // Reading of the Conductivity sensor + ECRes = ConductivitySensor.readConductivity(); + // Conversion from resistance into us/cm + ECValue = ConductivitySensor.conductivityConversion(ECRes); + + /////////////////////////////////////////// + // 3. Print the output values + /////////////////////////////////////////// + + // Print of the results + USB.print(F("Temperature (celsius degrees): ")); + USB.println(temp); + + // Show the remaining battery level + USB.print(F("Battery Level: ")); + USB.print(PWR.getBatteryLevel(),DEC); + USB.print(F(" %")); + + // Show the battery Volts + USB.print(F(" | Battery (Volts): ")); + USB.print(PWR.getBatteryVolts()); + USB.println(F(" V")); + + // Show the battery charging current (only from solar panel) + USB.print(F("Battery charging current (only from solar panel): ")); + USB.print(CHRG, DEC); + USB.println(F(" mA")); + + USB.print(F("ORP Estimated: ")); + USB.print(value_orp_calculated); + USB.println(F(" volts")); + + // Print of the results + USB.print(F("DO Output Voltage: ")); + USB.print(value_do); + + // Print of the results + USB.print(F(" DO Percentage: ")); + USB.println(value_do_calculated); + + USB.print(F("pH value: ")); + USB.print(pHVol); + USB.println(F("volts | ")); + USB.print(F(" pH Estimated: ")); + USB.println(pHValue); + + // Print of the results + USB.print(F("Conductivity Output Resistance: ")); + USB.println(ECRes); + + // Print of the results + USB.print(F(" Conductivity of the solution (uS/cm): ")); + USB.println(ECValue); + + // 3. Turn off the sensors + /////////////////////////////////////////// + + Water.OFF(); + + // Create new frame (ASCII) + frame.createFrame(ASCII); + // set frame fields (Time from RTC) + frame.addSensor(SENSOR_TIME, RTC.hour, RTC.minute, RTC.second); + // Add temperature + // USB.print(F(" a crapat iar ")); + frame.addSensor(SENSOR_WATER_WT, temp); + // USB.print(F(" a crapat si din nou")); + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + //USB.print(F(" a crapat iarrrrr")); + frame.addSensor(SENSOR_BAT_VOLT, VOLT); + frame.addSensor(SENSOR_BAT_CURR, CHRG); + // Add PH + frame.addSensor(SENSOR_WATER_PH, pHValue); + // Add ORP value + frame.addSensor(SENSOR_WATER_ORP, value_orp_calculated); + // Add DO value + frame.addSensor(SENSOR_WATER_DO, value_do_calculated); + // Add conductivity value + frame.addSensor(SENSOR_WATER_COND, ECValue); + + // USB.print(F(" a crapat de tot ")); + // Show the frame + frame.showFrame(); + + //////////////////////////////////////////////// + // 3. Send to Meshlium + //////////////////////////////////////////////// + USB.print(F("Sending the frame...")); + error = _4G.sendFrameToMeshlium( host, port, frame.buffer, frame.length); + + // check the answer + if ( error == 0) + { + USB.print(F("Done. HTTP code: ")); + USB.println(_4G._httpCode); + USB.print("Server response: "); + USB.println(_4G._buffer, _4G._length); + } + else + { + USB.print(F("Failed. Error code: ")); + USB.println(error, DEC); + } + } + else + { + // Problem with the communication with the 4G module + USB.println(F("4G module not started")); + USB.print(F("Error code: ")); + USB.println(error, DEC); + } + + + //////////////////////////////////////////////// + // 4. Powers off the 4G module + //////////////////////////////////////////////// + USB.println(F("4. Switch OFF 4G module")); + _4G.OFF(); + + + //////////////////////////////////////////////// + // 5. Sleep + //////////////////////////////////////////////// + USB.println(F("5. Enter deep sleep...")); + PWR.deepSleep("00:00:10:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); + + USB.ON(); + USB.println(F("6. Wake up!!\n\n")); + +} \ No newline at end of file diff --git a/projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi b/projects/IoTBoardCode/Waspmote/Waspmote/Waspmote Gases Board/BEIA GAS 2 similarity index 75% rename from projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi rename to projects/IoTBoardCode/Waspmote/Waspmote/Waspmote Gases Board/BEIA GAS 2 index a32bb7e1..3fe7ca87 100644 --- a/projects/IoTBoardCode/Waspmote/GAS_WiFi4/GAS_WiFi +++ b/projects/IoTBoardCode/Waspmote/Waspmote/Waspmote Gases Board/BEIA GAS 2 @@ -1,511 +1,549 @@ -/* - * ------------ [Ga_v30_01] - Temperature, Humidty and Pressure -------------- - * - * Explanation: This example read the temperature, humidity and - * pressure values from BME280 sensor - * - * Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L. - * http://www.libelium.com - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Version: 3.0 - * Design: David Gascón - * Implementation: Ahmad Saad -*/ - -// Library include -#include -#include -#include - -// choose socket (SELECT USER'S SOCKET) -/////////////////////////////////////// -uint8_t socket = SOCKET0; -/////////////////////////////////////// - - -// choose URL settings -/////////////////////////////////////// -char type[] = "http"; -char host[] = "82.78.81.171"; -char port[] = "80"; -/////////////////////////////////////// - -uint8_t error; -uint8_t status; -unsigned long previous; - - - -#define NUM_OF_POINTS 3 - -//********************************************************************************* -// O2 Sensor must be connected in SOCKET1 -//********************************************************************************* -O2SensorClass O2Sensor(SOCKET_1); - -// Percentage values of Oxygen -#define POINT1_PERCENTAGE 0.0 -#define POINT2_PERCENTAGE 5.0 -// Calibration Voltage Obtained during calibration process (in mV) -#define POINT1_VOLTAGE 0.35 -#define POINT2_VOLTAGE 2.0 - -float concentrations_o2[] = {POINT1_PERCENTAGE, POINT2_PERCENTAGE}; -float voltages_o2[] = {POINT1_VOLTAGE, POINT2_VOLTAGE}; - - -//********************************************************************************* -// CO2 Sensor must be connected physically in SOCKET2 -//********************************************************************************* -CO2SensorClass CO2Sensor(SOCKET_2); - -// Concentratios used in calibration process -#define POINT1_PPM_CO2 350.0 // PPM VALUE <-- Normal concentration in air -#define POINT2_PPM_CO2 1000.0 // PPM VALUE -#define POINT3_PPM_CO2 3000.0 // PPM VALUE - -// Calibration vVoltages obtained during calibration process -#define POINT1_VOLT_CO2 0.300 -#define POINT2_VOLT_CO2 0.350 -#define POINT3_VOLT_CO2 0.380 - -float concentrations_co2[] = {POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2}; -float voltages_co2[] = {POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2}; - - -//********************************************************************************* -// NO2 Sensor must be connected physically in SOCKET3 -//********************************************************************************* -NO2SensorClass NO2Sensor(SOCKET_3); - -// Concentratios used in calibration process -#define POINT1_PPM_NO2 10.0 // PPM VALUE <-- Normal concentration in air -#define POINT2_PPM_NO2 50.0 // PPM VALUE -#define POINT3_PPM_NO2 100.0 // PPM VALUE - -// Calibration voltages obtained during calibration process (in KOHMs) -#define POINT1_RES_NO2 45.25 // <-- Rs at normal concentration in air -#define POINT2_RES_NO2 25.50 -#define POINT3_RES_NO2 3.55 - -float concentrations_no2[] = {POINT1_PPM_NO2, POINT2_PPM_NO2, POINT3_PPM_NO2}; -float voltages_no2[] = {POINT1_RES_NO2, POINT2_RES_NO2, POINT3_RES_NO2}; - -//********************************************************************************* -// CO Sensor must be connected physically in SOCKET_4 -//********************************************************************************* -COSensorClass COSensor(SOCKET_4); - -// Concentratios used in calibration process -#define POINT1_PPM_CO 100.0 // <--- Ro value at this concentration -#define POINT2_PPM_CO 300.0 // -#define POINT3_PPM_CO 1000.0 // - -// Calibration resistances obtained during calibration process -#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. -#define POINT2_RES_CO 40.665 // -#define POINT3_RES_CO 20.300 // - -float concentrations_co[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO }; -float resValues_co[] = { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO }; -//********************************************************************************* -// VOC Sensor must be connected physically in SOCKET5 -//********************************************************************************* -VOCSensorClass VOCSensor(SOCKET_5); - -// Concentratios used in calibration process (PPM VALUE) -#define POINT1_PPM_VOC 100.0 // <--- Ro value at this concentration -#define POINT2_PPM_VOC 300.0 -#define POINT3_PPM_VOC 1000.0 - -// Calibration resistances obtained during calibration process -#define POINT1_RES_VOC 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. -#define POINT2_RES_VOC 40.665 // -#define POINT3_RES_VOC 20.300 // - -float concentrations[] = { POINT1_PPM_VOC, POINT2_PPM_VOC, POINT3_PPM_VOC }; -float resValues[] = { POINT1_RES_VOC, POINT2_RES_VOC, POINT3_RES_VOC }; - - -//********************************************************************************* -// LPG Sensor can be connected in SOCKET6 AND SOCKET7 -//********************************************************************************* -LPGSensorClass LPGSensor(SOCKET_6); ; // <---- SOCKET7 Class used - -// Concentratios used in calibration process -#define POINT1_PPM_LPG 10.0 // PPM VALUE <-- Normal concentration in air -#define POINT2_PPM_LPG 50.0 // PPM VALUE -#define POINT3_PPM_LPG 100.0 // PPM VALUE - -// Calibration voltages obtained during calibration process (in KOHMs) -#define POINT1_RES_LPG 45.25 // <-- Rs at normal concentration in air -#define POINT2_RES_LPG 25.50 -#define POINT3_RES_LPG 3.55 - -float concentrations_lps[] = {POINT1_PPM_LPG, POINT2_PPM_LPG, POINT3_PPM_LPG}; -float voltages_lps[] = {POINT1_RES_LPG, POINT2_RES_LPG, POINT3_RES_LPG}; - -//********************************************************************************* -// Solvent Vapors Sensor must be connected physically in SOCKET_6 or SOCKET_7 -//********************************************************************************* -SVSensorClass SVSensor(SOCKET_7); - -// Concentratios used in calibration process -#define POINT1_PPM_SV 10.0 // <-- Normal concentration in air -#define POINT2_PPM_SV 50.0 -#define POINT3_PPM_SV 100.0 - -// Calibration voltages obtained during calibration process (in KOHMs) -#define POINT1_RES_SV 45.25 // <-- Rs at normal concentration in air -#define POINT2_RES_SV 25.50 -#define POINT3_RES_SV 3.55 - -float concentrations_sv[] = { POINT1_PPM_SV, POINT2_PPM_SV, POINT3_PPM_SV }; -float voltages_sv[] = { POINT1_RES_SV, POINT2_RES_SV, POINT3_RES_SV }; - -//********************************************************************************* -// BME280 Definitions -//********************************************************************************* -#include - -float temperature; // Stores the temperature in ºC -float humidity; // Stores the realitve humidity in %RH -float pressure; // Stores the pressure in Pa - -//********************************************************************************* - - -char node_ID[] = "BEIA_GAS1"; //ex GAS_WiFi - -void setup() -{ - // Configure the calibration values - O2Sensor.setCalibrationPoints(voltages_o2, concentrations_o2); - // Configure the calibration values - CO2Sensor.setCalibrationPoints(voltages_co2, concentrations_co2, NUM_OF_POINTS); - // Configure the calibration values - NO2Sensor.setCalibrationPoints(voltages_no2, concentrations_no2, NUM_OF_POINTS); - // Configure the calibration values - VOCSensor.setCalibrationPoints(resValues, concentrations, NUM_OF_POINTS); - // Configure the calibration values - LPGSensor.setCalibrationPoints(voltages_lps, concentrations_lps, NUM_OF_POINTS); - // Calculate the slope and the intersection of the logarithmic function - COSensor.setCalibrationPoints(resValues_co, concentrations_co, NUM_OF_POINTS); - // Calculate the slope and the intersection of the logarithmic function - SVSensor.setCalibrationPoints(voltages_sv, concentrations_sv, NUM_OF_POINTS); - - USB.ON(); - USB.println(F("Frame")); - - // Set the Waspmote ID - frame.setID(node_ID); - - /////////////////////////////////////////// - // 1. Turn on the board - /////////////////////////////////////////// - - //Power gases board and wait for stabilization and sensor response time - Gases.ON(); -} - -void loop() -{ - // get actual time - previous = millis(); - ////////////////////////////////////////////////// - // 1. Switch ON - ////////////////////////////////////////////////// - error = WIFI_PRO.ON(socket); - - if (error == 0) - { - USB.println(F("WiFi switched ON")); - } - else - { - USB.println(F("WiFi did not initialize correctly")); - } - ////////////////////////////////////////////////// - // 2. Join AP - ////////////////////////////////////////////////// - // check connectivity - status = WIFI_PRO.isConnected(); - - // check if module is connected - if (status == true) - { - USB.print(F("WiFi is connected OK")); - USB.print(F(" Time(ms):")); - USB.println(millis()-previous); - - ////////////////////////////////////////////////////////////////////// - // 2. Read Sensors - ////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////// - // 2.1 Read Temperature, Humidity and Pressure Sensor (BME280) - ////////////////////////////////////////////////////////////////////// - - // Read enviromental variables - temperature = Gases.getTemperature(); - humidity = Gases.getHumidity(); - pressure = Gases.getPressure(); - - ////////////////////////////////////////////////////////////////////// - // 2.2 Read O2 Sensor - Connected in SOCKET1 - ////////////////////////////////////////////////////////////////////// - O2Sensor.ON(); - delay(1000); - // O2 Sensor does not need power suplly - float O2Vol = O2Sensor.readVoltage(); - delay(100); - // Read the concentration value in % - float O2Val = O2Sensor.readConcentration(); - O2Sensor.OFF(); - - ////////////////////////////////////////////////////////////////////// - // 2.3 Read CO2 Sensor - Connected in SOCKET2 - ////////////////////////////////////////////////////////////////////// - CO2Sensor.ON(); - delay(1000); - // PPM value of CO2 - // Voltage value of the sensor - float CO2Vol = CO2Sensor.readVoltage(); - // PPM value of CO2 - float CO2PPM = CO2Sensor.readConcentration(); - CO2Sensor.OFF(); - - ////////////////////////////////////////////////////////////////////// - // 2.4 Read NO2 Sensor - Connected in SOCKET3 - ////////////////////////////////////////////////////////////////////// - NO2Sensor.ON(); - delay(1000); - // PPM value of NO2 - float NO2Vol = NO2Sensor.readVoltage(); // Voltage value of the sensor - float NO2Res = NO2Sensor.readResistance(); // Resistance of the sensor - float NO2PPM = NO2Sensor.readConcentration(); // PPM value of NO2 - NO2Sensor.OFF(); - - ////////////////////////////////////////////////////////////////////// - // 2.4 Read VOC Sensor - Connected in SOCKET5 - ////////////////////////////////////////////////////////////////////// - VOCSensor.ON(); - delay(1000); - // PPM value of VOC - float VOCVol = VOCSensor.readVoltage(); // Voltage value of the sensor - float VOCRes = VOCSensor.readResistance(); // Resistance of the sensor - float VOCPPM = VOCSensor.readConcentration(); // PPM value of VOC - VOCSensor.OFF(); - - // 2.5 Read LPG Sensor - Connected in SOCKET7 - ////////////////////////////////////////////////////////////////////// - LPGSensor.ON(); - delay(1000); - // PPM value of CH4 - float LPGVol = LPGSensor.readVoltage(); // Voltage value of the sensor - float LPGRes = LPGSensor.readResistance(); // Resistance of the sensor - float LPGPPM = LPGSensor.readConcentration(); // PPM value of LPGfloat LPGPPM = LPGSensor.readConcentration(); - LPGSensor.OFF(); - - // 2.6 Read LPG Sensor - Connected in SOCKET6 - ////////////////////////////////////////////////////////////////////// - COSensor.ON(); - // PPM value of CO - delay(1000); - float COVol = COSensor.readVoltage(); // Voltage value of the sensor - float CORes = COSensor.readResistance(); // Resistance of the sensor - float COPPM = COSensor.readConcentration(); // PPM value of CO - COSensor.OFF(); - - // 2.7 Read SV Sensor - Connected in SOCKET7 - ////////////////////////////////////////////////////////////////////// - SVSensor.ON(); - // PPM value of SV - float SVVol = SVSensor.readVoltage(); // Voltage value of the sensor - float SVRes = SVSensor.readResistance(); // Resistance of the sensor - float SVPPM = SVSensor.readConcentration(); // PPM value of Solvent Vapor sensor - SVSensor.OFF(); - - - /////////////////print of results////////////////////////// - // O2 Sensor does not need power suplly - USB.print(F("O2 concentration Estimated: ")); - USB.print(O2Vol); - USB.print(F(" mV | ")); - - USB.print(F(" O2 concentration Estimated: ")); - USB.print(O2Val); - USB.println(F(" %")); - - // Print of the results - USB.print(F("NO2 Sensor Voltage: ")); - USB.print(NO2Vol); - USB.print(F(" V |")); - - // Print of the results - USB.print(F(" NO2 Sensor Resistance: ")); - USB.print(NO2Res); - USB.print(F(" Ohms |")); - - // Print of the results - USB.print(F(" NO2 concentration Estimated: ")); - USB.print(NO2PPM); - USB.println(F(" PPM")); - - - // Print of the results - USB.print(F("CO Sensor Voltage: ")); - USB.print(COVol); - USB.print(F(" mV |")); - - // Print of the results - USB.print(F(" CO Sensor Resistance: ")); - USB.print(CORes); - USB.print(F(" Ohms |")); - - USB.print(F(" CO concentration Estimated: ")); - USB.print(COPPM); - USB.println(F(" ppm")); - - // Print of the results - USB.print(F("CO2 Sensor Voltage: ")); - USB.print(CO2Vol); - USB.print(F("volts |")); - - USB.print(F(" CO2 concentration estimated: ")); - USB.print(CO2PPM); - USB.println(F(" ppm")); - - // Print of the results - USB.print(F("VOC Sensor Voltage: ")); - USB.print(VOCVol); - USB.print(F(" V |")); - - // Print of the results - USB.print(F(" VOC Sensor Resistance: ")); - USB.print(VOCRes); - USB.print(F(" Ohms |")); - - USB.print(F(" VOC concentration Estimated: ")); - USB.print(VOCPPM); - USB.println(F(" ppm")); - - // Print of the results - USB.print(F("Solvent Vapors Sensor Voltage: ")); - USB.print(SVVol); - USB.print(F(" V |")); - - // Print of the results - USB.print(F(" Solvent Vapors Sensor Resistance: ")); - USB.print(SVRes); - USB.print(F(" Ohms |")); - - // Print of the results - USB.print(F(" Solvent Vapors concentration Estimated: ")); - USB.print(SVPPM); - USB.println(F(" PPM")); - - // Print of the results - USB.print(F("LPG Sensor Voltage: ")); - USB.print(LPGVol); - USB.print(F(" V |")); - - // Print of the results - USB.print(F(" LPG Sensor Resistance: ")); - USB.print(LPGRes); - USB.print(F(" Ohms |")); - - USB.print(F(" LPG concentration Estimated: ")); - USB.print(LPGPPM); - USB.println(F(" ppm")); - - // 3. Create ASCII frame - /////////////////////////////////////////// - - // Create new frame (ASCII) - frame.createFrame(BINARY, node_ID); - // Add Oxygen voltage value - frame.addSensor(SENSOR_GASES_O2, O2Val); - // Add CO2 PPM value - frame.addSensor(SENSOR_GASES_CO2, CO2PPM); - // Add NO2 PPM value - frame.addSensor(SENSOR_GASES_NO2, NO2PPM); - // Add VOC PPM value - frame.addSensor(SENSOR_GASES_VOC, VOCPPM); - // Add LPG PPM value - frame.addSensor(SENSOR_GASES_LPG, LPGPPM); - // Add CO PPM value - frame.addSensor(SENSOR_GASES_CO, COPPM); - // Add SV PPM value - frame.addSensor(SENSOR_GASES_SV, SVPPM); - // Add BAT level value - frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); - // Show the frame - frame.showFrame(); - - - // 3.2. Send Frame to Meshlium - /////////////////////////////// - - // http frame - error = WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); - - // check response - if (error == 0) - { - USB.println(F("HTTP OK")); - USB.print(F("HTTP Time from OFF state (ms):")); - USB.println(millis()-previous); - } - else - { - USB.println(F("Error calling 'getURL' function")); - WIFI_PRO.printErrorCode(); - } - } - else - { - USB.print(F("WiFi is connected ERROR")); - USB.print(F(" Time(ms):")); - USB.println(millis()-previous); - } - ////////////////////////////////////////////////// - // 3. Switch OFF - ////////////////////////////////////////////////// - WIFI_PRO.OFF(socket); - USB.println(F("WiFi switched OFF\n\n")); -// Go to deepsleep - // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm - USB.println(F("Go to deepsleep --- After 10 seconds, Waspmote wakes up thanks to the RTC Alarm")); - //PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); - // USB.ON(); - //USB.println(F("\nwake up")); - - // After wake up check interruption source - //if( intFlag & RTC_INT ) - // { - // clear interruption flag - // intFlag &= ~(RTC_INT); - - // USB.println(F("---------------------")); - //USB.println(F("RTC INT captured")); - //USB.println(F("---------------------")); - Utils.blinkLEDs(300); - Utils.blinkLEDs(300); - Utils.blinkLEDs(300); - // } - delay (10000); -} +/* + * ------------ [Ga_v30_01] - Temperature, Humidty and Pressure -------------- + * + * Explanation: This example read the temperature, humidity and + * pressure values from BME280 sensor + * + * Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L. + * http://www.libelium.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Version: 3.0 + * Design: David Gascón + * Implementation: Ahmad Saad +*/ + +// Library include +#include +#include +#include + +// choose socket (SELECT USER'S SOCKET) +/////////////////////////////////////// +uint8_t socket = SOCKET0; +/////////////////////////////////////// + + +// choose URL settings +/////////////////////////////////////// +char type[] = "http"; +char host[] = "82.78.81.171"; +char port[] = "80"; +/////////////////////////////////////// + +uint8_t error; +uint8_t status; +unsigned long previous; + + + +#define NUM_OF_POINTS 3 + +//********************************************************************************* +// O2 Sensor must be connected in SOCKET1 +//********************************************************************************* +O2SensorClass O2Sensor(SOCKET_1); + +// Percentage values of Oxygen +#define POINT1_PERCENTAGE 0.0 +#define POINT2_PERCENTAGE 5.0 +// Calibration Voltage Obtained during calibration process (in mV) +#define POINT1_VOLTAGE 0.35 +#define POINT2_VOLTAGE 2.0 + +float concentrations_o2[] = {POINT1_PERCENTAGE, POINT2_PERCENTAGE}; +float voltages_o2[] = {POINT1_VOLTAGE, POINT2_VOLTAGE}; + + +//********************************************************************************* +// CO2 Sensor must be connected physically in SOCKET2 +//********************************************************************************* +CO2SensorClass CO2Sensor(SOCKET_2); + +// Concentratios used in calibration process +#define POINT1_PPM_CO2 350.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_CO2 1000.0 // PPM VALUE +#define POINT3_PPM_CO2 3000.0 // PPM VALUE + +// Calibration vVoltages obtained during calibration process +#define POINT1_VOLT_CO2 0.300 +#define POINT2_VOLT_CO2 0.350 +#define POINT3_VOLT_CO2 0.380 + +float concentrations_co2[] = {POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2}; +float voltages_co2[] = {POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2}; + + +//********************************************************************************* +// NO2 Sensor must be connected physically in SOCKET3 +//********************************************************************************* +NO2SensorClass NO2Sensor(SOCKET_3); + +// Concentratios used in calibration process +#define POINT1_PPM_NO2 10.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_NO2 50.0 // PPM VALUE +#define POINT3_PPM_NO2 100.0 // PPM VALUE + +// Calibration voltages obtained during calibration process (in KOHMs) +#define POINT1_RES_NO2 45.25 // <-- Rs at normal concentration in air +#define POINT2_RES_NO2 25.50 +#define POINT3_RES_NO2 3.55 + +float concentrations_no2[] = {POINT1_PPM_NO2, POINT2_PPM_NO2, POINT3_PPM_NO2}; +float voltages_no2[] = {POINT1_RES_NO2, POINT2_RES_NO2, POINT3_RES_NO2}; + +//********************************************************************************* +// CO Sensor must be connected physically in SOCKET_4 +//********************************************************************************* +//COSensorClass COSensor(SOCKET_4); + +// Concentratios used in calibration process +//#define POINT1_PPM_CO 100.0 // <--- Ro value at this concentration +//#define POINT2_PPM_CO 300.0 // +//#define POINT3_PPM_CO 1000.0 // + +// Calibration resistances obtained during calibration process +//#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. +//#define POINT2_RES_CO 40.665 // +//#define POINT3_RES_CO 20.300 // + +//float concentrations_co[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO }; +//float resValues_co[] = { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO }; +//********************************************************************************* +// VOC Sensor must be connected physically in SOCKET5 +//********************************************************************************* +VOCSensorClass VOCSensor(SOCKET_5); + +// Concentratios used in calibration process (PPM VALUE) +#define POINT1_PPM_VOC 100.0 // <--- Ro value at this concentration +#define POINT2_PPM_VOC 300.0 +#define POINT3_PPM_VOC 1000.0 + +// Calibration resistances obtained during calibration process +#define POINT1_RES_VOC 230.30 // <-- Ro Resistance at 100 ppm. Necessary value. +#define POINT2_RES_VOC 40.665 // +#define POINT3_RES_VOC 20.300 // + +float concentrations[] = { POINT1_PPM_VOC, POINT2_PPM_VOC, POINT3_PPM_VOC }; +float resValues[] = { POINT1_RES_VOC, POINT2_RES_VOC, POINT3_RES_VOC }; + + +//********************************************************************************* +// LPG Sensor can be connected in SOCKET6 AND SOCKET7 +//********************************************************************************* +LPGSensorClass LPGSensor(SOCKET_6); ; // <---- SOCKET7 Class used + +// Concentratios used in calibration process +#define POINT1_PPM_LPG 10.0 // PPM VALUE <-- Normal concentration in air +#define POINT2_PPM_LPG 50.0 // PPM VALUE +#define POINT3_PPM_LPG 100.0 // PPM VALUE + +// Calibration voltages obtained during calibration process (in KOHMs) +#define POINT1_RES_LPG 45.25 // <-- Rs at normal concentration in air +#define POINT2_RES_LPG 25.50 +#define POINT3_RES_LPG 3.55 + +float concentrations_lps[] = {POINT1_PPM_LPG, POINT2_PPM_LPG, POINT3_PPM_LPG}; +float voltages_lps[] = {POINT1_RES_LPG, POINT2_RES_LPG, POINT3_RES_LPG}; + +//********************************************************************************* +// Solvent Vapors Sensor / APP1 must be connected physically in SOCKET_6 or SOCKET_7 +//********************************************************************************* +APSensorClass APPSensor(SOCKET_7); // + + +//SVSensorClass SVSensor(SOCKET_7); + +// Concentratios used in calibration process +//#define POINT1_PPM_SV 10.0 // <-- Normal concentration in air +//#define POINT2_PPM_SV 50.0 +//#define POINT3_PPM_SV 100.0 + +// Calibration voltages obtained during calibration process (in KOHMs) +//#define POINT1_RES_SV 45.25 // <-- Rs at normal concentration in air +//#define POINT2_RES_SV 25.50 +//#define POINT3_RES_SV 3.55 + +//float concentrations_sv[] = { POINT1_PPM_SV, POINT2_PPM_SV, POINT3_PPM_SV }; +//float voltages_sv[] = { POINT1_RES_SV, POINT2_RES_SV, POINT3_RES_SV }; + +//********************************************************************************* +// BME280 Definitions +//********************************************************************************* +#include + +float temperature; // Stores the temperature in ºC +float humidity; // Stores the realitve humidity in %RH +float pressure; // Stores the pressure in Pa + +//********************************************************************************* + + +char node_ID[] = "BEIA_GAS2"; //ex GAS_WiFi + +void setup() +{ + // Configure the calibration values + O2Sensor.setCalibrationPoints(voltages_o2, concentrations_o2); + // Configure the calibration values + //CO2Sensor.setCalibrationPoints(voltages_co2, concentrations_co2, NUM_OF_POINTS); + // Configure the calibration values + NO2Sensor.setCalibrationPoints(voltages_no2, concentrations_no2, NUM_OF_POINTS); + // Configure the calibration values + VOCSensor.setCalibrationPoints(resValues, concentrations, NUM_OF_POINTS); + // Configure the calibration values + LPGSensor.setCalibrationPoints(voltages_lps, concentrations_lps, NUM_OF_POINTS); + // Calculate the slope and the intersection of the logarithmic function + //COSensor.setCalibrationPoints(resValues_co, concentrations_co, NUM_OF_POINTS); + // Calculate the slope and the intersection of the logarithmic function + //SVSensor.setCalibrationPoints(voltages_sv, concentrations_sv, NUM_OF_POINTS); + // Concentratios used in calibration process (in PPM) + APPSensor.concentrations[POINT_1] = 10.0; // <--- Ro value at this concentration + APPSensor.concentrations[POINT_2] = 50.0 ; + APPSensor.concentrations[POINT_3] = 100.0; + // Calibration resistances obtained during calibration process (in Kohms) + APPSensor.values[POINT_1] = 45.25; // <-- Ro Resistance at 100 ppm. Necessary value. + APPSensor.values[POINT_2] = 25.665; + APPSensor.values[POINT_3] = 2.300; + // Define the number of calibration points + APPSensor.numPoints = 3; + // Calculate the slope and the intersection of the logarithmic function + APPSensor.setCalibrationPoints(); + USB.ON(); + USB.println(F("Frame")); + + // Set the Waspmote ID + frame.setID(node_ID); + + /////////////////////////////////////////// + // 1. Turn on the board + /////////////////////////////////////////// + + //Power gases board and wait for stabilization and sensor response time + Gases.ON(); +} + +void loop() +{ + // get actual time + previous = millis(); + ////////////////////////////////////////////////// + // 1. Switch ON + ////////////////////////////////////////////////// + error = WIFI_PRO.ON(socket); + + if (error == 0) + { + USB.println(F("WiFi switched ON")); + } + else + { + USB.println(F("WiFi did not initialize correctly")); + } + ////////////////////////////////////////////////// + // 2. Join AP + ////////////////////////////////////////////////// + // check connectivity + status = WIFI_PRO.isConnected(); + + // check if module is connected + if (status == true) + { + USB.print(F("WiFi is connected OK")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + + ////////////////////////////////////////////////////////////////////// + // 2. Read Sensors + ////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////// + // 2.1 Read Temperature, Humidity and Pressure Sensor (BME280) + ////////////////////////////////////////////////////////////////////// + + // Read enviromental variables + temperature = Gases.getTemperature(); + humidity = Gases.getHumidity(); + pressure = Gases.getPressure(); + + ////////////////////////////////////////////////////////////////////// + // 2.2 Read O2 Sensor - Connected in SOCKET1 + ////////////////////////////////////////////////////////////////////// + O2Sensor.ON(); + delay(1000); + // O2 Sensor does not need power suplly + float O2Vol = O2Sensor.readVoltage(); + delay(100); + // Read the concentration value in % + float O2Val = O2Sensor.readConcentration(); + O2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.3 Read CO2 Sensor - Connected in SOCKET2 + ////////////////////////////////////////////////////////////////////// + //CO2Sensor.ON(); + //delay(1000); + // PPM value of CO2 + // Voltage value of the sensor + //float CO2Vol = CO2Sensor.readVoltage(); + // PPM value of CO2 + //float CO2PPM = CO2Sensor.readConcentration(); + //CO2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.4 Read NO2 Sensor - Connected in SOCKET3 + ////////////////////////////////////////////////////////////////////// + NO2Sensor.ON(); + delay(1000); + // PPM value of NO2 + float NO2Vol = NO2Sensor.readVoltage(); // Voltage value of the sensor + float NO2Res = NO2Sensor.readResistance(); // Resistance of the sensor + float NO2PPM = NO2Sensor.readConcentration(); // PPM value of NO2 + NO2Sensor.OFF(); + + ////////////////////////////////////////////////////////////////////// + // 2.4 Read VOC Sensor - Connected in SOCKET5 + ////////////////////////////////////////////////////////////////////// + VOCSensor.ON(); + delay(1000); + // PPM value of VOC + float VOCVol = VOCSensor.readVoltage(); // Voltage value of the sensor + float VOCRes = VOCSensor.readResistance(); // Resistance of the sensor + float VOCPPM = VOCSensor.readConcentration(); // PPM value of VOC + VOCSensor.OFF(); + + // 2.5 Read LPG Sensor - Connected in SOCKET7 + ////////////////////////////////////////////////////////////////////// + LPGSensor.ON(); + delay(1000); + // PPM value of CH4 + float LPGVol = LPGSensor.readVoltage(); // Voltage value of the sensor + float LPGRes = LPGSensor.readResistance(); // Resistance of the sensor + float LPGPPM = LPGSensor.readConcentration(); // PPM value of LPGfloat LPGPPM = LPGSensor.readConcentration(); + LPGSensor.OFF(); + + // 2.6 Read LPG Sensor - Connected in SOCKET6 + ////////////////////////////////////////////////////////////////////// + //COSensor.ON(); + // PPM value of CO + //delay(1000); + //float COVol = COSensor.readVoltage(); // Voltage value of the sensor + //float CORes = COSensor.readResistance(); // Resistance of the sensor + //float COPPM = COSensor.readConcentration(); // PPM value of CO + //COSensor.OFF(); + + // 2.7 Read SV Sensor - Connected in SOCKET7 + ////////////////////////////////////////////////////////////////////// + //SVSensor.ON(); + // PPM value of SV + //float SVVol = SVSensor.readVoltage(); // Voltage value of the sensor + //float SVRes = SVSensor.readResistance(); // Resistance of the sensor + //float SVPPM = SVSensor.readConcentration(); // PPM value of Solvent Vapor sensor + //SVSensor.OFF(); + + // 2.6 Read APP1 Sensor - Connected in SOCKET7 + APPSensor.ON(); + delay(1000); + // PPM value of APP1 + float APPVol = APPSensor.readVoltage(); // Voltage value of the sensor + float APPRes = APPSensor.readResistance(); // Resistance of the sensor + float APP_PPM = APPSensor.readConcentration(); // PPM value of AP1 + + + /////////////////print of results////////////////////////// + // O2 Sensor does not need power suplly + USB.print(F("O2 concentration Estimated: ")); + USB.print(O2Vol); + USB.print(F(" mV | ")); + + USB.print(F(" O2 concentration Estimated: ")); + USB.print(O2Val); + USB.println(F(" %")); + + // Print of the results + USB.print(F("NO2 Sensor Voltage: ")); + USB.print(NO2Vol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" NO2 Sensor Resistance: ")); + USB.print(NO2Res); + USB.print(F(" Ohms |")); + + // Print of the results + USB.print(F(" NO2 concentration Estimated: ")); + USB.print(NO2PPM); + USB.println(F(" PPM")); + + + // Print of the results + // USB.print(F("CO Sensor Voltage: ")); + //USB.print(COVol); + //USB.print(F(" mV |")); + + // Print of the results + //USB.print(F(" CO Sensor Resistance: ")); + //USB.print(CORes); + //USB.print(F(" Ohms |")); + + //USB.print(F(" CO concentration Estimated: ")); + //USB.print(COPPM); + //USB.println(F(" ppm")); + + // Print of the results + //USB.print(F("CO2 Sensor Voltage: ")); + //USB.print(CO2Vol); + //USB.print(F("volts |")); + + //USB.print(F(" CO2 concentration estimated: ")); + //USB.print(CO2PPM); + //USB.println(F(" ppm")); + + // Print of the results + USB.print(F("VOC Sensor Voltage: ")); + USB.print(VOCVol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" VOC Sensor Resistance: ")); + USB.print(VOCRes); + USB.print(F(" Ohms |")); + + USB.print(F(" VOC concentration Estimated: ")); + USB.print(VOCPPM); + USB.println(F(" ppm")); + + // Print of the results + //USB.print(F("Solvent Vapors Sensor Voltage: ")); + //USB.print(SVVol); + //USB.print(F(" V |")); + + // Print of the results + //USB.print(F(" Solvent Vapors Sensor Resistance: ")); + //USB.print(SVRes); + //USB.print(F(" Ohms |")); + + // Print of the results + //USB.print(F(" Solvent Vapors concentration Estimated: ")); + //USB.print(SVPPM); + //USB.println(F(" PPM")); + + // Print of the results + USB.print(F("LPG Sensor Voltage: ")); + USB.print(LPGVol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" LPG Sensor Resistance: ")); + USB.print(LPGRes); + USB.print(F(" Ohms |")); + + USB.print(F(" LPG concentration Estimated: ")); + USB.print(LPGPPM); + USB.println(F(" ppm")); + + // Print of the results + USB.print(F("Air Pollutans Sensor Voltage: ")); + USB.print(APPVol); + USB.print(F(" V |")); + + // Print of the results + USB.print(F(" Air Pollutans Sensor Resistance: ")); + USB.print(APPRes); + USB.print(F(" Ohms |")); + + USB.print(F(" Air Pollutans concentration Estimated: ")); + USB.print(APP_PPM); + USB.println(F(" ppm")); + + // 3. Create ASCII frame + /////////////////////////////////////////// + + // Create new frame (ASCII) + frame.createFrame(BINARY, node_ID); + // Add Oxygen voltage value + frame.addSensor(SENSOR_GASES_O2, O2Val); + // Add CO2 PPM value + //frame.addSensor(SENSOR_GASES_CO2, CO2PPM); + // Add NO2 PPM value + frame.addSensor(SENSOR_GASES_NO2, NO2PPM); + // Add VOC PPM value + frame.addSensor(SENSOR_GASES_VOC, VOCPPM); + // Add LPG PPM value + frame.addSensor(SENSOR_GASES_LPG, LPGPPM); + // Add CO PPM value + //frame.addSensor(SENSOR_GASES_CO, COPPM); + // Add SV PPM value + //frame.addSensor(SENSOR_GASES_SV, SVPPM); + // Add APP1 PPM value + frame.addSensor(SENSOR_GASES_AP1, APP_PPM); + // Add BAT level value + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + // Show the frame + frame.showFrame(); + + + // 3.2. Send Frame to Meshlium + /////////////////////////////// + + // http frame + error = WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); + + // check response + if (error == 0) + { + USB.println(F("HTTP OK")); + USB.print(F("HTTP Time from OFF state (ms):")); + USB.println(millis()-previous); + } + else + { + USB.println(F("Error calling 'getURL' function")); + WIFI_PRO.printErrorCode(); + } + } + else + { + USB.print(F("WiFi is connected ERROR")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + } + ////////////////////////////////////////////////// + // 3. Switch OFF + ////////////////////////////////////////////////// + WIFI_PRO.OFF(socket); + USB.println(F("WiFi switched OFF\n\n")); +// Go to deepsleep + // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm + USB.println(F("Go to deepsleep --- After 10 seconds, Waspmote wakes up thanks to the RTC Alarm")); + //PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); + // USB.ON(); + //USB.println(F("\nwake up")); + + // After wake up check interruption source + //if( intFlag & RTC_INT ) + // { + // clear interruption flag + // intFlag &= ~(RTC_INT); + + // USB.println(F("---------------------")); + //USB.println(F("RTC INT captured")); + //USB.println(F("---------------------")); + Utils.blinkLEDs(300); + Utils.blinkLEDs(300); + Utils.blinkLEDs(300); + // } + delay (900000); +} diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Waspmote XBEE/XBEE01 b/projects/IoTBoardCode/Waspmote/Waspmote/Waspmote XBEE/XBEE01 new file mode 100644 index 00000000..dc38d54b --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/Waspmote XBEE/XBEE01 @@ -0,0 +1,200 @@ +#include +#include + +// PAN (Personal Area Network) Identifier +uint8_t panID[2] = {0xbe,0x1a}; + +// Define Freq Channel to be set: +// Center Frequency = 2.405 + (CH - 11d) * 5 MHz +// Range: 0x0B - 0x1A (XBee) +// Range: 0x0C - 0x17 (XBee-PRO) +uint8_t channel = 0x14; + +// Define the Encryption mode: 1 (enabled) or 0 (disabled) +uint8_t encryptionMode = 1; + +// Define the AES 16-byte Encryption Key +char encryptionKey[] = "libelium2015MVXB"; + +// Destination MAC address +////////////////////////////////////////// +char RX_ADDRESS[] = "0013A20041678B8C"; +////////////////////////////////////////// + +// Define the Waspmote ID +char NODE_ID[] = "XBEE01"; + + +// define variable +uint8_t error; + +// messure every 10 minutes +unsigned long delay_interval = 5000; + + +void setup() +{ + // open USB port + USB.ON(); + + USB.println(F("-------------------------------")); + USB.println(F("Configure XBee 802.15.4")); + USB.println(F("-------------------------------")); + + // init XBee + xbee802.ON(); + + delay(1000); + + + ///////////////////////////////////// + // 1. set channel + ///////////////////////////////////// + xbee802.setChannel( channel ); + + // check at commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.print(F("1. Channel set OK to: 0x")); + USB.printHex( xbee802.channel ); + USB.println(); + } + else + { + USB.println(F("1. Error calling 'setChannel()'")); + } + + + ///////////////////////////////////// + // 2. set PANID + ///////////////////////////////////// + xbee802.setPAN( panID ); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.print(F("2. PAN ID set OK to: 0x")); + USB.printHex( xbee802.PAN_ID[0] ); + USB.printHex( xbee802.PAN_ID[1] ); + USB.println(); + } + else + { + USB.println(F("2. Error calling 'setPAN()'")); + } + + ///////////////////////////////////// + // 3. set encryption mode (1:enable; 0:disable) + ///////////////////////////////////// + xbee802.setEncryptionMode( encryptionMode ); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.print(F("3. AES encryption configured (1:enabled; 0:disabled):")); + USB.println( xbee802.encryptMode, DEC ); + } + else + { + USB.println(F("3. Error calling 'setEncryptionMode()'")); + } + + ///////////////////////////////////// + // 4. set encryption key + ///////////////////////////////////// + xbee802.setLinkKey( encryptionKey ); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.println(F("4. AES encryption key set OK")); + } + else + { + USB.println(F("4. Error calling 'setLinkKey()'")); + } + + ///////////////////////////////////// + // 5. write values to XBee module memory + ///////////////////////////////////// + xbee802.writeValues(); + + // check the AT commmand execution flag + if( xbee802.error_AT == 0 ) + { + USB.println(F("5. Changes stored OK")); + } + else + { + USB.println(F("5. Error calling 'writeValues()'")); + } + + + USB.println(F("-------------------------------")); + + +//pm +USB.ON(); + USB.println(F("Frame Utility Example for Gases Pro Sensor Board")); + + // Set the Waspmote ID + // Set the Waspmote ID + frame.setID(NODE_ID); + +} + + + +void loop() +{ + + // switch on RTC + RTC.ON(); + // Create new frame (ASCII) + frame.createFrame(ASCII); + // set frame fields (Time from RTC) + frame.addSensor(SENSOR_TIME, RTC.getTime()); + // set frame fields (Battery sensor - uint8_t) + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + + // show Frame + frame.showFrame(); + // switch off RTC + RTC.OFF(); + + // 5. Sends the frame to Meshlium with GET + USB.print(F("Sending the frame to Meshlium with GET method...")); + + /////////////////////////////////////////// + // 2. Send packet + /////////////////////////////////////////// + + // send XBee packet + error = xbee802.send( RX_ADDRESS, frame.buffer, frame.length ); + + // check TX flag + if( error == 0 ) + { + USB.println(F("send ok")); + + // blink green LED + Utils.blinkGreenLED(); + + } + else + { + USB.println(F("send error")); + + // blink red LED + Utils.blinkRedLED(); + } + + USB.println(F("-------------------------------")); + USB.print(F("Going to sleep for ")); + USB.print(delay_interval / 1000); + USB.println(F(" secounds.")); + USB.println(F("-------------------------------")); + + // sleep + delay(delay_interval); +} From f1a95f122c709167230f292d9b0e66f91d011dd5 Mon Sep 17 00:00:00 2001 From: pasatsanduadrian Date: Mon, 6 Jul 2020 16:03:31 +0300 Subject: [PATCH 7/8] Create Radiation1WiFi.c --- .../Waspmote/Radiation1/Radiation1WiFi.c | 187 ++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation1WiFi.c diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation1WiFi.c b/projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation1WiFi.c new file mode 100644 index 00000000..69ec512a --- /dev/null +++ b/projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation1WiFi.c @@ -0,0 +1,187 @@ +#include //modificat +#include +#include + +// citeste accelerometru +// choose socket (SELECT USER'S SOCKET) +uint8_t socket = SOCKET0; +/////////////////////////////////////// +uint8_t status; +int x_acc; +int y_acc; +int z_acc; + + +// choose URL settings +/////////////////////////////////////// +char type[] = "http"; +char host[] = "82.78.81.171"; +char port[] = "80"; +/////////////////////////////////////// + +uint8_t error; +unsigned long previous; + + +char node_ID[] = "RADIATION1"; + +void setup() +{ + USB.println(F("Start program")); + USB.println(F("***************************************")); + USB.println(F("Once the module is set with one or more")); + USB.println(F("AP settings, it attempts to join the AP")); + USB.println(F("automatically once it is powered on")); + USB.println(F("Refer to example 'WIFI_PRO_01' to configure")); + USB.println(F("the WiFi module with proper settings")); + USB.println(F("***************************************")); + + ACC.ON(); + + + // open USB port + USB.ON(); + USB.println(F(" Radiation board sensor example")); + + frame.setID(node_ID); + +} + +void loop() + +{ + // get actual time + previous = millis(); + ////////////////////////////////////////////////// + // 1. Switch ON + ////////////////////////////////////////////////// + error = WIFI_PRO.ON(socket); + + if (error == 0) + { + USB.println(F("WiFi switched ON")); + } + else + { + USB.println(F("WiFi did not initialize correctly")); + } + ////////////////////////////////////////////////// + // 2. Join AP + ////////////////////////////////////////////////// + // check connectivity + status = WIFI_PRO.isConnected(); + + // check if module is connected + if (status == true) + { + USB.print(F("WiFi is connected OK")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + + /////////////////////////////////////////// + // 1. Create ASCII frame + /////////////////////////////////////////// + /////////////////////////////////////////// + //----------Check Register----------------------- + // should always answer 0x32, it is used to check + // the proper functionality of the accelerometer + status = ACC.check(); + + //----------X Value----------------------- + x_acc = ACC.getX(); + + //----------Y Value----------------------- + y_acc = ACC.getY(); + + //----------Z Value----------------------- + z_acc = ACC.getZ(); + + //------------------------------- + + USB.print(F("\n------------------------------\nCheck: 0x")); + USB.println(status, HEX); + USB.println(F("\n \t0X\t0Y\t0Z")); + USB.print(F(" ACC\t")); + USB.print(x_acc, DEC); + USB.print(F("\t")); + USB.print(y_acc, DEC); + USB.print(F("\t")); + USB.println(z_acc, DEC); + + delay(1000); + + // Turn on the board + /////////////////////////////////////////// + RadiationBoard.ON(); + delay(100); + + // create new frame + frame.createFrame(ASCII, node_ID); + + USB.println(F("Measuring radiation")); + float radiation = RadiationBoard.getRadiation(); + float radiationcpm = RadiationBoard.getCPM(5000); + + USB.print(F("radiation[uSv/h]: ")); + USB.println(radiation); + USB.println(); + + + USB.print(F("radiation[cpm]: ")); + USB.println(radiationcpm); + USB.println(); + + + // add frame fields + frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); + frame.addSensor(SENSOR_RADIATION, radiation); +// frame.addSensor(SENSOR_RADIATION, radiationcpm); + frame.addSensor(SENSOR_ACC, ACC.getX(), ACC.getY(), ACC.getZ()); + + // Power off the board + RadiationBoard.OFF(); + + /////////////////////////////////////////// + // 2. Send packet + /////////////////////////////////////////// + + // Show the frame + frame.showFrame(); + /////////////////////////////// + // 3.2. Send Frame to Meshlium + /////////////////////////////// + + // http frame + error = WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); + + // check response + if (error == 0) + { + USB.println(F("HTTP OK")); + USB.print(F("HTTP Time from OFF state (ms):")); + USB.println(millis()-previous); + } + else + { + USB.println(F("Error calling 'getURL' function")); + WIFI_PRO.printErrorCode(); + } + } + else + { + USB.print(F("WiFi is connected ERROR")); + USB.print(F(" Time(ms):")); + USB.println(millis()-previous); + } + + ////////////////////////////////////////////////// + // 3. Switch OFF + ////////////////////////////////////////////////// + WIFI_PRO.OFF(socket); + USB.println(F("WiFi switched OFF\n\n")); + USB.println(F("Go to deepsleep After 30 minutes, Waspmote wakes up thanks to the RTC Alarm")); + +// Go to deepsleep + // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm + PWR.deepSleep("00:00:00:60", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); +} From f1a80bb3bd07dab2276a7d97feb4907fe3097ad9 Mon Sep 17 00:00:00 2001 From: pasatsanduadrian Date: Mon, 6 Jul 2020 16:48:19 +0300 Subject: [PATCH 8/8] am editat extensia fisierelor si denumirea --- .../{BEIA_GAS1 => BEIAGAS1.c} | 0 .../{Model RPI code => ModelRPIMQTTcode.py} | 0 .../Waspmote/Radiation1/Radiation 1[WiFi] | 187 ------------------ .../{radiation board 2 => radiationboard 2.c} | 0 ...S PRO - custom code => GASPROcustomcode.c} | 0 .../{gistfile1.txt => SEP3gAltfactor.c} | 0 .../{Custom SCP => CustomSCPBeiaFARM.c} | 0 .../{xBEE_SEP1 => xBeeSEP1.c} | 0 .../{Smart Water code => SmartWaterCode.c} | 0 .../{BEIA GAS 2 => BeiaGas2.c} | 0 .../{XBEE01 => XBEE01Waspmote.c} | 0 11 files changed, 187 deletions(-) rename projects/IoTBoardCode/Waspmote/Waspmote/Gases Board BEIA GAS1/{BEIA_GAS1 => BEIAGAS1.c} (100%) rename projects/IoTBoardCode/Waspmote/Waspmote/RPI model/{Model RPI code => ModelRPIMQTTcode.py} (100%) delete mode 100644 projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation 1[WiFi] rename projects/IoTBoardCode/Waspmote/Waspmote/Radiation2 XBEE/{radiation board 2 => radiationboard 2.c} (100%) rename projects/IoTBoardCode/Waspmote/Waspmote/SCP/{GAS PRO - custom code => GASPROcustomcode.c} (100%) rename projects/IoTBoardCode/Waspmote/Waspmote/SEP 3G Altfactor/{gistfile1.txt => SEP3gAltfactor.c} (100%) rename projects/IoTBoardCode/Waspmote/Waspmote/SEP FARM/{Custom SCP => CustomSCPBeiaFARM.c} (100%) rename projects/IoTBoardCode/Waspmote/Waspmote/SEP1 XBEE Altfactor/{xBEE_SEP1 => xBeeSEP1.c} (100%) rename projects/IoTBoardCode/Waspmote/Waspmote/Smart Water/{Smart Water code => SmartWaterCode.c} (100%) rename projects/IoTBoardCode/Waspmote/Waspmote/Waspmote Gases Board/{BEIA GAS 2 => BeiaGas2.c} (100%) rename projects/IoTBoardCode/Waspmote/Waspmote/Waspmote XBEE/{XBEE01 => XBEE01Waspmote.c} (100%) diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Gases Board BEIA GAS1/BEIA_GAS1 b/projects/IoTBoardCode/Waspmote/Waspmote/Gases Board BEIA GAS1/BEIAGAS1.c similarity index 100% rename from projects/IoTBoardCode/Waspmote/Waspmote/Gases Board BEIA GAS1/BEIA_GAS1 rename to projects/IoTBoardCode/Waspmote/Waspmote/Gases Board BEIA GAS1/BEIAGAS1.c diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/RPI model/Model RPI code b/projects/IoTBoardCode/Waspmote/Waspmote/RPI model/ModelRPIMQTTcode.py similarity index 100% rename from projects/IoTBoardCode/Waspmote/Waspmote/RPI model/Model RPI code rename to projects/IoTBoardCode/Waspmote/Waspmote/RPI model/ModelRPIMQTTcode.py diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation 1[WiFi] b/projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation 1[WiFi] deleted file mode 100644 index 9d7a52f7..00000000 --- a/projects/IoTBoardCode/Waspmote/Waspmote/Radiation1/Radiation 1[WiFi] +++ /dev/null @@ -1,187 +0,0 @@ -#include -#include -#include - -// citeste accelerometru -// choose socket (SELECT USER'S SOCKET) -uint8_t socket = SOCKET0; -/////////////////////////////////////// -uint8_t status; -int x_acc; -int y_acc; -int z_acc; - - -// choose URL settings -/////////////////////////////////////// -char type[] = "http"; -char host[] = "82.78.81.171"; -char port[] = "80"; -/////////////////////////////////////// - -uint8_t error; -unsigned long previous; - - -char node_ID[] = "RADIATION1"; - -void setup() -{ - USB.println(F("Start program")); - USB.println(F("***************************************")); - USB.println(F("Once the module is set with one or more")); - USB.println(F("AP settings, it attempts to join the AP")); - USB.println(F("automatically once it is powered on")); - USB.println(F("Refer to example 'WIFI_PRO_01' to configure")); - USB.println(F("the WiFi module with proper settings")); - USB.println(F("***************************************")); - - ACC.ON(); - - - // open USB port - USB.ON(); - USB.println(F(" Radiation board sensor example")); - - frame.setID(node_ID); - -} - -void loop() - -{ - // get actual time - previous = millis(); - ////////////////////////////////////////////////// - // 1. Switch ON - ////////////////////////////////////////////////// - error = WIFI_PRO.ON(socket); - - if (error == 0) - { - USB.println(F("WiFi switched ON")); - } - else - { - USB.println(F("WiFi did not initialize correctly")); - } - ////////////////////////////////////////////////// - // 2. Join AP - ////////////////////////////////////////////////// - // check connectivity - status = WIFI_PRO.isConnected(); - - // check if module is connected - if (status == true) - { - USB.print(F("WiFi is connected OK")); - USB.print(F(" Time(ms):")); - USB.println(millis()-previous); - - /////////////////////////////////////////// - // 1. Create ASCII frame - /////////////////////////////////////////// - /////////////////////////////////////////// - //----------Check Register----------------------- - // should always answer 0x32, it is used to check - // the proper functionality of the accelerometer - status = ACC.check(); - - //----------X Value----------------------- - x_acc = ACC.getX(); - - //----------Y Value----------------------- - y_acc = ACC.getY(); - - //----------Z Value----------------------- - z_acc = ACC.getZ(); - - //------------------------------- - - USB.print(F("\n------------------------------\nCheck: 0x")); - USB.println(status, HEX); - USB.println(F("\n \t0X\t0Y\t0Z")); - USB.print(F(" ACC\t")); - USB.print(x_acc, DEC); - USB.print(F("\t")); - USB.print(y_acc, DEC); - USB.print(F("\t")); - USB.println(z_acc, DEC); - - delay(1000); - - // Turn on the board - /////////////////////////////////////////// - RadiationBoard.ON(); - delay(100); - - // create new frame - frame.createFrame(ASCII, node_ID); - - USB.println(F("Measuring radiation")); - float radiation = RadiationBoard.getRadiation(); - float radiationcpm = RadiationBoard.getCPM(5000); - - USB.print(F("radiation[uSv/h]: ")); - USB.println(radiation); - USB.println(); - - - USB.print(F("radiation[cpm]: ")); - USB.println(radiationcpm); - USB.println(); - - - // add frame fields - frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel()); - frame.addSensor(SENSOR_RADIATION, radiation); -// frame.addSensor(SENSOR_RADIATION, radiationcpm); - frame.addSensor(SENSOR_ACC, ACC.getX(), ACC.getY(), ACC.getZ()); - - // Power off the board - RadiationBoard.OFF(); - - /////////////////////////////////////////// - // 2. Send packet - /////////////////////////////////////////// - - // Show the frame - frame.showFrame(); - /////////////////////////////// - // 3.2. Send Frame to Meshlium - /////////////////////////////// - - // http frame - error = WIFI_PRO.sendFrameToMeshlium( type, host, port, frame.buffer, frame.length); - - // check response - if (error == 0) - { - USB.println(F("HTTP OK")); - USB.print(F("HTTP Time from OFF state (ms):")); - USB.println(millis()-previous); - } - else - { - USB.println(F("Error calling 'getURL' function")); - WIFI_PRO.printErrorCode(); - } - } - else - { - USB.print(F("WiFi is connected ERROR")); - USB.print(F(" Time(ms):")); - USB.println(millis()-previous); - } - - ////////////////////////////////////////////////// - // 3. Switch OFF - ////////////////////////////////////////////////// - WIFI_PRO.OFF(socket); - USB.println(F("WiFi switched OFF\n\n")); - USB.println(F("Go to deepsleep After 30 minutes, Waspmote wakes up thanks to the RTC Alarm")); - -// Go to deepsleep - // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm - PWR.deepSleep("00:00:00:60", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF); -} diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Radiation2 XBEE/radiation board 2 b/projects/IoTBoardCode/Waspmote/Waspmote/Radiation2 XBEE/radiationboard 2.c similarity index 100% rename from projects/IoTBoardCode/Waspmote/Waspmote/Radiation2 XBEE/radiation board 2 rename to projects/IoTBoardCode/Waspmote/Waspmote/Radiation2 XBEE/radiationboard 2.c diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/SCP/GAS PRO - custom code b/projects/IoTBoardCode/Waspmote/Waspmote/SCP/GASPROcustomcode.c similarity index 100% rename from projects/IoTBoardCode/Waspmote/Waspmote/SCP/GAS PRO - custom code rename to projects/IoTBoardCode/Waspmote/Waspmote/SCP/GASPROcustomcode.c diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/SEP 3G Altfactor/gistfile1.txt b/projects/IoTBoardCode/Waspmote/Waspmote/SEP 3G Altfactor/SEP3gAltfactor.c similarity index 100% rename from projects/IoTBoardCode/Waspmote/Waspmote/SEP 3G Altfactor/gistfile1.txt rename to projects/IoTBoardCode/Waspmote/Waspmote/SEP 3G Altfactor/SEP3gAltfactor.c diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/SEP FARM/Custom SCP b/projects/IoTBoardCode/Waspmote/Waspmote/SEP FARM/CustomSCPBeiaFARM.c similarity index 100% rename from projects/IoTBoardCode/Waspmote/Waspmote/SEP FARM/Custom SCP rename to projects/IoTBoardCode/Waspmote/Waspmote/SEP FARM/CustomSCPBeiaFARM.c diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/SEP1 XBEE Altfactor/xBEE_SEP1 b/projects/IoTBoardCode/Waspmote/Waspmote/SEP1 XBEE Altfactor/xBeeSEP1.c similarity index 100% rename from projects/IoTBoardCode/Waspmote/Waspmote/SEP1 XBEE Altfactor/xBEE_SEP1 rename to projects/IoTBoardCode/Waspmote/Waspmote/SEP1 XBEE Altfactor/xBeeSEP1.c diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Smart Water/Smart Water code b/projects/IoTBoardCode/Waspmote/Waspmote/Smart Water/SmartWaterCode.c similarity index 100% rename from projects/IoTBoardCode/Waspmote/Waspmote/Smart Water/Smart Water code rename to projects/IoTBoardCode/Waspmote/Waspmote/Smart Water/SmartWaterCode.c diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Waspmote Gases Board/BEIA GAS 2 b/projects/IoTBoardCode/Waspmote/Waspmote/Waspmote Gases Board/BeiaGas2.c similarity index 100% rename from projects/IoTBoardCode/Waspmote/Waspmote/Waspmote Gases Board/BEIA GAS 2 rename to projects/IoTBoardCode/Waspmote/Waspmote/Waspmote Gases Board/BeiaGas2.c diff --git a/projects/IoTBoardCode/Waspmote/Waspmote/Waspmote XBEE/XBEE01 b/projects/IoTBoardCode/Waspmote/Waspmote/Waspmote XBEE/XBEE01Waspmote.c similarity index 100% rename from projects/IoTBoardCode/Waspmote/Waspmote/Waspmote XBEE/XBEE01 rename to projects/IoTBoardCode/Waspmote/Waspmote/Waspmote XBEE/XBEE01Waspmote.c