SK6812 LEDs, Tasmota and Home Assistant

Installing the requirements should be easy, just run:

$ pip3 install --user platformio

Truncated output should look like this:

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting platformio
  Downloading https://files.pythonhosted.org/packages/15/58/49a7134412731bd585f996d9c69e70f7eff0bacf795a7a55524dadf412cd/platformio-4.3.1.tar.gz (169kB)
    100% |████████████████████████████████| 174kB 1.2MB/s
<snip>
Successfully built platformio
Installing collected packages: bottle, marshmallow, pyelftools, semantic-version, tabulate, platformio
Successfully installed bottle-0.12.18 marshmallow-3.5.1 platformio-4.3.1 pyelftools-0.26 semantic-version-2.8.4 tabulate-0.8.7

To set up the drivers to use the SK6812 properly, there’s a few configuration changes that need to be done. Open Tasmota/tasmota/my_user_config.h in a text editor and search for USE_WS2812. You’ll want to update the next few lines to match these. We’re going to make sure the DMA thing’s commented out, (// at the start of the line), the hardware’s set to be right, and the colour type is set to GRBW, because SK6812’s have their colours in a different order.

#define USE_WS2812
//  #define USE_WS2812_DMA
#define USE_WS2812_HARDWARE NEO_HW_SK6812
#define USE_WS2812_CTYPE NEO_GRBW

If you do all this and you set a colour of red and it comes out green, the colours are backwards and you need to make sure you set NEO_GRBW not NEO_RGBW

Now run platformio to compile your binary. The -e flag sets the environment, skipping unnecessary ones, run this from the base Tasmota directory.

$ platformio run -e tasmota
Processing tasmota (platform: espressif8266@2.4.0; framework: arduino; board: esp01_1m)
------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp01_1m.html
PLATFORM: Espressif 8266 2.4.0 > Espressif Generic ESP8266 ESP-01 1M
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
PACKAGES:
 - framework-arduinoespressif8266 372a3ec2
 - tool-esptool 1.413.0 (4.13)
 - tool-esptoolpy 1.20800.0 (2.8.0)
 - toolchain-xtensa 2.40802.191122 (4.8.2)
Converting tasmota.ino
<snip>
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [======    ]  55.2% (used 45188 bytes from 81920 bytes)
Flash: [=====     ]  48.8% (used 499736 bytes from 1023984 bytes)
Creating BIN file ".pioenvs/tasmota/firmware.bin" using ".pioenvs/tasmota/firmware.elf"
bin_map_copy([".pioenvs/tasmota/firmware.bin"], [".pioenvs/tasmota/firmware.elf"])
bin_gzip([".pioenvs/tasmota/firmware.bin"], [".pioenvs/tasmota/firmware.elf"])
=== [SUCCESS] Took 221.20 seconds ===

Environment       Status    Duration
----------------  --------  ------------
tasmota           SUCCESS   00:03:41.202
= 1 succeeded in 00:03:41.202 =

Now it’s time to write the binary to the device.

esptool.py --port /dev/ttyUSB0 write_flash -fs 1MB -fm dout 0x0 .pioenvs/tasmota/firmware.bin

This assumes you’re on a linux machine, the bit after --port could be COM5 if you’re on windows or /dev/cu.somethingweird on macOS depending on your particular device and OS.

The only other thing you should have to do from here is set up Tasmota. These things go into the console.

  1. Pixels 60 Depending on how many pixels on your strip.
  2. Color #FF000000 to test it goes red.
  3. Color #00FF0000 to test it goes green.
  4. Color #0000FF00 guess what this’ll be?
  5. Color #000000FF to check white’s a thing too.
  6. SetOption19 1 Run this when you’ve done all your other config to enable Home Assistant auto-discover.

tl;dr

# Grab the source:  
git clone https://github.com/arendst/Tasmota
cd Tasmota

# Edit the config (make sure the GRBW and device lines are changed)
vi tasmota/my_user_config.h

# Install the requirements
pip3 install --upgrade pip; pip3 install --user platformio

# Build the firmware
platformio run -e tasmota

# Install the firmware
esptool.py --port /dev/ttyUSB0 write_flash -fs 1MB -fm dout 0x0 .pioenvs/tasmota/firmware.bin


#tasmota #programming #embedded #home assistant #leds #sk6812