Driver for GY-45 MMA8451 Digital Triaxial Accelerometer

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
ldaponte
Posts: 4
Joined: Sun Dec 16, 2018 10:06 pm

Driver for GY-45 MMA8451 Digital Triaxial Accelerometer

Post by ldaponte » 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.

Thanks

Larry

User avatar
mattyt
Posts: 410
Joined: Mon Jan 23, 2017 6:39 am

Re: Driver for GY-45 MMA8451 Digital Triaxial Accelerometer

Post by mattyt » Mon Jan 07, 2019 11:34 am

Hi Larry,

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!

Cheers,
Matt

Post Reply