busio module contains classes to support a variety of serial
When the microcontroller does not support the behavior in a hardware
accelerated fashion it may internally use a bitbang routine. However, if
hardware support is available on a subset of pins but not those provided,
then a RuntimeError will be raised. Use the
bitbangio module to explicitly
bitbang a serial protocol on any general purpose pins.
All classes change hardware state and should be deinitialized when they
are no longer needed if the program continues after use. To do so, either
deinit() or use a context manager. See
Lifetime and ContextManagers for more info.
import busio from board import * i2c = busio.I2C(SCL, SDA) print(i2c.scan()) i2c.deinit()