Problem uploading code to esp8266

Hello. Can anyone help? I've been trying to upload the code for a few days, but an error occurs.
Where am I wrong?

I'm uploading a video with the settings of my Arduino. At the end of the video you can see the error of the program.

I follow the steps on this topic.

all link is here (video, code, etc...) => https://pastebin.com/7132NPhX

Immediately apologize for my English.
Thanks in advance.

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

1 Like

Where did you get the code ?

1 Like

Add this line to the top of your sketch:

#define DEBUGPRINTLN0(x) Serial.println(x)

Good question...

1 Like

I'll leave it to others to deal with the forum etiquette, sending people to read other posts elsewhere instead of you just posting your code directly here etc.

Just replace the 'DEBUGPRINTLN0' with 'Serial.println' and see if it compiles.
I don't know why/how the author of the page you linked to got his code to compile; either something is missing from it or the DEBUGPRINTLN0 synonym was defined in his version of the libraries he included. Just change it into syntactically correct C and see how far you get.

1 Like

Please post your code here as described in the link that I posted

1 Like

yes. this is work. my code upload. no see error. but not connected to WI-FI, and to Domoticz.

OK! :slight_smile: Tnx!

I post a code.

`/* PIR Advanced motion Detection with deep-sleep mode */

ADC_MODE(ADC_VCC); //vcc read

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

// WiFi credentials & Domoticz API IDX.
const char* WIFI_SSID = "<YOUR_WIFI_SSID>";
const char* WIFI_PASS = "<YOUR_WIFI_PASS>";
const char* DOMOTICZ_SRV = "http://192.168.123.100:8080";
const char* DOMOTICZ_SWITCH_IDX = "45";
const char* DOMOTICZ_VOLT_IDX = "22";
const int PIRSignalPin = 14; //Using GPIO14 for PIR Data

void setup() {
HTTPClient http; // HTTP object
String api; // Holds full API string for Domoticz
int httpCode; // Return HTTP code
String response; // Response from HTTP GET request
float vdd; // Internal voltage
String s_vdd; // Internal voltage (formatted as string)

Serial.begin(115200);
Serial.setTimeout(2000);

while (!Serial) { } // Wait for serial to initialize.

Serial.println("");
Serial.println("-------------------------------------");
Serial.println("PIR Motion Detection Firmware!");
Serial.println("-------------------------------------");

// Connect to Wifi.
Serial.print("Connecting to ");
Serial.print(WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASS);

while (WiFi.status() != WL_CONNECTED) {
// Check to see if
if (WiFi.status() == WL_CONNECT_FAILED) {
Serial.println("");
Serial.println("Failed to connect to WiFi. Please verify credentials!");
delay(10000);
} else {
delay(500);
Serial.print(".");
}
}

Serial.println("");
Serial.print("WiFi connected with IP address: ");
Serial.println(WiFi.localIP());

// Send post request to Domoticz
Serial.println("");

Serial.println("Sending On signal to Domoticz.");
//Build API command
api = DOMOTICZ_SRV;
api += "/json.htm?type=command&param=switchlight&idx=";
api += DOMOTICZ_SWITCH_IDX;
if (digitalRead(PIRSignalPin)==HIGH) {
api += "&switchcmd=On";
} else {
DEBUGPRINTLN0("Sending 'Off' signal to Domoticz.");
api += "&switchcmd=Off";
}
http.begin(api); //Specify request destination
httpCode = http.GET(); //Send the request and set return code
Serial.print("Return code: ");
Serial.println(httpCode);
if (httpCode > 0) { //Check the returning code
response = http.getString(); //Get the request response
Serial.println("Response:");
Serial.println(response);
}
http.end(); //Close connection

delay(200);

Serial.print("Sending voltage to Domoticz: ");
vdd = ESP.getVcc() / 1024.0f;
s_vdd = String(vdd, 3);
Serial.println(s_vdd);

api = DOMOTICZ_SRV;
api += "/json.htm?type=command&param=udevice&idx=";
api += DOMOTICZ_VOLT_IDX;
api += "&nvalue=0&svalue=";
api += s_vdd;
http.begin(api); //Specify request destination
httpCode = http.GET(); //Send the request and set return code
Serial.print("Return code: ");
Serial.println(httpCode);
if (httpCode > 0) { //Check the returning code
response = http.getString(); //Get the request response
Serial.println("Response:");
Serial.println(response);
}
http.end(); //Close connection

Serial.println("");
Serial.println("Going into deep sleep!");
ESP.deepSleep(0); // forever

}

void loop() {
// Never reached!
}`

