#include "HX711.h"
#include <LiquidCrystal_I2C.h>
#include <RotaryEncoder.h> // biblioteca botao rotativo
LiquidCrystal_I2C lcd(0x27, 16, 2);
// variaveis botao rotativo
int valor;
int points;
RotaryEncoder encoder(0, 1);
const int LOADCELL_DOUT_PIN = 5;
const int LOADCELL_SCK_PIN = 17;
HX711 scale;
float calibration_factor = -1365;
void setup() {
Serial.begin(115200);
lcd.init();
lcd.backlight();
lcd.begin(16,1);
pinMode(2, INPUT);
Serial.begin(9600);
Serial.println("Gire o encoder....");
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale();
scale.tare(); //Reset the scale to 0
long zero_factor = scale.read_average(); //Get a baseline reading
delay(1000);
}
void loop(){
unsigned int ADC = scale.get_units();
float weight = float(ADC) / 2100.00 * 5.00;
// Serial.print("ADC = ");
//Serial.print(ADC);
// Serial.print(", weight = ");
// Serial.println(weight);
lcd.setCursor(2,1);
lcd.print(weight);
//lcd.print("kilos");
lcd.setCursor(5,0);
lcd.print("Dosador");
static int pos = 0;
encoder.tick();
int newPos = encoder.getPosition();
//Se a posicao foi alterada, mostra o valor
//no Serial Monitor
if (pos != newPos) {
Serial.print(newPos);
Serial.println();
pos = newPos;
}
}Loading
esp32-s2-devkitm-1
esp32-s2-devkitm-1