ESP8266 first code help

 postStr += String(deviceId);
    postStr += "&message_parameter=";
    postStr += String(message);
    postStr += "\r\n\r\n";

there is in the ending
still sometime work and some time no

now I understand
and if I connect the sensor to GPIO3 I will not be able to "debug" it - right?
or can I ? because I don't send any data to the device using serial . just read data using the serial

I just need to use 1 GPIO ...

Thanks ,

You can use GPIO2 to debug (Serial1).
Or you could debug over the network.

how can I debug over the network\GPIO2?

what I need to change in the code? wire setting?

if I change my code to work with GPIO3 - will it work?

Thanks ,

To use GPIO2 for debugging, just use Serial1 instead of Serial.
Over the network is more involved.

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,

here too

    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);

[/quote]

look at the code again
there is

 client.print("\n\n");

everywhere

where do you want to me to add?

Thanks ,

    client.println("POST /pushingbox HTTP/1.1");
    client.println("Host: api.pushingbox.com");
    client.println("Connection: close");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.print("Content-Length: ");
    client.println(postStr.length());
    client.println();
    client.println();
    client.print(postStr);

\n\n is not \r\n\r\n

PieterP:
To use GPIO2 for debugging, just use Serial1 instead of Serial.

Everywhere you're using "Serial.println()" for example, just use "Serial1.println()" instead.

but I need to declare what is serail1 , no ?

No.
Please read the documentation.

sorry - my mistake
I have change it
but still not working
It work 4-5 times , but after nothing I get no notification ,
but in the serial+wiresahrk I can see he send the command , but nothing
any more ideas?

Thanks ,

david1234:
sorry - my mistake
I have change it
but still not working
It work 4-5 times , but after nothing I get no notification ,
but in the serial+wiresahrk I can see he send the command , but nothing
any more ideas?

Thanks ,

read the response and print it to Serial

PieterP:
No.
Please read the documentation.

I am guessing you did not see that he wasted your time with his duplicate post.

ieee488:
I am guessing you did not see that he wasted your time with his duplicate post.
http://forum.arduino.cc/index.php?topic=549270.0

I didn't, thanks for pointing it out.

@david1234: Stop wasting everyone's time by discussing the same problem across multiple threads!

this is not the same
here I had a problem with the hardware connection and setting
this problem solve thank to you -and I understand my mistake.
so thank you again for helping me here !

in other post I have a probelm sending the notification
I don't think it the same problem - therefor I open another post ......

if you think it duplicate - I will "close" this one and only response to the other one

again - I don't think it's the same problem