Arduino NodeMCU error solved

Hello, I am using NodeMCU Programming board with 2 distance sensors. Two days ago the code worked just fine but now I have a bunch of errors, and I tried even with an example from Arduino basics and still doesn't compile. I updated all the libraries but still nothing....
Here is the code for Arduino :

#include<ESP8266WiFi.h>   //   include ESP8266 library

const char* ssid= "******";    // wifi name
const char* pass= "**********";  // wifi password
const char* server = "";  // server name
String apikey = "********************";  // Api key from website
WiFiClient client;   // create a client Class

const int trigPin = 12;
const int echoPin = 14;
#define SOUND_VELOCITY 0.034

long duration;
float distanceCm;

void setup() {
  Serial.begin(115200);  // Initialize the Serial monitor at 9600 bps
  Serial.print("void loop Robotech and Automation");
  Serial.println("Temperarute and Humidity Sensor");

  WiFi.begin(ssid,pass);  // Wifi Initialization with SSID and PASSWORD
  Serial.print("Connecting to ");
  Serial.print(ssid);  // Print connecting to Wifi name
 // here is waiting to connect internet
  Serial.println(" ");
  Serial.println("connected succesfully to : ");
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input

void loop() {
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculate the distance
  distanceCm = duration * SOUND_VELOCITY/2;
 if (distanceCm > 500)
  Serial.print("Error in measuring");
 else {
  // Prints the distance on the Serial Monitor
  Serial.print("Distance (cm): ");
if(client.connect(server, 80))
  String postreq = apikey;
  postreq += "&field1=";
  postreq += String(distanceCm);
  postreq += "\r\n\r\n";

  client.print("POST /update HTTP/1.1\n");
  client.print("Connection: close\n");
  client.print("X-THINGSPEAKAPIKEY: " + apikey + "\n");
  client.print("Content-Type: application/x-www-form-urlencoded\n");
  client.print("Content-Length: ");

I get errors like :
Arduino: 1.8.16 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"
undefined reference to ets_post' undefined reference to vPortFree'
and a bunch of others like this
Can someone please help me with that . Thank you

builds on my Win10 PC target board "NodeMCU 1.0 (ESP-12E Module" without problems

can only assume you have currupt libraries???
can you try it on a different PC?

1 Like

Thank you, I reinstalled Arduino and its libraries and now it works

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