For our “Safe Bike Path” project, weighing sensors are necessary to test if there is any car running or turning over the bike path. In our prototype, we are going to use the load sensor as follow:
The maximum weight will be 50 kg /110 lb. We went through some existing tutorials and found that it’s easy to be used.
The parts we need in this section are:
- Load (Weighing) Sensors
- Arduino board
- Amplifier HX711
- LEDs
The first job is to read data from the load sensors.
The code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
/* Arduino pin 2 -> HX711 CLK 3 -> DOUT 5V -> VCC GND -> GND Most any pin on the Arduino Uno will be compatible with DOUT/CLK. The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine. */ #include "HX711.h" #define DOUT 3 #define CLK 2 HX711 scale(DOUT, CLK); float calibration_factor = -7050; //-7050 worked for my 440lb max scale setup void setup() { Serial.begin(9600); 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(), 1); Serial.print(" lbs"); //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()) { char temp = Serial.read(); if(temp == '+' || temp == 'a') calibration_factor += 10; else if(temp == '-' || temp == 'z') calibration_factor -= 10; } } |
Sources:
http://www.instructables.com/id/Arduino-Bathroom-Scale-With-50-Kg-Load-Cells-and-H/
https://arduino.stackexchange.com/questions/11946/how-to-get-weight-data-from-glass-electronic-bathroom-scale-sensors/18698#18698
https://electronics.stackexchange.com/questions/102164/3-wire-load-cells-and-wheatstone-bridges-from-a-bathroom-scale/199470#199470
http://www.instructables.com/id/Make-your-weighing-scale-hack-using-arduino/