I want to make a temperature sensor that I can remotely access with parts I have already. I'm going to try and use [ESPHome](https://esphome.io/), an ESP32 (the `esp32doit-devkit-v1` specifically) and a DHT22 sensor.
Step 1 was to install esphome with `pipx` and go through [getting started](https://esphome.io/guides/getting_started_command_line). Also added the [dht](https://esphome.io/components/sensor/dht.html) component. But the pins are labelled weird. Actually, it's straightforward, just a different syntax. I am using GPIO23 (labelled D23) on the board. Confirmed from [this site](https://mischianti.org/doit-esp32-dev-kit-v1-high-resolution-pinout-and-specs/)
That's working, and I have wireguard working too! Pretty straightforward the [wireguard](https://esphome.io/components/wireguard.html) and [debian's docs](https://wiki.debian.org/WireGuard). This is so freaking magic!
Finally, we have nginx doing HTTPS termination. This is what I had for my location section:
```
location / {
proxy_pass http://192.168.11.2/;
proxy_set_header Host $http_host;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
```
(needed because esphome web uses [server sent events](https://stackoverflow.com/questions/13672743/eventsource-server-sent-events-through-nginx))
Final config
```yaml
esphome:
name: REDACTED
esp32:
board: esp32doit-devkit-v1
framework:
type: arduino
# Enable logging
logger:
wifi:
ssid: "REDACTED"
password: "REDACTED"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "REDACTED Fallback Hotspot"
captive_portal:
sensor:
- platform: dht
pin: GPIO23
temperature:
name: "Room Temperature"
humidity:
name: "Room Humidity"
update_interval: 60s
binary_sensor:
- platform: wireguard
status:
name: 'WireGuard Status'
web_server:
port: 80
ota: false
auth:
username: REDACTED
password: REDACTED
wireguard:
address: 192.168.11.2
private_key: REDACTED
peer_endpoint: REDACTED
peer_public_key: REDACTED
time:
- platform: sntp
id: sntp_time
timezone: America/Toronto
servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
```
Pretty magical!
Final note, if I find the nginx isn't working well with SSE, I can use [rinetd](https://github.com/samhocevar/rinetd) to just do port-forwarding for http without https.