Code failure

36 views
Skip to first unread message

Nic Sony Phone

unread,
Nov 22, 2019, 10:40:00 AM11/22/19
to TasmotaUsers
I wrote some rules code for a Sonoff TH16 with a temperature probe DS18B20 to control a geyser as thermostat. I also publish custom mqtt messages on state changes as well as every minute.

The code works mostly... But i get a device reset with a "hardware watchdog" or "exception" error. This only happens when the thermostat is off, and the temperature drops below the minimum threashold. Device will restart and function as normal.

Can anyone spot the error?

var1 - Temperature
var2 - print + error
var3 - tele time snapshot
var4 - publish timer (s)
var5 - power state 1/0

Rule1
ON System#Boot DO backlog mem1 59; mem2 52; var4 60; RuleTimer1 30; Teleperiod 60 ENDON
ON Power1#Boot DO backlog Power 0; var5 0 ENDON
ON tele-DS18B20#Temperature DO backlog var1 %value%; var3 %timestamp% ENDON
ON var1#state>60 DO var2 3 ENDON
ON var1#state<60 DO event chkt=%var1% ENDON ON var2#State DO event prt=%value% ENDON
ON event#prt>1 DO POWER 0 ENDON
ON event#prt=3 DO Publish2 bb/ERROR/geyser {"ER":"High_%var1%"} BREAK
ON event#prt=2 DO Publish2 bb/ERROR/geyser {"ER":"NULL_PR"} BREAK

Rule2
ON event#chkt<%mem2% DO var2 1 ENDON
ON event#chkt>%mem1% DO var2 0 ENDON
ON event#prt<2 DO POWER1 %var2% ENDON
ON Power1#State DO backlog var5 %value%; event pubgsa; event pubpush ENDON
ON Rules#Timer=1 DO backlog event pubgsa; Ruletimer1 %var4% ENDON

Rule3
ON event#pubgs DO Publish2 bb/metrics/geyser/thermo {"POWER":"%var5%"} ENDON
ON event#pubgsa DO Publish2 bb/metrics/geyser/thermo {"Temp":"%var1%","POWER":"%var5%","HiLvl":"%mem1%","LoLvl":"%mem2%","Teletime":"%var3%"} ENDON
ON event#pubpush DO Publish bb/push/geyser/thermo {"Thermo":"%var5%"} ENDON


Any help will be appreciated.

Philip Knowles

unread,
Nov 23, 2019, 1:50:52 AM11/23/19
to TasmotaUsers, Nic Sony Phone
It seems to be complicated.
If you start with
ON DS18B20#Temperature<%mem2% DO Power1 1 ENDON
ON DS18B20#Temperature>%mem1% DO Power1 0 ENDON
it will do your on/off based on your high and low setpoints (and publish to MQTT when it changes state).
You're sending an alarm if the temp goes over 60 which is fair enough but I would relate it to the setpoint and 60 is close to the high setpoint and you may get spurious alarms. I would use mem3 as your alarm and set it at start up at something like 62
Once you know that is working correctly add the additional bits one at a time.
Incidentally I would always have my low setpoint as mem1 and the high as mem2 . Serves as a visual reminder which way the setpoints should be.
I tend to write the rules in notepad and cut and paste so it's easy to add and subtract bits.

Regards

Phil K

Sent from Outlook Mobile


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Nic Sony Phone <nic.p...@gmail.com>
Sent: Friday, November 22, 2019 3:40:00 PM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Code failure
 
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/bb457e23-5b14-47d2-ba1b-a5d8eda1b90f%40googlegroups.com.

Nic Sony Phone

unread,
Nov 23, 2019, 5:33:39 PM11/23/19
to TasmotaUsers
After changing lots of things, i tested the code on a different TH16, without issues.

I did an OTA reflash again 6.6.0 with Sonoff.bin, and that seems to fix the issue.

I would suggest to anyone who gets a random Hardware Watchdog reset or Exeption error reset to try reflashing OTA. I suspect the FTDI adaptors barely delivers enough power.

I will in future flash a blank, then Sonoff.bin, get setup on the network and do an OTA before anything. The OTA went flawless with first sonoff-minimal.bin, then Sonoff.bin

Never had an issue with basic R2, I think the bigger pcb on the TH16 is to blame.

Michael Ingraham

unread,
Nov 23, 2019, 6:53:54 PM11/23/19
to TasmotaUsers
Flashing via serial should always be preceded by erase_slash. Loading a "blank" may not erase all of flash.

FTDI are notorious for bad knock offs. Insufficient power is usually the culprit. The Tasmota wiki installation prerequisites suggest the best adapters for serial flashing.

Reply all
Reply to author
Forward
0 new messages