Hey guys
I’m not sure why, but my Electron keeps timing out on me.
I start it up and initially I can make calls to it from a PHP curl call or from the command line with the expected results. However, I’m not sure if it happens after x number of calls, or x minutes of inactivity, or what, but the device just starts timing out on all calls from either the PHP page or the CLI.
If I reset the device it works as it should for a short while before again beginning to timeout.
Command Line call:
particle call shot-bot shoot A
The code on my device is as follows:
#include "cellular_hal.h"
// set the APN to 'internet' for MTN SIM card
STARTUP(cellular_credentials_set("internet", "", "", NULL));
int trigger1 = D1;
int trigger2 = D2;
//pushbutton pins
int BUTTON_1_PIN = D1;
int BUTTON_2_PIN = D2;
//pump/relay pins
int PUMP_1_PIN = D3;
int PUMP_2_PIN = D4;
//Time for pumping stations to turn on in milliseconds
int PUMP_1_TIME = 2500;
int PUMP_2_TIME = 2500;
void setup()
{
pinMode(trigger1, OUTPUT);
pinMode(trigger2, OUTPUT);
Particle.function("shoot",triggerShot);
digitalWrite(trigger1, LOW);
digitalWrite(trigger2, LOW);
pinMode(BUTTON_1_PIN, INPUT);
pinMode(BUTTON_2_PIN, INPUT);
pinMode(PUMP_1_PIN, OUTPUT);
pinMode(PUMP_2_PIN, OUTPUT);
}
void loop()
{
// check for button1 push
if(digitalRead(BUTTON_1_PIN) == HIGH)
{
digitalWrite(PUMP_1_PIN, HIGH);
delay(PUMP_1_TIME);
digitalWrite(PUMP_1_PIN, LOW);
}
// check for button2 push
if(digitalRead(BUTTON_2_PIN) == HIGH)
{
digitalWrite(PUMP_2_PIN, HIGH);
delay(PUMP_2_TIME);
digitalWrite(PUMP_2_PIN, LOW);
}
}
int triggerShot(String command) {
if (command=="A") {
digitalWrite(PUMP_1_PIN,HIGH);
delay(PUMP_1_TIME);
digitalWrite(PUMP_1_PIN, LOW);
return 1;
}
else if (command=="B") {
digitalWrite(PUMP_2_PIN,HIGH);
delay(PUMP_2_TIME);
digitalWrite(PUMP_2_PIN, LOW);
return 1;
}
else {
return -1;
}
}
Other things to note, which I haven’t solved and may or may not be related to the issue.
I cannot update my device OTA (annoying)
When the device starts up it flashes cyan really fast for a short time, and then briefly, a few fast red flashes before breathing cyan and successfully connecting to the cloud.
Any insight into this would be much appreciated.