Hello Guys,
I am using Boron 2G/3G particle for publish some data to cloud after every 3 minutes. After 3 minutes it wake up and send data to cloud then goes to sleep. I want to test this loop for 1000 times. It was going very well till 823. I don’t know what happen after that Boron wake up after 3 minutes looking for internet (Green light blink ) for 40-50 seconds then it goes back to sleep. it is not connected to internet and not post data after 823 cycle. By resetting, it shows the same behavior even after 1st cycle now.
I run the other codes, it is working fine and connecting to internet and posting data accurately both on particle and our dashboard.
For your reference, please find the code. Thanks in advance
// This #include statement was automatically added by the Particle IDE.
#include <PowerShield.h>
// -----------------------------------------------------------------
// Function and Variable with photo sensors (resistor or transistor)
// -----------------------------------------------------------------
// In this example, we're going to register a Particle.variable() with the cloud so that we can read brightness levels from the photoresistor or phototransistor.
// We'll also register a Particle.function so that we can turn the LED on and off remotely.
PowerShield batteryMonitor;
// We're going to start by declaring which pins everything is plugged into.
int led = D6; // This is where your LED is plugged in. The other side goes to a resistor connected to GND.
int photosensor = A0; // This is where your photoresistor or phototransistor is plugged in. The other side goes to the "power" pin (below).
int analogvalue; // Here we are declaring the integer variable analogvalue, which we will use later to store the value of the photoresistor or phototransistor.
int ledToggle(String command);
int x=0;// Forward declaration
int i=0;
int a=1;
// EXAMPLE
FuelGauge fuel;
// Next we go into the setup function.
void setup() {
// This is here to allow for debugging using the USB serial port
Serial.begin();
// This essentially starts the I2C bus
batteryMonitor.begin();
// This sets up the fuel gauge
batteryMonitor.quickStart();
// Wait for it to settle down
delay(500);
// First, declare all of our pins. This lets our device know which ones will be used for outputting voltage, and which ones will read incoming voltage.
pinMode(led, OUTPUT); // Our LED pin is output (lighting up the LED)
digitalWrite(led, LOW);
// We are going to declare a Particle.variable() here so that we can access the value of the photosensor from the cloud.
Particle.variable("analogvalue", &analogvalue, INT);
// This is saying that when we ask the cloud for "analogvalue", this will reference the variable analogvalue in this app, which is an integer variable.
// Particle.publish("resistor", String(analogvalue), PRIVATE);
// We are also going to declare a Particle.function so that we can turn the LED on and off from the cloud.
Particle.function("Post per day",ledToggle);
// This is saying that when we ask the cloud for the function "led", it will employ the function ledToggle() from this app.
}
// Next is the loop function...
void loop() {
Particle.function("Post per day",ledToggle);
delay (10000);
}
// Finally, we will write out our ledToggle function, which is referenced by the Particle.function() called "led"
int ledToggle(String command) {
int x = atoi(command);
Particle.function("Post per day",ledToggle);
for ( i=0; i<x; i++)
{
analogvalue = analogRead(photosensor);
analogvalue=(analogvalue)+6400;
delay (100);
Particle.publish("resistor", String(analogvalue), PRIVATE);
float cellVoltage = batteryMonitor.getVCell();
Particle.publish("ps-voltage", String(cellVoltage), PRIVATE);
Particle.publish("ps-voltage", String(i), PRIVATE);
System.sleep(D6,RISING,86400/x);
delay(100);
}
return 1;
}