How to use the I2C module for 1602 LCD screen with PICAXE 20M2?

eaquinte

New member
Good morning,

First of all, I want to apologize for the English, but I don't control it much and I'm using the translator.

Now, what I come to. I would like to know if someone can guide me on how to use the I2C module for LCD 1602 screen in PICAXE 20M2 to be able to send messages dynamically. What I want to do is be able to display values read from an ADC input and display them on the LCD.

Thanks in advance.
 

AllyCat

Senior Member
Hi,

Welcome to the forum.

Do you have an internet link to a data sheet or the device that you want to use? Because normally a "1602" display does not have an I2C Bus, but a 4-bit or 8-bit parallel bus.

However, THIS THREAD asks a similar question. I'm sorry it does not lead directly to a useful solution; but it does link to another thread.

Cheers, Alan.
 

eaquinte

New member
Thank you.

I bought a 1602 LCD and an I2C module, when you mention "data sheet", do you mean the I2C module or the LCD?

I checked the thread that you share, and the truth is that I am not able to understand many of the things commented there. Sorry, but the truth is that I'm very new to picaxe and all this microcontroller stuff, so I can't understand much about it.
 

inglewoodpete

Senior Member
It is not clear which i2c decoder/driver chip your "I2C module" is using. Can you provide the part number and/or a link to the data sheet for the I2C module?
 

hippy

Ex-Staff (retired)
I checked the thread that you share, and the truth is that I am not able to understand many of the things commented there.
This is one of the reasons we recommend our serial LCD and OLED displays which can easily be connected to a PICAXE and used with simple SEROUT commands, for example -


It is more difficult to use parallel LCD and OLED displays, more difficult still to use I2C displays, and it's usually easier and the recommended course to start with the simple option and then gain the knowledge and experience which will make using those easier.

There are a lot of modules manufactured as "1602" - which usually just means two lines of 16 characters, which can have varying features. It will help if you can provide a link to what you have purchased, even better if it has a circuit diagram showing how the display should be interfaced, how any I2C controller connects to the display.
 

lbenson

Senior Member
1602 displays are not that hard without the I2C module, though they do take 6 I/O lines instead of 2. Here's an example: 14M to LCD

With a 14M2 or bigger, you still have a good many I/O lines left for your project.
 

hippy

Ex-Staff (retired)
1602 displays are not that hard without the I2C module, though they do take 6 I/O lines instead of 2.
Absolutely but there is quite a jump from using serial to using a parallel display. It's not overly difficult but nowhere near as easy as using SEROUT commands is, will require a greater understanding of PICAXE commands and how the displays themselves work which many new arrivals won't have.

My recommendation would be to start with serial and stick with that for an easy life. If one wants to move into parallel display driving; the AXE130 serial range is good for that, a great platform in its own right for writing code to directly control the attached 8-bit parallel LCD or OLED. From that, and gaining a better understanding of the display itself, it's then just a step to 4-bit driving and comprehending I2C driving.

I do understand people buying I2C displays which may be cheap. They are not that hard to use, though some can take effort to figure out. But there's a steepish learning curve, a lot to take in and understand, especially if new to displays and PICAXE.

It seems to me to be a prerequisite that one understands 8-bit parallel to understand I2C display driving, difficult to explain I2C display driving without explaining 8-bit parallel first.
 

eaquinte

New member
It is not clear which i2c decoder/driver chip your "I2C module" is using. Can you provide the part number and/or a link to the data sheet for the I2C module?


Thanks for answering

I was looking for the datasheet but I couldn't find it. I attach the link of the page where I bought it



I already requested the datasheet from the page, if they give me an answer I will provide it to you.

Thanks in advance
 

AllyCat

Senior Member
Hi,

Yes, that I2C Interface is well-known on this forum to drive a 1602 LCD and certainly it can be used. However, this is a very complex project for a beginner to PICaxe. The Original Poster in the thread which I linked to in #2 decided that it was too difficult. :(

But if you do want to proceed with this project, then you must be aware that both the I2C Interface (Expander Chip) and the 1602 LCD are very "dumb" components and all the display "intelligence" must be written into the PICaxe Program. With an Arduino, all this code is "hidden" in the Library program.

Also, the I2C Expander must operate the 1602 in "4-bit data mode", because the other 4 data-bits are used for Control lines (Clock / Strobe , Display / Command , Read / Write and Backlight On / Off). Therefore, I recommend that you start by driving your 1602 directly from the PICaxe 20M2 in 4-bit mode, as suggested in #6. If that works then you can simply introduce the I2C Expander Hardware and add the additional program code to use I2C. But if you cannot get the 4-bit mode to work, then you can try the simpler 8-bit parallel mode first.

HERE is a very good introduction to using the 4-bit mode with almost any PICaxe chip. It was written by somebody who has already contributed to this thread (in #4), so you should be able to get more help if you need it. :)

Cheers, Alan.
 

Flenser

Senior Member
eaquinte,

I was writing an A*****o style library for a LCDs with a PCF8574 based I2C backpack module and when I did a search of the Forum I found that this has already been done.

In 2015 rolfi@tisco.no posted an include file here https://picaxeforum.co.uk/threads/subs-macros-for-i2c-displays.28211/ with the code to drive one of the 1602 LCDs with a PCF8574 based I2C backpack module like you describe.

Speddo posted his update of rolfi's include file together with two demo programs in this post: https://picaxeforum.co.uk/threads/subs-macros-for-i2c-displays.28211/post-334059

Download the three files from Speddo's post into the same directory
Rename the file SubsMacros_Serial_LCD.txt to SubsMacros_Serial_LCD.basinc
Update Test_The_Include.bas demo program to use a 20M2 instead of a 14M2
and try downloading Test_The_Include.bas into your 20M2 chip.

I don't own a 20M2 chip but I just tested Speddo's demo program Test_The_Include.bas on a 14M2 chip and it worked first time.

Note that you may need to adjust the LCD contrast using the pot on the PCF8574 based I2C backpack module to see the displayed text.

The file SubsMacros_Serial_LCD has the following list of the functions that the library contains and the test program Test_The_Include.bas calls several of these functions to show how they are used.
;--------------------------------------------------------------
; InitD Initialize display
; ClrD Clear display
; WriteN(number,"R") Write byte or word number at
; WriteN(number,"L") cursor pos, right or left adjust
; WriteC(byte) Write char at cursor pos (byte)
; GotoXY(xpos,line) Place cursor at pos x, line y
; EraseC Erase character at cursor
; EraseCN(N) Erase N char starting at cursor
; BackStp Backstep cursor
; HideCur Hide cursor
; BlinkCur Blink cursor on top of ev. char

Once you have it working with your 20M2 and 1602 LCD with an I2C module you can try out calling these other functions.

You must call the InitD fuction first, to initialize the 1602 LCD display, before you call any or the other functions.
'Initialise the display
InitD ;initialise LCD
 

kfjl

Member
This is MGU's code. In the opening frames you can see it works perfectly, so the code is good and so is the circuit. Just moving the module can stop it working, so if you have dodgy contacts you're in trouble.
This is not an easy project for a beginner.
LCD problems
 
Last edited:
Top