Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //But me coffee: https://paypal.me/chlebovec
- #include "HX711.h"
- #define DOUT 3
- #define CLK 2
- HX711 scale;
- float calibration_factor = -50.10; //KALIBRAČNÝ FAKTOR
- void setup() {
- scale.begin(DOUT, CLK);
- Serial.begin(115200);
- Serial.println("HX711 calibration sketch");
- Serial.println("Remove all weight from scale");
- Serial.println("After readings begin, place known weight on scale");
- Serial.println("Press + or a to increase calibration factor");
- Serial.println("Press - or z to decrease calibration factor");
- scale.set_scale();
- scale.tare(); //Reset the scale to 0
- long zero_factor = scale.read_average(); //Get a baseline reading
- Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
- Serial.println(zero_factor);
- }
- void loop() {
- scale.set_scale(calibration_factor); //Adjust to this calibration factor
- Serial.print("Reading: ");
- Serial.print(scale.get_units(10), 2);
- Serial.print(" g"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
- Serial.print(" calibration_factor: ");
- Serial.print(calibration_factor);
- Serial.println();
- if (Serial.available())
- {
- //LADENIE
- char temp = Serial.read();
- if (temp == '+' || temp == 'a')
- calibration_factor += 0.1;
- else if (temp == '-' || temp == 'z')
- calibration_factor -= 0.1;
- }
- }
Add Comment
Please, Sign In to add comment