In: Electrical Engineering
To write strain gauge in an arduino code which is given below as : #include <TFT.h> // Arduino LCD library #include <SPI.h> // pin definition for the MICRO #define cs 7 #define dc 0 #define rst 1 TFT TFTscreen = TFT(cs, dc, rst); // char array to print to the screen char strainPrint[4]; char thermoPrint[4]; void setup() { // Put this line at the beginning of every sketch that uses the GLCD: TFTscreen.begin(); // clear the screen with a white background TFTscreen.background(255, 255, 255); // write the static text to the screen // set the header font color to black TFTscreen.stroke(0, 0, 0); // set the font size TFTscreen.setTextSize(2); // write the text to the top left corner of the screen TFTscreen.text("Sensor Values :\n ", 0, 0); // ste the font size very large for the loop TFTscreen.setTextSize(4); } void loop() { // Read the value of the strain sensor on A0 String strainVal = String(analogRead(A0)); // Read the value of the thermo sensor on A1 String thermoVal = String(analogRead(A1)); // convert the readings to char arrays strainVal.toCharArray(strainPrint, 4); thermoVal.toCharArray(thermoPrint, 4); // set the font color for strain output to blue TFTscreen.stroke(255, 0, 0); // print the strain sensor value TFTscreen.text(strainPrint, 0, 20); // set the font color for thermo output to red TFTscreen.stroke(0, 0, 255); // print the thermo sensor value TFTscreen.text(thermoPrint, 0, 60); // wait for a moment delay(250); // clear screen TFTscreen.stroke(255, 255, 255); TFTscreen.text(strainPrint, 0, 20); TFTscreen.text(thermoPrint, 0, 60); }
The Hx711 uses SPI interface to communiacate to the Arduino. Scale manufacturers use specifically designed ICs to convert the analog voltage reading to digital, the HX711 is one such specialized instrument amplifier that is commonly used inside many consumer scales. The HX711 is powered from 2.7 to 5V and uses a 2 wire digital interface (Clock and Data).