Open Werevolk opened 7 years ago
can you share your code?
It's a standard example: `
const char host = "esp8266-webupdate"; const char ssid = "SSID"; const char* password = "PASS";
ESP8266WebServer httpServer(80); ESP8266HTTPUpdateServer httpUpdater;
void setup(void){
Serial.begin(115200); Serial.println(); Serial.println("Booting Sketch..."); WiFi.mode(WIFI_AP_STA); WiFi.begin(ssid, password);
while(WiFi.waitForConnectResult() != WL_CONNECTED){ WiFi.begin(ssid, password); Serial.println("WiFi failed, retrying."); }
MDNS.begin(host);
httpUpdater.setup(&httpServer); httpServer.begin();
MDNS.addService("http", "tcp", 80); Serial.printf("HTTPUpdateServer ready! Open http://%s.local/update in your browser\n", host); }
void loop(void){ httpServer.handleClient(); } `
It works fine if I'm not including HX711 library but I get WDT reset when I'm trying to perform OTA with included library.
Sounds similar to #63 - not sure what, but something in the include apparently upsets the ESP network libraries. @Werevolk Can you try moving the include of HX711.h after all the other includes?
Just tried to move include after all the others. Not helped at all, same error on OTA:
Soft WDT reset
ctx: cont sp: 3fff0380 end: 3fff0750 offset: 01b0
I think I've found the solution! I cpmmented out yield() in H711.cpp `
// "yield" is not implemented as noop in older Arduino Core releases, so let's define it.
// See also: https://stackoverflow.com/questions/34497758/what-is-the-secret-of-the-arduino-yieldfunction/34498165#34498165
// void yield(void) {};
`
And finally OTA is able to finish without WDT resets!
As I understand it also will fix an issue causing resets when module is failed to initialize at setup().
@werevolk i will be very great full to you if you please upload the code which have hx711 & dth sensor for nodemcu.
Hi guys,
I had the same problem as in the first post and could also solve it by commenting the yield part...
Now I encounter a reset error when adding the line
HX711 scale(SCALE_DOUT_PIN, SCALE_SCK_PIN);
The Error:
ets Jan 8 2013,rst cause:2, boot mode:(1,6)
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
My code is actually nothing special, just WIFI Connect and MQTT initialisation. Now I am debugging line by line of my HX711 code and I am now at the line mentioned above.
Any idea?
edit:
This is my code:
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "HX711.h"
//WIFI Settings
const char* ssid = "";
const char* password = "";
const char* mqtt_server = "192.168.1.50";
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
randomSeed(micros());
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}
Serial.println();
// Switch on the LED if an 1 was received as first character
if ((char)payload[0] == '1') {
digitalWrite(BUILTIN_LED, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is acive low on the ESP-01)
} else {
digitalWrite(BUILTIN_LED, HIGH); // Turn the LED off by making the voltage HIGH
}
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Create a random client ID
String clientId = "ESP8266Client-";
clientId += String(random(0xffff), HEX);
// Attempt to connect
if (client.connect(clientId.c_str())) {
Serial.println("connected");
// Once connected, publish an announcement...
client.publish("outTopic", "hello world");
// ... and resubscribe
client.subscribe("inTopic");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
// Scale Settings
#define calibration_factor 20000 //This value is obtained using the SparkFun_HX711_Calibration sketch
const int SCALE_DOUT_PIN = D2;
const int SCALE_SCK_PIN = D3;
HX711 scale(SCALE_DOUT_PIN, SCALE_SCK_PIN);
void setup() {
delay(5000);
Serial.begin(115200);
//WIFI Setup, MQTT
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
//Waage Setup
scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
Serial.println("Readings:");
}
void loop() {
if (!client.connected()) {
reconnect();
}
//HX711 scale(SCALE_DOUT_PIN, SCALE_SCK_PIN);
//scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
Serial.print("Reading: ");
float Message = scale.get_units();
Serial.print(Message); //(scale.get_units(), 1); //scale.get_units() returns a float
Serial.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
String pubString = String(Message);
pubString.toCharArray(msg, pubString.length()+1);
client.publish("TEST",msg);
delay(2000);
}
Hello
Thanks for this publish. To stop hangUp of my ESP8266, i've little modified HX711.cpp and HX711.h
On HX711.h, i've add new variable named : unsigned long YIELDMILLIS; And, on HX711.cpp, i've:
On function <<long HX711::read() {>>, i've little modified starting of it by: long HX711::read() {
// wait for the chip to become ready YIELDMILLIS = millis(); while (!is_ready()) { // Will do nothing on Arduino but prevent resets of ESP8266 (Watchdog Issue) yield(); if (millis() - YIELDMILLIS > 500) { //Try to fetch response for 5 return -1; }
}
This new, don't hangup my loop ;-)
Bye ! Manu
thank you!!!!
Hi! First off all, many thanks for great and easy to use library! Recently I came over an issue when trying to implement OTA update in my sketch. Everything works fine from the example sketch that I found here: https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WebServer/examples/WebUpdate/WebUpdate.ino But as soon as I include in the examle it crashes with that in serial:
I'm using NodeMCU v3 by Lolin for tests. That happens even when there is no scale.begin in code, only library include. For now I disabled OTA functionality, but hopefully this issue could be fixed.
Sorry for my bad English :)