Introduction: Weighing Scale With Touchscreen (Arduino)
Ever wanted to build a Weighing Scale with a touchscreen? Never thought of it? Well read on and try building one...
Do you know what a TFT touchscreen and a Load Cell are ?
If Yes skip to Step 1 else just start by reading the Intro.
What is a Load Cell ?
A load cell is a transducer that produces electrical signal when a force is applied on it and deforms it.There are different types of load cell: button type,canister type, beam type,S-type,etc.Here I have used the Beam Type.
The beam type has 4 strain gauges. When the object to be measured is kept on the load cell the force being sensed deforms the strain gauge. The strain gauge measures the deformation (strain) as a change in electrical resistance, which is a measure of the strain and hence the applied forces. A load cell usually consists of four strain gauges in a Wheatstone bridge configuration.The electrical signal output is typically in the order of a few millivolts and requires amplification by an instrumentation amplifier before it can be used.That is why we will be using the HX711 amplifier.
What is a TFT Touchscreen?
TFT screens, are a type of active matrix LCD display capable of displaying millions of high-contrast, clear and bright color pixels.The TFT technology works by controlling brightness in red, green and blue sub-pixels through transistors for each pixel on the screen.The pixels themselves do not produce light; instead, the screen uses a backlight for illumination.
Touch screens are a type of overlay placed on a display screen used to register touch interaction on the screen. Touch screens are not a type of display, but rather a component that can be added to an existing screen. Touch screens use two different methods to register touch interaction called "resistive" and "capacitive," which refer to pressure and touch sensitivity respectively.The one we will be using is a resistive type.
TFT touch screens use both the TFT and touch screen technologies together to create a touch-based interface overlay on a thin, lightweight display.
Want to learn more just Google it :D
Step 1: COMPONENTS REQUIRED
- Load Cell (Beam Type) (I have used the one with 10kg limit)
- HX711 Load Cell Amplifier
- Arduino Uno
- 2.4" TFT Touchscreen
- Jumper Wires
- 9v battery
- 7805 IC
- 0.33uF Electrolytic Capacitor
- 0.1uF Ceramic Capacitor
component images taken from google images
Step 2: Connecting the TFT & Load Cell With Arduino
Connecting the TFT touchscreen to UNO:
Well the thing is that connecting the TFT to the UNO is a piece of cake. Now how to do it ? Well you will notice that the TFT has a SD card slot on the bottom side now place the TFT on the UNO in such a way that the SD card slot comes on the same side with the USB Port of the UNO. Press fit it on the UNO and when you plug the UNO to your PC you will see a white screen on the TFT. Before press fitting it place a tape on the metallic USB port of UNO.
Well congrats the TFT has been properly connected to your UNO !!! But it won't be long before you realize that the TFT has taken all of the Arduino UNO's pins. And you still have a load cell to connect.
What to do ? Hmmm... Well do you remember the SD card slot I was talking about earlier... we haven't put a card in it so that means we are not gonna use it.. So we will not be using the pins named as follows :
We can manage well without the SD card as we are not going to display any images.
Now these above mentioned pins are connected to digital pins 10,11,12 & 13.
So by using jumper wires connect all the pins except (the above mentioned ones) of the TFT back to UNO as it would have been if the TFT was press fitted on the UNO as mentioned before.
Connecting the Load Cell With HX711:
The Load Cell will have 4 wires as its output which will be given to the HX711's input i.e
- RED wire to E+
- BLACK wire to E-
- GREEN wire to A+
- WHITE wire to A-
Connecting HX711 to UNO:
- Connect pin DT of HX711 to digital pin 11 of UNO
- Connect pin SCK of HX711 to digital pin 10 of UNO
Step 3: Mechanical Arrangement
Now you can place the UNO,HX711 and TFT anywhere you want. But the Load cell should be placed in a cantilever manner. Take 2 rectangular pieces of plywood 1) 150mmX150mm(For the Base) and 2) 100mmX150mm (For placing the weights)
Mount the load Cell as shown in the image or in a Z shape
Check the images that I have attached to get a better understanding.
Now note that while you place the weight the whole thing will toppel as the base is not fixed. Secure the base in any manner suitable by you (I have used a C-Clamp).
Step 4: Required Libraries and Identifying the TFT Driver
The Libraries that you will be needing are:
You will need all the above four libraries for the TFT to work properly along with the TFT.
Now the first thing that you should do is find out whic driver you have running your TFT
for this run the graphictest in the TFTLCD_5408 examples.
Now you will be able to see your TFT come to life. And there you can see some text after some time which will contain the Driver ID.
Just run the Touch_shield_kbv example and it will display the ID.
Step 5: Configuring the Touch
The problem that you might face now is that the x & y co-ordinates are inverted either horizontally or vertically.
You can notic this after using the paint function after clicking the 'EXIT' option on the TFT screen.
You would definitely want to fix this.So you will have to hamper the code " Touch_shield_kbv " . Try changing
tp.x to 1050-tp.x or tp.y to 1050-tp.y these are the values that you will have to play around to get the touch working properly. Or Try changing the pins to YP,XP,YM,XM.
If everything is working properly upload the code that I have attached at the end.
You can create your very own user interface by using some of the functions like tft.fillScreen(); tft.fillRect(); tft.drawRect(); tft.print(); tft.setCursor(); ,etc. Now to make the drawn rectangle behave like a button the touch should be proper. Just map the x and y co-ordinates and write it in a IF statement under the IF touch-sensed condition i.e(tp.z)
Now if you want to increase the least count of the Load Cell then change the value from 1 to any greater value in this function --> Serial.print(scale.get_units() ,1);
Step 6: How to Use It
Just click on LOAD CELL then click on START and wait for all the messages to finish displaying click on Unit Change and select your desired unit and it will start displaying the result once you place some load on it.
The calibration factor is different for different load cells for me it was -90000
Click on + or - to increase or decrease the calibration factor.
Note : When you will be using an UNO with a TFT and a Load cell the number of pins will be limited ..Now not that the HX711 requires a supply voltage ranging from 3.3V-5V (5.5V at max ..Thats what I have read).
So I have used a 9V battery and a 7805 to produce 5v supply for the HX711.
Thank you for Reading this Instrucatble.
Video Coming Soon..
Step 7: Arduino Code
Participated in the
First Time Author Contest