From 6222a2304249b79d6cf56fe96002b9acce97da28 Mon Sep 17 00:00:00 2001 From: Fisch Date: Thu, 18 Feb 2021 22:10:39 +0100 Subject: [PATCH] simple hx711 test --- platformio.ini | 20 ++++++++++++++++++++ src/main.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 platformio.ini create mode 100644 src/main.cpp diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..2972119 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,20 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:d1_mini] +platform = espressif8266 +board = d1_mini +framework = arduino + + +monitor_speed= 115200 + +lib_deps = + bogde/HX711 @ 0.7.4 diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..9a93d17 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,28 @@ +#include + +#include "HX711.h" + +// HX711 circuit wiring +const int LOADCELL_DOUT_PIN = D2; +const int LOADCELL_SCK_PIN = D3; + +HX711 scale; + +void setup() { + Serial.begin(115200); + scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); +} + +void loop() { + + if (scale.wait_ready_retry(10)) { + long reading = scale.read(); + Serial.print("HX711 reading: "); + Serial.println(reading); + } else { + Serial.println("HX711 not found."); + } + + delay(1500); + +} \ No newline at end of file