Monday 28 March 2022

The many versions of the Wireles Door Sensor an Version 5

 

The Journey so far

I have to admit that it's become a bit of an obsession to try and get this sensor smaller and to use less power at each revision. well I've just finished version 5 which has definitely got the consumption down to a really low level, 3.9uA at its lowest.

Versions 1 to 4 in a row

....... and Version 5
Version 5 assembled PCB




Version 5 has two functions, the normal reed switch trigger so it can be used as a Window/Door sensor and a single button input so it can be used as a Doorbell switch or general WiFi button.

The trigger circuitry combines an edge triggered Monostable circuit from two XOR gates and a single OR gate latch circuit, this latch is triggered either by a pulse from the Monostable or the press of a button which sets the latch.
Once the latch has been set it can then be reset by a LOW signal from the ESP12 when the code has finished running on the ESP12, I used GPIO16 as it is held high during boot.

Schematic

Circuit diagram V5

Using the circuit above the quiescent current of the whole device when there is no magnet next to the reed switch, i.e. door open is 3.90uA and if you were using it as a WiFi connected button then that would be the Quiescent drain, if used as a door/Window sensor then when the magnet is next to the reed switch the quiescent is slightly higher at 5.4uA due to R1 drawing current when the reed switch is closed.

Battery Life

Actual Current consumption

Using a  Nordic Power Profiler Kit II I made some current measurements of the device in the different states: -
Current Consumption Graph


Using an online battery lifetime calculator I found here I calculated these battery times based on a usage of 10 activations per day: -
As you can see the worst consumption will give a battery life of more than 7 years! although this will only be an esitmate and in "real life" I assume there will be other factors that may impact on the battery life but only time will tell but I think you would have a good chance of getting a few years out of a relatively small cell.

The files are available on my Github page



109 comments:

MakerMeik said...

You are so amazing. Thanks for the great work and especially for sharing it.

michael said...

Hi,
really a great project. Thanks for sharing your knowledge!

I have got a question regarding ordering populated PCBs from jlcpcb:

Your "Window sensor V5updated BOM.csv" on your github project "Window-Door-sensor-Version-5" do not show the LED_small D1. But the LED is listed in the file "Window sensor V5-top.pos". I could not find any further details regarding the LED (voltage etc.). Can you please let me know, what LED to use and do you know the LCSC part number?

thanks for your help!

with kind regards

michael

Gadjet said...

Sorry Michael I decided to leave out the LED at the last moment from the assembly as I was aiming to use as little current as possible, I just bought some 0805 LEDs to add myself when testing out the boards so I would know when the LDO was powered up before I added an ESP.

The series resistor is 1K and I just added an 0805 Green LED to test it I bought from Ebay.

Also when I was looking at the JLCPCB parts list there wasn't many LEDs to choose from and they seemed expensive or had a large min order quantitys at the time.

Thanks,
Phil

Anonymous said...

Hi Gadjet,

JLCPCB asks for a CPL file containing the parts positions for the pick n place process. I understand that it can be generated out of KiCad but I was wondering if you already have one prepared. It's the first time I am ordering assembled PCBs so I am not familiar with the process.

Thanks

Andreas

Gadjet said...

Andreas, As I remember the zip file on github contains the .pos files, one of those is the cpl file that JLCpcb needs, after uploading you will be able to check the component layout visually.

Anonymous said...

Thanks Gadjet, found it!

Andreas

Unknown said...

Hi mate! First, thanks for sharing your work... I already order pcbs and components... By chance, did you create any 3D model to be printed for this v5?
Thankd once more.

Gadjet said...

Hi,
Thanks, I've added the exported Step file for the board to the the GIT repository.

Unknown said...

Thanks Gadjet.
Sorry, I wanted to mean a 3D for a CASE for the board.
I saw a case for your V1.

potros

Gadjet said...

Ah! OK I'll upload one later.

Anonymous said...

Sorry to bother you. I'm trying to order the pcb with the top assembled on JLCPCB but i get error when i upload BOM and Pick&Place file. I have never order PCBs before.

Gadjet said...

OK I will have a check of the files, what is the error?

Gadjet said...

