I have spent the last few weeks working on getting a SainSmart 3.2" TFT with touch control working with my Raspberry Pi and I have had success.
You can see an update on this project here;
https://ozzmaker.com/2013/05/27/raspberry-pi-with-a-3-2-tft-with-touch-control-part-2/
I have currently connected it up with a breadboard, I now need to work on a more permanent solution.
Download the Kernel that contains the drivers.
Click on the images for a larger view.
![]() |
![]() |
Click the image below for a much larger version |
![]() |
My setup;
M74HC4040B1R
74HC4094N
5v to TFT
3.3v to ICs
Reset through 10k resistor
Back light connected to 3.3v
I start Xwindows with sudo FRAMEBUFFER=/dev/fb1 startx -- -dpi 60
Thanks to XaLKiDEoS , Notro, drsb and valdodov.;
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=64&t=33679
http://www.valdodov.com/
[wp_ad_camp_1]
sounds great. I have been thinking of getting a Raspberry Pi but I’m not sure as of yet.
Reblogged this on anthonyvenable110 and commented:
great
Mark, that’s a hell of a job. Nice one! I hope you’ll document and diagram it as I think a lot of people will want to do this!
Reblogged this on SainSmart.
This looks excellent. For someone who has pretty much zero knowledge on how to achieve what you have here, could you provide some links or references for where I should start?
Thank-you
Read through this thread, it has all the info you need.
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=64&t=33679
I have the same LCD as you do. i was wondering if you could help me with the pinout of the LCD… valdodov has a different lcd and his schematic doesn’t transfer well to the one you have i think. is there a schematic that you could post or tell me where BL_CNT is connected from the 4094s to the LCD?
TIA
I have post a schematic on this page, it will have the information you need.
https://ozzmaker.com/2013/05/23/raspberry-pi-with-a-3-2-tft-with-touch-control/
very nice
how is the performance for viewing web page?
or running a gui program?
Awesome Job! . Quick question though: where did you get the drivers ?
Valdodov has the Kernel and drivers on his site.
http://valdodov.com/tft_lcd/src/raspberry-pi.tar.gz
I am confused now. Shouldn’t the ripple counter be at pin 2 not 3. Since we want it to count to 32. Right ?
we do need to count 32, which is Q5.
So as long as it is connected to Q5, you should be right.
Look at these… Q5 is on different pins;
http://www.nxp.com/documents/data_sheet/74HC_HCT4040.pdf
http://www.st.com/web/en/resource/technical/document/datasheet/CD00002533.pdf
Thanks for the schematic, I will try and see if this works. if not, its probably some issue with the kernel. Also, if it is due to the kernel… was the kernel files just supposed to be copy pasted into the specific folders? was i supposed to enter anything in the command-line/terminal to get the display to start working?
Just need to overwrite what is on your SD card.
Everything is setup to get the displaying going on boot.
Tis is how I do it;
mkdir display_kernel
cd display_kernel
wget http://valdodov.com/tft_lcd/src/raspberry-pi.tar.gz
tar xfv raspberry-pi.tar.gz
rm raspberry-pi.tar.gz
sudo cp -r * /
sudo reboot
I have tried doing it the way you mentioned it above, but every time we try it the kernel doesn’t boot (get the rainbow startup screen when plugging in a HDMI monitor). We are running Raspbian.
Is there anything we need to do before using the commands you listed?
no.. that should be enough.
Once you install the Kernel as the instructions above, the terminal will not appear out the HDMI port anymore.
You can disable this by inserting your SDcard into a PC and open cmdline.txt on the SDcard and delete this text from the end of the first line;
fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11
Thanks man. Tell me if i understand correctly.
the Spi (MOSI) is buffering 32 bits (when the strobe is off) then the SPI (MOSI) waits for 32 spi cycles (When strobe is on ) . Am i understanding correctly .
So when the strobe is on the Spi is not doing anything right ?
The way I understand it is;
MOSI is always sending and the strobe goes off for every bit that MOSI sends. This way, it gets shifted into the shift registers..
The 4040 is counting the strobes… then after the 32nd strobes, it latches and sends the data to the LCD
Thank you
So i have all the items now . I really appreciate yours answers again thank you.
Just to clarify:
1. VCC is 3.3 coming from the pi right ? and it has a capacitor going to the ground ?
2. OE is 3.3 coming directly from the pi, I see in your pic there is couple of resistors ?
3. And how much VCC does the screen need ?
Again Thank you
Emad, have a look at the updated schematic above… it has the details you need.
So i finally assembled all my stuff. But the CE0 is always high which resets the ripple counter off all the time. Is that supposed to be the case?
Thanks for the schematic.
Hey mwilliams03
I have connected all . But on start up all i have is a blank white screen. How does the controller initialize on your touch screen ?
Hey! We had the same problem and the issue was that we wasn’t using the same chips that Mark. If you use another chip there is a possibility that those chips won’t be as fast enough as they should. We bougth the chips where he says in the description and it works perfectly.
Greetings.
That’s great and all, but is there a way to push raw image data (bitmap images, video, etc) to this display without making it an active tty/X display? Something that can run headless and have data pushed to it from a remote ssh session, cron job, etc?
I’m thinking of a Python or C library, or better yet an optimized binary that you can pipe the raw data to from another process to send it to the screen…
yes to all the above. You just need to write to the framebuffer
FBI can display images
mplayer2 can display video
Check out my other post about programming for the framebuffer and touchscreen
https://ozzmaker.com/2013/09/07/programming-a-touchscreen-on-the-raspberry-pi/
Just what I needed to know. Works like a charm.
Thanks!
Hi Mwilliams03,
I would like to do like your schematic but I have a doubt. Do I need any capacitors to use the screen ?
Thank’s you,
Tobios.
Yes you do, each IC needs a 100nF cap.
Look at the bottom left of the schematic.
Thank’s for your quick response.
I feel a bit stupid 😀
Another noob question : the part at the bottom left of the schematic (“On all chips”) represent the Raspberry Pi ?
Thank’s you.
“On all chips” is for the 4040 and 4094 chips in the schematic above
Hey Mark,
Where did you find the pin out for the sainsmart touch screen? We were looking at the following data sheet and it has different pin assignments. Please help us clear up this confusion. Thank you!!
http://www.urel.feec.vutbr.cz/MIA/2011/Matyas/dl/240374PQ.pdf
the display in your datasheet uses ILI9325 driver chip for the display.
Grab this;
http://www.sainsmart.com/zen/documents/20-011-C46/ITDB02_Graph16.rar
It is for a different product, however the driver ICs are the same as well as the pin-outs.
Mark
Thanks for the quick response, we registered the device and tested it with
FRAMEBUFFER=/dev/fb1 startx
however we just got a blank screen and when we rebooted were are now getting the following error returned from dmesg:
[ 118.601962] fb_ssd1289 fb_ssd1289.0: Missing info about ‘dc’ gpio. Aborting.
[ 118.602067] fb_ssd1289: probe of fb_ssd1289.0 failed with error -22
Any help would be appreciated!! Thanks!
is /dev/fb1 present?
Have you tried another program.. E.g FBI can disapply images to the framebuffer without starting X.
sudo fbi -noverbose -T 1 -a -d /dev/fb1 file
If you cant display the image or you get the same error, I would recheck the wiring. Are you using a breadboard?
No /dev/fb1 is not present. We are using a breadboard and just rechecked all of the wiring. The wiring looks good, but we are missing the filter capacitors (can’t get them till tomorrow) would that be the issue? It looks like a few people had this same issue but there is no definitive solution. What exactly is error -22?
the CAPS shouldn’t really matter… you should at least see something.
I had trouble getting mine going on a breadboard, I always had loose connections.
How did you install the Kernel/modules?
Hey Mark,
We were following the instructions on github/notro/fbtft/wiki but I think I just realized that that’s a different method. So in order to install the kernel/modules should we use the compiled files on Voldadov’s site? If so, how do I copy those drivers? I extracted them to the desktop then did:
sudo cp -r /home/pi/Desktop/root /root
sudo cp -r /home/pi/Desktop/lib /lib
sudo cp -r /home/pi/Desktop/etc /etc
But I had no way of confirming if the files actually copied, was this the correct command?
We were using notro’s firmware from the aforementioned website. Is this not compatible?
Should I start with a fresh version of raspbian and copy those 3 files and then it’ll be good to go?
The hodge podge of different tutorials and methods is kind of throwing us off, so If you could possibly just give us an overview of what we need to do on the software side starting from the beginning!
This is our first rasp pi project and obviously our inexperience is showing so thank you very much for your help!!
i was thinking you used Notro’s.
Voldadov’s is what I use.
you have root… it should be boot.
This is what I do;
mkdir temp
cd temp
wget http://www.valdodov.com/tft_lcd/src/raspberry-pi.tar.gz
tar xfv raspberry-pi.tar.gz
rm raspberry-pi.tar.gz
sudo cp -r * /
sudo reboot
Thanks for the quick response,
Sorry root was just a typo, I meant boot
I’m assuming it has to be a wiring issue because your method worked and upon reboot the HDMI output showed only the rainbow screen so I know its trying to route the video to the touch screen but all we’re getting is a blank screen so there has to be something wrong with our circuit. We’ll take another look at the circuit tomorrow and see whats wrong. Thanks again for all of your help!!
Hey Mark,
Finally got it working! (Sort of) Must have had a few dead rails on my breadboard because I purchased an new breadboard, and lo and behold, our screen works. We can see the boot information and there are no errors, but it stops at a blinking command prompt, but I cannot type with the keyboard, and it does not boot into the desktop. So we’re kind of stuck at a blank command prompt. Is there any code I can edit to make it boot into the desktop? Or is there any way to make the keyboard work?
Do you have the keyboard directly connected to the Pi? Or are you accessing the Pi via SSH from another PC?
If from another PC,you have to specify the framebuffer.
You can start X with;
sudo FRAMEBUFFER=/dev/fb1 startx — -dpi 60
View pictures with FBI:
sudo fbi -noverbose -T 1 -a -d /dev/fb1 file
Play video with;
sudo mplayer -vo fbdev2:/dev/fb1 -x 128 -y 160 -zoom file
We have the keyboard directly conneected to the pi. Should we be using SSH? And we can get it to work by deleting the
fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11
line from the cmdline file, and using the FRAMEBUFFER command. We were just trying to boot directly to the desktop on the touch screen.
Also, it does not register any touch inputs, could this be a conflict with the keyboard/mouse?
Hello Mark,
I am working for several months with the Raspberry and I also know a few experminete performed. Well me too interested this project. I myself already so bought a 3.2 “touchscreen, but I dunno exactly how to wire the. Could you maybe make a wiring diagram. That would be very nice.For example, with http://fritzing.org/
Many greetings from Germany
hi
i have 2.8″ display of INANBO and want to config it by raspberry .is this driver file(that you used it)useful for my display???
What controller does your display use?
Hi Mark,
We are following your circuit for interfacing the raspberry pi with touch screen. We have currently wired on a breadboard and currently working on a better consistent solution like having it on a PCB.
I was just wondering if the schematic you posted on this page was done in eagle PCB? I am currently using eagle PCB for creating schematic and getting a board layout.
I wanted to know what kind of Connectors for Raspberry Pi and Sainsmart touch screen for the schematic.
Any help would be appreciated!! Thanks!
Try a prototyping board, like I have done here;
https://ozzmaker.com/2013/05/27/raspberry-pi-with-a-3-2-tft-with-touch-control-part-2/
I’m not sure what you mean by connectors? i just used normal single core hookup cable.
BTW: I am working on a PCB board also, which I will start selling by the start of Jan 2014.
Hi
I have rebuild your project…. very nice but my display on the way….can´t test it at the moment. 🙁
does the touch function work in xbmc? will use this gadget for a little internet radio.
if i read right… i can´t use the display AND the HDMI???
Thx for help
Neox666x
Hi
My display has arrived yeeeha…. but doesnt work only blank white screen
i have a TFT_320QVT or 1982AY-cxh ……. K613690S
i think the pin layout is diffrent to yours….. they have other names on some pins 🙁
hope to get this work….
okay driver is loading no failures all ok
with FRAMEBUFFER=dev/fb1 Startx there is a fatal error …….
FATAL: Module g2d_23 not found.
what happend? whats wrong?………
🙁
before loading X, are you able to see the terminal on the TFT?
cat /proc/bus/input/devices
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name=”ADS7846 Touchscreen”
P: Phys=spi0.1/input0
S: Sysfs=/devices/platform/bcm2708_spi.0/spi_master/spi0/spi0.1/input/input0
U: Uniq=
H: Handlers=mouse0 event0
B: PROP=0
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003
but get blank screen…. 🙁
Ok Toucscreen ins working but get no picture
only blank screen have checked the wires 20 times…….
Xorg log
can you please help me?
do you see the new framebuffer?
ls -l /dev/fb1
Have you got fbcon enable (show terminal on TFT)?
cat /boot/cmdline.txt
If both of these comeback correct, I would say it is the wiring.
Are you using a breadboard?
Hi
Now i went from 3.3 to 5v at all now i get some colored lines flickering
i´m using other chips as yours they need 5v next should be a software problem i think.
[ 0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 b cm2708_fb.fbheight=416 bcm2708.boardrev=0x100000e bcm2708.serial=0x93fdb0a6 smsc 95xx.macaddr=B8:27:EB:FD:B0:A6 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.me m_base=0x1ec00000 vc_mem.mem_size=0x20000000 dwc_otg.lpm_enable=0 console=ttyAM A0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:1 fbcon=font:ProFont6x11
is this right ? i think its the wrong size
Ignore it… below is a copy of my DMESG. And mine is working fine.
It has to be your wiring. Are you using a breadboard? What chips are you using, are they fast enough?
Maybe place a LED at each output on the chips to confirm that data is being sent.
[ 0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xe bcm2708.serial=0xf4a38b4 smsc95xx.macaddr=B8:27:EB:4A:38:B4 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:1 fbcon=font:ProFont6x11
Hi
i have installed notro´s fbtft…… now my dmesg is
[ 115.876282] fbtft_device: SPI devices registered:
[ 115.876331] fbtft_device: spidev spi0.0 500kHz 8 bits mode=0x00
[ 115.876348] fbtft_device: spidev spi0.1 500kHz 8 bits mode=0x00
[ 115.876359] fbtft_device: ‘fb’ Platform devices registered:
[ 115.876379] fbtft_device: bcm2708_fb id=-1 pdata? no
[ 115.876614] fbtft_device: GPIOS used by ‘sainsmart32’:
[ 115.876631] fbtft_device: (none)
[ 115.876641] fbtft_device: ‘fb’ Platform devices registered:
[ 115.876658] fbtft_device: bcm2708_fb id=-1 pdata? no
[ 115.876691] fbtft_device: fb_ssd1289 id=0 pdata? yes
[ 115.916139] fb_ssd1289 fb_ssd1289.0: Missing info about ‘dc’ gpio. Aborting.
[ 115.916238] fb_ssd1289: probe of fb_ssd1289.0 failed with error -22
Notro’s will not work with the above circuit diagram.
The above is for Valdodov’s implementation.
quick instructions to use Valdodov’s;
mkdir display_kernel
cd display_kernel
wget http://valdodov.com/tft_lcd/src/raspberry-pi.tar.gz
tar xfv raspberry-pi.tar.gz
rm raspberry-pi.tar.gz
sudo cp -r * /
sudo reboot
All wired pins blinking
DC blinking faster and all powering pins are good
i have used CD 74HCT4094E and CD4040BE
I´m using same GND for all is it ok?
crw-rw—T 1 root video 29, 1 Jan 12 12:33 /dev/fb1
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:1 fbcon=font:ProFont6x11
no breadboard
i dont know the word for my board im using a board with much holes and must brazing?
You must be using a prototyping board.
Using the same GND is okay.
The CD4040BE is too slow, it has a max frequency of 12MHz.
you need a HC4040, which are up around 60-70MHz
lsmod |grep ssd1289
ssd1289 22454 1
fb_sys_fops 1440 1 ssd1289
sysimgblt 2143 1 ssd1289
sysfillrect 3299 1 ssd1289
syscopyarea 3020 1 ssd1289
ok have to order this …….0.40 € and 6 € for shipping…… damn
…
Question 🙂
can we use this to send a 60mhz signal from pin 7 to the lcd?
http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter
Hi
Part has arrived an screnn is not full working 🙁
hae the boot screen with white lines ….. by starting xbmc screen gets smoothy to white and finish….. think its wrong screen size… how can i set the resolution for all in to 320×240?
hm…. can see the boot rows…. sometimes…….
sometimes with blue stripes…. sometimes not all letters only a small stripe….. and agter getting message ???52×21??? screen goes slowly white……
I think……. i have killed the display :-p … ok next one…
I was looking on digikey and can only find this chip:
http://www.digikey.com/product-search/en?WT.z_header=search_go&lang=en&site=us&keywords=568-1451-5-ND&formaction=on&x=0&y=0
I am moast worried about the frequency which is 98MHz insted of 70MHz do you think this chip will work for this project?
the 75HC4040N is perfect.
Hello
I have been working a project for a while now and i am trying to get this screen working with this exact same setup. I have tested and rebuild this circuit multiple times all i can seem to do is get is the HDMI rainbow screen and a white screen with a slight flicker. if you have any ideas on what i can do to try and get this working it would be much appreciated.
It could be anything.
-Are you using a breadboard?
-what chips are you using?
-What TFT are you using?
-What driver?
I am using the same chips and TFT as you are using. The driver i am using is Raspbian. I am using a breadboard but i have checked the circuit multiple times using a multimeter to confirm the connections so i am not sure if that is an issue.
I used the following to setup the screen on the Pi.
mkdir display_kernel
cd display_kernel
wget http://valdodov.com/tft_lcd/src/raspberry-pi.tar.gz
tar xfv raspberry-pi.tar.gz
rm raspberry-pi.tar.gz
sudo cp -r * /
sudo reboot
Is there another step i am missing?
those steps are correct.
I had major issues when using a breadboard with my first prototype… it only worked 1% of the time.
It was a lot easier once I soldered to a prototyping board… it worked first go .. and always worked.
You can also try a LED(through a resister)at each pin on the chips to if they are sending data.
Ok the new display make s same failures………Damn…..only stripes nothing more……
Hey Mark,
Thank you for your help. I found a small connection issues with one of the ribbon cables i was using from the raspberry to the breadboard. Now that it is fixed everything works great without any problems. Thanks.
I had implement this circuit but the screen remain white can any body help me please
I used 74HC 4094 but nothing work.
Should i use 74HCT 4094?
Is there a difference between HC and HCT?
Thanks for your answers!
good job ! it’s working well on Rpi b+ too
I have a question about kernel: I install the Rpi version 2014-06-20-wheezy-raspbian, kernel version 3.12.25+ #700 after upgrade, but after apply valdodov, kernel come back to 3.6.11 #41 …
how apply your kernel patch without change back version ?
(I tried to update and upgrade after applying your patch, but tft still white and no FrameBuffer created)
thanks in advance !
Hi Romain,
It did work on Rpi B+ indeed, but the startx command never worked properly,
which command you used to make it work,
I used:
sudo FRAMEBUFFER=/dev/fb1 startx — -dpi 60
or
FRAMEBUFFER=/dev/fb1 startx — -dpi 60
or
sudo FRAMEBUFFER=/dev/fb1 startx
with no luck, any recommendation would be great,
Thank you in advance,
Try this
1. Disable framebuffer driver option for /dev/fb0
Open up the framebuffer conf file;
Comment out the line of text below;
Option "fbdev" "/dev/fb0"
This can be done by adding a hash (#) at the beginning of line.
#Option "fbdev" "/dev/fb0"
Mark Williams, Thank you soooo much, i have been struggling with this for weeks, you the saver 🙂
Cheers,
Hasan
Hello the valdodov side is down where can i get the files?
THX
Here is an old kernel build.
https://ozzmaker.com/downloads/valdodov3.2.raspberry-pi.tar.gz
Hello
Thanks for the Kernel but on my Pi is nothing to go the Display is not working. I have the Sainsmart 3,2 TFT with the Modul that is in the Video (selfmade) but i find no error in my circuit board it is with 3 74HC4094 and 1 74HC4040 . ? Is there a Kernel that Support this Version with no updates.?
Hi,
Thanks bunch for the info, its great,
I managed to get it working with the driver, but i have a very strange problem,
first the lcd mirror the data, so i see the lines but all mirrored,
second, the startx doesn’t work, i used both:
1- sudo FRAMEBUFFER=/dev/fb1 startx
2- FRAMEBUFFER=/dev/fb1 startx
it keep saying, errors,
I think its only working properly with version of 2013,
any newer versions always return errors when using FRAMEBUFFER….startx,
and also the other problem that the 2013 version doesn’t work properly on new models of Raspberry Pi, such as B+ ,,etc
anyone a idea where this vertical flashing lines come from?
It has been awhile since I have looked at this version of the display with the above SPI interface.
I will try and help.
some questions;
What are the exact models and manufacture of the 4094 and 4040 are you using?
Are they being powered from the 3.3v?
Do you have a link to the TFT you are using?
M74HC4094B1, SN74HC4040N
4040:
http://www.reichelt.de/ICs-74HC40-DIL/74HC-4040/3/index.html?ACTION=3&GROUPID=2933&ARTICLE=3225&OFFSET=500&WKID=0&SID=61VK4zjH8AAAIAABWor1sb951c902c83774da01e15382092bc75b&LANGUAGE=EN
4094:
http://www.reichelt.de/ICs-74HC40-DIL/74HC-4094/3/index.html?ACTION=3&GROUPID=2933&ARTICLE=3239&OFFSET=500&WKID=0&SID=61VK4zjH8AAAIAABWor1sb951c902c83774da01e15382092bc75b&LANGUAGE=EN
Capacitors:
http://www.reichelt.de/Aluminum-Electrolyte-Capacitors-radial/SM-0-1-63RAD/3/index.html?ACTION=3&GROUPID=3145&ARTICLE=18156&OFFSET=16&WKID=0&SID=61VK4zjH8AAAIAABWor1sb951c902c83774da01e15382092bc75b&LANGUAGE=EN
TFT:
http://www.sainsmart.com/sainsmart-3-2-tft-lcd-display-touch-panel-pcb-adapter-sd-slot-for-arduino-2560.html
capacitors, background light, resistor->reset, OE are all powered by 3.3v from Pi (Pin 1)
those components all look correct to me.
I don’t think it has anything to do with the back light.
At first glance I would have said there is an issue with the decoupling capacitors on all the ICs.
The capacitor you link is correct. You have all the capacitors connected as shown in the schematic?
You can also try and force the 4040 to go faster my connecting it to 5v
i found the issue…. above GND is a Pin named “VCC” – it was not connected (and looking at your schematics, it didn’t look like it has to be connected to 5v)
After connecting it to 5v of the pi, flickering stopped and the colors aren’t pale anymore
Thanks =)
Hi everyone,
Did anyone tried it with Raspberry pi 2, its not working on it with me at all,
however if i access it through SSH, i can start normal but not the lcd
will 74HC595 work instead of 74HC4094???