tmr.alarm seems to quit service
Posted: Sat Jan 09, 2016 1:27 pm
Hi all,
I try to set up an application with an ESP8266-01 module using deep sleep and tmr.alarm.
The hardware of the module is modified so that pin8 of the ESP is connected to RST and deep sleep works perfectly.
The main task of this project is to wake up, count the changes at gpio.3 for 10 seconds print the result and go to sleep again.
The structure of the source is as follows ( I reduced to the major code lines)
Just to make the code more readable I removed the Wifi initialization in init.lua and the message send function after end of measurement.
I shoulkd mention that the frequency of the signal at gpio.3 is in the range of several Hertz to approx. 400Hz.
The code is called by init.lua and starts as intended. Sometimes, after several wakeup- count -sleep cycles the tmr.alarm1 seems to quit. I can see gpio.4 going hing but then it stays high forever. The number of cycles after the problem comes up is unpredictable. Sometimes it hapens after 2 cycles, sometimes it takes 30 or more cycles.
Does anybody see an error in the code or is there a general problem?
Thanks in advance
Reinhard
I try to set up an application with an ESP8266-01 module using deep sleep and tmr.alarm.
The hardware of the module is modified so that pin8 of the ESP is connected to RST and deep sleep works perfectly.
The main task of this project is to wake up, count the changes at gpio.3 for 10 seconds print the result and go to sleep again.
The structure of the source is as follows ( I reduced to the major code lines)
Just to make the code more readable I removed the Wifi initialization in init.lua and the message send function after end of measurement.
I shoulkd mention that the frequency of the signal at gpio.3 is in the range of several Hertz to approx. 400Hz.
Code: Select all
gpio (3, gpio.INT)
gpio (4,gpio,OUTPUT)
function DoCount()
tme.wdclr()
Counts = Counts+1
end
function StartMeasurement ()
Counts = 0
gpio.write(4,gpio.HIGH)
gpio.trig (3,"down",DoCount)
tmr.alarm(1,10000,0 function() StopMeasurement() end)
end
function StopMeasurement()
gpio.write(4,gpio.LOW)
print (Counts)
tmr.alarm(2,1000,0, fuction() node.dsleep(10*1000000,1) end)
end
--####
StartMeasurement()
The code is called by init.lua and starts as intended. Sometimes, after several wakeup- count -sleep cycles the tmr.alarm1 seems to quit. I can see gpio.4 going hing but then it stays high forever. The number of cycles after the problem comes up is unpredictable. Sometimes it hapens after 2 cycles, sometimes it takes 30 or more cycles.
Does anybody see an error in the code or is there a general problem?
Thanks in advance
Reinhard