Can Arduino act as I2C slave?

I have acquired a couple of Nextion LCD touch screens to use in an upcoming project. They communicate through I2C only. From my understanding the screen will output a short message (message type, control id (page and element on the page), and event, e.g. button press or button release). In other cases some information (string or number) is also transmitted. All messages are terminated by a series of three consecutive bytes, all containing 0xFF.
What I would like to do is have the Nextion act as master on the I2C bus, and the microcontroller act as slave, so the m/c will wait for the screen to send some data, then act on it. To me it seems the m/c needs some sort of interrupt triggered by the I2C bus receiving some data that it can then read and act on.
There is an Itead library published that seems to support this by using callbacks, but it is written in C, and, to my way of thinking anyway, seems to be unnecessarily complicated. But if I could put a Python wrapper around it, maybe it would be satisfactory. The library is here: https://github.com/itead/ITEADLIB_Arduino_Nextion/archive/master.zip
I’ve searched the forums, the documentation and the net, but it seems Zerynth support for I2C is pretty thin. And I’m not clear about how to set up the scenario I’m looking at, or even if it is possible in Zerynth. If the Arduino can only act as master then it will be constantly polling the screen for any data. I guess that would be acceptable too if it was the only way, but a bit untidy in my humble opinion.
All advice gratefully received

hi @mogplus8
Unfortunately, In the I2C documentation :

At the moment, Zerynth VM supports only a single master protocol version where the microcontroller is the master.

So even using the Itead library might not be possible.
Does the LCD display provide an interrupt pin for example or any other indication for new updates?
How does the official SDK handle incoming data? Is it through polling continuously?

Thanks for your answer Karim, you’ve answered the question. Obviously I should have RTFMed a bit harder!

I haven’t actually played much with the screens as the official Nextion editor, which is afaik the only way to program them, only runs on Windows and I haven’t got a Windows machine. I’ve got Win7 running under Virtualbox on my Linux PC, but it has issues talking to usb devices for some reason, so it’s all a bit hard. My actual project is a fair way off too, so still exploring development options.

Not sure what you mean by official SDK, unless the Nextion editor counts. The board does have some gpio pins, I actually didn’t notice that before but your suggestion sent me off to check! They are hidden in a ribbon connector, so you have to buy a special breakout board to use them, so I may have to invest in one of them ($3 from Banggood). The Nextion editor allows you to write to a gpio pin, so it may indeed be possible to use it as an interrupt that triggers an i2c read by the master to the screen. Not sure if that would be preferable to just setting the master to “listen” mode, and reacting when a message is received. Like I said, early days and I am very much on the serial communication learning curve.

:wink: Ian

All of us are gulity of not reading the manuals :grin:

This is due to the Virtual Machine software itself, problems arise when you pass USB device between host and VM environment.
It would be much easier to use a native windows OS and avoid all of the VM hassle.

I also read that the Nextion displays contain ARM based uC, So maybe you can controll the uC to output signals on the pins from the Nextion editor. :smile: