The raw code is here: https://github.com/Astu04/Pushetta_ESP8266
I figure you'd just add in an "if " statement then if button state high/true run through the connection process.
I couldn't find any reference to using button or triggers to connect and using the Arduino IDE, ideally I'd love to have some sort of input trigger the connection versus the connection being available all the time.
Also some sort of sleep mode to cut down on power consumption (that's another story I guess)
My code is similar to this - I get the impression that the TCP connection is creating issues.
void loop()
{
if (buttonState = =HIGH) {
Serial.println("Connecting to Pushetta");
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 80;
if (!client.connect("api.pushetta.com", httpPort)) {
Serial.println("Connection failed");
return;
}
sendToPushetta(CHANNEL, "Hello world!");
delay(60000);
}
}
else {
//do nothing
}