Page 1 of 1

Emulation of multiple I2C slaves with a Pyboard D-series

Posted: Sun May 17, 2020 9:08 am
by luca824
Hi all,

I'm working on a project with the aim to adopt a pyboard d-series to emulate the behavior of multiple i2c slave like a temperature or a magnetic sensor, ecc...

The pyboard in this case, acting as a slave, should be able to:
- receive the slave address from master (reading the byte first byte sent)
- identify slave address and R/W bit
- check if the address received is attributed to one of the sensors that I want to emulate (whose addresses are known)
- if it is, send the ACK to master and send data related to the sensor called (already stored in pyboard's memory)

Main problems met to accomplish these functions are:
- it seems to be impossible attribute multiple I2C address to single device
- find out which particular I2C address was queried

I'd like to know if any solutions exist to implement these functions on micropython (in particular on Pyboard D-series) or if is needed adopt a different microcontroller and a lower level language.

Thank you guys, any suggestion is well accepted

Re: Emulation of multiple I2C slaves with a Pyboard D-series

Posted: Mon May 18, 2020 5:52 am
by pythoncoder
The pyb module doesn't support multiple slave addresses on one bus. You might be able to do it at register level using the stm module, but you'd have to do some research with the chip datasheet. As far as I know you're the first person to consider this.

Re: Emulation of multiple I2C slaves with a Pyboard D-series

Posted: Mon May 18, 2020 8:00 am
by chuckbook
STM32F7xx supports two slave addresses in HW plus one broadcast (ADDR 0). MP currently supports only one slave address.