MicroPython M5Stack support
MicroPython M5Stack support
Hi,
A noob question:
I recently got an M5Stack board and want to run MicroPython on it. Since the default UIFlow firmware seems to be bloated with a lot of unnecessary stuff, I decided to flash the MicroPython firmware on it. So far, this wasn't an issue. Seems to work fine.
But now I wonder what I need to do to get the M5Stack Python libraries installed and running? Is it possible to get them installed in the MicroPython firmware?
A noob question:
I recently got an M5Stack board and want to run MicroPython on it. Since the default UIFlow firmware seems to be bloated with a lot of unnecessary stuff, I decided to flash the MicroPython firmware on it. So far, this wasn't an issue. Seems to work fine.
But now I wonder what I need to do to get the M5Stack Python libraries installed and running? Is it possible to get them installed in the MicroPython firmware?
Re: MicroPython M5Stack support
You could use this : M5Stack's fork of lobo's micropython fork.
Re: MicroPython M5Stack support
Ok. The same then. As far as I can tell, this firmware should contain most of the M5Stack's peculiarities. Normally help('modules') should show m5stack and others (ubutton, units) as well as other specific and as undocumented modules written in C (m5ui etc)... Looking at units.py, I discovered a mention to at least two modules that are not included in the repo: dht12 and bmp280. Both can be found on the web...
As I said, it should. I have not tested it: flashing the firmware would erase the file system, and force me to reinstall all my personal files.
As I said, it should. I have not tested it: flashing the firmware would erase the file system, and force me to reinstall all my personal files.
Re: MicroPython M5Stack support
[quote=fstengel post_id=34555 time=1551775485 user_id=3920]
Ok. The same then. As far as I can tell, this firmware should contain most of the M5Stack's peculiarities. Normally [b]help('modules')[/b] should show [b]m5stack[/b] and others ([b]ubutton[/b], [b]units[/b]) as well as other specific and as undocumented modules written in C ([b]m5ui[/b] etc)... Looking at [b]units.py[/b], I discovered a mention to at least two modules that are not included in the repo: dht12 and bmp280. Both can be found on the web...
As I said, it should. I have not tested it: flashing the firmware would erase the file system, and force me to reinstall all my personal files.
[/quote]
dht12 and bmp280 are there somewhere because that is what the M5Stack environmental sensor uses.
Ok. The same then. As far as I can tell, this firmware should contain most of the M5Stack's peculiarities. Normally [b]help('modules')[/b] should show [b]m5stack[/b] and others ([b]ubutton[/b], [b]units[/b]) as well as other specific and as undocumented modules written in C ([b]m5ui[/b] etc)... Looking at [b]units.py[/b], I discovered a mention to at least two modules that are not included in the repo: dht12 and bmp280. Both can be found on the web...
As I said, it should. I have not tested it: flashing the firmware would erase the file system, and force me to reinstall all my personal files.
[/quote]
dht12 and bmp280 are there somewhere because that is what the M5Stack environmental sensor uses.
Re: MicroPython M5Stack support
Indeed they should be. However, it seems that the M5Stack github repo is incomplete or way behind the (private?) repo used for building the firmware used with UIFlow. This is annoying.
Re: MicroPython M5Stack support
Ahh the repo!
sorry I'm only working on the precompiled firmware as I'm working on a UIFlow book.
Re: MicroPython M5Stack support
DHT12 for micropython : https://github.com/mcauser/micropython-dht12
BMP280 : https://github.com/Dafvid/micropython-bmp280
BMP280 works fine. but DHT 12 sometimes throw out error message like checksum error or OSError: [Errno 19] ENODEV. I'm not sure the error is due to hardware or code. below is the code:
from machine import I2C, Pin, reset
from dht12 import DHT12
from bmp280 import BMP280
from time import sleep
i2c = I2C(scl=Pin(22), sda=Pin(21), freq=100000)
sensor = DHT12(i2c)
bmp = BMP280(i2c)
def getV():
sensor.measure()
print(sensor.temperature() + "C")
print(sensor.humidity() + "%")
print(bmp.pressure / 1000 + "KPa")
BMP280 : https://github.com/Dafvid/micropython-bmp280
BMP280 works fine. but DHT 12 sometimes throw out error message like checksum error or OSError: [Errno 19] ENODEV. I'm not sure the error is due to hardware or code. below is the code:
from machine import I2C, Pin, reset
from dht12 import DHT12
from bmp280 import BMP280
from time import sleep
i2c = I2C(scl=Pin(22), sda=Pin(21), freq=100000)
sensor = DHT12(i2c)
bmp = BMP280(i2c)
def getV():
sensor.measure()
print(sensor.temperature() + "C")
print(sensor.humidity() + "%")
print(bmp.pressure / 1000 + "KPa")
Re: MicroPython M5Stack support
One thing about the DTH series is their low sample rate (around 1Hz). It is very possible you overwhelm the sensor by requesting values too frequently. Another thing would be to encapsulate the measures within a try: except: block and manage the errors...