60 lines
2.5 KiB
Markdown
60 lines
2.5 KiB
Markdown
# About
|
|
|
|
While setting up some basic home automation, I realized that there things that I'd like to track simply by pressing a button. For example, has anyone fed the dog this morning? She's more than willing to ask for breakfast even if she's already eaten it :)
|
|
|
|
While searching for a good product for this, I couldn't find one, so I decided to make my own. The primary goals are:
|
|
|
|
1. It must be cheap, ideally around \$5.
|
|
2. It must be reasonably manufacturable (on the order of 10s to 100s).
|
|
3. It must be re-useable, no tossing it when the battery dies!
|
|
4. It must reasonably small and inoffensive.
|
|
5. It must integrate with HomeAssistant, ideally with minimal configuration.
|
|
|
|
Unfortunately, shortly after I ordered my first rev of PCBs, Ikea released the $10 [Shortcut Button](https://www.ikea.com/ca/en/p/tradfri-shortcut-button-white-20356382/) which meets most of my criteria. Falling victim to the sunk cost fallacy, I plan to see it through to making a few of these.
|
|
|
|
# Q&A
|
|
|
|
## Why are there two microcontrollers?
|
|
|
|
Cost and ease of development.
|
|
|
|
Both ESP8266 and ATTINY(2/4/8)5 modules can be had for around \$1 each, and
|
|
there are retail programming jigs available. I have a kid now and don't want to
|
|
spend my time making a programming board.
|
|
|
|
The ESP8266 alone cannot really wake from multiple sources and know trap the
|
|
source of the interrupt- there is only one pin that can wake up the micro from
|
|
deep sleep, and that same pin needs to be used if you want to use the RTC as a
|
|
wake source. Sure, you could use an OR-gate and also wire each source to a GPIO,
|
|
but you might miss the source by the time the ESP wakes up to check the pins.
|
|
|
|
Hence, the ATTINY is used to capture the wakeup and inform the ESP8266, who does
|
|
the heavy lifting.
|
|
|
|
### What about ESP32?
|
|
|
|
The cheapest modules I can find at the time of writing are around \$3.50 apiece,
|
|
and they can be power hungry (spikes up to 750mA compared to 400mA, from what I
|
|
read).
|
|
|
|
### What about ESP32-S2?
|
|
|
|
They appear promising and are only \$2 per module on Digikey at the time of
|
|
writing, however they are not supported by platformio yet.
|
|
|
|
### What about ...?
|
|
|
|
I probably wasn't aware that it exists.
|
|
|
|
# Development
|
|
|
|
The standard PlatformIO tooling should work. However, here's a bit of setup I had to do in order to make emacs+clangd happy:
|
|
|
|
``` sh
|
|
cd <PROJECT_DIR>
|
|
# Create the compile_commands.json
|
|
pio build -t compiledb
|
|
# Link the compile_commmands.json from the git root, which is where tools are expecting it
|
|
ln ./.pio/build/<ENV>/compile_commands.json ../../compile_commands.json
|
|
```
|