Authorized Online Retailers:



In this lesson, we will show how to use NodeMCU to work as Web Server to get remote temperature/humidity from DHT11 sensor and control LED throw browser(or mobile APP).





3.3v or 5v VCC
D4 S(data)
D3 LED long pin
GND LED short pin through resistance

Upload Sketch

Connect the NodeMCU to computer via USB cable,download sketch from and load it into Arduino IDE(Version1.6.4+), Make sure DHT library and NodeMCU library has been installed in Arduino IDE. If you have not installed these library, read Lesson 1 and DHT library installation guide:

Edit the code to fit your own WiFi and MQTT settings as following operations:

1)Hotspot Configration:

const char* ssid = "your_hotspot_ssid";

const char* password = "your_hotspot_password";

After do that,choose the corresponding board type and port type as below,then upload the sketch to the NodeMCU.

Running Result

Once the upload done,if wifi hotspot ssid and password setting is ok, all the connections are normal, open the Serial Monitor(set baud rate to 115200 in lower right corner),you will see following result:

Now you can see the nodemcu_ip_address of your IoT web server is, write down this IP address and we will use this ip address to access the web page.

Now go to your PC which is in the same LAN of NodeMCU wifi router, open browser and visit url: http://nodemcu_ip_address (in our example, nodemcu_ip_address  is

You will see web page as following:

When you click Turn on LED button in this page, the LED connected to D3 will turn on and web page will show as following:

When you click Display Temperature and Humidity Button, the Web Page will show DHT11 temperature and humidity value as following: