How can a device reliably determine if it is standing up or laying down? - Page 1
Forum section: electronics / projects

author: pjetson
author_rank: Newbie
timestamp: August 22, 2022, 04:33:37 am
content: I am developing a device that is similar in size and shape to an 18650 battery. The device has a micro and battery inside, and will spend most of its time in deep sleep.The device must be aware of whether it is standing up on end, or laying down. When it detects that it has changed between one orientation and the other, it sends out a radio signal then goes back to deep sleep. It most circumstances, the device will only be stood up or laid down a few times a day.The device is completely stand-alone and not attached to anything. It will usually be on a nominally horizontal surface like desk, table, shelf, or something similar.I've tried using a tilt switch (which had a small metal ball inside, rolling against contacts), but it was unreliable, almost as if the ball wasn't making good contact.I've also tried a mercury switch, which was much more reliable than the tilt switch, but since it contains mercury, it's not environmentally friendly (and therefore also not easy to find/buy).I believe there may be switches available that contain a fluid other than mercury, and also magnetic tilt switches, but I suspect that these would have the same problem that I am running up against.If I positioned the tilt/mercury switch "on end" so that the switch is closed when the device is standing up, then lay the device down, the switch would not always open, because the ball/mercury would not always roll/flow away from the contacts.If I mounted the switch on an angle instead, then lay the device down, there are some positions (rotations of the device) where the switch is still closed, so the device may not know it's been laid down. And, if the device is laid down and then rolls, the switch may indicate that the device has been stood up. So, I don't think tilt switches are really a viable proposition.It seems that accelerometers replace tilt switches nowadays. But I need to keep the power consumption of the device as low as possible, so I can't keep the micro running to continuously monitor the output of an accelerometer. Maybe there are very low power stand-alone accelerometers that can be programmed with limits and with an output that could be used to wake up the micro, but I haven't seen anything like that.Does anyone have any ideas?Thanks, Peter

author: ledtester
author_rank: Super Contributor
timestamp: August 22, 2022, 05:34:12 am
content: Might be worth it to get a "cube timer" to see what makes it tick...https://www.amazon.com/Gravity-Kitchen-Workout-Management-Minutes/dp/B08XQH51Z6An aliexpress listing:https://www.aliexpress.com/item/3256802741500374.html

author: pjetson
author_rank: Newbie
timestamp: August 22, 2022, 06:06:49 am
content: Quote from: evb149 on August 22, 2022, 05:15:41 amThat sounds like it would solve my problems, but I can't seem to find anything like that with Google that isn't far too large. Do you know of a manufacturer or part number?

author: inse
author_rank: Super Contributor
timestamp: August 22, 2022, 06:11:20 am
content: An accelerometer would do the job for sure, but it would be overengineered to distinguish between two orientations.Searching for 'tilt switch' returns apparently a million products, there should be also some reliable solutions available.Regarding the power consumption, having the uC in sleep mode and turning on the supply and reading the sensor in suitable intervals should manage to bring the power consumption down.I once made a car GPS speedometer that measured the battery voltage every 100ms to check whether the engine was running or not - that brought the average current consumption down to the uA range.

author: ledtester
author_rank: Super Contributor
timestamp: August 22, 2022, 06:11:35 am
content: Quote from: pjetson on August 22, 2022, 04:33:37 amI'd take a look at the OncQue product line. Their corporate site ishttps://www.oncque.com/but you can find demo videos on youtube. You can buy some of their products in small quantities on alibaba.com.

author: Kalvin
author_rank: Super Contributor
timestamp: August 22, 2022, 07:02:41 am
content: TwoThree questions come to my mind:- how long the battery should last ie. what is the maximum allowed idle-state current consumption? 1uA, 2uA, 5uA, 10uA, 20uA, 50uA, 100uA?- how quickly the device shall detect the change of the orientation? 1ms, 10ms, 100ms, 1s, 10s, 1minute?- how much effort you want to invest in order to obtain the best performance?If you need a relatively fast response time (say less than second or so), you might want to use a mems accelerometer with ultra-low power consumption, which has built-in orientation detection, and which will "automagically" wake up the system when the orientation changes (using an interrupt output signal). In this way you can achieve idle-state current consumption in range around a few microamperes quite easily.For the less challenging response times you can use a MCU with ultra low sleep state current consumption (typically 500nA or less when the internal timer is running) along with the mems accelerometer: The MCU will wake up periodically using its internal timer, and check the accelerometer's orientation in programmed intervals. In this way you can achieve average idle-state current consumption below 1uA.

author: Haenk
author_rank: Super Contributor
timestamp: August 22, 2022, 07:22:54 am
content: Can't you make a device on your own?Ring of wire, very thin wire with some weight attached in the middle. No contact in normal position, contact when tilted. Probably the "chinese toy"-approch, but worth a try I guess.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: August 22, 2022, 07:58:55 am
content: Accelerometers may be overkill, but they are cheap (around 30 cents in 100x at LCSC), robust and very easy to integrate.Most have low power modes, but unless you want to wake your MCU on tilt, you can just keep it powered off most of the time.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: August 22, 2022, 08:13:52 am
content: Quote from: Haenk on August 22, 2022, 07:22:54 amUnless you're making pretty large quantites, the time spent faffing about DIYing is not worth it compared to using an off-the-shelf accelerometer. switch contacts are non-trivial to get right.

author: pjetson
author_rank: Newbie
timestamp: August 22, 2022, 10:50:14 pm
content: Thanks to all the posters for your ideas - you've given me a few leads to track down.I'm keen on the simplicity of the "bell and clapper" type of tilt switch, which could work in my application, but I can't seem to find anything small enough. On the negative side, such a switch might turn out to be too subject to false triggering by vibration, which is what I think this type of switch might be meant to detect.

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 22, 2022, 11:08:50 pm
content: Quote from: pjetson on August 22, 2022, 04:33:37 amThere are indeed. And even when they don't have an internal wake-up mechanism, most of current accelerometers have a stand-by mode with very low current draw and active modes that are also very low power if you stick to a low sample rate. You'll need to carefully design your system so there is minimal current drawn when the system is in "sleep" mode and develop the MCU firmware accordingly (so pick one that has appropriate low-power modes too.)I've developed a device a few years ago of this kind. It was supposed to become "active" in a certain position. I used an accelerometer, but the one that fit the requirements there and that was available at the time didn't have a standalone wake-up mechanism. So the MCU was just in low-power mode and would wake-up via its internal low-power timer once every second or so, on a very low clock frequency, would read the accelerometer and deduce position, and then would either continue to active mode (then switching to a much higher clock freq) or fall back in deep sleep mode. Along with an ultra-low power regulator, the whole system only drew ~6 µA on average with this scheme.But there are now some accelerometers which can wake up the MCU upon some detected movement, so that'd be even lower average current.

author: David Hess
author_rank: Super Contributor
timestamp: August 23, 2022, 12:52:45 am
content: I would use an accelerometer. That is how your phone does it.

author: Scrts
author_rank: Frequent Contributor
timestamp: August 23, 2022, 04:20:45 am
content: Look up "inclinometer". Basically multiple axis accelerometers inside... E.g. ST IIS2ICLX