{"id":16367749,"url":"https://github.com/jackgruber/esp32_ttn_environmental_sensor","last_synced_at":"2025-03-23T02:33:04.517Z","repository":{"id":158957260,"uuid":"289491125","full_name":"JackGruber/esp32_ttn_environmental_sensor","owner":"JackGruber","description":"Battery/solar-powered ESP32 TTN (LoraWAN) sensor for measuring temperature, humidity, air pressure and fine dust.","archived":false,"fork":false,"pushed_at":"2022-08-17T17:03:13.000Z","size":3179,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-15T02:11:42.035Z","etag":null,"topics":["bme280","esp32","lorawan","sds011","ttn","ttn-application"],"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/JackGruber.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}},"created_at":"2020-08-22T13:17:21.000Z","updated_at":"2024-12-02T20:37:30.000Z","dependencies_parsed_at":"2023-06-15T02:30:36.120Z","dependency_job_id":null,"html_url":"https://github.com/JackGruber/esp32_ttn_environmental_sensor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackGruber%2Fesp32_ttn_environmental_sensor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackGruber%2Fesp32_ttn_environmental_sensor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackGruber%2Fesp32_ttn_environmental_sensor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackGruber%2Fesp32_ttn_environmental_sensor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JackGruber","download_url":"https://codeload.github.com/JackGruber/esp32_ttn_environmental_sensor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245047981,"owners_count":20552430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bme280","esp32","lorawan","sds011","ttn","ttn-application"],"created_at":"2024-10-11T02:50:46.196Z","updated_at":"2025-03-23T02:33:04.118Z","avatar_url":"https://github.com/JackGruber.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESP32 battery/solar powerd environmental sensor\n\nBattery/solar-powered ESP32 TTN (LoraWAN) sensor node for measuring temperature, humidity, air pressure, fine dust, UV and LUX.\n\n\u003cimg src=\"img/case_open.jpg\"\u003e\n\nThe microcontroller is an ESP32, but I don't use a ready-made module, because they need too much power even in DeepSleep. Instead I use a WROOM32 module.\n\nThe following sensors are used: SDS011 (Fine dust),  BME280 (Temperature / Humidity / Air pressure), VEML6075 (UV Index) and TSL2591 (LUX).\n\nFor power supply a 18650 battery is used, which is charged via solar pannel and TP4056. Since the ESP32 and the sensors require 3.3 V, the MCP1700-3302E voltage regulator is used, because the a full loaded 18650 provieds 4.2V and the ESP32 is only rated for 3.0 V~3.6 V. Only the SD011 needs 5V, these are generated with a step-up converter.\n\nSince the SDS011 also needs too much current during the DeepSleep phases of the ESP32, it is switched on and off by N-channel MOSFET (IRL3103PBF).\n\nEvery 5 minutes the measurements are sent via LoRaWAN. I retrieve the values via MQTT and Telegraf and visualize them in a Grafana dashboard.\n\nThe whole thing was then installed in a weatherproof housing, the cables and the AAA are led down by Cable Glands to the outside to keep the housing as waterproof as possible. Only the BME280 was mounted outside in a Stevenson Screen.\n\n## Components / BOM\n\n* 1x WROOM32 module\n* 1x TP4056 module\n* 1x MCP1700-3302E\n* 1x Solar panel 6V 3W (180x150 mm)\n* 1x 18650 battery\n* 1x 18650 battery holder\n* 1x 5V DC-DC boost converter module\n* 1x RFM95 module\n* 1x RFM95 breadboard\n* 1x BME280 sensor\n* 1x SDS011 module\n* 1x TSL2591 sensor\n* 1x IRL3103PBF\n* 1x VEML6075 sensor\n* 1x Housing IP65 171 x 121 x 55 mm\n* 1x Cable Gland PG7\n* 2x Cable Gland PG11\n* 7x Standoff/Spacer 20 mm\n* Aquarium hose\n* ...\n\n## Schematic\n\n\u003cimg src=\"img/schematic.png\"\u003e\n\n### TP4056 modification\n\nThe charging LED lights up as soon as the solarpannel supplies some current. However, this will cause the LED to discharge the battery when there is little sunshine.\n\nTo prevent this, I have soldered out the charging LED.\n\n\u003cimg src=\"img/TP4056_board_led.jpg\"\u003e\n\n### Solar panel\n\nThe simple solar panels with plastic covers do not withstand UV radiation and wether conditions very well outdoors and the performance decreases drastically.\n\n\u003cimg src=\"img/solar_panel_bad.jpg\"\u003e\n\nTherefore, I now use a slightly better one with a glass cover.\n\n\u003cimg src=\"img/solar_panel.jpg\"\u003e\n\n### RFM95 Breadboard\n\nI have use the [iBrick / RFM95LORA Breadboard](https://github.com/iBrick/RFM95LORA_Breadboard) to make the RFM95 module breadboard/hole matrix board friendly. You can direct download the [Gerberfile](https://github.com/iBrick/RFM95LORA_Breadboard/blob/master/RFM95Breadboard.rar) from the Git repro.\n\n\u003cimg src=\"img/rfm95_breadboard.jpg\"\u003e\n\n## Power consumption\n\n| Mode | Power consumption |\n| ---- | ----------------- |\n| SDS011 measurement (30 sec) | 175 mA |\n| LoRa activity | 7 mA |\n| DeepSleep | 52 uA |\n\n### Battery levels overview (Measuring and data send interval every 5 minutes)\n\nThe data are still from the use with the 2W solar pannel!\n\n#### No charge current  \n\n\u003cimg src=\"img/power_no_solar.jpg\"\u003e\n\n`1` = Disconnect solar pannel, `2` = Last data packet sent\n\n#### Normal operation\n\n\u003cimg src=\"img/power_operation.jpg\"\u003e\n\n`1` = First data packet sent after after approx. 6 houre of charge, `2` = Rainy days\n\n## TTN payload decoder\n\n```javascript\nfunction decodeUplink(input) {\n  var decoded = {};\n  \n  decoded.vcc = (input.bytes[0] + 200)/100;\n\n  if(input.bytes[1] != 255 || input.bytes[2] != 255)\n  {\n    decoded.pm25 = ((input.bytes[1] \u003c\u003c (8*1) | input.bytes[2] \u003c\u003c (8*0)) / 10);\n  }\n\n  if(input.bytes[3] != 255 || input.bytes[4] != 255)\n  {\n    decoded.pm10 = ((input.bytes[3] \u003c\u003c (8*1) | input.bytes[4] \u003c\u003c (8*0)) / 10);\n  }\n  \n  if(input.bytes[5] != 255 || input.bytes[6] != 255)\n  {\n    decoded.temperature = ((input.bytes[5]\u003c\u003c24\u003e\u003e16 | input.bytes[6]) / 10);\n  }\n  \n  if(input.bytes[7] != 255)\n  {\n    decoded.humidity = input.bytes[7];\n    decoded.humidity \u0026= ~(1 \u003c\u003c 7);\n    if(input.bytes[7] \u003e\u003e 7 == 1) { decoded.humidity +=0.5 }\n  }\n  \n  pressure = (input.bytes[8] \u003c\u003c (8*0) | input.bytes[9] \u003c\u003c (8*1) | input.bytes[10]  \u003c\u003c (8*2)) / 100;\n  if(pressure \u003e= 300 \u0026\u0026 pressure \u003c= 1100) { decoded.pressure = pressure }\n\n  if(input.bytes[11] != 255) decoded.uvi = input.bytes[11] / 10;\n\n  if(input.bytes[14] != 255)\n  {\n    decoded.lux = (input.bytes[12] \u003c\u003c (8*0) | input.bytes[13] \u003c\u003c (8*1) | input.bytes[14]  \u003c\u003c (8*2)) / 100;\n  }\n  \n  return {\n    data: decoded,\n    warnings: [],\n    errors: []\n  };\n}\n```\n\n## 3D Printing\n\n### PCB and SDS011 mounting\n\nThe STL and Fusion 360 Archive files are included in the 3D folder\n\n\u003cimg src=\"img/sensor_mounting.jpg\"\u003e\n\u003cimg src=\"img/sensor_mounting_case.jpg\"\u003e\n\n### Stevenson Screen\n\nFor the Stevenson Screen, I have used a modle from [Thingiverse](https://www.thingiverse.com/thing:3044446/files)\n\n## Pictures\n\nGrafana Dashboard for the visualization of the measured values.\n\n\u003cimg src=\"img/dashboard.jpg\"\u003e\n\nThe whole mounted outside on the windowsill.\n\n\u003cimg src=\"img/dust_sensor_outdoor.jpg\"\u003e\n\n\n## Links\n\n* [Thingiverse Stevenson Screen](https://www.thingiverse.com/thing:3044446/files)\n* [iBrick / RFM95LORA Breadboard](https://github.com/iBrick/RFM95LORA_Breadboard)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackgruber%2Fesp32_ttn_environmental_sensor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackgruber%2Fesp32_ttn_environmental_sensor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackgruber%2Fesp32_ttn_environmental_sensor/lists"}