Simple arduino-based sensor to determine the height of my standing desk.
- main.ino: Attempt to connect to wifi network (blink WIFI LED while connecting, WIFI LED on when connected).
- main.ino: Determine desk height by measuring 3 times in rapid succession and taking the max value (this smooths out sensor readings).
- main.ino: Send a basic json payload with the deskheight to my home server (blink SUCCESS LED).
- main.ino: In case of any issues, blink ERROR LED.
- home server: listen on port and dump incoming json to file using logstash
- home server: for every incoming request, create according sensor in home-assistant using logstash
- home server: in home-assistant, use template sensor to determine whether desk is up or down based on sensor value.
Bill of Materials
- Wemos D1 (=cheap arduino clone with wifi chip)
- Arduino compatible ultrasonic sensor HC-SR04
- Arduino compatible 9V Power adapter
- Some LEDs (optional) to indicate connectivity to WiFi network and logstash server.
The code can be found in main.ino.
Requires some a
secrets.h file that sits in the same directory that looks like:
#define SECRET_WIFI_SSID "myssid"; #define SECRET_WIFI_PASSWORD "mysecretpassword"; #define SECRET_HTTP_HOST "10.1.1.1" #define SECRET_HTTP_PORT 1234 #define SECRET_HTTP_USER "secret-user" #define SECRET_HTTP_PASSWORD "secret-password"