I've tidied up the files on GIThub there is now only one BOM and Position file and they are in the "Window sensor V5.zip" file, these files should work with JLCPCB.

Anonymous said...

It worked. Thank you!

Gadjet said...

Good news, just double check the JLCpcb part numbers in the BOM to make sure the file has correctly linked the right parts, it should be correct but I have had errors before.

Anonymous said...

Hi mate

Finally I received my boards and components, and I have found the time to solder my first unit. Doesnt look as pro as yours but my resources are limited :-)

Im playing with it, and I sucesfull comunicate with ESPNow with an ESP32... it works very well.

But Im facing a problem. Ramdomly the unit keeps sending the message for a while (few seconds) in a loop, before the LDO is dissabled. I have monitorized it, and the END signal from ESP8266 works well, so the only reason to keep the LDO enabled is the two previous gates.

Did you face anything similar to this? Is the magnet power critical? (im using a small but quite powerfull one)

Thanks in advance.

potros

Gadjet said...

I can't say that I've had that problem, do you have an oscilloscope so you can check the waveforms on the logic gate inputs or the enable pin of the regulator?

Even if it was switch bounce it shouldn't last that long! I'm not sure what coulf be happening.
Can you link to some photos of your board maybe?

Anonymous said...

Hi mate.

I have changed the cap (C4) and the supply to a batt, and it seems problems gone.

It works like a charm right now :-)

Not sure how can upload pictures here... I can send them to your email, if you want.

potros

Gadjet said...

Hi I can post a temp email address here you can send to but it's only valid for 10 mins so you need to tell me when you're ready to send, if you like?

Anonymous said...

Hi

Not needed. I have prepared a compressed file, with following inside:

* Picture of front and back board
* Oscilloscope pictures, wrong and ok, of signals END and VCC
* A small video, showing how it works with an ESP32 with LCD, showing how the state changes.

You can download it from: https://we.tl/t-F0e8u062Mr
Available for one week.

I have still pending to prepare a case.

Thanks once more.
potros.

Gadjet said...

Potros,
Great news you got it working, thanks for the pictures and video, I will have a look at them.
I have uploaded some STL files to Github for a case but it is quite specific to the battery being used.
I am happy to modify the design to suit another battery if you need one.

Unknown said...

Hi Gadjet, I was just wondering about the battery - where could I find the specific one this case was designed for?

Gadjet said...

These were the ones I bought, you can get the dimensions from here
https://smile.amazon.co.uk/gp/product/B08BFMW4B1/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

Anonymous said...

Hi mate!

I would like to contact you. In order to secure our email adresses I have created a temporary one: lovett34@whcosts.com

I have some changes I want to discuss/share with you

Could you please write me there? Thanks

potros

Anonymous said...

Hi thanks for this wonderful project ...i love to try them. Can you share what all stuffs we need to get this started soo i can buy one by one and get all set .

Gadjet said...

Hi, thanks for the feedback all the information to make one is on my github page, there is a link in the last line of the post :-)

Gadjet said...

Thanks Nick, I think this was the power management IC that was mentioned https://www.torexsemi.com/file/xc6192/XC6192.pdf I think if I made it any better it would generate it's own energy :-) although I have bought a few little (really small) solar cells to experiment with to see if one of those could generate the power to extend the life of the battery or maybe used in conjunction with a supercap?

NickLuzz said...

You are right, I cannot really get better than that! Maybe smaller?
Adding tiny solar cells sound cool! Looking forward to see those in action 🙂

Anonymous said...

Hi Gadjet, amazing project! I am quite new to electronics and I was wondering what changes would have to be made to make this work with a 6V battery? I'm trying to understand the schematic and I can see that there is a voltage regulator, but I am guessing the resistances would need to change?

Gadjet said...

Hi, the regulator is good upto 16V but the logic gates are connected directly to the battery and are only rated to 5.5V so 6V may be pushing it a little, consider putting a couple of dioeds in series with the battery +ve to drop the voltage by 1.2V.

Anonymous said...

Hi, is there a way to buy one or two of your sensor boards? In best case smd equipped and with the case. Unfortunately, I can't solder.

Gadjet said...

I do have a few spare so I suppose I could sell a couple, what sort of application do you want it for?

NickLuzz said...

I'd happily take 1-2 pieces as window monitor, if you have spares...

Gadjet said...

I'm just looking at setting up a Tindie store if anyone's interested in buying one?

Anonymous said...

Hi, yes I'm interested in one or two as a bathroom window sensor. IOT environment with MQTT server is available.

NickLuzz said...

I would be ok to wait if you need to collect a few orders to justify making a new batch.

Have you done any work to integrate those little solar panels you bought?

Gadjet said...

I have a few spares around me to cover some initial sales, I'm just setting it up on Tindie working out my costs etc. and how to sell them, an all in one kit with ESP12 attached and some code inside and with basic 3D printed enclosure or all seperately ?

I had a quick look at the solar panels and they don't output as much as I thought but I still mean to some some more investigations when time will allow me to

Anonymous said...

I would be fine with a bunch of all of them to start coding right away.

Roman said...

Hello,
My pcb is done. Thank you a lot for this great job. I would like to check my work. Can you let me know what is the voltage on GPIO13 (if project is powered by 18650-4.2v)?
Thank you in advance.

Gadjet said...

Hi,
You're welcome.

GPIO13 will be high (>4v) with the Reed switch open and low (<1v) with it closed.

Anonymous said...

Gadjet - thanks so much for the responses so far. I’ve learned so much from this project but am still trying to understand - after shutdown of the LDO, will both change of states of the reedswitch start up and be fed over espnow? I seem to be getting mixed results.

Also - would you have or know of an appropriate sketch for MQTT only for this circuit instead of Espnow? I have a multiple APs and I think getting the right channel is going to be a challenge once I have a lot of these working.

Thanks!

Gadjet said...

Hi,
Whenever the reed switch is opened or closed it will trigger the LDO to switch on the supply to the ESP12F and it should stay switched on until the ESP switches GPIO low (you have to switch it high ASAP in your code to keep it awake to start with).

You can use any sketch that connects to your WiFi and MQTT (try google) as long as you switch GPIO16 low when you've finished sending but this will use more power, I would try using ESP-NOW to begin with to see if it works.

Gadjet said...

When someone mentioned they were having issues with the circuit and wanted more information I got suspicious and checked the BoM file and found a mistake!

Unfortunately U4 in the bomfile has got the wrong LSC part number against it, the part number should be C7470 and NOT C9055.

I'm really sorry that this mistake made it in to the Github files, I was sure that I'd already corrected it.

The C0955 is the LDO regulator and it will need to be changed for the OR gate and the module will then work correctly.

