You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a project where I need to capture the weight from an HX711 load cell connected to an ESP32 board and integrate the data with Azure IoT Hub using the Azure SDK for C.
I have already configured the iot_configs.h file correctly with the necessary Azure IoT settings.
The goal is to send the weight data captured from the HX711 sensor to Azure IoT Hub.
I’ve successfully connected the HX711 to the ESP32 and can read the weight, but I'm struggling to combine this with the Azure SDK C code to send the weight_In_g data as telemetry to Azure IoT central. Could anyone guide integrating the weight capture program with Azure SDK C? Any code examples or references would be greatly appreciated.
Hardware:
ESP32
HX711
Software:
Azure IoT Central
Arduino IDE Code
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 03_Load_Cell_Sensor_5kg_Calibration
// In this step, the calibration value will be stored in the ESP32 flash memory.
// The calibration value in this step will be used in the next step.
//----------------------------------------Including the libraries.
#include "HX711.h"
//----------------------------------------Defines the connected PIN between HX711 and ESP32.
#define LOADCELL_DOUT_PIN 5
#define LOADCELL_SCK_PIN 18
//----------------------------------------
// Predefined calibration factor (set to 382 as per your requirement)
#define CALIBRATION_FACTOR 382
// Bool variable to display the weighing results.
bool show_Weighing_Results = false;
int weight_In_g; // Int variable to hold the value of the weighing results in units of grams (g).
float weight_In_oz; // Float variable to hold the value of the weighing results in units of ounce (oz).
// Initialize the HX711 library as LOADCELL_HX711.
HX711 LOADCELL_HX711;
//________________________________________________________________________________VOID SETUP()
void setup() {
// put your setup code here, to run once:
// Set the predefined calibration factor directly
LOADCELL_HX711.set_scale(CALIBRATION_FACTOR);
delay(1000);
// Tare the scale
LOADCELL_HX711.tare();
Serial.println("Scale has been tared.");
show_Weighing_Results = true;
Serial.println();
Serial.println("The scales are ready to use.");
}
//________________________________________________________________________________
//________________________________________________________________________________VOID LOOP()
void loop() {
// put your main code here, to run repeatedly:
//----------------------------------------The condition for printing the results of weighing objects on the serial monitor after the calibration process is complete.
if (show_Weighing_Results == true) {
if (LOADCELL_HX711.is_ready()) {
// The value 10 in get_units(10) means getting the average value of 10 readings.
// For more details see in File -> Examples -> HX711 Arduino Library -> HX711_full_example
// Get the reading of the object's weight in grams (g).
weight_In_g = LOADCELL_HX711.get_units(10);
// Get the reading of the object's weight in ounces (oz).
weight_In_oz = float(weight_In_g) / 28.34952;
Serial.print("Weight : ");
Serial.print(weight_In_g);
Serial.print(" g");
Serial.print(" | ");
Serial.print(weight_In_oz, 2);
Serial.println(" oz");
} else {
Serial.println("HX711 not found.");
}
}
//----------------------------------------
delay(1000);
}
The text was updated successfully, but these errors were encountered:
I'm working on a project where I need to capture the weight from an HX711 load cell connected to an ESP32 board and integrate the data with Azure IoT Hub using the Azure SDK for C.
I have already configured the iot_configs.h file correctly with the necessary Azure IoT settings.
The goal is to send the weight data captured from the HX711 sensor to Azure IoT Hub.
I’ve successfully connected the HX711 to the ESP32 and can read the weight, but I'm struggling to combine this with the Azure SDK C code to send the weight_In_g data as telemetry to Azure IoT central. Could anyone guide integrating the weight capture program with Azure SDK C? Any code examples or references would be greatly appreciated.
Hardware:
ESP32
HX711
Software:
Azure IoT Central
Arduino IDE Code
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 03_Load_Cell_Sensor_5kg_Calibration
// In this step, the calibration value will be stored in the ESP32 flash memory.
// The calibration value in this step will be used in the next step.
//----------------------------------------Including the libraries.
#include "HX711.h"
//----------------------------------------Defines the connected PIN between HX711 and ESP32.
#define LOADCELL_DOUT_PIN 5
#define LOADCELL_SCK_PIN 18
//----------------------------------------
// Predefined calibration factor (set to 382 as per your requirement)
#define CALIBRATION_FACTOR 382
// Bool variable to display the weighing results.
bool show_Weighing_Results = false;
int weight_In_g; // Int variable to hold the value of the weighing results in units of grams (g).
float weight_In_oz; // Float variable to hold the value of the weighing results in units of ounce (oz).
// Initialize the HX711 library as LOADCELL_HX711.
HX711 LOADCELL_HX711;
//________________________________________________________________________________VOID SETUP()
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println();
delay(2000);
Serial.println("Setup...");
delay(1000);
Serial.println();
Serial.println("Do not place any object or weight on the scale.");
delay(1000);
Serial.println();
Serial.println("LOADCELL_HX711 begin.");
LOADCELL_HX711.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
// Set the predefined calibration factor directly
LOADCELL_HX711.set_scale(CALIBRATION_FACTOR);
delay(1000);
// Tare the scale
LOADCELL_HX711.tare();
Serial.println("Scale has been tared.");
show_Weighing_Results = true;
Serial.println();
Serial.println("The scales are ready to use.");
}
//________________________________________________________________________________
//________________________________________________________________________________VOID LOOP()
void loop() {
// put your main code here, to run repeatedly:
//----------------------------------------The condition for printing the results of weighing objects on the serial monitor after the calibration process is complete.
if (show_Weighing_Results == true) {
if (LOADCELL_HX711.is_ready()) {
// The value 10 in get_units(10) means getting the average value of 10 readings.
// For more details see in File -> Examples -> HX711 Arduino Library -> HX711_full_example
}
//----------------------------------------
delay(1000);
}
The text was updated successfully, but these errors were encountered: