I got my code working and can accurately see how many pints are left in my keg. : )
For fun I thought I would add the AHT10 temp and humidity sensor to pins A6 and A7.
But my temp always reads 1023.
I got my code working and can accurately see how many pints are left in my keg. : )
For fun I thought I would add the AHT10 temp and humidity sensor to pins A6 and A7.
But my temp always reads 1023.
#include <AHT10.h>
#include "HX711.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;
const int TempSensePin = A6;
const int HumSensePin = A7;
long EmptyKeg = 247134;
long ScaleZeroOffset = 719000;
long ScaleZero = 1;
long OnePint = 7625.0;
long PintsLeft = 1.0;
double Ounces = 476.5;
float reading2;
int chk;
int hum = 0; //Stores humidity value
int temp = 0; //Stores temperature value
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
HX711 scale;
void setup() {
Serial.begin(9600);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
lcd.init();
lcd.backlight();
}
void loop() {
if
(scale.is_ready()) {
reading2 = scale.read();
reading2 = (reading2 + 500000);
Serial.println();
Serial.print("reading2 ");
Serial.println(reading2);
delay (20000);
PintsLeft = ((ScaleZeroOffset - reading2))- EmptyKeg;
Serial.print("Pints Left ");
Serial.println(PintsLeft);
Ounces = PintsLeft % 7250;
Serial.println(Ounces);
Ounces = Ounces/725.0;
Serial.println(Ounces);
Ounces = ((float)Ounces*1.60);
Serial.println(Ounces);
PintsLeft = (PintsLeft/7250);
Serial.print("Pints Left ");
Serial.println(PintsLeft);
Serial.print("Ounces ");
Serial.println(Ounces);
lcd.clear();
lcd.print("Keg has ");
lcd.print(PintsLeft);
lcd.print(" Pints ");
lcd.setCursor(0,1);
lcd.print(Ounces);
lcd.print(" OZs left");
delay (15000);
int hum = analogRead(TempSensePin); //Stores humidity value
int temp = analogRead(HumSensePin); //Stores temperature value
lcd.clear();
lcd.print("Temperature ");
lcd.println(temp);
lcd.print("Humidity ");
lcd.println(hum);
delay (5000);
} else {
Serial.println("HX711 not found.");
}
delay(1000);
}
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.