![]() I2c.readfrom_mem(42, 8, 3) # read 3 bytes from memory of slave 42, I2c.readfrom(42, 4) # read 4 bytes from slave with 7-bit address 42 I2c.writeto(42, b'123') # write 3 bytes to slave with 7-bit address 42 I2c.scan() # scan for slaves, returning a list of 7-bit addresses I2c = I2C(1, freq=400000) # create I2C peripheral at frequency of 400kHz PinĪn example of using I2C follows: from machine import I2C The following table shows the pin layout associated with the example below. The appropriate I/O configuration will be performed automatically. Note You are not required to configure the XBee I/O using AT commands prior to creating an I2C object. Using the scl and sda parameters to select pins is not valid on the XBee device. The only valid value is 1, which uses DIO1 for SCL and DIO11 for SDA. The I2C implementation is provided through hardware, so when you use machine.I2C to initialize I2C, use the id parameter to select the interface. The MicroPython API is the same as documented in the MicroPython library reference except that the XBee device does not support primitive operations or the deinit operation. This allows you to perform basic sensing and actuation with I2C devices such as sensors and actuators via MicroPython without an additional microcontroller. The XBee device can function as an I2C master controlled by MicroPython. ![]() Printing the I2C object gives you information about its configuration. They can be initialized when created, or initialized later on. When created, I2C objects are associated with a specific two wire bus. At the physical level it consists of two wires: SCL and SDA, the clock and data lines respectively. I2C is a two-wire protocol for communicating between devices. Note This section only applies to devices that support the I2C feature.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |