I also read this which (as @BDub explains) is disconcerting… suggests that power-cycle of cellular radio cannot be un-done in code with the current firmware…
I could not find the toolchain instructions, but I noticed that after the initial failed notification, I received some of the subsequent times… using your adaptation of my earlier code, adding your fuel gauge piece and using the Wev IDE build:
#define REMIND_INTERVAL_MINS 1 //60
int toggleLed(String command);
const int triggerPin = D1;
const int resetPin = D3;
FuelGauge fuel;
char publishString[64] = "";
void setup()
{
pinMode(triggerPin,INPUT); // External Pulldown Resistor attached
pinMode(resetPin, INPUT);
sprintf(publishString, "Power Detector Started, Fuel:%.1f%%", fuel.getSoC());
Particle.publish("pushover", publishString);
}
void loop()
{
System.sleep(triggerPin, FALLING);
while(digitalRead(triggerPin) == LOW) // send message every 30mins until power is restored or battery croaks
{
unsigned long start = millis();
while (millis() - start < 1000UL)
{
Particle.process();
}
sprintf(publishString, "Power Loss Detected, Fuel:%.1f%%", fuel.getSoC());
Particle.publish("pushover", publishString);
System.sleep(resetPin, RISING, REMIND_INTERVAL_MINS * 60); // test every X minutes
}
unsigned long start = millis();
while (millis() - start < 1000UL)
{
Particle.process();
}
Particle.publish("pushover", "Particle Power Restored!!");
}
@bpr Hey how did you go about adding all the programs required to build locally? Are you using Windows? I’m on Windows 8.
I use this Toolchain for Windows Installer but the Mingw.zip program did not install correctly so I need to install that manually. You can choose to not install that via clicking the box next to that program.
Are there any instructions you are following that taught you the flow of building locally?
I’m on Windows 10 now. I’m a little fuzzy on the whole process, it’s been a little while. This thread documents most of my stumbling around to the final success: Photon, local build, on Windows
I lucked out and somehow manually installed it all without @mumblepins well-regarded installer
Turned out to essentially be the same to set up the toolchain on 10 as on win 7, i think, though I found and installed a more recent version of gcc (5.2.1 20151202).
The key for me was the path order stuff as mentioned in that thread
So, I noticed that I was getting pretty consistent messages at startup. Reviewing the documentation on sleep (which seems to skirt the whole wakeup part, ironically) I scrolled lower to reset() and voilà. It occurred to me that I could try to just trigger a reset. Well it simplified everything and it **works.
** by works, I mean my Electron seems to take a lot of time negotiating with the cellular network, occasionally timing out (burst of red flashing) but eventually attaches and I get the message.
Well, it is hard to optimize when one cannot figure out how to simply reconnect to cellular!
Right now I am using a SIM card from my unlimited data plan, and I’m not sure If I will even use this application.
Trying to come up with a use for my new Electron, I thought to myself, “what is the easiest and most obvious use of this device” and came up with this one.
BUT, I know that I will enjoy the ride up the learning curve again!
Yea same here. One use I have is a simple mail box delivery detector but that’s not going to work how I want it until System.sleep() is working correctly. I have not gotten any feedback from @Bdub on the latest System.sleep issue where it will not work after 25 mins but considering its a critical feature I’m sure it will get fixed sometime in the future