NodeMCU board (ESP8266) with JavaScript
This repository provides a little introduction into getting going with the NodeMCU board (1.0/v2) and Espruino (JavaScript for Microcontrollers, v1.87). It provides an installation guide and some examples.
Examples
Title | Description |
---|---|
Hello World | A simple Hello World example |
Blink | A simple example to flash the integrated LED |
Wi-Fi | A simple example to connect to a Wi-Fi AP and make the NodeMCU board available through espruino.local |
HTTP Server | A simple Web Server to control the integrated LED |
Installation
I spent 2-3 days to make everything working, so I decided to provide a compressed folder (esptool.py v1.2 & Espruino v1.87) with everything you need to flash the firmware.
You probably need to install pyserial
for using the esptool.py
. It can be achieved with sudo easy_install pyserial
(macOS), sudo apt-get install python-serial
(Linux) or sudo pip install pyserial
.
Move inside the downloaded folder
cd Downloads
cd Espruino_v1_87
Erase the flash memory
python esptool.py --port /dev/tty.SLAB_USBtoUART erase_flash
Flash the NodeMCU with Espruino
python esptool.py --port /dev/tty.SLAB_USBtoUART --baud 115200 write_flash --verify --flash_freq 80m --flash_mode dio --flash_size 32m 0x0000 "boot_v1.4(b1).bin" 0x1000 espruino_esp8266_user1.bin 0x37E000 blank.bin
After flashing the firmware, you may have to unplug/plug the NodeMCU to the computer. To test the installation process, you can use Screen
and send some JavaScript code, like process.memory()
or digitalWrite(NodeMCU.D4, HIGH);
to turn on the built-in led.
screen /dev/tty.SLAB_USBtoUART 115200
Launch Google Chrome, install the Espruino Web IDE
(extension) and modify the Baud Rate to 115200
(Espruino Web IDE > Settings > Communications > Baud Rate).
It's possible to program the board Over-The-Air by defining a hostname and configuring a connection to it. Use the Wi-Fi example and add its hostname espruino.local:23
in the configuration (Espruino Web IDE > Settings > Communications > Connect over TCP Address).
Sources
- Run Espruino on the NodeMCU devkit
- Espruino Hardware Reference
- Download Espruino
- CP210x USB to UART Bridge VCP Drivers
- Esptool.py
- Tutorials and examples
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.