Skip to content

Deep sleep unreliable with resistor #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pronkster opened this issue Apr 26, 2017 · 83 comments
Closed

Deep sleep unreliable with resistor #59

pronkster opened this issue Apr 26, 2017 · 83 comments

Comments

@pronkster
Copy link

Hi there,

Firstly wanted to say that you are doing an awesome job here. 👍

My iSpindle is setup with the Wemos D1 Mini PRO which works fine except, the iSpindle wouldn't wake up from deep sleep with the config as described in your Wiki. A quick google told me that this is a known issue with the Wemos in general (all models) and that replacing the 470 ohms resistor with a diode solves this issue.

Credits go to schufti in this forum post: http://www.esp8266.com/viewtopic.php?f=13&t=7918&start=24#sthash.9AUQQ49G.dpuf

" instead of experimenting with resistors and relying on the "it worked for me" value, it would be more technically correct to use a schottky diode (e.g. BAT43) to cleanly pull rst low without side effects when gpio16 is high.

p.s.: the cathode (ring) towards gpio16 ..."

It worked for me so thought id share and hopefully it works for others as well.

Cheers

@universam1
Copy link
Owner

Thats indeed a great idea! Let me know how it goes!
Regarding the resistors I found that sometimes a lower resistor ~370 Ohm works better.

@pronkster
Copy link
Author

So far so good! All functions work perfectly, even the reset! No need for a resistor I reckon, just use a diode instead. Needs more testing on the normal Wemos D1 mini as well though

@universam1
Copy link
Owner

It seems to me that the selection of the diode to be a schottky is a critical one here!
According to the datasheet, the min. Input Low Voltage must be < 0.25×VIO while the Output Low Voltage is up to 0.1×VIO.
Therefore, this leaves 500mV where the BAT43 will drop around 300mV or more. So a regular silicium diode will fail in this setup!
Using a BAT43 or better is a requirement so to speak.

@pronkster
Copy link
Author

Are you able to share a link to that data sheet? I have looked everywhere but haven't been able to find a good detailed one yet.

I have replaced the resistor with a normal 100v 1a diode and this seems to work just fine (no BAT43). Im trying to figure out why there is a resistor required but all I can find in the original documents is a direct connection RST to D0.. to me it seems D0 just need to have power for the unit to come back from deep sleep. Would it not be that the lower the voltage the less reliable the unit becomes? Not sure why a diode would work better than a direct connection though..

@universam1
Copy link
Owner

universam1 commented Apr 27, 2017

The link: http://download.arduino.org/products/UNOWIFI/0A-ESP8266-Datasheet-EN-v4.3.pdf

If it works on your current setup it does not imply that it will be reliable under different conditions like a nearly empty battery or at lower temperatures. According to the DS it violates the limits with a normal diode.
The resistor is there to protect the D0 output if through UART chip the RST is pulled down at the same time. I've fried already a D1 because of this.

@pronkster
Copy link
Author

pronkster commented May 2, 2017

Cheers, thanks for the link! I will do some more testing over the next few days and let you know how I go.

@Kloorob
Copy link

Kloorob commented May 9, 2017

Hi,
I have just found this article on Github, as I am having the same issue with my iSpindle setup using a Wemos D1 Mini, which like pronkster works fine when first connecting / linking to Ubidots (all reading show up) then nothing after that, and hence I suspected the iSpindle wouldn't wake up to transmit the next signal / link to Ubidots?

Therefore, can you propose a remedy for this issue please, as I view this project as too fantastic for me to give up on it?

Also, thanks for all your hard work.

@universam1
Copy link
Owner

Use a Schottky diode or a lower resistor of 350 Ohms.

@pronkster
Copy link
Author

pronkster commented May 9, 2017

I finally had some time to look at this in more detail. I found there is a lot of conflicting information online around the use of resistors and diodes and in particular, which one is the correct one (and how do you know for sure). This is what I have found so far:

There are three ways to revive from (deep) sleep;

  1. You can press the reset button
  2. You connect RST and GND with a switch (effectively the same as a RST button)
  3. You can use the inbuild sleep function

The inbuild Deep sleep function uses GPIO16 as an Output which is ether HIGH (3.3 V) during sleep or LOW (0.0V) once the timer has finished.

Connecting D0 (GPIO16) directly to RST as per original manual will result in a constant 3.3 V on RST while in sleep and prevents a manual or software reset to pull LOW. Uploading firmware is apparently not working either (not tested this myself).

To fix these issues you can either use a resistor lower than 350 Ohm or better, a diode between RST and D0 (pointing to D0 ).

A diode or resistor will prevent 3.3 V on RST while D0 is HIGH during deep sleep thus allowing a manual RST through USB-TTL or the RST circuit. It is also preventing damaging the chip if the RST is pulled down through UART chip when booting up. Apparently the problem is that during during Linux Kernel boot phases 1-3 all pins are floating (GPU to CPU handover) and on Phase 4, the PINs are set to the correct state. Connecting D0 and RST directly can result in a fired WEMOS.

Using a higher resistor might work when your battery is full but might not work once your battery is running lower. I am using a normal diode (not a Schottky) and this works great so far. However, I have not done any testing over a longer period. I will do soon and update once I know more.

@Kloorob
Copy link

Kloorob commented May 10, 2017

Hi Pronkster.

Hope you don’t mind me asking, can you kindly give me the actual diode part number / type you are using please, so that I can try and use the same and test it on my pcb please?

Thanks.

@wizbrewery
Copy link

wizbrewery commented May 11, 2017

Hi, getting the same issue here using weemos mini pro. I get a couple of pings once programmed and reset then goes to sleep forever. Will try the diode trick tomorrow, cheers

@pronkster
Copy link
Author

@Kloorob - I am using a 100v 1A diode. I believe the product number is 1N4934 but will confirm when I am home this weekend.

@wizbrewery
Copy link

Hi, tried with IN4001 thanks @pronkster works great :)

@pronkster
Copy link
Author

Just checked and I am using the 1N4934

@universam1
Copy link
Owner

don't use a standard diode because it is out of spec. Use a schottky instead!

@pronkster
Copy link
Author

Hi @universam1, are you able to elaborate on that? Please correct me if I am wrong but my findings are that for the purpose of this project, any diode will do. The Deep Sleep function uses GPIO16 as an output, not as an input so it doesn't really matter if LOW is higher than 0V. The whole purpose of this diode is to protected RST when GPIO16 (or D0) is high during reset or when using the USB firmware upload.

@universam1
Copy link
Owner

@pronkster Check my above elaboration on the datasheet why it is critical to use the right kind of diode here

@Phrozentech
Copy link

@universam1 so using a BAT41 or BAT43 would be the best diode to utilize instead of the 370ohm resistor in this case? I'd like to use something that's consistent, since it looks like if my battery gets below 3.6-3.5 the device doesn't wake up, I'm still testing that theory though.

@Kloorob
Copy link

Kloorob commented May 20, 2017

Hi @universam1. Just to let you know that I built a new board today and added a BAT43 Schottky Diode in place of the 470 ohm resistor, and my iSpindel is now working, which is brilliant!
Thanks for your help.
Cheers.

@lekrom
Copy link

lekrom commented May 26, 2017

Dear @universam1,
I absolutely agree with your assesment on the diode.
May i recommend you update the docs / circuit diagram to use the schottky diode instead?
Regards,
Lekrom

@lekrom
Copy link

lekrom commented May 26, 2017

Epic project by the way...

@universam1
Copy link
Owner

thanks @Kloorob @lekrom thats good feedback!
Would like a little more feedback but I tend towards this being the better way.

@lekrom
Copy link

lekrom commented May 26, 2017

A simple yet elegant sollution. Cant think of a better way. Should work for virtually any condition. Schottkys are also typically much faster that Si-diodes, ideal for protection purposes, so should work very well for protecting the IO pin in thet scenario nentioned. Must admit, I was puzzled by the resistor in the circuit. A few quick searches led to this thread. I have been working (and playing) with microcontrollers for many years, although Esp8266 still very new to me. Missed the wake from deep sleep GPIO16 thing...

@Kloorob
Copy link

Kloorob commented May 26, 2017

Hi @universam1, Just to give you some further background as I have built 5 boards and the first 4 board, I thought that I messed up in the soldering, and hence, I couldn't get it to work. However, on my fifth board, I used a BAT43 Schottky Diode and it worked. All I need to do now is to put it into a fermenter to give it long test.
Thanks for your help.

@universam1
Copy link
Owner

nice @Kloorob @lekrom I'm fine with it. Feel free to create a Merge Request to the docs, BOM etc. Thanks

@Phrozentech
Copy link

Phrozentech commented Jun 3, 2017

I used a BAT46 instead of a BAT43 and was able to get readings until 3.67v then it stopped communicating. Looks like a 197.36hrs between diode and using a BAT46 currently recharging the battery and rerunning the test again.

@fogarasia
Copy link

Poiting to D0

@JETET
Copy link

JETET commented Jul 17, 2019

The tasting looking towards D0?

@fogarasia
Copy link

Yes, the simbol for the cathode https://images.app.goo.gl/KeJWW6c37EyUiDHw6

@ErikdBr
Copy link
Contributor

ErikdBr commented Jul 17, 2019

I'm going to try the BAT 43 that I bought here very expensive € 1.95

50 pieces for € 3,16 --> https://nl.aliexpress.com/item/32854110199.html

@stefschin
Copy link

Hi, I've been using with many iSpindel same diode you take out from Wemos D1 mini, it's a B5819WS Schottky diode, same characteristics as 1N5819 but in SMD package.

@JETET
Copy link

JETET commented Jul 17, 2019

I changed resistance by Bat 43 and keeps going into sleeper mode and no way to wake up gives me the following error Thank you

Samples:30 min:63.61 max:63.62 time:510
17:46:41.854 -> x: 11124 y: 12176 z: 944
17:46:41.889 -> Tilt: 63.62
17:46:41.889 -> Tacc: 40.68
17:46:41.889 -> Volt: 4.52
17:46:41.889 -> Temp: 31.37
17:46:41.889 -> Parse error at 1
17:46:41.889 -> Gravity: 0.00
17:46:41.889 -> IP: 192.168.1.100
17:46:41.889 ->
17:46:41.889 -> calling HTTP
17:46:41.889 -> {"name":"iSpindel000","ID":8034015,"token":"vd6n1r6eop1sh6f9dmceibpufc","angle":63.61637,"temperature":31.375,"temp_units":"C","battery":4.51512,"gravity":0,"interval":3600,"RSSI":-53}HTTPAPI: posting
code: 200
17:46:43.757 -> {
17:46:43.757 -> "status" : 200,
17:46:43.757 -> "ts" : "2019-07-17 11:46:39",
17:46:43.757 -> "data" : { }
17:46:43.757 -> }

17:46:43.861 -> Final-sleep: 3600s; RT: 304578

@stefschin
Copy link

Your interval is set to 3600 s, that is 60 minutes. You have to wait 1 hour to wakeup or change your interval setting to less seconds, I usually use 30 s for calibration and tests

@JETET
Copy link

JETET commented Jul 17, 2019

And it would activate itself?

@JETET
Copy link

JETET commented Jul 17, 2019

hour tells me this I have set it every 5 seconds to see if it responds and if it does what updates me every 5 seconds is the brewspy
Captura de pantalla 2019-07-17 18 31 31

@fogarasia
Copy link

Now looks ok

@JETET
Copy link

JETET commented Jul 17, 2019

If you thank everyone, now I have another question once i enter sleeper mode as I can re-enter the ispindel menus in the browser without resetting in the browser

Portal

@daveparrywellmeadow
Copy link

daveparrywellmeadow commented Jan 18, 2021

Not sure if I can reopen this thread and a lot has been said on it already, so just a quick question.
I have built an iSpindel with the BAT43 between RST and D0. Still having problems waking up after deep sleep. I do get a blurt of illegal characters on the Serial Monitor when the time is up though, so I wondering whether I have a different problem? i.e. it starts to wake then fails to complete waking. Is that a thing?

image

Thanks

Dave

@ErikdBr
Copy link
Contributor

ErikdBr commented Jan 18, 2021

Not sure if I can reopen this thread and a lot has been said on it already, so just a quick question.
I have built an iSpindel with the BAT43 between RST and D0. Still having problems waking up after deep sleep. I do get a blurt of illegal characters on the Serial Monitor when the time is up though, so I wondering whether I have a different problem? i.e. it starts to wake then fails to complete waking. Is that a thing?

image

Thanks

Dave

Do you know a diode has a plus and min side, anode and cathode? The cathode side with the black belt should go to D0. If it is the other way around it will not work.
Screenshot_20210118-220901_Chrome

@daveparrywellmeadow
Copy link

Hi Erik, yes - but thanks for checking. I should have included that in my post. I have the black band at the D0 end.

It strikes me that it is starting to wake up though as there is activity around 60 seconds after the previous cycle started. Just seems to crash during the wakening though. Is this a known problem do you know?

@ErikdBr
Copy link
Contributor

ErikdBr commented Jan 18, 2021

Not a known problem as far as I know, sounds like one of the hardware components is dodgy. Or the soldering somewhere.

