Node MCU LED Control:
About project
Thanks to this project I have learned how to control actuating device (LED diodes) via sending requests http.
To represent LED lights I used power of 2:
GREEN = 2^0 = 1
YELLOW = 2^1 = 2
RED = 2^2 = 4
Project contains:
- http server written in GO,
- client code for ESP8266 in INO = listening one endpoint, and depending on its value control LEDs
Project features:
- control LED lights via HTTP
- logging of LED changes
HARDRWARE PART:
Traffic lights LED module:
ESP 8266 : Pinouts
ESP8266 PINOUT | LED MODULE |
---|---|
GND | GND |
D1 | R |
D2 | Y |
D4 | G |
SERVER ENPOINTS:
Set LED's status:
`http://IP:5108/led/setstatus?led=value`
Where:
- IP = your computer's IP address, where api is running
- Value = Integer value from 0 to 7
LED Statues:
Check LED's status:
http://IP:5108/led/checkstatus
Return: integer value which representing LEDs turn on status (see table above)
RUN PROJECT INSTRUCTION:
- RUN server:
- go to
web
folder - use command
go run .
- go to
- ESP8266:
- use Arduino IDE to edit code: edit
SSID
andpassword
- connect LED module to ESP8266 in the right way
- upload code to your ESP via Arduino IDE
- use Arduino IDE to edit code: edit
- TEST:
- Send request via Postman to endpoint:
/led/setstatus?led=
- Observe change on LED lights
- Send request via Postman to endpoint: