reading I2C data between pic processor and lcd display


i have a controller board that use a pic processor and a i2c lcd screen

what i want to do is reading the text that the pic sends to the display
i will use an esp32 board to read the text and then after reading send this text with wifi to another esp inside the house

is this possible ?
if yes any idea how this can be done ?


Yes, it is possible. You can sample and decode the data on the I2C lines. Most likely the PIC uses 5V logic, so you will need level shifters for the ESP32 board.

That would be a challenging project for someone with advanced programming skills.

I don't know if the ESP32 has hardware I2C. An Uno, Mega and nano have and they also work at 5v so one of them might be a better choice for early experiments.

Simple I2C Tutorial

esp32 is not mandatory
i forgot that esp runs on 3.3V
i saw wifi modules that runs on uno

thanks for the link to the tutorial

That would be a challenging project for someone with advanced programming skills.

In other words: it is not possible yet :confused:

The “SoftwareSerial” seems to work well on a ESP32. If that is possible then a I2C sniffer is also possible. But I don’t know if someone has made that yet.

As far as I know, there is only one I2C sniffer, as I mention here: Arduino I2C libraries · Testato/SoftwareWire Wiki · GitHub. The ATtiny uses a USI, which can be made to do many things.
There is other code, but they can only capture something that has very specific timing.

Some want to use a man-in-the-middle approach. Then the Arduino simulates the display as a Slave and sends the command forward to the display (while capturing or changing the data). The chance that such a man-in-the-middle will work is very low.

In the end, I’m afraid it is not possible.
Wait a year or a few years. Someone has to come up with something like that sooner or later.

Well, it is not possible for a beginner, and I doubt very, very much if someone with the expertise to write the code would find such a project to be worth the effort.

I wonder if this project would help you out at all. It uses an ATTiny2313 @ 20MHz and supposedly captures I2C data and transfers it out over a normal serial link to a host PC.

The I2C sniffer looked interesting until I saw that the author does not provide source code, just a HEX load module.

I have seen other references to I2C sniffers, but you still have the problem of figuring out how the data sent between the PIC and the LCD display correspond to the actual data of interest. There could be lots of screen formatting commands, etc.

I just noticed that. Oh well.

On a slightly different tack, I was reading the Mega328P data sheet to see what I could see on the TWI interface. There's an interesting register called TWAMR (Two Wire Address Mask Register) - it's section 26.9.6 on my datasheet.

I got my hopes up that it may be possible to mask out all the address bits and therefore receive all I2C messages regardless of the intended receive address.

But then I realised that the I2C processing logic would probably also generate ACK signals on the I2C bus in response to each of these messages.

However, I wonder if writing a 0 to the TWEA (TWI Enable Acknowledge) bit in the TWCR would suppress the ACK thereby making the Mega328P invisible on the I2C bus but able to receive all I2C messages.

I've yet to figure out if the above works and if it does, how you can figure out the I2C address of the slave device in the message you've just received. I wonder if the address appears in TWDR register.

I'll hopefully give it a try tomorrow just to see what happens.

I have created a new page about I2C Sniffers: I2C Sniffers · Testato/SoftwareWire Wiki · GitHub.

You could start with the i2c-sniffer by Teknoid. I have not tested that myself yet.

i've found this

HD44780-decoder-master on github
it seems possible to "read" the lcd

anyone tried this ?

Link: GitHub - dsalzman/HD44780-decoder: Arduino Library for decoding HD44780 protocol. This is useful when you want to extract information from a proprietary system that uses an HD44780 LCD..
That is not I2C, it captures the 4-bit signals to a LCD display.

A quick update just in case anybody is following this thread.

I've currently got 2 Arduino UNOs connected via I2C. The first UNO continually writes out one byte using the hardware TWI to I2C addresses #1 to #6.

The second UNO was initially configured using the hardware TWI with I2C address #1 and as expected the 2 UNOs talk over I2C with UNO #1 receiving ACKs correctly ( Wire.endTransmission() == 0 ) when writing to address #1

I then added 1 line of code to UNO #2 in setup() to simply set the TWAMR register to 0x06.

Rerunning the code with this change and UNO #1 is now receiving ACKs from I2C addresses #1, #2 & #3, which is to be expected.

I then "hacked" wire.c & wire.h to add a new function getAddress(), and also twi.c & twi.h to add a new function called twi_getAddress().

From some very basic tests, it looks like I can now read the actual I2C address that was sent by UNO #1.

The next step is to disable the ACKs and add in the diode & resistor to the SCL & SDA lines and see if I can really listen in to an I2C conversation without interfering with the waveforms.