Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision |
en:iot-open:espressif_es8266_http_led_control [2023/10/10 09:05] – ktokarz | en:iot-open:espressif_es8266_http_led_control [2023/11/23 10:46] (current) – pczekalski |
---|
=== === | ====== Controlling LED with Simple Web Server ====== |
<box #5374d5></box> | {{:en:iot-open:czapka_b.png?50| General audience classification icon }}{{:en:iot-open:czapka_e.png?50| General audience classification icon }}\\ |
<box #5374d5></box> | A sample Web application hosted on ESP8266 MCU is presented below.\\ |
=== Controlling LED with simple Web server === | This application allows it to control the state of the LED remotely, connecting to the ESP8266 board with a web browser. The program presented is based on the example "HelloServer" available in the ''ESP8266WebServer'' library. Some modifications were made to simplify the program and to handle requests to turn the LED on and off. To check if it works, adding WiFi network credentials and setting the ''led'' constant with the number of GPIO to which the LED is connected is required. After a successful connection to the WiFi, ESP8266 would present through the serial monitor the IP address (e.g. 192.168.4.1). Writing in the address bar in the browser "HTTP://192.168.4.1" should return the serial monitor message "hello from esp8266!".\\ |
<box #5374d5></box> | |
<box #5374d5></box> | |
| |
It is possible to control the state of the LED connected to the ESP8266 board using HTTP requests from a web browser. The program presented in this subchapter is based on the example "HelloServer" available in the ESP8266WebServer library. Some modifications were made to simplify the program. To check if it works it is required to add WiFi network credentials, and set the **led** variable with the number of GPIO to which the LED is connected. After a successful connection to the WiFi ESP8266 would present through the serial monitor the IP address (e.g. 192.168.1.100). Writing in the address bar in the browser "192.168.1.100" should return to the serial monitor message "hello from esp8266!". LED behaviour is controlled with the following requests: "192.168.1.100/LED0" and "192.168.1.100/LED1". | Assuming the address in the terminal is ''192.168.4.1'' one may use the following URLs to disable and enable the LED, respectively: |
The example uses MDNS protocol that allows to access the board with the address <code> http://esp8266/ </code>. It is possible to use it instead of IP address: <code> http://esp8266/LED0 http://esp8266/LED1 </code> | <code> |
| http://192.168.4.1/LED0 |
| http://192.168.4.1/LED1 |
| </code> |
| |
<code c> | <code c> |