segunda-feira, dezembro 10, 2012

Getting an inexpensive 16×2 LCD screen working on the raspberry pi




media


I finally freed up one of my breadboards. I got my semi-permanent temperature sensing interface fully up and running with the Pi Cobbler – logging to COSM.

Last 7 days outdoor temp


So now I could take the components off my other breadboard and free up the Gertboard for other experiments.


LCD Next


The next thing I wanted to get working was a 16 x 2 LCD panel. (£6 from Tandy) Having seen other people get these working, I figured it couldn’t be all that hard and it wasn’t too bad actually. But I did make one small mistake along the way. I got it working the second time I tried it.



16 x 2 LCD Screen attached to Raspberry P



The mistake I made was trying to run it from a separate 5 Volt supply instead of directly from the Pi. I hadn’t connected it to the Pi’s earth, which I think is why it didn’t work first time round. Properly grounded, I think it would run from a separate supply (but don’t connect the +ves together or the regulators will have a fight).


5V or 3V3?


There are 3V3 (3.3 Volt) versions of these LCDs available, but the 5V ones are more common. According to my flavour-of-the-month site, Adafruit, it’s safe enough to use a 5 Volt LCD with the Raspberry Pi as long as the read-write pin (pin 5) is connected to ground. As long as we only “write” to the screen and don’t try to take input from it (like you would on some embedded device with input buttons e.g. a battery charger).


That way, you won’t “send” a 5 Volt signal to the Pi’s GPIO (General Purpose Input Output) ports, which run on 3V3. Sending a 5 Volt signal to a 3V3 port would be very likely to toast the port. This is the basis of the instructions I followed…


http://learn.adafruit.com/drive-a-16×2-lcd-directly-with-a-raspberry-pi/overview


…but I didn’t use the Pi Cobbler this time as it’s already in use with my semi-permanent temperature logging setup. Once I get that onto a permanent board, the Cobbler will be free again.


Identifying the pinouts


I very carefully identified the pinouts on the Raspberry Pi’s GPIO header using this very helpful graphic from the wiki.




GPIO Pinouts on the Raspberry Pi



And connected eight wires to the ports directly.



Port wiring for the LCD screen



Odd behaviour


I’ve noticed a few times that this screen sometimes needs the scripts to be run a couple of times before it works properly. I don’t have an explanation for that. Once or twice it has displayed what looks like Japanese characters instead of Roman alpha-numerics.



Some Japanese characters?



It might be that I haven’t used the Adafruit scripts properly, or it may be that they’re optimised for their own distro. No matter. On this occasion, the solution lay elsewhere. Eventually I switched to another driver by Matt Hawkins, from here.


New driver cured it


And after a bit of tweaking it finally does exactly what I want, reliably – yay Smile



Success at last – degree symbol too Wink



Now this little LCD is displaying data pulled from my COSM temperature feed every 40 seconds. As I progressively add more sensors, I’ll be able to alternate the display, showing each set of readings for a few seconds before going on to the next. I’ve got plans for barometric pressure and light sensors already – who knows what else will crop up to occupy the remaining channels on the ADC? ROTFL (Currently four channels available).






via RasPi.tv http://raspi.tv/2012/getting-an-inexpensive-16x2-lcd-screen-working-on-the-raspberry-pi

Sem comentários:

LinkWithin

Related Posts Widget for Blogs by LinkWithin