I have also had to change the IC on my boards I had made :-(

Anonymous said...

Gadjet - Thank you for the update and clarification, at least I know I'm not crazy anymore! I actually learned quite a bit on this process with troubleshooting - both hardware and software so the challenge has been worth it.

Thanks again for updating BOM - I'm ordering now.

Gadjet said...

I'm sorry for the trouble, did you already have some made?

When I received mine at first I just assumed my circuit was crap :-( and put them in a drawer then a couple of weeks later I decided to go over the PCB with a magnifying glass and then noticed that U4 was the same ID as the LDO and then I found the error in the BoM file ( I hate setting up the BoM File for the PCB!).

I ordered some of the correct parts and used a hotplate to rework the PCBs and then they worked as expected .... thank goodness!

I thought I had corrected the BoM file but I mustn't have!

Roman said...

Good afternoon, ID is not a problem. We all have to watch out what we want to reach in our (or better in your) project.
Good luck with new projects - will we get any presented soon?

Anonymous said...

No worries - like I said it was actually a learning experience. I did have some made but only ended up using 5/10. Once I get more conformable with soldering things that size I'm going to change the LDO on those. I worry I'll make it worse lol.

Gadjet said...

I used one of these PCB hot plates to replace the chip https://www.youtube.com/watch?v=QarizoUnRfk

Gadjet said...

I didn't populate the PCB though I fed the element from my 10A power supply in current limit mode to control the temperature, it worked OK

Anonymous said...

Hello, have you already published your Tindie offer with these sensor components? I tried to find it without success. Could you provide a link after your offer is online?

Gadjet said...

I'm still sorting it out, trying to understand how much it may cost me in time and effort to set-up the store, I'll post a link on here when I've sorted it out.

Anonymous said...

Updated BOM on new board is a win. Sensor does exactly as described and is fantastic. It’s freaky fast.

Gadjet said...

That's great news, it's the ESP-NOW it is really really fast it only takes around 300mS to send the data packet hence the long battery life.

Anonymous said...

I tried with gates and it's consuming 300-400uA each which adds up to .9mA with esp off. i cant get a single gates here in my place. i can only get 4 channel based ic gates. is there anything you can help or recommend??

Gadjet said...

Are you connecting the unused gate inputs to ground?
If you leave them floating they can have random operations and higher current consumption.
What is the specification of the gates you are using, i.e. what is the suppy current?

Anonymous said...

yes unused gate inputs are grounded.
these are the gates I use
https://www.electronicscomp.com/74hc32-quad-2-input-or-gate-ic-dip-14-package
https://www.electronicscomp.com/74hc86-quad-2-input-exor-gate-ic-india
even by grounding un used gate inputs still it consumes 400uA that's too much ig. can you have a look at those gates and help me with some suggestions?
one more to ask , is it possible replace gates with attiny 13a to power ldo?

Gadjet said...

Looking at the data sheet in the link you sent there is a 74hc32 and an 74hct32, the 74hct32 has a much higher supply current, check the specific IC type number also are you sure there's nothing else in the circuit causing the drain, can you measure an IC on its own, out of the circuit? or try another make of IC, a lower power version

Anonymous said...

with gates and without esp it shows .9mA and by removing one ic gate..it reduces by 400uA. I'm using 74hc32 and 74hc86 gates. not sure why these take soo much uAmps each. and sure these isn't anything else which causing drain...only change made was instead of C4 1uF I'm using 10uF. anything else you want to suggest

Gadjet said...

Not really, it does look like it's the Gate ICs, if that is the case then you will have to buy a different make of Gate chip, e.g. the spec for the ST M74HC32 states about 1uA at 25 Degrees
https://www.st.com/resource/en/datasheet/cd00000301.pdf

Anonymous said...

thanks for responding. Yes I will change gate ics.Im planning to buy these gates below can you please check would these work based on datasheets? looking forward for your reply.

https://sharvielectronics.com/product/cd4071-quad-2-input-or-gate-ic-dip-14-package/

https://sharvielectronics.com/product/cd4070-quad-2-input-exclusive-or-xor-gate-ic-dip-14-package/

Gadjet said...

I can't say for definite that they will or will not work, I used ttl chips not CMOS, they have a low quiescent current so give them a try.

Anonymous said...

Hi Gadjet,
I'm deeply impressed by your great work. Did you set up your Tindie shop? I just checked it but could not find the sensor.
I am interested in buying one including the case.
Greetings, Ede

Gadjet said...

Hi Ede,
I've basically set it up but not activated it yet, I have a lot going on at the moment but I will finish it off hopefully in the next few eeeks.

Anonymous said...

Hi thanks for this wonderful project. it's really hard to find the gates you have used. May be can you make a version of door sensor with attiny instead of gates? also I have issue with ldo. I tried the same ldo you use and when i power the ldo with 5v I get a output of 3.3v, that's how it supposed to work but when i connect esp(i mean power esp)then ldo output voltage drops to 1.1v and esp fails to boot. not sure what's wrong from my side. have you faced any others issue before?
the ldo I use is SPX3819M5-L-3-3/TR – 500mA Low-Noise LDO Voltage Regulator IC SMD. Hope you respond back with some quick fix. thank you

Gadjet said...

Hi, I don't use the attiny so will not be making a version using it but there is a guy on Youtube that has a similar project that does use an attiny
https://www.youtube.com/watch?v=Oi3RwFTchig
As for the LDO I cannot understand why you cannot get it working? no-one else has had that issue maybe it is wired incorrectly or a faulty chip?
Visit the Github page, raise an issue and post some pictures? maybe we can see what the issue is?

Anonymous said...

hello Gadjet, thanks for this wonderful project.
Sorry to bother you, before just I get started I have few questions. what's the whole circuit power consumption when reed switch is open and when it is closed? also does the gates work with both reed open and close? or just works for one state?

Gadjet said...

Check out the Github page for more details, the module reports the door opening and the door closing and consumes around 4 to 5 uA when not sending a message depending on the door/window status.
The ESP is powered up by the reed switch opening and closing and powered down when the door remians open or closed.

Anonymous said...

Hi sir thanks for this project and work. I really don't understand the logic here i could see you have pulled up with 1m Resistor and connected those to gate u1 and u2
if you don't mind can you please share what these gates actually doing here and what happens when reed switch is closed and what happens when reed is open?

Gadjet said...

Thanks, essentially the first XOR gate buffers the signal from the Reed switch, the signal also goes to the second XOR gate and a delayed version of the same signal goes into the second input on the second gate which basically causes the output of the second gate to pulse the OR Gate which self latches and enables the LDO, the LDO stays active until the ESP switches it off via GPIO16.

Anonymous said...

Hi mate. How have you been doing? Iam trying to use this same circuit for just push button not with reed soo what changes should I make in code? soo instead of checking reed states I think we should send a string as BUTTON_PRESSED as the state to the receiver? and make some changes their as well. what's your opinion?

Gadjet said...

Hi, in the code you can use GPIO12 instead of GPIO13 to read the switch or just change the declaration for the reedswitch to GPIO12 and you can change the variable "myData.state" to button pressed if you like

Olli said...

Where can I get the code or sketch for
ESPNow2Mqtt?

Greetings
Olli

Gadjet said...

Olli,
You can get it from my Github
https://github.com/gadjet/Window-Door-sensor-Version-5

Olli said...

Hello Gadjet,
does the Sensor_V5_with_Switch_Off.ino connect the window sensor to MQTT on my iobroker?
I can't see any settings for MQTT in the sketch.
How do I get the messages into the MQTT server?

I'm a complete newbie and need some help.
Thank you

Gadjet said...

Hi Olli,
Sorry, it's been a while since I did anything with htis, I'm a bit rusty.... right
The sensor board doesn't have any connection with MQTT, the sensor board just sends an ESPNOW data packet which needs to be received by another ESP setup as a gateway.

There's more than one way to configure your receiver/gateway: -
1 - Use two ESP devices connected together by serial comm's, ine to receive the ESPNOW data and the other to connect to your MQTT server, the receiver transmits the data serially to the other ESP which is connected to the MQTT server.
2 - Use one ESP device as an ESPNOW data receiver and send the received data via serial comm's to another device, I use a raspberry pi runing node red, node red is connected to the MQTT server via the Pi.

If you google ESPNOW gateway there are many examples of how to set this up.

I hope this helps

Olli said...

Hello Gadjet,
thanks for the help,
I tested a few things but unfortunately no success.
I put some data in the folder, maybe you can take a look.
Data arrives at the receiver.
But nothing arrives at the ESP2Mqtt.

https://drive.google.com/drive/folders/1KKBrUskQUiAIafYO9OpplOx-ruzH2LoK?usp=sharing

Thank you
Olli

Gadjet said...

Does you data packet message structure that you send from your sensor match the stucture shown in lines 41 - 49 of espnowmqtt.ino?

Gadjet said...

How do you know the data arrives at the receiver, how do you view it?

Olli said...


I adjusted it, unfortunately no change yet

steelsparky said...

Hey if you bear with me I’ll try to do a Google docs of my example sketches using two d1 minis attached in parallel communicating through serial rx-tx for a esp-now receiver and seperate mqtt gateway.

I actually just picked this back up after a year to do some tweaking and it’s still pretty rock solid with my setup. Looking to improve code to do a better restart if Wi-Fi or mqtt server reconnects but I did help myself by adding a UPC on my router.

Olli said...


How do you know the data arrives at the receiver, how do you view it?

On the Serial monitor

steelsparky said...

Your esp-now receiver will send the message it receives from any of your senders (door-window) over serial to a esp2mqtt gateway which publishes those message to your server.

From there you could do many things. I personally use Home Assistant and Nodered to capture the mqtt in from
the esp2mqtt gateway and set the state of a sensor in HA to view.

Gadjet said...

Olli,
Sorry to ask the question but have you connected the tx/rx lines correctly between the ESPs?

Olli said...

Gadjet,

Sorry to ask the question but have you connected the tx/rx lines correctly between the ESPs?

No problem ;)
I've soldered it firmly now,
I think it's ok.

Olli said...

Serial monitor esptomqtt ESP
00:45:45.912 ->
00:45:45.912 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
00:45:45.912 ->
00:45:45.912 -> load 0x4010f000, len 3424, room 16
00:45:45.912 -> tail 0
00:45:45.912 -> chksum 0x2e
00:45:45.912 -> load 0x3fff20b8, len 40, room 8
00:45:45.912 -> tail 0
00:45:45.912 -> chksum 0x2b
00:45:45.912 -> csum 0x2b
00:45:45.912 -> v00046330
00:45:45.912 -> ~ld

steelsparky said...

Here check out the last 3 files added. Wasn’t crazy about a Google doc share

https://github.com/steelsparky/Window-Door-sensor-Version-5

Olli said...

Thanks steelsparky,
it works !!!

The data arrives in iobroker like this:
{"id":"2","state":"Open","vBatt":"0","Temp":"0.00"}
How to put each value in its own folder (Topic)?

Thank you all for help.

Olli

steelsparky said...

Cool glad to hear!

So in the gateway sketch it’s stringing together that entire payload in a single line json format that could be parsed out separately. I’m essentially doing just that with the state value in Nodered. And I know which board it is because each board has its own topic. Ex: EspNOW/Board/2/# That was good enough for me.

Alternatively you could probably alter the sketch to do separate topics if you desired with individual payloads. I’m not familiar with iobroker unfortunately so I’m probably not much help on that.

JosephR said...
This comment has been removed by the author.
JosephR said...

Hi, Gadjet/steelsparky,

I have a similar project that I am working on.

I have some ropes around a field. I want to put a 8266 with a gyro sensor on each rope, so I can know if a rope gets torn and falls. The field is a ~10 km in circumference and i have 200+ ropes. I am concerned about battery life, so many parts of your journey are helpful to me.

I would be willing to hire you as a consultant to help my project.

Can you please email me at jr11219@gmail.com?

Thanks
Joseph

Sunil said...

Hi Gadjet,

Very impressive work and excellent progress on MakerMeik's design. I have been using an earlier version of a window sensor using ATiny+ESP12F and have also prototyped MakerMeik's circuit for use within a MQTT environment.

I am now looking to try out your version 5 and have a couple of questions:

a) Do you have LCSC part numbers for the battery connector and pin header?

