Live temperature readings from your room, as Discord Rich Presence!
  • JavaScript 54%
  • C++ 31.5%
  • Nix 14.5%
Find a file
2025-02-13 15:32:37 +01:00
discord-rpc update package.json 2021-07-10 20:56:21 +02:00
esp-server esp-server: add flake.nix 2025-02-13 15:32:37 +01:00
.gitignore esp-server: add flake.nix 2025-02-13 15:32:37 +01:00
LICENSE Create LICENSE 2021-07-10 21:07:33 +02:00
README.md esp-server: add flake.nix 2025-02-13 15:32:37 +01:00

RoomWeather

ESP Board / API

This was made for a NodeMCU ESP8266 development board and a DTH22 sensor. There are guides available on the internet on how to wire this up, depending on your model.
The code could also be easily adapted to utilize a DTH11 or with a little effort even any other sensor.

The libraries 'Adafruit Unified Sensor' and 'DHT sensor library' are required.

Before compiling you need to set the SSID and Password of your WiFi in arduino_secrets.h (as in the example file) and adjust the static IP settings at the top of esp-server.ino for your network.

If you have nix installed, you can simply do something like this without installing anything:

cd esp-server
nix develop
arduino-cli compile -b esp8266:esp8266:d1_mini
arduino-cli upload -p /dev/ttyUSB0 -b esp8266:esp8266:d1_mini

There are currently four API endpoints:

  • /weather: returns temperature and humidity as application/json
  • /temperature: returns raw temperature reading in celsius as text/plain
  • /humidity: returns raw humidity reading in percent as text/plain
  • /metrics: prometheus metrics

Discord RPC

First edit config.json (copy the example) and fill in your application id from discord as well as your apiBaseURL (the local ip of your ESP8266).
You can also configure the updateInterval (in seconds) and the RPC labels/button.

Install dependencies and run it:

yarn
yarn start

Contributing

This code is licensed under the GPL v3.0 or later.
Feel free to fork and PR if you want to improve it :)

Credits

esp-server.ino is based on the Arduino example ESP8266WebServer/HelloServer.
The Discord RPC is based on simple-discord-rpc by Jxyme.