{"id":30274264,"url":"https://github.com/martinthoma/temperature-sensor","last_synced_at":"2026-04-17T04:33:38.030Z","repository":{"id":305559835,"uuid":"1023193812","full_name":"MartinThoma/temperature-sensor","owner":"MartinThoma","description":"Build the perfect temperature/humidity sensor for my smart home","archived":false,"fork":false,"pushed_at":"2025-07-21T16:40:08.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-26T21:58:16.302Z","etag":null,"topics":["esp32","home-automation","humidity","humidity-sensor","iot","sensors","smart-home","temperature","temperature-sensor"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MartinThoma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-20T18:09:59.000Z","updated_at":"2025-07-21T16:40:13.000Z","dependencies_parsed_at":"2025-07-20T20:46:46.013Z","dependency_job_id":null,"html_url":"https://github.com/MartinThoma/temperature-sensor","commit_stats":null,"previous_names":["martinthoma/temperature-sensor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MartinThoma/temperature-sensor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinThoma%2Ftemperature-sensor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinThoma%2Ftemperature-sensor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinThoma%2Ftemperature-sensor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinThoma%2Ftemperature-sensor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MartinThoma","download_url":"https://codeload.github.com/MartinThoma/temperature-sensor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinThoma%2Ftemperature-sensor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31915289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esp32","home-automation","humidity","humidity-sensor","iot","sensors","smart-home","temperature","temperature-sensor"],"created_at":"2025-08-16T08:29:15.732Z","updated_at":"2026-04-17T04:33:38.023Z","avatar_url":"https://github.com/MartinThoma.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Temperature- and Humidity Sensor\n\nThe idea behind this project is to create a temperature and humidity sensor that can be easily integrated into a home automation system, such as Home Assistant.\n\nIn a private house every room should have at\nleast one sensor, potentially more to get the\ntemperature gradient within a room (from floor\nto ceiling, from window to door).\n\nIt is primarily designed to be used indoors.\n\nAs one home might have 15 rooms and every room might have 1-3 sensors, the price should be low\nenough to allow for multiple sensors without breaking the bank.\n\nFor the same reason, the sensor should be low power, so it can run on batteries for a long time.\n\nIt also should not break the wi-fi by having too many sensors connected to the same network.\n\nThe sensor should cover:\n\n* Temperature: -40°C to +60°C, so an unheated garage or an attic in summer can\n  be monitored\n* Humidity: 0% to 100% RH, to account for all indoor environments\n* Accuracy: ±1°C and ±5% RH, so it is not too expensive but still accurate\n  enough for most use cases\n* One value every minute should always be enough\n\n## Hardware\n\n### Components: 9.63€\n\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eComponent\u003c/th\u003e\n        \u003cth\u003eSpecs\u003c/th\u003e\n        \u003cth\u003ePrice\u003c/th\u003e\n        \u003cth\u003ePrice per piece\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003ca href=\"https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_en.pdf\"\u003eESP-WROOM-32 Development board\u003c/a\u003e\u003c/td\u003e\n        \u003ctd\u003etwo low-power Xtensa® 32-bit LX6, 520 KB of on-chip SRAM; Wi-Fi 802.11 b/g/n (802.11n up to 150 Mbps); Bluetooth v4.2 BR/EDR + BLE; –40 °C to +85 °C\u003c/td\u003e\n        \u003ctd\u003e7€\u003c/td\u003e\n        \u003ctd\u003e7€\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003ca href=\"https://www.mouser.com/datasheet/2/758/DHT11-Technical-Data-Sheet-Translated-Version-1143054.pdf?srsltid=AfmBOorywJsEEEBtBxdXiNRqFNXPa3f5OPcv28YAAwzZxsxg1NEnql1v\"\u003eDHT11 Temperature and Humidity Sensor\u003c/a\u003e\u003c/td\u003e\n        \u003ctd\u003e20-90%RH and 0-50 ℃; ±5％RH; ±2℃; Resolution of 1°C and 1% RH; Requires 3-5.5V DC\u003c/td\u003e\n        \u003ctd\u003e3x for 7.89€\u003c/td\u003e\n        \u003ctd\u003e2.63€\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n\n### Assembly\n\n1. Connect the DHT11 sensor to the ESP32:\n   - VCC to 3.3V (3V3)\n   - GND to GND\n   - Data pin to GPIO 4 (D4)\n\n## Software\n\n### Size\n\n```\n$ idf.py size\n\n                             Memory Type Usage Summary\n┏━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n┃ Memory Type/Section   ┃ Used [bytes] ┃ Used [%] ┃ Remain [bytes] ┃ Total [bytes] ┃\n┡━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n│ Flash Code            │       567086 │          │                │               │\n│    .text              │       567086 │          │                │               │\n│ Flash Data            │       110564 │          │                │               │\n│    .rodata            │       110308 │          │                │               │\n│    .appdesc           │          256 │          │                │               │\n│ IRAM                  │        98143 │    74.88 │          32929 │        131072 │\n│    .text              │        97115 │    74.09 │                │               │\n│    .vectors           │         1028 │     0.78 │                │               │\n│ DRAM                  │        33272 │    18.41 │         147464 │        180736 │\n│    .data              │        16672 │     9.22 │                │               │\n│    .bss               │        16600 │     9.18 │                │               │\n│ RTC FAST              │           36 │     0.44 │           8156 │          8192 │\n│    .force_fast        │           36 │     0.44 │                │               │\n│ RTC SLOW              │           24 │     0.29 │           8168 │          8192 │\n│    .rtc_slow_reserved │           24 │     0.29 │                │               │\n└───────────────────────┴──────────────┴──────────┴────────────────┴───────────────┘\nTotal image size: 792501 bytes (.bin may be padded larger)\n```\n\n\n### Setup\n\n1. Copy the environment variables template:\n   ```bash\n   cp .envrc.example .envrc\n   ```\n\n2. Edit `.envrc` and set your WiFi credentials:\n   ```bash\n   export WIFI_SSID=\"YourWiFiNetworkName\"\n   export WIFI_PASS=\"YourWiFiPassword\"\n   ```\n\n3. Source the environment variables before building:\n   ```bash\n   source .envrc\n   ```\n\n### Development\n\nRequirements:\n\n```\n. $HOME/esp/esp-idf/export.sh\n```\n\nMake sure to source your WiFi credentials and then build and flash:\n\n```bash\nsource .envrc\nidf.py -p /dev/ttyUSB0 flash monitor\n```\n\n## Communication\n\nHome Assistant can get the data from the sensor via HTTP requests (polling a REST API).\n\n### TODO\n\n* Integrate into Home Assistant, maybe via [ESPHome](https://esphome.io/)\n* [ESP32 Wi-Fi Provisioning via Bluetooth](https://randomnerdtutorials.com/esp32-wi-fi-provisioning-ble-arduino/)\n* Make a rigid case, e.g. with a 3D printer. Should be easy to swap\n  batteries/plug in a USB cable.\n* Run with batteries (2x AAA Battery Holder)\n* Configure WiFi credentials via Bluetooth\n* Use less energy:\n    - Switch from polling to MQTT\n    - Use deep sleep mode\n    - Switch from Wi-Fi to something\n      less power hungry (e.g. LoRaWAN, Zigbee, Thread, BLE, ESP-NOW)\n\n## Improvements\n\n* Sensor:\n    * The DHT22 (AM2302) would cover especially low temperatures (down to -40°C)\n      and has a better accuracy (±0.5% RH, ±0.3°C). It is almost twice as\n      expensive, though (~5€ per piece).\n    * The AHT20 is more accurate than the DHT22, has a higher resolution, requires a lower voltage, uses less power. [Wiring seems easy](https://www.espboards.dev/sensors/aht20/)\n    * The BME280 would also give Barometric Pressure. [Tutorial](https://randomnerdtutorials.com/esp32-bme280-arduino-ide-pressure-temperature-humidity/)\n    * The SHT35 has a slightly better accuracy than the AHT20, but is more expensive. The SHT45 additionally has lower power consumption, but is even more expensive.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinthoma%2Ftemperature-sensor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinthoma%2Ftemperature-sensor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinthoma%2Ftemperature-sensor/lists"}