b) MakerMeik's circuit was using the EN pin to restart the ESP whereas you are using the LDO voltage regulator to control Vcc for restarting. What was the design consideration behind this change?

Thanks,

Sunil

Gadjet said...

Sunil,
Thanks for the feedback.
For the connectors, as they are through hole components they weren't added by JLCPCB, they are just standard molex connectors I already had.

The main difference from the original from Makermeik's circuit is that whereas MM's ESP8266 was put into sleep mode and was woken up by the pulse on the EN pin I actually power down the ESP8266 completely and the external logic circuit toggles on the EN for the LDO when triggered then when the ESP has finished transmitting it switches the LDO off completely resulting an a quiescent of around 4 to 5uA (depending on the logic gates) as opposed to 20uA'ish sleep mode.

Sunil said...

Thank you for the prompt response.

Rajeev said...

I guess it would be a step better if we replace two XOR gate ics with one dual channel 2 input xor gates like SN74LVC2G86.

Gadjet said...

Rajeev,
Yes I suppose it would.

Rajeev said...

Hello Gadjet, I have analyzed the circuit a few times and I was wondering if there should be a week pull down (say 100k) at pin GPIO12 which is used to read the status of Input. This will be in parallel to the capacitor 100nf already in place there. This is just to ensure that GPIO12 (INPUT) remains GND by default and does not float. This may be especially required when there is no reed switch (also no XOR gates) and only SW is connected to VCC). Perhaps presence of two xor gates before will ensure a logic 0 by default but additional high pull down may be a safer and we can do away with XOR gates, just for the case when the circuit is used as switch. This addition will also work okay even if there is reed + XOR gates part.

