1

I would like to interconnect Raspberry Pi and Arduino over I2C.

RPi will act as MASTER while Arduino is SLAVE.

I understand that I2C is designed that only master can send messages to slaves and then wait for responses.

I have sensor connected to Arduino, Arduino check periodically sensor value. My intent is, when sensor value exceed defined limit, inform RPi - send message to it. I want RPi as MASTER, because it also can query Arduino anytime. Can I start communication as SLAVE device?

Is it possible somehow? Do I need to use different bus than I2C?

  • See answer below. With pigpio, the Pi does not have to be a master, and you can have ore than one on the same I2C bus. – SDsolar Jun 1 '17 at 9:06
1

You need to use a separate signalling method to alert the Pi that a sensor value is ready to be collected.

This is usually done using an interrupt signal. Your Arduino changes the state of a GPIO pin which is connected to a GPIO pin (through suitable logic level translation as necessary) on the Pi. When the Pi sees that pin change state it requests the data from the Arduino.

It is most common to have the transition from HIGH to LOW as an interrupt signal (aka Active Low) since that allows a simple wired-OR arrangement (open drain GPIOs with a pullup resistor) to allow more than one device to raise the same interrupt.

0

Yes you can!

The new pigpio library allows the Pi to act as a slave so all devices are equal.

Before this recent release, the Pi was always a master and had to poll the others, interrupting them.

But now you can let the other devices work on their own time schedules without the interrupts.

Here is where you get it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.