Reset on debounce

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
jadro
Posts: 25
Joined: Wed Apr 29, 2020 7:02 pm

Reset on debounce

Post by jadro » Wed Jul 08, 2020 7:09 am

Hi,

I have D1 mini ESP8266 with Micropython firmvare and I dont know if there is bug...

My program is created for button socket with mqtt and works. I have one led to indicate button pressed and can be operate with the button or mobile phone as mqtt client. But I discover that if the button is pressed several times quickly it resets whole program and blocks its firmware. I can even upload new script to it with uPyCraft IDE. If reboot, it opens couple of times on my laptops port and can see that script in it is broken, it is empty. It somehow erase main script and one thing that can be done is to flash firmware again and upload scripts again. My debounce function opens txt file and writes text ON or OFF in it (I use with statement to open file with no close while this statement closes file automatically). Yesterday I refleash 6 times :-(
Anyone have this strange problem?

Thanx,
Jadro

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Reset on debounce

Post by jimmo » Wed Jul 08, 2020 12:11 pm

I think it might be helpful if you can share your code and we can take a look.
jadro wrote:
Wed Jul 08, 2020 7:09 am
My debounce function opens txt file and writes text ON or OFF in it (I use with statement to open file with no close while this statement closes file automatically).
It sounds like something is going wrong while this function is writing to the filesystem. If the device resets mid-write then that can cause corruption.

Why does your debounce function need to write to the filesystem?

jadro
Posts: 25
Joined: Wed Apr 29, 2020 7:02 pm

Re: Reset on debounce

Post by jadro » Wed Jul 08, 2020 12:23 pm

I will share my code sun as possible...

I use txt file because my switch will work for socket in my house. When current or even my provider internet goes down then I have to look inside to see last state od pin (ON or OFF) and according to this I need last state to start with... But this does not work as well and I think of comment this in my code...

jadro
Posts: 25
Joined: Wed Apr 29, 2020 7:02 pm

Re: Reset on debounce

Post by jadro » Wed Jul 08, 2020 3:45 pm

Remove unnecessary code and function that reads/writtes to the file has resolve my problem.

Thanx jimmo for help,
Jadro

Post Reply