I have a non-Arduino device that displays its output on a standard 16x2 LCD display via I2C. I do not have the ability to change the code of the non-Arduino device. However, I would like to be able to take its output, and send it to a computer via USB serial.
So... what I am thinking I could do, is use an Arduino Nano in place of the LCD display. The Nano would be an I2C slave using the same address as the I2C LCD display. It would receive the commands intended for the display, and build up a "virtual display" in memory, i.e. a 2x16 area of characters representing the display output of the other device. Then, it could send this to the PC via the standard USB serial interface.
Question... is anyone aware of a library or code snippet that already does this? I have done quite a bit of Google searching, but all I get is how to write to an LCD display, which is obviously not what I am trying to do. In the absence of anything else, the next step would be to review (a) the 4-byte LCD interface, and (b) the I2C interface, and create my own library that would do this... but I'm hoping something already exists??? Rather not reinvent the wheel...
I don’t know if it has been done before, but the solution will have to emulate part of the functionality of the Hitachi HD44780 chip that is found in these LCD devices. The spec, including the mcu interface is here:
Hopefully that “non-Arduino” device doesn’t use too many exotic features such as user defined characters, scrolling etc.
Well for a start, you have set yourself a more realistic problem than this one which may be worth studying, particularly Bill's comments re the HD44780 as 6v6gt mentions.
Has it been done before - and published? There's the question!
It is definitely do-able as you can use the I2C interface to pause and allow sufficient time for your processing. Looks like this will keep you well occupied for the Covid-19 duration.
The device in question is a ham radio automatic antenna tuner. It uses a PIC 16F1984 (I believe) microcontroller. I do have the source code. I do not have a PIC in-circuit programmer. Even if I get one, I think I still need the Arduino, in order to be the USB interface. (Goal: control the tuner remotely via my PC.) I thought it might be easier to read the display, than to update the PIC to send messages specifically to my Nano... mainly, the I2C instructions I see in the source code are kind of cryptic to me, ie. They are doing things like seeing pins to a high impedance state or somesuch, rather than a higher level "WriteI2C" concept.
But, looks like I'm going to be learning some I2C ins-and-outs regardless.
I will say, no special features. Just displays letters and numbers, no scrolling.
I suppose the complexity depends on the pic application, but I don’t know much about this development system. Anyway, here is an example I found in c which uses a library to talk to a LCD 1602 type display (with an I2C backpack) and it is reasonably clear what is going on. https://simple-circuit.com/mplab-xc8-i2c-lcd-pic-microcontroller/
Or another version described as ‘simplified’. (The non-simplified version must then be a horror to look at):
If you have the pic source code, the best solution could be to use I2C directly to talk to your Arduino instead of trying to interpret the data intended for the display.
Having the source code is an incredible advantage. However you look at it, learning PIC and getting a programmer is going to be by far the easiest approach.
{OK, so I did program PICs back in the "naughties" or so. }