Skip to content

Instantly share code, notes, and snippets.

@fliphess
Last active June 13, 2018 13:07
Show Gist options
  • Save fliphess/c200208320df69ee0149e2efd59e04a5 to your computer and use it in GitHub Desktop.
Save fliphess/c200208320df69ee0149e2efd59e04a5 to your computer and use it in GitHub Desktop.
esp_milight_hub

Flashing a newer version of the esp milight hub to your nodemcu v2

Prerequisites

Connect the NRF24L01+ to the NodeMCU

To connect the nodemcu to the NRF24L01+ transceiver, use the following pins:

NODEMCU PIN NRF24L01+ PIN
3V (NOT Vin) VCC
G GND
D0 CE
D5 (HSCLK) SCK
D6 (HMISO) MISO
D7 (HMOSI) MOSI
D8 (HCS) CSN

The pins of the NRF2401+:

nrf

The pins of the NodeMCU:

nodemcu

Install esptool.py

Install esptool from Expressif through pip or by downloading a recent-ish release (mine is from last year but still suffices)

Download a newer esp_milight_hub firmware

The current version I used is the latest stable release from github: 1.6.5.

Go to esp_milight hub releases to download a newer bin file.

Download the prebuild bin file for the esp8266 version of your choice. In this case the nodemcuv2:

URL="https://github.com/sidoh/esp8266_milight_hub/releases/download/1.7.0-dev3/esp8266_milight_hub_nodemcuv2-1.7.0-dev3.bin"
wget -O /tmp/milight.bin "$URL" 

Flash the new firmware on the NodeMCU

Getting started

To flash the nodemcu, connect it to your usb port. I recommend using a powered USB hub in between when you are using a laptop, as these little fuckers need a stable power source when flashing. If your upload fails with undetermined errors, try again using a powered USB hub ;)

Install The USB to serial drivers

You might need to install the CP210X USB to UART Bridge VCP Drivers first to connect to the serial device of the NodeMCU.

Flashing

To flash the firmware, use the following command:

esptool.py --port /dev/cu.SLAB_USBtoUART write_flash -fm dio 0x00000 /tmp/milight.bin

If you have multiple serial devices connected, the /dev/cu.SLAB_USBtoUART device might have a slighlty different name like /dev/cu.SLAB_USBtoUART_114 or something.

For more information about flashing, check the flashing page in the nodemcu manual

Troubleshooting

Test if your serial is functioning ok

To test if you serial connectivity is functional, you can read the chip_id of the nodemcu:

esptool.py --port /dev/cu.SLAB_USBtoUART chip_id

Hard reset the flash of the nodemcu

In case of undefined errors while running and or errors when flashing, most of the times it helps if you do a erase_flash (hard reset) To do this, use the following command:

esptool.py --port /dev/cu.SLAB_USBtoUART erase_flash

After this you'll have to re-upload the bin file

Upload / Flashing results in a nonresponsive nodemcu

If the esptool.py method doesn't work, you can try PlatformIO alternatively. This is a little more work, and takes a bit longer, but is a more robust and stable way to flash the esp_milight_hub firmware.

To use the platformio method you need install nodejs with npm, python and python-dev

To use platformio to flash the firmware:


# install platformio 
pip install -U https://github.com/platformio/platformio-core/archive/develop.zip

# clone repo
git clone https://github.com/sidoh/esp8266_milight_hub.git &&  cd esp8266_milight_hub

# flash firmware
export ESP_BOARD=nodemcuv2
platformio run -e $ESP_BOARD --target upload

Useful links

To connect the milight lights to home-assistant, use the instructions from the author of the esp milight hub Chris Mullins.

More instructions of how to use the esp_milight_hub, have a look at the github wiki of the project.

To find out how to connect any es8266 board with a NRF2401 module, have a look in the documentation from mysensors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment