I am using a ndemcu - newest version- and have connected a sensor to uart alt, which transfers values followed by a line break every.
Unfortunately after some time (30mins - 6h) there is no more data received/read and it is not crashing (the rest of the code I wrote is still running through successfully). To make sure it is not an issue with the sensor, I succesfully used it with my raspberry pi (works perfectly).
Things, I have tried so far:
- Once I see, data is not read (updated) anymore, I tried to restart the module (node.restart)
- Also tried tried to resetup uart
All of these changes did not have any effect. It just works normally again, once I have reset the device (power off, power on)
The code (just the reading part) is fairly simple:
local capture = function(data)
local number = tonumber(data)
if number ~= nil and number ~= 0 then
pm25 = number
end
end
local start = function()
tmr.alarm(4, 10000, tmr.ALARM_SINGLE, function()
print("start uart")
uart.alt(1)
uart.setup(0, 9600, 8, uart.PARITY_NONE, uart.STOPBITS_1, 0)
uart.on("data", "\n", function(data)
capture(data)
end, 0)
end)
end
I am kinda stuck here, because I cannot really identify whats happening. Anybody having any ideas either on how to fix it or debug it further?
Best regards,
termi