Using my M5Stack with Blynk makes sense: it has plenty sensors and a display and LEDs.
- Update M5Stack firmware to v1.7.0 via the M5Burner
- Have ampy installed
- Download BlynkLib.py from https://github.com/vshymanskyy/blynk-library-python
- Set your M5 into “APP Mode” to be able to use the REPL reliably (boot, hit Setup button, select mode, reboot)
- Upload BlynkLib.py:
❯ export AMPY_PORT=/dev/ttyUSB0
❯ export AMPY_BAUD=115200
❯ ampy ls /flash
/flash/apps
/flash/blocks
/flash/boot.py
/flash/emojiImg
/flash/img
/flash/main.py
/flash/res
❯ ampy mkdir /flash/lib
❯ ampy put BlynkLib.py /flash/lib/BlynkLib.py
❯ ampy get /flash/boot.py > boot.py
# Edit boot.py to include /flash/lib in the Python search path
# Like this:
#import machine, os, sys
#try:
# sd = machine.SDCard(slot=3, miso=19, mosi=23, sck=18, cs=4)
# sd.info()
# os.mount(sd, '/sd')
# print("SD card mounted at \"/sd\"")
# sys.path.append('/flash/lib')
#except:
# pass
❯ ampy put boot.py /flash/boot.py
- Now put your M5Stack back into Internet Mode and reboot
- Connect via https://flow.m5stack.com to your M5Stack
Sample program:
from m5stack import *
from m5ui import *
from uiflow import *
import BlynkLib
BLYNK_AUTH = "YOUR_BLYNK_AUTH_KEY"
blynk = BlynkLib.Blynk(BLYNK_AUTH)
setScreenColor(0x000000)
lcd.clear()
# Register virtual pin handler
@blynk.on("V3")
def v3_write_handler(value):
v=int(value[0])
s='Current slider value:'+str(v)+'.'
lcd.clear(0x000000)
lcd.text(0, 20, s)
while True:
blynk.run()
Using the Bylnk App update Virtual Pin 3 and the value should be displayed on the M5Stack’s LCD.