This project was made basically in order to explore the possibilities of Espruino firmware.
The index.js
contains logic of several modes of operation of the LED strip, e.g. blink, rainbow, running dots. These modes can be changed through the web interface.
The html page also displays information about the temperature and humidity in the room from the connected DHT22 sensor.
On first boot the wifi starts in access point mode with Espruino_Server
SSID.
Connect to it and type 192.168.4.1
in the browser to open web interface.
If you wish to connect to an existing wifi network you need open /wifi
page, type SSID and password, click submit and reboot the microcontroller.
We will use Espruino to programming ESP8266 microcontroller on JavaScript language. There is a page with the features and limitations of this firmware on esp8266. Implemented JavaScript features in espruino can be found here.
If you try to flash the microcontroller first time, you may need to install driver for CH340. NodeMCU usually has this microschema on the board, but if your has another chip, e.g PL2303HX or CP2102, then you need to install driver for yours.
NodeMCU module do not require special preparation for flashing as for ESP-01, and you do not need USB-TTL adapter. Just connect module to your PC via USB cable and execute the command
$ /path/to/esptool/esptool.py --port /dev/ttyUSB0 --baud 115200 \
write_flash --flash_freq 80m --flash_mode qio --flash_size 32m \
0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin \
0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin
You may find more information about flashing here.
By default the led strip is connected to pin 12 (D6) and DHT22 is connected to pin 13 (D7). You may change this at any time, just change variables LED_STRIP_PIN
and DHT_PIN
in the code. Please note, not all pins are available for connection of external hardware.
The full connection schema is following:
- LED: connect power to VIN, gnd to gnd, dat to D6 (pin 12)
- DHT22: connect power to 3v pin, gnd to gnd, dat to D7 (pin13)
- Open Web IDE
- Click the connect button at the left top corner
- Choose the port which microcontroller connected to
- If everything is ok you go to REPL mode
- Copy the code to the right part of window
- Change destination to flash (arrow near icon in the middle of window) and click on this button to start flashing