56 lines
1.9 KiB
Markdown
56 lines
1.9 KiB
Markdown
# Overview
|
|
|
|
IoTButton is a low-cost, low-powered, WiFi-enabled button targetting simple home
|
|
automation use-cases. The Button integrates simply into HomeAssistant's device
|
|
discovery mechanism, making integration with the rest of the Home Assistant
|
|
ecosystem straightforward.
|
|
|
|
The button combines an ESP8266 for WiFi connectivity, and an ATTINY85 for
|
|
low-power monitoring and triggering the ESP8266.
|
|
|
|
# FAQ
|
|
|
|
# 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
|
|
```
|