Getting started with an I2C LCD using a bus pirate

I got one of these (The LCD!) LCDs from the budget and the motive is to use them to display air quality. Low and behold I got them and these things are tiny… I mean more than I thought. BUT they should get the job done. This post is a little one where I try and get it to work and experiment with I2C. Lets go!

midas.jpg

 

The LCD itself

To be honest the features of this LCD are great but the cost is a little higher than I would like. The special thing about these is that they work at 3.3V which means they can be directly connected to my Launchpads. Great! Now how do I get em to work. The datasheet is available as with all element14 parts and you can download it for use. I will take out the parts that we need and discuss.

 

Shabaz sir used it in his posts about the CC3200 and he did it effortlessly. I had to mess with somethings hence I am posting a bit of my experience.

 

First things first…

The pin configuration. Before we start with the software lets ready the hardware and for that we need to know about the pin config. Its in the datasheet and the useful parts are:

 

a.png

b.png

 

 

 

Brilliant now this means that  I can work with only 4 Pins. I need the VDD, VSS(GND), SDA and SCL. I can tie the reset and everything around. I am not going to make footprints or PCBs for this thing so I will directly solder everything in place. The pins are connected as:

1 – VOUT , 4 – VDD and 8 – RST to the 5V output from the CC3200 Launchpad. Why 5V? Because if you want to run it off the 3.3V then you need to add two caps. I will save those caps and use the 5V available on the LP.

5- VSS to Ground

6 – SDA to the I2C SDA Pin

7- SCL to the I2C SCL Pin

 

Done!

4 pins is all I need. If I need to reset it I can do it in software OR power the thing OFF and ON. Great!

The results of my soldering is shown below. In my deficen I would like to say that I do not have the finer tips for the soldering station so this will have to do.

 

LCD1.jpg

 

 

The bus pirate.

I would like to run the LP directly with the LCD but there is a problem. I don’t want to mess with code then find out that my soldering was dry. So I chose to use the Bus Pirate.

For thos who dont know, the bus pirate is a small tool that can be used with most serial bus protocols to debug and analyse them. Here I will be using it for I2C. Hooking it up is easy. The above four pins to the pins on the pirate and done! Well one more thing. The I2C bus needs pull-ups and the voltage of these pull ups matters for the controllers being used. I want the bus to go 3V3 so I can solder some external pullups. The simpler solution is that there is a Pull up connection on the BP which can be enabled or disabled in Software. Any voltage 3V3 or 5V can be selected externally using the provided pin and so I connected the Pullup wire to the 3V3 generated by the BP itself. Neat!

 

c.png

d.png

e.png

 

On to the bus!

There are a gazillion tutorials for the I2C bus on the net so I wont bother. The signaling is not important here but what is important is the protocol itself.

In order to talk to a device, the bus is pinged with a start signal.(For signalling details, google it! or PM me.) Next the address of the device to be hailed is sent. The addersses are 7 bit with the last bit signifiying read or write operation. Next data or commands are sent post which the device sends an ACK or acknowledge for each byte successfully received. This makes sure you are talking to something. Lets go by example here.

 

The first thing here is the address. The buspirate is used via a serial terminal program. After bringing it into I2C mode and enabeling the power and pullups, we try to talk to the LCD. Its address is 0b01111100 where the last bit is 0 for write operations. Hence for a read operation, we would use 0x7d. That simple. A quick look at the datasheet…

 

f.png

 

Easy right.. OK moving on.

 

We need to send it something that tells it that I want to send commands to initialize it. These commands also include resetting the LCD and moving the cursor around. So how do we do that?

The next byte we send will be 0x00 if we want to send a single command.

I made the string in notepad and pasted it into the realterm console as:

 

s.png

press enter and…

1.png

 

The ACKs means the LCD is present and responding. Good. Now to print something. Now the Datasheet has a table that you can decode but I have a trick. All the characters are assigned their ascii code and you can go to asciitable.com and get the hex values directly.

 

Copy and paste the string into the console and…

2.png

 

The Hello pops up on the LCD.

lcd2.jpg

 

Conclusion

A lot of work just to get a hello but it is worth it in the long run. I hope this helps people thinking about adding an LCD to their project. Graphical LCDs are also possible but this is just smaller and quicker.

Cheers,

IP

Advertisements

7 Replies to “Getting started with an I2C LCD using a bus pirate”

  1. Thanks for this amazing tutorial. It helped me a lot, since I want to create a user interface with this exact LCD. Now I have to try it out.

    Thanks again and have Happy Holidays!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s