microPython already has build in support for APA102: http://docs.micropython.org/en/latest/esp8266/esp8266/quickref.html#apa102-driver So it is easy to use the Blinkt! with an ESP8266 running microPython firmware.
You can find Blink! on Pimoroni Web Shop: https://shop.pimoroni.com/products/blinkt
From an hardware point of view the Blinkt! require:
- 5V on pin 2
- Ground on pin 6
- BMC 23 on pin 16
- BMC 24 on pin 18
- See more on https://pinout.xyz/pinout/blinkt
Unfortunately, on my ESP8266 I don't have 5V (when USB is not connected), but only regulated 3V. But by chance, the APA102 is OK with that, maybe it is less bright, but good enough for me.
AFAIR, I choosed 13 and 14 as GPIO on the ESP8266. I guess 13 to be connected to 23 and 14 to 24.
To make it even more easy, and be able to reuse Blinkt! example, I created a think layer that provide the same API as the Blinkt! library.
To help run more example "out of the box", I added some more helper library for missing function in microPython.
-
I put all my library (those that you "import") in the lib folder. That folder does not exist by default, but is in the default search path. So this is the right place to put such file.
-
I only do microPython from the REPL, so to create file I use a trick with f.write(''' This require to us the paste without indentation and no to do too big files. Feel free to install any other way.
-
There are other issue that make using Blinkt! code example difficult:
3.1) There is not colorsys library build in, so I made a mini version with what I need.
3.2) You can not really execute a python script, you can only import the file, once. So it is best to create a main function and call that one when you want.
3.3) There is no decent random library and a lot of example use integer random number. I provided a mini implementation of the function needed.
3.4) The time resolution is to the second only, so no decimal value. It is best to use time.ticks_ms() if sub second precision is required.
Except for point 3.4 that require some deep change in the code, most example might work "out of the box". You will find my version of the rainbow.py example that work. Make sure you put this file at the root of the "filesystem".
If you want to auto-start some example when you power the ESP8266, you can use "main.py" file for that:
import my_rainbow my_rainbow.main()
You can find other example using Blinkt on the github of the Blinkt! library: https://github.com/pimoroni/blinkt/tree/master/examples
Here will come a tentative to see what example are likely or unlikely to work on ESP8266
- 1d_tetris.py This fail, but I don't know why. I don't see why it would not work.
- binary_clock.py There is no RTC on my ESP8266 and localtime() does not produce the same tuple as in Python3.
- binary_clock_meld.py See above
- cheerlights.py Making this one work should be a goal as typically IoT, but module requests is missing, there is a some copy floating, that lack TSL support. Would need to try harder.
- cpu_load.py Not workinkg or likely useless on ESP8266
- cpu_temp.py Not working or likely useless on ESP8266
- gradient_graph.py WORKING by (1) removing "set_clear_on_exit()" that is not implemented (2) using time.ticks_ms()/500 rather than time.time() * 2
- graph.py WORKING by (1) removing "set_clear_on_exit()" that is not implemented (2) using time.ticks_ms() / 1000 rather than time.time()
- larson.py WORKING by changing time: start_time = time.ticks_ms() and delta = (time.ticks_diff(start_time,time.ticks_ms())) / 1000 * 16 ... after some time I get the following error: "IndexError: list index out of range". Making the array bigger by one might help, for unknown reason
- larson_hue.py NOT TESTED
- mem_load.py Not working or likely useless on ESP8266
- morse_code.py WORKING as is without modification
- mqtt.py FAIL because paho.mqtt.client is not available
- pulse.py FAIL because numpy is not available
- rainbow.py WORKING with provided version
- random_blink.py FAIL because at random.sample(range(8), random.randint(1, 5)) because random.sample is not implemented
- random_blink_colours.py WORKING as is without modification (but fake set_clear_on_exit)
- resistor_clock.py There is no RTC on my ESP8266 and localtime() does not produce the same tuple as in Python3.
- rgb.py FAIL we can not execute python script in microPython, so passing parameter fail
- solid_colours.py WORKING as is without modification (but fake set_clear_on_exit)
- twitter_monitor.py Library tweepy likely missing and/or too big and/or relying on missing library
For Blinkt! usage, the new version of random.py is not required.
That new version only add an implementation of sample that I need for another project.