Good day.

The NodeMCu successfully connected to mobile hotspot when i didn't put any others codes except the Wifibegin etc.

Howveer when I include some codes for temparature sensor, it keeps on connecting whereas the everything else including the SSID, password remain the same.

Below are my codes, I tried many, I mean I tried almost everything possible(that's stated in forums), read forums after forum. Please let me know if I missed something out here.


PS: i attached my codes here

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

/* Wi-Fi setting connect to your smartphone Wi-Fi hotspot */
const char *ssid = "Thanks";
const char *password = "​For reading";

/* Variable for taking out LM35 value */
String tempValue;
int analogValue;
int tempPin = A0;
float milliVolts;
float celcius;
/* Variable for sending data to server */
String postData;
int httpCode;
String payload;
void setup(){
/* If Wi-Fi hotspot is not found, show ..... in serial monitor */
/* If Wi-Fi hotspot is found, show IP address in serial monitor */
Serial.println("Connected to ");
Serial.println("IP address: ");
void loop(){
/* Getting value from LM35 */
analogValue = analogRead(tempPin);
milliVolts = (analogValue/1024.0)*3300;
celcius = milliVolts/10;
tempValue = String(celcius);
/* Sending LM35 value to server */
HTTPClient http;
postData = "tempValue=" + tempValue;
httpCode = http.POST(postData);
payload = http.getString();
Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload
  • 1
    Your code is missing from the question. Also, what temperature sensor did you use and what pins did you use to connect your sensor? – StarCat Mar 26 at 13:50
  • @StarCat Hello. Thanks for replying..Edited. Codes as attached. 3.3V, GND,A0 – nelson wong Mar 26 at 14:05

Get rid of the delay - this STOPS processing for five seconds, not really what you want in a wifi scenario - some routers might disconnect you in this time if no pingbackis are coming
If you need a 5 second- non blocking break for your routines look at this example
ArduinoIDE -> examples -> 2 Digital -> blinkwithoutdelay.
For further assistance copy and paste your code in code tags and not as a picture.

| improve this answer | |
  • Hello . Thanks for your feedback. I edited and pasted the code in text form. I tried omitting the delay(5000), but still doesn't work out... I reexamine the codes, and can't see the prob, please let me know you can detect the problem...thank you!!! – nelson wong Mar 28 at 2:15
  • You still have delay in your loop, as long as you use delays debugging is useless /* Getting value from LM35 */ delay(1000); => get rid replace with something if(millis() - startTime < timeToWait)... >> see blinkwithoutdelay example – Codebreaker007 Mar 28 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.