Page 1 of 1
Driver for GY-45 MMA8451 Digital Triaxial Accelerometer
Posted: Mon Jan 07, 2019 8:06 am
I’m looking for a MicroPython driver for the GY-45 MMA8451 Digital Triaxial Accelerometer. Something that would work with an ESP8266. I’ve found a CircuitPython driver so I will port this to MicroPython if needed, assuming it is a fairly straight forward procedure. Any guides on differences between the two Python versions that would help me in such a port. I imagine it would help my effort to have a circuit python board when doing such a port.
Re: Driver for GY-45 MMA8451 Digital Triaxial Accelerometer
Posted: Mon Jan 07, 2019 11:34 am
I'd suggest porting; the only difference is in the I2C driver.
Take a look at MicroPython's I2C interface
. Typically you should expect the I2C device to be created and passed in to your class, then just use the 'Standard bus operations' to read/write. The context managers (with device as i2c...) are not necessary in MicroPython. Some of the methods in CircuitPython are a little different - for example I believe write_then_readinto is equivalent to the combination of writeto (with stop=False) followed by readfrom_into.
If you get stuck try the methods at the REPL and see if the device responds as you expect.
Let us know how you go!