gadjet / Window_Door-Sensor

8 stars 1 forks source link

Is this hardware issue like capacitor blown or so? #2

Closed sheminasalam closed 2 years ago

sheminasalam commented 2 years ago

Hi there I have an issue with version 1 of this sensor. It would be good if you could help me out with it. My sensor can detect when the window is open without any issues. But when it comes to closing, it wont work all the time. I tried to diagnose the issue with serial monitor and found that when the window is being closed, the esp8266 starts to wake but before executing any functions, it hangs up. One more thing I noticed is that when this problem occurs the onboard led won't even blink like when the board boots up. But when we push the reset button(GPIO16) in closed state, the device boots fine and completes action and sleeps.

Is this a code issue or some hardware issue? what can be the issue? I am confused because majority of the time this works fine.

gadjet commented 2 years ago

With version 1 it does need a good capacitor, i got away with using a 220uF capacitor but I would recommend starting with 1000uF and making sure it works OK then redcuing it and testing. A lot of issues with ESPs can be traced to lack of power supply. Some general questions to narrow it down: -

Do you have access to an oscilloscope to monitor the supply voltage at the ESP device?

sheminasalam commented 2 years ago

I am powering it with 18650 2200mah battery. LDO is asm7111 3.3v.

These are the details that I know of. 1) The problem happens only when the door is closing. When the door is opened, the sensor works fine. How can that happen? 2) Also this happens mostly when the door is kept open for sometime and then closed. 3) If the interval between opening and closing is little, it mostly wont happen. 4) Also even if this happens, if you open the door and close it again, it mostly likely will work. 5) I also noticed that even if the device did not update the door closed state while closing, if you hit the reset button while closed, it will update the correct(closed) state. 6) When I used serial window to observe the issue, I found that when the door is closing, instead of resetting the device as when door is closed, the reset procedure is arrested midway. That is the board starts reset but doesn't even reach calling setup function. 7) Instead of batteries, I trying this powering from the usb to ttl adapter with directly providing 3.3v to esp and then again I found the same issue. So power supply cannot be the problem.

It looks like capacitor may not be charging or so at times thus reducing the voltage to EN pin reduced during booting while door is closed. Could this be a factor.

gadjet commented 2 years ago

OK one issue is the regulator, do you mean the the ams1117 ? if so this regulator isn't a low voltage drop regulator and can drop over 1V when supplying the ESP during transmission, not good enough for using with a single L-Ion cell.

Also there are many FTDI connectors that are not upto supplying a good voltage for the ESP but it would probably be OK, the only way to rule the supply out as a problem would be to have an oscilloscope across the ESP VCC and ground.

Could you add a photograph of you device? Are you using the PCB design I added to the project?

gadjet commented 2 years ago

Also what size Capacitor are you using?

sheminasalam commented 2 years ago

As you advised, I changed my power supply from 18650 to lipo and now I believe the issue is sorted. But then again I have multiple such sensors which are using 18650 without any issues.

BTW I use your exact circuit but with the exception that the capacitors are through hole type and so pcb has such changes.

gadjet commented 2 years ago

GLad you got it working but I would really recommend changing your regulator to a low dropout type because if you are using a battery then the voltage will naturally fall over time and you will get the problem back due to the high voltage drop of the regulator the AMS1117 is only really useful with a 5V fixed DC supply to 3.3V not for use with batteries, I would use the HT7533 as in the circuit diagram or something similar. The HT7533 has a dropout voltage of around 80mV instead of the AMS1117's of around 1V.

sheminasalam commented 2 years ago

Ok, I will try to change my sensors to version 5. Thanks