gemu2015 / Sonoff-Tasmota

Tasmota Fork TCS34725,PN532_i2,ccc1101 Moritz support,m5stack 4,7 epaper, hotplug drivers
GNU General Public License v3.0
24 stars 19 forks source link

esp8266 crashes when using http() and gwr() (trying to retrieve a json from a url) #34

Closed MagTun closed 2 years ago

MagTun commented 2 years ago

PROBLEM DESCRIPTION

A clear and concise description of what the problem is. My esp8266 keep resetting itself when I use http() and gwr()

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [ ] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:

Rules output here:

- [ x] Provide the output of this command: `Status 0`:

STATUS 0 output here:

15:17:35.264 RSL: STATUS = {"Status":{"Module":0,"DeviceName":"Tasmota","FriendlyName":["Tasmota"],"Topic":"tasmota_BC8288","ButtonTopic":"0","Power":1,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0}} 15:17:35.271 RSL: STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota/release/tasmota.bin.gz","RestartReason":"External System","Uptime":"0T00:11:14","StartupUTC":"2021-09-08T14:06:21","Sleep":50,"CfgHolder":4617,"BootCount":52,"BCResetTime":"2021-08-24T14:31:21","SaveCount":120,"SaveAddress":"F5000"}} 15:17:35.278 RSL: STATUS2 = {"StatusFWR":{"Version":"9.5.0.2(tasmota)","BuildDateTime":"2021-09-02T20:50:19","Boot":31,"Core":"2_7_4_9","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8266EX","CR":"335/699"}} 15:17:35.284 RSL: STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["SFR_7DC0",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00008009","2805C8000100060000005A0A000000000000","00000080","00006000","00000000"]}} 15:17:35.294 RSL: STATUS4 = {"StatusMEM":{"ProgramSize":699,"Free":304,"Heap":24,"ProgramFlashSize":1024,"FlashSize":4096,"FlashChipId":"1640EF","FlashFrequency":40,"FlashMode":3,"Features":["00000809","87DAC787","043E8001","000000CF","010013C0","C000F981","00004004","00001000","00000020"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,16,18,19,20,21,22,24,26,27,29,30,35,37,45","Sensors":"1,2,3,4,5,6"}} 15:17:35.300 RSL: STATUS5 = {"StatusNET":{"Hostname":"tasmotaBC8288-0648","IPAddress":"192.168.1.32","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.1.1","Mac":"EC:FA:BC:BC:82:88","Webserver":2,"WifiConfig":4,"WifiPower":17.0}} 15:17:35.305 RSL: STATUS6 = {"StatusMQT":{"MqttHost":"","MqttPort":1883,"MqttClientMask":"DVES%06X","MqttClient":"DVES_BC8288","MqttUser":"DVES_USER","MqttCount":0,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4}} 15:17:35.311 RSL: STATUS7 = {"StatusTIM":{"UTC":"2021-09-08T14:17:35","Local":"2021-09-08T15:17:35","StartDST":"2021-03-28T02:00:00","EndDST":"2021-10-31T03:00:00","Timezone":"+01:00","Sunrise":"06:17","Sunset":"19:17"}} 15:17:35.316 RSL: STATUS9 = {"StatusPTH":{"PowerDelta":[0,0,0],"PowerLow":0,"PowerHigh":0,"VoltageLow":0,"VoltageHigh":0,"CurrentLow":0,"CurrentHigh":0}} 15:17:35.323 RSL: STATUS10 = {"StatusSNS":{"Time":"2021-09-08T15:17:35","ENERGY":{"TotalStartTime":"2021-08-24T14:31:21","Total":0.000,"Yesterday":0.000,"Today":0.000,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":0,"Current":0.000}}} 15:17:35.330 RSL: STATUS11 = {"StatusSTS":{"Time":"2021-09-08T15:17:35","Uptime":"0T00:11:14","UptimeSec":674,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":0,"POWER":"ON","Wifi":{"AP":1,"SSId":"SFR_7DC0","BSSId":"60:35:C0:53:7D:C6","Channel":11,"Mode":"11n","RSSI":42,"Signal":-79,"LinkCount":1,"Downtime":"0T00:00:05"}}}

- [x ] Provide the output of the Console log output when you experience your issue; if applicable:
  _(Please use_ `weblog 4` _for more debug information)_

Console output here:

00:00:00.001 HDW: ESP8266EX 00:00:00.054 CFG: Loaded from flash at FB, Count 122 00:00:00.059 FRC: Some settings have been reset (2) 00:00:00.061 CFG: CR 335/699, Busy 0 00:00:00.064 SRC: Restart 00:00:00.066 Project tasmota Tasmota Version 9.5.0.2(tasmota)-2_7_4_9(2021-09-02T20:50:19) 00:00:00.070 Script: nv=3, tv=1, vns=20, ram=92 00:00:00.222 WIF: Checking connection... 00:00:00.223 WIF: Attempting connection... 00:00:00.559 WIF: Connecting to AP1 SFR_7DC0 Channel 11 BSSId 60:35:C0:53:7D:C6 in mode 11n as tasmota_BC8288-0648... 00:00:01.754 WIF: Checking connection... 00:00:01.755 WIF: Attempting connection... 00:00:02.755 WIF: Checking connection... 00:00:02.756 WIF: Attempting connection... 00:00:03.757 WIF: Checking connection... 00:00:03.758 WIF: Connected 00:00:04.012 HTP: Web server active on tasmota_BC8288-0648 with IP address 192.168.1.32 00:00:04.316 HTP: Console 00:00:04.433 RTC: UTC 2021-09-08T14:26:30, DST 2021-03-28T02:00:00, STD 2021-10-31T03:00:00 15:26:31.023 RSL: INFO1 = {"Info1":{"Module":"Generic","Version":"9.5.0.2(tasmota)","FallbackTopic":"cmnd/DVES_BC8288_fb/","GroupTopic":"cmnd/tasmotas/"}} 15:26:31.029 RSL: INFO2 = {"Info2":{"WebServerMode":"Admin","Hostname":"tasmota_BC8288-0648","IPAddress":"192.168.1.32"}} 15:26:31.039 RSL: INFO3 = {"Info3":{"RestartReason":"External System"}} 15:26:31.045 RSL: RESULT = {"POWER":"ON"} 15:26:31.048 RSL: POWER = ON 15:26:32.455 QPC: Reset


### TO REPRODUCE
_Steps to reproduce the behavior:_

I have modified the `user_config_override.h` as follow:

ifndef _USER_CONFIG_OVERRIDEH

define _USER_CONFIG_OVERRIDEH

ifndef USE_SCRIPT

define USE_SCRIPT

endif

ifdef USE_RULES

undef USE_RULES

endif

define USE_WEBSEND_RESPONSE

endif // _USER_CONFIG_OVERRIDEH


And then I use this script:

D tvstr="" tvnum=0 res=0 flg=0 S if upsecs%10==0 then ; get contents to http page, directly call section >E when ready flg=1 print call luftsensor ; IP could be either http://192.168.1.39:888/data.json (it's a portmap to port 80 via a wifi repeater) or http://192.168.1.33/data.json ; res=http("192.168.1.39:888" "/data.json") res=http("192.168.1.33" "/data.json") flg=0 endif E if flg>0 then ; extract 4 occurrence of text "value" tvstr=gwr("value" 4) print %tvstr% print "111" ; get rid of " chars at start tvstr=st(tvstr " 2) print %tvstr% print "222" ; convert string to number tvnum=tvstr print %tvnum% print "333" endif

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen. I want to use my Tasmota NodeMCU esp8266 to turn ON/OFF my DIY air filter when my Luftdaten sensor is above a certain threshold). The smart plug should connect to my json local url and based on the data in this json (if value of SDS_P1 is above 5 or value of SDS_P2 is above 10), the NodeMCU should switch on and off the air filter.

The json looks like that :

{"software_version": "VV-111-133", "age":"12", "sensordatavalues":[{"value_type":"SDS_P1","value":"6.32"},{"value_type":"SDS_P2","value":"2.70"},{"value_type":"temperature","value":"25.00"},{"value_type":"humidity","value":"58.10"},{"value_type":"samples","value":"4902366"},{"value_type":"min_micro","value":"29"},{"value_type":"max_micro","value":"234874"},{"value_type":"interval","value":"145000"},{"value_type":"signal","value":"-55"}]}

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

gemu2015 commented 2 years ago

ok, just uploaded a debug version add #define HTTP_DEBUG to user config and report the console messages

MagTun commented 2 years ago

Thanks a lot for that! I am not sure what you mean by "debug version" but I download the code from this repo and build it via platformIO and it worked! The value was retrieved. Then I tested with the current Tasmota development which is 9.5.0.8 and the value was also retrieved! I just need to retrieve the second value for SDS_P2 and then to switch the plug on/off based on a threshold. I will then publish the code for the others luftdaten users.

Thanks a lot for your help! You were amazing!

The final script with the working http() and gwr() can be found here.