I have an Argon running 1.5.2 that seems to have recurring issues with connectivity. It connects, runs several minutes then disconnects and repeats the process. I noted it was having issues making a cloud connection (rapid cyan blinking followed by 3 orange blinks. I tried doing particle keys server
and particle keys doctors
as the documentation suggested, but without any benefit. It’s odd that this device has been running for a long time, but I didn’t notice these issues. The LED is hidden from view most of the time, so this may be a long standing issue.
I use the device with a solenoid and a NeoPixel ring to signal when the garage door is open/closed and other conditions. It’s a simplistic program and I can’t see if I’m doing something wrong. Any ideas would be appreciated. It’s a very convenient way to know what’s happening at the garage and now a water leak detector.
Here’s my app code:
#include "Particle.h"
#include "neopixel.h"
SYSTEM_MODE(AUTOMATIC);
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D0
#define PIXEL_COUNT 24
//#define PIXEL_TYPE SK6812RGBW
#define PIXEL_TYPE WS2812B //this is required for the neopixel ring I own
#define BRIGHTNESS 10 // 0 - 255
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
int solenoid = D8;
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int hour = 0;
int minute = 0;
int second = 0;
uint32_t color = 0;
uint32_t lights[30];
int i=0;
uint32_t blue = 0xFF;
uint32_t red = 0xFF00;
uint32_t green = 0xFF0000;
char gDeviceInfo [200];
int gAction = 0;
void setup() {
pinMode(solenoid,OUTPUT);
Serial.begin(9600);
Time.zone(-5); //EST
Particle.function("pulseSolenoid",pulseSolenoid);
Particle.function("setPixelsRed", setPixelsRed);
Particle.function("setPixelsGreen", setPixelsGreen);
Particle.function("setPixelsBlue", setPixelsBlue);
Particle.function("setPixelsOff",setPixelsOff);
Particle.subscribe("waterLeak",waterLeak,MY_DEVICES);
Particle.subscribe("GDO",doorOpened,MY_DEVICES);
Particle.subscribe("GDOSTILL",doorOpenStill,MY_DEVICES);
Particle.subscribe("GDC",bothDoorsClosed,MY_DEVICES);
strip.setBrightness(BRIGHTNESS);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
gAction = 8;
snprintf(gDeviceInfo, sizeof(gDeviceInfo)
,"Application: %s, Date: %s, Time: %s, System firmware: %s, SSID: %s, RSSI: %d"
,__FILENAME__
,__DATE__
,__TIME__
,(const char*)System.version() // cast required for String
,(const char*)WiFi.SSID() // cast not required but always safe when in doubt if String or char*
,WiFi.RSSI().rssi
);
Particle.variable("deviceInfo",gDeviceInfo);
}
void loop() {
switch (gAction)
{
case 0: //do nothing
gAction = 0;
break;
case 1: // door opened
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
for (uint16_t i=0;i<=23;i++){
strip.setPixelColor(i,255,0,0); //red
}
strip.show();
gAction = 0;
break;
case 2: // doorOpenStill
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
delay(1000);
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
delay(1000);
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
gAction = 0;
break;
case 3: // bothDoorsClosed
for (uint16_t i=0;i<=23;i++){
strip.setPixelColor(i,0,255,0); //green
}
strip.show();
gAction = 0;
break;
case 4: // pulse solenoid
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
setPixelsRed("");
gAction = 0;
break;
case 5: // set pixels red
//Serial.println("setPixelRed");
for (uint16_t i=0;i<=23;i++){
strip.setPixelColor(i,255,0,0); //red
}
strip.show();
gAction = 0;
break;
case 6: //set pixels green
//Serial.println("setPixelGreen");
for (uint16_t i=0;i<=23;i++){
strip.setPixelColor(i,0,255,0); //green
}
strip.show();
gAction = 0;
break;
case 7: //set pixels blue
//Serial.println("setPixelBlue");
for (uint16_t i=0;i<=23;i++){
strip.setPixelColor(i,0,0,255); //blue
}
strip.show();
gAction = 0;
break;
case 8: // set pixels off
//Serial.println("setPixelOff");
for (uint16_t i=0;i<=23;i++){
strip.setPixelColor(i,0,0,0); //off
}
strip.show();
gAction = 0;
break;
case 9: // doorOpenStill
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
delay(1000);
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
delay(1000);
Particle.process();
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
delay(1000);
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
delay(1000);
Particle.process();
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
delay(1000);
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
delay(1000);
Particle.process();
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
delay(1000);
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
delay(1000);
Particle.process();
digitalWrite(solenoid,HIGH);
delay(50);
digitalWrite(solenoid,LOW);
gAction = 0;
break;
default:
gAction = 0;
}
}
void doorOpened(const char *event, const char *data) {
gAction = 1;
}
void doorOpenStill(const char *event, const char *data) {
gAction = 2;
}
void bothDoorsClosed(const char *event, const char *data) {
gAction = 3;
}
void waterLeak (const char *event, const char *data) {
gAction = 9;
}
int pulseSolenoid (String command) {
gAction = 4;
return 1;
}
int setPixelsRed (String command) {
gAction = 5;
return 1;
}
int setPixelsGreen (String command) {
gAction = 6;
return 1;
}
int setPixelsBlue (String command) {
gAction = 7;
return 1;
}
int setPixelsOff (String command) {
gAction = 8;
return 1;
}