Hello everybody,
here's one of the projects I've been working on these past few weeks. I was quite inspired by Joe Lucid's Tino and Tom's TH Mote and tried to reuse (or abuse) some of their ideas when designing low-power, miniature motion sensor. I named it "Limbus" because it resides in the interface between man and machine (or between changing environment and the more rigid/stagnent home). Actually this is only one of the devices in the Limbus series, but I'll tell you more about them later.
Now, some design requirements for the motion sensor:
- nice appearance (similar to Felix's MotionMote). After all, this is one of those few sensors that need to be visible, so no ugly tinkering this time (see below some before/after pictures to see what kind of MonsterMote's I've had until now
)
- small size (especially the depth) and light weight, since I wanted to attach the sensors to walls with double-sided tape.
- low power PIR sensor -> smaller battery -> size and weight reduced automatically
- more robust than the ubiquitous cheap, chinese PIR sensor
- temp & humidity sensor included
- wirelessly updated
- preferably also ICSP and FTDI interfaces
Here are notes on the current design:
PIR sensor:
Panasonic EKMB1101113 (
http://www.mouser.fi/ProductDetail/Panasonic-Industrial-Devices/EKMB1101113/?qs=raAh8RbVwI5epY%252bTpPfoFA%3d%3d)
Somebody mentioned this on other thread. It's really nice PIR sensor, with standby current of only 1 uA. It's a tad expensive (18,8 euros on Mouser, on Digikey 20.79 euros), but my free time is more expensive when it comes to having headaches with the chinese PIR sensors (susceptability to voltage fluctuations and nearby wireless transmissions). On my tests I found I've found it to be quite stable, so no need to add "dead time" after RFM69 transmissions anymore. Only thing that I wished it had is lower height, but I guess one can't have everything
One thing to mention: I found out that when used wirelessly (no FTDI/ICSP cable attached), it wouldn't trip to motion always, but when oscilloscope probe was attached, it miraculously started to work. Even though the example wiring in the datasheet doesn't mention this, a 100K resistor between GND and OUT solves this (I didn't try other values though)
SI7021 temperature and humidity sensor:
Standby current 60 nA so no other power down mechanisms needed. Relative humidity conversion current 150 uA, duration 2.6 ms (8-bit resolution).
Temperature conversion current 90 uA, duration 2.4 (12-bit res). For some reason no way to enable both 8-bit RH and 11-bit temp resolution together(?). Peak current during I2C operations is 3.5mA (<100 uS), but I haven't measured what is the average current consumption and duration during temp & RH comms yet.
Flash chip W25X40CL (same as is Moteinos).
To squeeze out even the 1 uA sleep current, the chip is put behind mosfet to power it up only during OTA firmware updates. The Optiboot boot loader was modified to turn the power on when updating the firmware.
Watchdog TPL5010:
Only 35 nA operational current. Wakes the CPU every second so that 328P can be put to power-down mode. Interval is set with two parallel 1% resistors. Recommended for 1 second is 7.15K || 19.1K = 5.202K, but I didn't have those exotic values so 6.82K || 22K = 5.194K is close enough. (should calibrate this individually for accuracy but at this point it's "good enough").
I had originally trouble with the example schematic suggesting to wire the reset output to CPU, since 1 second is too short time to get even past boot loader without the WD then resetting the CPU again. I removed the wire and put pull-up resistor from VDD to WD reset pin, but the latter seems unnecessary.
Other problem was that sometimes the WD would not acknowledge the DONE-signal from CPU after a single missed WAKEUP signal, and the WD would just keep resetting the CPU (or would try, since reset is not attached anymore), and would not send any more WAKEUPs (which leads to eternal sleep unless interrupt comes from PIR). After a while (and many more explicit DONEs before going to sleep) the WD would eventually start acknowledging them again, but this was quite annoying. Configuring the WAKEUP interrupt handler right at the setup (and not before sleep) and keeping it attached all the time seems to help though.
Now one remaining problem is that I can't get the WD to reset it's time cycle (DONE signal does not seem to do this), so if I want to explicitly use internal WD to sleep for shorter duration, there's eventually going to be overlap between the two WD cycles and CPU wakes up earlier than supposed.
Has someone here had similar issues with TPL5010?
Atmega328p:
Running now in 8 Mhz. According to datasheet min voltage is 2.4, but I suspect when battery level declines, voltage might droop under this during tx, so maybe it could be better to run it with 4 Mhz. On the other hand, we want to do our stuff and get back to sleep as quickly as possible. But then again, we are waiting for many milliseconds during tx and temp/RH conversion. Maybe best to alternate between 1-8 Mhz and even put CPU to sleep during the whole 5 mS temp conversion? This needs more investigation.
Tag Connect for ICSP and FTDI connectors:
I hate soldering these bulky 2.54mm pitch connectors when mostly they are being unused, so I tried to look for alternatives (pogo pins, edge connectors). Eventually I found out about Tag Connect
(
http://www.tag-connect.com/) and I haven't looked back
It's pretty expensive for such a simple thing (33 euros for TC2030-MCP-NL cable + 16 euros for triple pack of back plates), but this is a one-time purchase and saves a lot of head-ache later. For the smaller footprint NL (no legs) version the back plate is recommended to hold the connector in place (at least when debugging with FTDI interface), so remember to take this in account when designing the 3d layout (you don't want the adjacent parts to get in the way).
Battery:
Both CR2450 (solder-type) and CR2032 (battery holder) can be installed. Battery voltage is read through resistor ladder (3.3K and 1K), powered by PNP mosfet (same mosfet as the flash chip). 100 nF cap is there to stabilize the measurement, but I still need to investigate how much removing this would decline the accuracy (with these values RC time constant = 0.33 mS, so around 3*RC= 1 mS with 0.767 mA is now wasted just waiting for the capacitor to charge).
Sleep modes:
- CPU power down without internal WD during longer (>1s) periods. RFM69W is in sleep. Current consumption is 1.5-2 microamps in this mode.
- When awake, RFM69W is put to Listen Mode automatically to save battery.
- For shorter periods (for example when flashing leds for 30ms) the internal WD is used to sleep. RFM69W stays awake (in Listen Mode).
- After booting the operation mode is "Service/maintenance" (for example 30-60 seconds), during which RFM69W is awake (in Listen Mode) to receive OTA updates and other configuration changes. There's a reset switch that is incidentally also used to enter service mode. CPU dozes in short (now 500ms) cycles with internal WD.
LEDs:
in addition to normal led, WS2812B RGB led is used for troubleshooting/debugging/signaling. Could be configured real-time to customize "motion detected" indicator light. Since WS2812B uses whopping 470 uA in idle (led off), it is powered by a second PNP mosfet. Maybe powering it directly from 328P pins could be possible, but I don't know how much is the peak current draw and I didn't want to risk frying any of the CPU pins.
PCB:
All the above could be fitted to 2-layered 31x31 mm PCB. Main restrictive factor was to have both CR2450 and PIR sensor side by side, since having them on separate sides would put too much bulk depth-wise. Also, with only 2 layers it was getting tiresome to route all the connections without having to have the board peppered with vias
Also having a well connected GND plane is nice.
One note: When using CR2032 the top (+) connectors (for CR2450) need a jumper wire. Also if reset switch is not soldered in, the top GND-connected holes need a jumper wire.
Enclosure:
34 x 34 x 18.5mm. Printed in PLA 1.75mm with 3d printer from Think3dPrint3d. Still need to tinker with the Simplify3D settings to get better quality front plate.
Here's some pictures of the completed ones:
They are quite an upgrade compared to the few Frankenmotes that I've had to endure up to now
Blunders (so far.. ) in rev 01:
- Output from PIR was originally wired to A7, which doesn't even have a interrupt capability
Now wired to D5
- 100k resistor added between GND and OUT (PIR sensor) for stability
- Bulky reset switch replaced with slim SMD switch (current footprint not compatible and I had to use extra wires so this work-around is not physically the most stable but works)
Future ideas and improvements:
- For non-wall attached sensors adding depth while reducing frontal size would be acceptable. Maybe one PCB with 328p + rfm69 + flash + voltage sensor, and a separate PCB for other peripherals (PIR, leds, si7021). Frontal size should come down to around the size of CR2450, depth maybe around the same, so nice cube form factor could be achieved.
- Give up the after-boot service mode and manual update initiation, and move to 100% Listen Mode? Then no manual button-pushing would be required. Also on-demand temperature sensing would be possible. How much would current consumption increase then?
- Swap RFM69W with smaller RFM69CW.