Hi
I’m using a script to read temps from sensors. The Electron in order to save energy only sends the info every 4 cycles of measurements.
Now I want to wakeup the electron if the temp is higer than alert variable, but I’m doing something wrong, anybody could help to me?
Thank’s
STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY));
SYSTEM_MODE(SEMI_AUTOMATIC);
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_BMP280.h>
#include "Adafruit_Sensor.h"
#include "Adafruit_BMP280.h"
Adafruit_BMP280 bmp; // I2C
retained float temp[5];
retained float press[5];
retained float vtime[5];
retained float Abatt[5];
retained float Alertfrozen=29;
String dest1;
String dest2;
String dest3;
String dest4;
// The variable we'll use to keep track of where we are in the array
retained unsigned int contador = 1;
void setup() {
Time.zone(+2);
bmp.begin();
//Reading battery level
FuelGauge fuel;
float batt;
batt = fuel.getVCell();
temp[contador] = bmp.readTemperature();
press[contador] = bmp.readPressure();
vtime[contador] = Time.now();
Abatt[contador] = batt;
if (bmp.readTemperature() >= Alertfrozen){
Particle.connect();
if (contador==1){
dest1 = "{";
dest1 = dest1 + "\"2\":\""+ (Time.now()-(360))+"\",";
dest1 = dest1 + "\"10\":\""+ Abatt[0] +"\",";
dest1 = dest1 + "\"32\":\""+ press[0] +"\",";
dest1 = dest1 + "\"33\":\""+ temp[0] +"\"";
+ "}";
Particle.publish("******",dest1);
}
else if (contador==2){
dest1 = "{";
dest1 = dest1 + "\"2\":\""+ (Time.now()-(360))+"\",";
dest1 = dest1 + "\"10\":\""+ Abatt[0] +"\",";
dest1 = dest1 + "\"32\":\""+ press[0] +"\",";
dest1 = dest1 + "\"33\":\""+ temp[0] +"\"";
+ "}";
Particle.publish("******",dest1);
delay(4001);
dest2 = "{";
dest2 = dest2 + "\"2\":\""+ (Time.now()-(240))+"\",";
dest2 = dest2 + "\"10\":\""+ Abatt[1] +"\",";
dest2 = dest2 + "\"32\":\""+ press[1] +"\",";
dest2 = dest2 + "\"33\":\""+ temp[1] +"\"";
+ "}";
Particle.publish("*****",dest2);
}
else if(contador==3){
dest1 = "{";
dest1 = dest1 + "\"2\":\""+ (Time.now()-(360))+"\",";
dest1 = dest1 + "\"10\":\""+ Abatt[0] +"\",";
dest1 = dest1 + "\"32\":\""+ press[0] +"\",";
dest1 = dest1 + "\"33\":\""+ temp[0] +"\"";
+ "}";
Particle.publish("******",dest1);
delay(4001);
dest2 = "{";
dest2 = dest2 + "\"2\":\""+ (Time.now()-(240))+"\",";
dest2 = dest2 + "\"10\":\""+ Abatt[1] +"\",";
dest2 = dest2 + "\"32\":\""+ press[1] +"\",";
dest2 = dest2 + "\"33\":\""+ temp[1] +"\"";
+ "}";
Particle.publish("*********",dest2);
delay(4001);
dest3 = "{";
dest3 = dest3 + "\"2\":\""+ (Time.now()-(120))+"\",";
dest3 = dest3 + "\"10\":\""+ Abatt[2] +"\",";
dest3 = dest3 + "\"32\":\""+ press[2] +"\",";
dest3 = dest3 + "\"33\":\""+ temp[2] +"\"";
+ "}";
Particle.publish("********",dest3);
}
}