If there's a lot of noise, well...then other measures might need to be taken, such as shielding or using ferrite beads.
this was a busy week, but now I can answer. At first, thanks for the tipps!
I tied many different combinations but don't find a solution for the reboot problem.
I have the suspicion that, the oled implementation donT work reliable in my case. If I replace "oled.line(....)" with "print(....)", the script works without reboots.
In future I will concentrate on the other oled implementations.
I learned a lot an that is important!
I have tried:
- to split the scripts to save heap ( it makes sense?)
- I change the TCP Server into UDP Server
- I insert "tmr.wdclr()" at different positions
- I insert collectgarbage() at different positions
- placed different capacitor direct before the esp board
- change display
- change board (ESP-01 and ESP-ADC DIP)
Can it be possible, that the "for" loops in the oled implementation (source) timed out the watchdog?
I wish you a good weekend
Alex
print(node.heap())
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","PASS")
wifi.sta.setip({ip="192.168.178.111",netmask="255.255.255.0",gateway= "192.168.178.1"})
print(wifi.sta.getip())
firststart = true
dofile("oledsrv.lua")
payload=nil
srv=net.createServer(net.UDP)
srv:on("receive",function(conn,payloadX)
if firststart==true then
oled.setup(6,5)
oled.invert(0)
oled.clear()
firststart=false
end
payload = payloadX
dofile("split.lua")
payload = nil
tmr.wdclr()
if lines[1]~=nil then tmr.wdclr() oled.line(1, 1, lines[1]) lines[1]=nil end
if lines[2]~=nil then tmr.wdclr() oled.line(2, 1, lines[2]) lines[2]=nil end
if lines[3]~=nil then tmr.wdclr() oled.line(3, 1, lines[3]) lines[3]=nil end
if lines[4]~=nil then tmr.wdclr() oled.line(4, 1, lines[4]) lines[4]=nil end
if lines[5]~=nil then tmr.wdclr() oled.line(5, 1, lines[5]) lines[5]=nil end
if lines[6]~=nil then tmr.wdclr() oled.line(6, 1, lines[6]) lines[6]=nil end
if lines[7]~=nil then tmr.wdclr() oled.line(7, 1, lines[7]) lines[7]=nil end
end)
srv:listen(31401)
local max_line_length = 21
lines = {}
print(payload)
local line
payload = payload:gsub("+", " ")
payload = payload:gsub("%%3A+", " ")
payload = payload:gsub("%%5B", " ")
payload = payload:gsub("%%5D", " ")
payload = payload:gsub("%[", " ")
payload = payload:gsub("%]", " ")
payload:gsub('(%s*)(%S+)',
function(spc, word)
if not line or #line + #spc + #word > max_line_length then
table.insert(lines, line)
line = word
else
line = line..spc..word
end
end
)
if line ~= nil then table.insert(lines, line) end
line = nil