Video How To: Battery Powered Chair Occupancy (Contact) Sensor
-
Pete, Thank you for taking the time to create, post and explain this. I've been struggling with an optimized battery powered sensor and this nailed it. Personally, I broke new ground on multiple fronts with this one. First foray with 2.2 and first custom boot loaders.
Question:
-
My objective is to create a standardized set of sketches for battery powered motion and door/window switches. I'm looking for that instant gratification of a light turning on the moment presence is detected. Yet, battery optimization is still important.
-
How do you recommend I remove some of your bouncing goodness in this sketch for my purposes?
-
I experimented with the following, but my knowledge of 2.2 and interrupt challenges is limited. My attempt was to reduce the sensor state checks from 3 to 1, but I failed at that. I assume it might be better to change the approach, but didn't want to start hacking your code goodness with my lack of 2.2 knowledge.
#define DEBOUNCE_DELAY 1001 // reduced to 1001. Appear to be no issues, but the impact is minimal
uint8_t oldContactVal = 1; //changed from 2 to 1. Caused failure, but I changed this combo of 3 variables at the same time. I'm not sure which one or if all together cause the failure. I'm still slow on arduino / mysensors logic.
uint8_t contactVal[1]; //changed from 2 to 1
uint8_t contactTracker = 0; //did not change. I left this at zero
int8_t wakeVal = 0; //did not change. I left this at zero
else {
//Woke by interrupt, send contact value
if (contactTracker < 1) { // I changed this for <2 to <1Any insights from the community are appreciated.
@pgregg88 said in Video How To: Battery Powered Chair Occupancy (Contact) Sensor:
I experimented with the following, but my knowledge of 2.2 and interrupt challenges is limited. My attempt was to reduce the sensor state checks from 3 to 1, but I failed at that. I assume it might be better to change the approach, but didn't want to start hacking your code goodness with my lack of 2.2 knowledge.
If you're using this for contact or motion sensors I would remove most of my code as it's not needed. For the motion sensor code it can be really simple as you don't even need a debounce. Check out the motion sensor sketch in the MySensors library. Really all you need is a digitalRead then send that value.
For the contact sensors I would just use a wait(20); and then read the sensor again to make sure it's still the same value (or you could use the debounce library). You can also check out the code in the binary sleep sensor and pull from that https://github.com/mysensors/MySensors/blob/development/examples/BinarySwitchSleepSensor/BinarySwitchSleepSensor.ino#L94 -
-
Thank a lot for the idea and for the video explaining the implementation.
Did you check the power consumption when you don't send battery life at regular intervals ? If you set the wake up only on interrupt then current in sleep mode goes from 5-6uA to 2 when contact is opened. It's so low that you don't really need regular reporting of battery life. I do that and report battery life only on opening/closing of doors/windows and my battery life is great even on chinese CR2032 cells (still over 85% on my entrance door).
I guess it would drop to 5-6µA when sensor is connected ?@Nca78 Wow, cool.
I never got readings down to 2uA. Maybe my multimeter isn't very good or something else...?The main reason I regularly report the battery is to provide a heartbeat as well as reset the sensor if for some reason it could not communicate with the gateway the first time.Edit: I just re-read your post. I now see that you were saying I could save those additional uA by not using the sleep. That is a good idea. I'm still a little torn on the idea because I like the assurance of the heartbeat. I'll have to think about it. Thanks for sharing though!
-
That doesn't work to me! :( I am using an arduino clone. I don't Know if that is the problem.
When I use your sketch (an others from Mysensors) my Arduino usage is 30mA, seems like the sleep method doesn't work rigth.
I test with a liltle example from rocketscream/Low-Power and then my Arduino usage is 16uA. Anyone know where the problem may be?
Thanks
-
That doesn't work to me! :( I am using an arduino clone. I don't Know if that is the problem.
When I use your sketch (an others from Mysensors) my Arduino usage is 30mA, seems like the sleep method doesn't work rigth.
I test with a liltle example from rocketscream/Low-Power and then my Arduino usage is 16uA. Anyone know where the problem may be?
Thanks
@Jic did you remove the led and voltage regulator?
-
@Jic did you remove the led and voltage regulator?
Yes, I have removed both
-
That doesn't work to me! :( I am using an arduino clone. I don't Know if that is the problem.
When I use your sketch (an others from Mysensors) my Arduino usage is 30mA, seems like the sleep method doesn't work rigth.
I test with a liltle example from rocketscream/Low-Power and then my Arduino usage is 16uA. Anyone know where the problem may be?
Thanks
-
Yes, I have removed both
@Jic - you should see in the serial debug if the node is sleeping or not. I have heard there might be a problem with sleep in som recent version. Maybe you investigate this and if nessecaru upgrade to development branch.
-
That doesn't work to me! :( I am using an arduino clone. I don't Know if that is the problem.
When I use your sketch (an others from Mysensors) my Arduino usage is 30mA, seems like the sleep method doesn't work rigth.
I test with a liltle example from rocketscream/Low-Power and then my Arduino usage is 16uA. Anyone know where the problem may be?
Thanks
-
Thanks for sharing this awesome project...
I want to install all my windows with reed sensors powered by 2AA alcaline batteries and would like they last more than 5 years... and I think your project fits perfectly
How long do those used batteries last?Did you implement what @Nca78 suggested?
I have already cut LED and Power Regulator from Arduino Pro Mini 3.3v and will change bootloader.
Have you choosen the best (lowest power consumption) bootloader to use?I would try the MYSBootloader_1MHz.hex from MySensors GitHub.
Would the optiboot_atmega328_01M_009600_NOLED from GertSanders better for low power?Thanks for the help...
-
Thanks for sharing this awesome project...
I want to install all my windows with reed sensors powered by 2AA alcaline batteries and would like they last more than 5 years... and I think your project fits perfectly
How long do those used batteries last?Did you implement what @Nca78 suggested?
I have already cut LED and Power Regulator from Arduino Pro Mini 3.3v and will change bootloader.
Have you choosen the best (lowest power consumption) bootloader to use?I would try the MYSBootloader_1MHz.hex from MySensors GitHub.
Would the optiboot_atmega328_01M_009600_NOLED from GertSanders better for low power?Thanks for the help...
@OliverDog if you are using 2xAA then 6uA in sleep mode is fine for a few decades.
You can estimate battery life there, if you don't spend your time jumping on your chair it should last the 5 years easily ;)
http://oregonembedded.com/batterycalc.htmFor the bootloaders battery life won't be different, any bootloader using internal oscillator at 1MHz is fine.
-
Great!!! Got it working, but can't measure the consumption...
My multimeter shows always 000.
The sensors is working fine and reporting properly while connected to multimeter, but always 0 current...
Tried 200u, 2000u, 20m and 200m, always reporting zero... Is is that low?Did I connect something wrong??? (multimeter in series with positive battery pole and circuit line in (Radio+APM+1M ResistorPin3)
Or is my aliexpress multimeter that bad???
-
Great!!! Got it working, but can't measure the consumption...
My multimeter shows always 000.
The sensors is working fine and reporting properly while connected to multimeter, but always 0 current...
Tried 200u, 2000u, 20m and 200m, always reporting zero... Is is that low?Did I connect something wrong??? (multimeter in series with positive battery pole and circuit line in (Radio+APM+1M ResistorPin3)
Or is my aliexpress multimeter that bad???
Clean desk you have here @OliverDog this would make my wife dream :D
For the multimeter, no idea. At 200u it should see something, maybe your red wire is in the wrong plug of the multimeter ? Usually it's a different plug for voltage and for current but you can have a different plug for high current (A) and low current (mA) too...
-
I had just cleaned it!!! My wife gave up caring about this desk...:smirk:
I found my multimeter fuse was burned... so I wired its base poles and now I can measure:
Sleeping + Reed Disconnected - most time 6 uA
Sleeping + Reed Connected - most time 9 uA
When sending new status to gateway - 25 - 230 uA (around 140 uA most times)
Sending time was less than 1 second.2 AA will give me 29 years (battery certainly will die first)
2 AAA - 12 years.
1 CR2032 - 2,5 years.Thanks for the help...
-
@OliverDog when sending to gateway you cannot trust your multimeter. It's probably around 15mA but only during a fraction of a second, and what you read is some kind of average between that and the very low power consumption in sleep mode.