can you explain howto?
what I need to change in the code?
/************
GeeksTips.com
ESP8266 Arduino Tutorial - Push notification messages example
Arduino code example
www.geekstips.com
- replace the dots with your Wi-fi credentials and
- your deviceId from pushingBox account
*/
#include <ESP8266WiFi.h>
// PushingBox scenario DeviceId code and API
String deviceId = "v124511AAZA63CAB";
const char* logServer = "api.pushingbox.com";
const char* ssid = "David";
const char* password = "123456d3e4f5";
const int GPIO2 = 2;//door sensor input [b]--->this I will change to 3[/b]
bool sending = false;
void setup() {
Serial.begin(115200);
delay(1);
// Sending a notification to your mobile phone
// function takes the message as a parameter
Serial.println("- connecting to Home Router SID: " + String(ssid));
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("- succesfully connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
delay(500);
pinMode (GPIO2 , INPUT);
delay(1500);
sendNotification("Sensor is now OnLIne!!");
}
void loop()
{
if (digitalRead(GPIO2) == LOW)
{
String line = "Door1 is Close";
if (sending == false)
{
Serial.println(line);
sendNotification(line);
sending = true;
}
}
else
{
String line = "Door1 is Open";
if (sending == true)
{
Serial.println(line);
sendNotification(line);
sending = false;
}
}
}
void sendNotification(String message) {
Serial.println("starting client");
WiFiClient client;
Serial.println("- connecting to pushing server: " + String(logServer));
if (client.connect(logServer, 80)) {
Serial.println("- succesfully connected");
Serial.println(deviceId);
String postStr = "devid=";
postStr += String(deviceId);
postStr += "&message_parameter=";
postStr += String(message);
postStr += "\r\n\r\n";
Serial.println("- sending data...");
client.print("POST /pushingbox HTTP/1.1\n");
client.print("Host: api.pushingbox.com\n");
client.print("Connection: close\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
Serial.println(postStr);
}
client.stop();
Serial.println("- stopping the client");
}
what else?
except the wiring of the serial to GPIO2 and not U0RXD(GPIO3)?
Thanks,