Hello everyone.
I have bought 2 pcs. Heltec lora32 V3. board, and made a code that reads a load cell an hX711,
the code works fine and the text appears on the Oled display.
but now the challenges start, I can’t get it to send it through lora to the other Heltec lora V3,
i have run an example to test lora works and it works but it doesn’t work with my code i use chat GPT to code
do not have the deepest understanding of it.
Is there a kind soul who would like to go through my code and add what is missing so that it can send it with lora and a code to the receiver Heltec lora32 V3.
#include <Wire.h>
#include “HT_SSD1306Wire.h”
#include “HX711.h”
// Heltec Display Setup
static SSD1306Wire display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED);
// HX711 Setup
#define DT 4 // Data pin
#define SCK 7 // Clock pin
HX711 scale;
// Kalibreringsfaktor (juster denne værdi for at få præcise målinger)
float calibrationFactor = 34000.0; // Skift til et passende tal for korrekt kalibrering
float maxForce = 200000.0; // Maksimal kraft i kg (justeret til vægt)
void VextON() {
pinMode(Vext, OUTPUT);
digitalWrite(Vext, LOW);
}
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println(“HX711 Tension Measurement Example”);
VextON();
delay(100);
// Initialiser display
display.init();
display.setFont(ArialMT_Plain_10);
// Initialiser HX711
scale.begin(DT, SCK);
scale.set_scale(calibrationFactor); // Sæt kalibreringsfaktor
scale.tare(); // Nulstil vægten til 0
Serial.println(“Setup Complete”);
}
void loop() {
// Læs kraft (træk) fra HX711
float force = scale.get_units(10); // Gennemsnit over 10 målinger
// Sørg for, at kraften er indenfor intervallet
if (force < 0) {
force = 0; // Negative værdier behandles som 0
}
if (force > maxForce) {
force = maxForce; // Begræns kraften til maksimal værdi
}
// Hvis du vil vise kg i stedet for N (kraft), skal du sikre, at kalibreringen er korrekt
int forceKg = (int)force; // Hvis du bruger kalibrering for vægt, kan du springe deling over
// Print kraften til Serial Monitor
Serial.print(“Trækkraft: “);
Serial.print(forceKg);
Serial.println(” kg”);
// Vis trækkraften på Heltec Skærm
display.clear();
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.setFont(ArialMT_Plain_16);
display.drawString(display.width() / 2, 10, “Trækkraft:”);
display.setFont(ArialMT_Plain_24);
display.drawString(display.width() / 2, 30, String(forceKg) + " kg");
display.display();
delay(500); // Opdater hver 500ms
}