Gadjet said...

Rajeev,
I would agree with you, I have always intended to have the PCB fully populated so was happy with the circuit, it was primarily designed to be used with a reed switch but if the logic gates are left off then yes the pulldown would be a good idea.

Rajeev said...

Gadjet,
Thanks for corroborating my point. Since I am making new design, I shall make a provision of the weak pull down resistor. I'll try to generalize the PCB to make it usable as a reed or use different GPIO as NO switch connected to V(Batt) May be ORing more I/Os for trigger. Let's see how it goes.

Rajeev said...

Hi Gadjet,
Further to my earlier comments - Is it okay to wire the RST as per the schematic or better to have a pull up (say 10K) and preferably a 100nf cap grounded?

Gadjet said...

Rajeev,
You are right again, best practice is to have a pullup, I think I accidently left this out because in the previous design the reset pin was connected to GPIO16 which has an ouptput which is high from boot and is used in the code to toggle the reset pin to wake itself from deep sleep.

As far as I'm aware in the time I've used this design I've had no spurious messages that I would expect if the module was reseting itself.

The cap isn't needed if the enable pin has a pullup and cap down to ground as I believe this has the same effect as the reset pin would have on power up.

But I may be wrong.

Rajeev said...

Hi Gadjet,

I agree with you on not using the capacitor grounded. On a subsequent thought I realized adding a grounded cap will most likely be detrimental. With every Enable high signal, it may produce a logic low momentarily. It might actually delay actual enabling. If that is desirable, cap might be added but again if there is any noise at incomin enable signal, the cap will cause disable/enable spike which might act as reset.

