ESP8266 Connect & POST on Button press
Posted: Thu Oct 08, 2015 11:38 pm
I'm trying to modify some code I found to add a button press versus the constant connect and post cycle/loop using the Arduino IDE.
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.
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.
Code: Select all
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
}