machine.I2C or pyb.I2C?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
chrisb2
Posts: 28
Joined: Sat Apr 01, 2017 4:19 am

machine.I2C or pyb.I2C?

Post by chrisb2 » Sat May 20, 2017 5:27 am

What are the pros and cons of using the machine.I2C or pyb.I2C libraries? Looks like machine.I2C is more 'portable' across the different hardware that MicroPython can run on? Are there any other considerations?

thanks,
Chris

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: machine.I2C or pyb.I2C?

Post by pythoncoder » Sat May 20, 2017 6:56 am

The machine library is portable and includes the facility for software I2C. I recently ported a project from the pyb implementation to machine. This was straightforward and the outcome worked on the Pyboard and the ESP8266.

In other areas pyb offers better Pyboard support. My approach for new projects is to use machine where possible, importing pyb for functionality not yet incorporated in machine.
Peter Hinch
Index to my micropython libraries.

Post Reply