Good Day,
I have two Argons running the same code. One of which is on my test bench. The other is mounted inside of an outside light to control the light. I have a antenna mounted to the case of the light connected on the inside to the Argon. The unit is about 150 feet away from an AP that also has a high gain antenna. Internet signal is great where the light is located.
My test bench Argon runs perfect.
The one thats in the field cycles on when plugged in, connects (breathing cyan) and works perfect for just a little bit (5 - 10mins). Then continues to breath cyan but is unreachable. The app nor the console are connecting, cannot read variable or call functions. It does list the variables and functions just cant do anything with them. They do show the device as breathing cyan, but I think I read that at this point that is normal for these devices.
So to talk this out… differences between test and field:
Different antennas - Test has supplied antenna and field has this
Distance from AP - Test 5 feet and field is 150 feet (good signal on other devices thou phone etc)
Mounted - Test is on desk on supplied breadboard and field is inside aluminum outside light with antenna mounted outside
Pertinent Code
void setup() {
Time.zone(-6);
WiFi.setCredentials("XXX", "###");
Particle.function("toggleLight", toggleLight);
Particle.function("setRise", setRise);
Particle.function("setSet", setSet);
Particle.variable("rise", todayRise);
Particle.variable("set", todaySet);
Particle.variable("current", currentTime);
Particle.variable("lighton", lightOn);
Serial.begin(9600);
pinMode(set, OUTPUT);
digitalWrite(set, HIGH);
lightOn = true;
while (!WiFi.ready()) {
WiFi.connect();
// wait 5 seconds for connection:
delay(5000);
}
}
void loop() {
unsigned long currentMillis = millis();
if (lastMillis == 0 || (currentMillis - lastMillis) > delayMillis) {
lastMillis = currentMillis;
currentTime = Time.hour();
Particle.publish("Check Light");
//getWeather();
checkToToggleLight();
}
}
int setRise(String command) {
todayRise = command.toInt();
}
int setSet(String command) {
todaySet = command.toInt();
}
int toggleLight(String command) {
if (command == "1") {
digitalWrite(set, HIGH);
lightOn = true;
if (isManual == 2) {
isManual = 0;
manualMillis = 0;
} else {
isManual = 1;
manualMillis = millis();
}
return 1;
} else if (command == "0") {
digitalWrite(set, LOW);
lightOn = false;
if (isManual == 1) {
isManual = 0;
manualMillis = 0;
} else {
isManual = 2;
manualMillis = millis();
}
return 1;
} else {
return -1;
}
}
void checkToToggleLight() {
if (isManual == 2) {
if ((millis() - manualMillis) > manualDelayMillis) {
manualMillis = 0;
if (lightOn == 0) {
digitalWrite(set, HIGH);
lightOn = true;
}
}
} else {
if (!WiFi.ready()) {
digitalWrite(set, HIGH);
lightOn = true;
} else if (currentTime > todayRise && currentTime < todaySet) {
if (lightOn) {
//turn off
digitalWrite(set, LOW);
lightOn = false;
}
} else {
if (!lightOn) {
//turn on
digitalWrite(set, HIGH);
lightOn = true;
}
}
}
}
Im sure that there are details that I forgot. So if your interested in lending a hand, just ask.
Any input would be greatly appreciated.