@daveparrywellmeadow
Copy link

Well in desperation I unsoldered the diode from the project board and resoldered it directly to the socket pins (with the wemos & gyro boards removed obviously). Definitely a clean connection and no chance of shorting against the 220k resistor.

Still the same behaviour. Hmmm. Faulty diode? Or wemos? Ah well, maybe I need to buy another kit of bits and try again as everyone else seems to have got their working. Chalk it up to learning...?

@camsaway
Copy link
Contributor

Blurt of garbled characters often means wrong board rate on the serial monitor. Have you checked this?

@daveparrywellmeadow
Copy link

Hi Cameron, thanks for trying to help.

It seems correct and I get a full page of intelligible text talking through the other steps right up until it goes to sleep.
Interestingly there is sometimes a string of similar characters at the start too.

I have also seen it in other people’s screenshots so it could just be some noise on the serial output when it is powered up?

@wizbrewery
Copy link

Hi Dave, On an unrelated project with a different esp device, I wnated to see the startup serial message to troubleshoot. As the esp has a default baud at startup (74880 for nodemcu LoLin device) set your serial port in your sketch to the default and your serial terminal too and you'll get boot info rather than the garbled you are getting.

@daveparrywellmeadow
Copy link

Hi Dave, On an unrelated project with a different esp device, I wnated to see the startup serial message to troubleshoot. As the esp has a default baud at startup (74880 for nodemcu LoLin device) set your serial port in your sketch to the default and your serial terminal too and you'll get boot info rather than the garbled you are getting.

That's a great tip. Thanks. Will give it a go this evening.

@daveparrywellmeadow
Copy link

Hi Dave, On an unrelated project with a different esp device, I wnated to see the startup serial message to troubleshoot. As the esp has a default baud at startup (74880 for nodemcu LoLin device) set your serial port in your sketch to the default and your serial terminal too and you'll get boot info rather than the garbled you are getting.

Yep - I got to see the real output during boot before the baud rate is changed. Not very informative though:
20:10:00.569 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
20:10:00.603 ->
20:10:00.603 -> load 0x4010f000, len 1384, room 16
20:10:00.603 -> tail 8
20:10:00.603 -> chksum 0x2d
20:10:00.603 -> csum 0x2d
20:10:00.603 -> v00000000
20:10:00.603 -> ~ld

@SquigglyData
Copy link

Hi Dave, On an unrelated project with a different esp device, I wnated to see the startup serial message to troubleshoot. As the esp has a default baud at startup (74880 for nodemcu LoLin device) set your serial port in your sketch to the default and your serial terminal too and you'll get boot info rather than the garbled you are getting.

Yep - I got to see the real output during boot before the baud rate is changed. Not very informative though:
20:10:00.569 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
20:10:00.603 ->
20:10:00.603 -> load 0x4010f000, len 1384, room 16
20:10:00.603 -> tail 8
20:10:00.603 -> chksum 0x2d
20:10:00.603 -> csum 0x2d
20:10:00.603 -> v00000000
20:10:00.603 -> ~ld

Hi @daveparrywellmeadow , did you get to the bottom of this? I'm having the exact same issue despite the BAT43 between RST and D0.

The iSpindel works correctly and sends data to Ubidots once, enters deep sleep and when it wakes I just get garbled characters on the serial monitor and nothing further happens. On the slower baud I get the same as you.

My next step is to try another d1 board but this feels like a nuclear option!

@daveparrywellmeadow
Copy link

Hi @daveparrywellmeadow , did you get to the bottom of this? I'm having the exact same issue despite the BAT43 between RST and D0.

I feel bad now for not posting an update on here sooner.

It’s all working now. I made another base board with the components on and inserted the same Wemos d1 on it, and it worked first time. I think I had a faulty pin connector that wasn’t quite connecting with the Wemos digital i/o pins.

I have also recreated the program myself using Arduino, without a lot of the ‘extra’ code which I didn’t need. This allowed me to add my own debugging comments in the serial monitor, eventually. I’ve now also mastered sending data to Google sheets which took ages. The pin numbers you need to initialise the Wemos with are different from the ones it is labelled with!

@SquigglyData
Copy link

Thanks Dave - I'll try rebuilding it! Fingers crossed that will solve the problem for me too!

@nkaramolegos
Copy link

Does anyone has used DB3 5T diode? It is bidirectional diode. Is that a problem?

@universam1
Copy link
Owner

It is not suitable for that purpose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests