2018年4月12日 星期四
HX711 Load Cell + NODEMCU
/*
* circuits4you.com
* 2016 November 25
* Load Cell HX711 Module Interface with Arduino to measure weight in Kgs
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 0 // D3
#define CLK 2 // D4
HX711 scale(DOUT, CLK);
//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands
//float calibration_factor = -96650; //-106600 worked for my 40Kg max scale setup
float calibration_factor = (-382155); //worked for my 5Kg max scale setup
//=============================================================================================
// SETUP
//=============================================================================================
void setup() {
Serial.begin(115200);
Serial.println("HX711 Calibration");
Serial.println("Remove all weight from scale");
Serial.println("After readings begin, place known weight on scale");
Serial.println("Press a,s,d,f to increase calibration factor by 10,100,1000,10000 respectively");
Serial.println("Press z,x,c,v to decrease calibration factor by 10,100,1000,10000 respectively");
Serial.println("Press t for tare");
delay(3000);
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);
Serial.println();
Serial.println("HX711 Scale Reading .....");
}
//=================================================================
// LOOP
//=================================================================
void loop() {
scale.set_scale(calibration_factor); //Adjust to this calibration factor
if (scale.get_units() > 0.002)
{
Serial.println("Reading: ");
Serial.print(scale.get_units(), 4);
Serial.print(" kg"); //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();
scale.power_down();
delay(1000);
scale.power_up();
}
else
{
Serial.println("HX711 Scale Reading .....");
scale.power_down();
delay(1000);
scale.power_up();
}
if(Serial.available())
{
char temp = Serial.read();
if(temp == '+' || temp == 'a')
calibration_factor += 10;
else if(temp == '-' || temp == 'z')
calibration_factor -= 10;
else if(temp == 's' || temp == 'S')
calibration_factor += 100;
else if(temp == 'x'|| temp == 'X')
calibration_factor -= 100;
else if(temp == 'd'|| temp == 'D')
calibration_factor += 1000;
else if(temp == 'c'|| temp == 'C')
calibration_factor -= 1000;
else if(temp == 'f'|| temp == 'F')
calibration_factor += 10000;
else if(temp == 'v'|| temp == 'V')
calibration_factor -= 10000;
else if(temp == 't'|| temp == 'T')
scale.tare(); //Reset the scale to zero
}
}
//==========================================================
訂閱:
張貼留言 (Atom)
2024_09 作業3 以Node-Red 為主
2024_09 作業3 (以Node-Red 為主 Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker 2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...
-
課程講義 下載 11/20 1) PPT 下載 + 程式下載 http://www.mediafire.com/file/cru4py7e8pptfda/106%E5%8B%A4%E7%9B%8A2-1.rar 11/27 2) PPT 下載...
-
• 認 識 PreFix、InFix、PostFix PreFix(前序式):* + 1 2 + 3 4 InFix(中序式): (1+2)*(3+4) PostFix(後序式):1 2 + 3 4 + * 後 序式的運算 例如: 運算時由 後序式的...
沒有留言:
張貼留言