{content removed as it was made redundant due to removal of content by OP}

Anyway, just check your WiFi connection settings. They probably should NOT include the '<' and '>' characters if I were to take a wild guess.

1 Like
/* PIR Advanced motion Detection with deep-sleep mode */

ADC_MODE(ADC_VCC); //vcc read

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

// WiFi credentials & Domoticz API IDX.
const char* WIFI_SSID = "<YOUR_WIFI_SSID>";
const char* WIFI_PASS = "<YOUR_WIFI_PASS>";
const char* DOMOTICZ_SRV = "http://192.168.123.100:8080";
const char* DOMOTICZ_SWITCH_IDX = "45";
const char* DOMOTICZ_VOLT_IDX = "22";
const int PIRSignalPin = 14; //Using GPIO14 for PIR Data

void setup() {
  HTTPClient http;      // HTTP object
  String api;           // Holds full API string for Domoticz
  int httpCode;         // Return HTTP code
  String response;      // Response from HTTP GET request
  float vdd;            // Internal voltage
  String s_vdd;         // Internal voltage (formatted as string)
  
  Serial.begin(115200);
  Serial.setTimeout(2000);

  while (!Serial) { }   // Wait for serial to initialize.
  
  Serial.println("");
  Serial.println("-------------------------------------");
  Serial.println("PIR Motion Detection Firmware!");
  Serial.println("-------------------------------------");

  // Connect to Wifi.
  Serial.print("Connecting to ");
  Serial.print(WIFI_SSID);
  WiFi.begin(WIFI_SSID, WIFI_PASS);

  while (WiFi.status() != WL_CONNECTED) {
    // Check to see if
    if (WiFi.status() == WL_CONNECT_FAILED) {
      Serial.println("");
      Serial.println("Failed to connect to WiFi. Please verify credentials!");
      delay(10000);
    } else {
      delay(500);
      Serial.print(".");
    } 
  }

  Serial.println("");
  Serial.print("WiFi connected with IP address: ");
  Serial.println(WiFi.localIP());

  // Send post request to Domoticz
  Serial.println("");
  
  Serial.println("Sending On signal to Domoticz.");
  //Build API command
  api = DOMOTICZ_SRV;
  api += "/json.htm?type=command&param=switchlight&idx=";
  api += DOMOTICZ_SWITCH_IDX;
  if (digitalRead(PIRSignalPin)==HIGH) {
    api += "&switchcmd=On";
  } else {
    DEBUGPRINTLN0("Sending 'Off' signal to Domoticz.");
    api += "&switchcmd=Off";
  }    
  http.begin(api);                        //Specify request destination
  httpCode = http.GET();                  //Send the request and set return code
  Serial.print("Return code: ");
  Serial.println(httpCode);
  if (httpCode > 0) {                     //Check the returning code  
    response = http.getString();          //Get the request response
    Serial.println("Response:");
    Serial.println(response);
  } 
  http.end();                             //Close connection

  delay(200);

  Serial.print("Sending voltage to Domoticz: ");
  vdd = ESP.getVcc() / 1024.0f;
  s_vdd = String(vdd, 3);
  Serial.println(s_vdd);
 
  api = DOMOTICZ_SRV;
  api += "/json.htm?type=command&param=udevice&idx=";
  api += DOMOTICZ_VOLT_IDX;
  api += "&nvalue=0&svalue=";
  api += s_vdd;
  http.begin(api);                        //Specify request destination
  httpCode = http.GET();                  //Send the request and set return code
  Serial.print("Return code: ");
  Serial.println(httpCode);
  if (httpCode > 0) {                     //Check the returning code  
    response = http.getString();          //Get the request response
    Serial.println("Response:");
    Serial.println(response);
  } 
  http.end();                             //Close connection
  
  Serial.println("");
  Serial.println("Going into deep sleep!");
  ESP.deepSleep(0); // forever

}

void loop() {
  // Never reached!
}

how to write javascript code inside client.println("");

client.println("");

@sandeshkale better open a thread for your question and before doing so (1) select an appropriate category on this forum to post to and (2) read the requirements for posting a new question.

Having said that, you probably have a problem with escape characters Escape sequences - cppreference.com

1 Like

i fix the problem. thx for all.
A replaced code

const char* WIFI_SSID = "<YOUR_WIFI_SSID>";
const char* WIFI_PASS = "<YOUR_WIFI_PASS>";
const char* WIFI_SSID = "YOUR_WIFI_SSID";
const char* WIFI_PASS = "YOUR_WIFI_PASS";

i remove < >

Looks like my wild guess was pretty accurate then.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.