Hello can I help please.
Im ESP32 - MODEMCU32S a connect to HX711 a waight senzor.
But problem dont found senzor.
My cod:
#include "HX711.h"
#include "WiFi.h"
#include "Wire.h"
#include "stdio.h"
#include <Arduino.h>
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif
const int LOADCELL_DOUT_PIN = 23;
const int LOADCELL_SCK_PIN = 22;
const char *ssid = "TESTMS";
const char *password = "autobus2020";
IPAddress server(192, 168, 10, 20);
long reading;
HX711 htu = HX711();
void TaskBlink(void *pvParameters);
void doServer(void *pvParameters);
void doMeasure(void *pvParameters);
void setup() {
Serial.begin(115200);
htu.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
if (!htu.is_ready()) {
Serial.println("Couldn't find sensor!");
while (1)
;
}
xTaskCreatePinnedToCore(TaskBlink, "TaskBlink", 1024, NULL, configMAX_PRIORITIES - 3, NULL, ARDUINO_RUNNING_CORE);
xTaskCreatePinnedToCore(doMeasure, "doMeasure", 8192, NULL, configMAX_PRIORITIES - 2, NULL, ARDUINO_RUNNING_CORE);
xTaskCreatePinnedToCore(doServer, "doServer", 8192, NULL, configMAX_PRIORITIES - 1, NULL, ARDUINO_RUNNING_CORE);
}
void loop() {
vTaskDelay(1000);
}
void TaskBlink(void *pvParameters) {
(void)pvParameters;
pinMode(LOADCELL_SCK_PIN, OUTPUT);
pinMode(LOADCELL_DOUT_PIN, INPUT);
for (; {
digitalWrite(LOADCELL_SCK_PIN, HIGH);
vTaskDelay(10);
Serial.print("mereni: ");
Serial.println(reading);
digitalWrite(LOADCELL_SCK_PIN, LOW);
vTaskDelay(490);
}
}
void doMeasure(void *pvParameters) {
(void)pvParameters;
for (; {
reading = htu.read();
vTaskDelay(1000);
}
}
void doServer(void *pvParameters) {
(void)pvParameters;
for (; {
vTaskDelay(100);
}
}
Terminal:
Executing task in folder skola: C:\Users\eriko.platformio\penv\Scripts\platformio.exe run <
Processing nodemcu-32s (platform: espressif32; board: nodemcu-32s; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via -v, --verbose
option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 32 (3.1.0) > NodeMCU-32S
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 3.10005.210223 (1.0.5)
- tool-esptoolpy 1.30000.201119 (3.0.0)
- toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> Library Dependency Finder (LDF) — PlatformIO latest documentation
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 29 compatible libraries
Scanning dependencies...
Dependency Graph
|-- 0.7.4
|-- 1.0
|-- 1.0.1
Building in release mode
Retrieving maximum program size .pio\build\nodemcu-32s\firmware.elf
Checking size .pio\build\nodemcu-32s\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 4.1% (used 13540 bytes from 327680 bytes)
Flash: [== ] 16.0% (used 209680 bytes from 1310720 bytes)
======================================================= [SUCCESS] Took 4.02 seconds =======================================================
Terminal will be reused by tasks, press any key to close it.
And to connect senzor:
Executing task in folder skola: C:\Users\eriko.platformio\penv\Scripts\platformio.exe device monitor <
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at Redirecting...
--- Miniterm on COM3 115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Couldn't find sensor!