Rajeev said...

Sorry, my mistake. In the above reply, I did not mean EN pin, rather I meant that noise on RST pin will also produce a negative spike, if cap is added. So, it will actually reset nullify the pull up benefit.

toys said...

Hi Gadjet,
Thanks for the v5 door sensor. Just ordered the pcb from jlcpcb. Hope to combine/adapt mrDiy.ca's hub3 on a veroboard and yours for my needs. Like the use of simple logic gates.
Mano

Gadjet said...

Hi Mano,
Thanks, I hope it all works for you
Phil

Rajeev said...

Hi Mano,

Can you please elaborate on what kind of changes you are envisaging. I too am trying some variations and some minor enhancement (as discussed in last few messages with Phil)

toys said...

Hi Rajeev,
sorry for the late reply...
MrDIy.ca's structure for decoding the espnow packet is as below.
typedef struct struct_message {
int mesh_id;
uint8_t sensor_id[6];
byte category;
bool status;
float temperature;
float humidity;
float battery;
} struct_message;

Phil's is very similar..

typedef struct struct_message {
int id;
char state[7];
int vBatt;
float Temp;
} struct_message;
so the plan is to expand Phil's structure to allow correct decoding OR modify Hub3's decoding to work with Phil's at this stage, to improve the delay on notifications of bell-push, door opens and PIR trips. ie.. remove the dependency on cloud services.

Rajeev said...

Hi Mano,

Thanks for your reply. Ok, now I understood the changes you are contemplating. I, at this stage, am trying minor hardware variations first. Thereafter, I shall go for software and hub part. I am just testing switching on/off of ESP8266. I shall try esp-now but shall also see if it works with wifi and as mqtt client as well first. Right now, I am having abrupt power off issues in WiFi. May be using esp now will resolve it, but I am wondering if WiFi connect attempt may also lead to hardware issues. I do wish to try variations and if you may like, we can commnicate one to one as well.

Rajeev said...

Hi Mano,
I fixed up the issue in my adaptation with a few minor HW changes. Now to your question of struct which is being used by Phil or mrdiy. The struct is just any structure of payload of whatever you want to send/recv. You can use either structure or even craft your own as per your need and vars you want to have in the message. Only thing to keep in mind is that you will need to have make changes in the parsing code. The message is just a string of chars and how you use it is entirely up to you. You just need to be consistent.

toys said...

Hi Rajeev,
Yes, understood. The boards arrived today, just waiting on the smd components to arrive then will begin the assembly.

Three button WiFi Remote

Using the power control circuit from the Wirelesse door/Window sensor I have designed a simple 3 button WiFi remote with the intention of co...

Popular Posts