{"id":21113666,"url":"https://github.com/masneyb/weather-station","last_synced_at":"2025-08-04T03:36:17.043Z","repository":{"id":122628606,"uuid":"62291261","full_name":"masneyb/weather-station","owner":"masneyb","description":"A lightweight, self contained, solar-powered weather station for the Raspberry Pi.","archived":false,"fork":false,"pushed_at":"2019-03-20T01:37:48.000Z","size":3204,"stargazers_count":171,"open_issues_count":0,"forks_count":13,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-04-04T08:39:38.862Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/masneyb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-06-30T07:52:13.000Z","updated_at":"2024-11-25T07:15:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbb6f2c8-96d9-4d34-b198-8e0492fc8272","html_url":"https://github.com/masneyb/weather-station","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/masneyb/weather-station","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masneyb%2Fweather-station","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masneyb%2Fweather-station/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masneyb%2Fweather-station/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masneyb%2Fweather-station/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masneyb","download_url":"https://codeload.github.com/masneyb/weather-station/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masneyb%2Fweather-station/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264323953,"owners_count":23590773,"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":[],"created_at":"2024-11-20T01:57:55.830Z","updated_at":"2025-07-08T18:31:55.221Z","avatar_url":"https://github.com/masneyb.png","language":"C","funding_links":[],"categories":["domotic"],"sub_categories":["USB GADGET"],"readme":"# Solar Powered Weather Station\n\n![Screenshot](images/weather-station-screenshot-20160827.png?raw=1)\n\n## High level overview\n\n- My [pi-yadl](pi-yadl) project is used to gather and graph the data from the following types\n  of sensors:\n  - [Argent Data Systems Weather Sensor Assembly](https://www.sparkfun.com/products/8942)\n    contains a wind vane, anemometer, and rain gauge. The wind speed average and gusts\n    over the last 2 minute, 10 minute and 60 minute periods are logged. The amount of\n    rain over the last 1 hour, 6 hours, 24 hours, and since midnight are logged.\n  - Supports various types of temperature and humidity sensors: DHT11, DHT22,\n    DS18B20, TMP36 (analog).\n  - Supports the BMP180 pressure, altitude and temperature sensor.\n  - Battery charge level is read via an analog to digital converter (ADC).\n- For the wind vane, wind speed and rain gauge, the pi-yadl program is ran\n  as a daemon in the background so that it can continuously monitor the rain\n  gauge and anemometer via interrupts. The values from these three sensors are\n  written out to a RRD database and JSON file every 30 seconds. The wind speed\n  values are updated internally every second so that it can obtain the correct\n  wind gusts.\n- The other sensors are polled every 5 minutes via a systemd timer and written\n  to various RRD databases and JSON files.\n- The RRD databases are used to show the historical readings and are\n  recreated at the beginning of each hour.\n- The web page uses Javascript and JQuery to download the various JSON files to\n  provide a dashboard showing the current sensor readings. The web page checks\n  for updated JSON files on the server every 10 seconds.\n- The nginx webserver runs on the Pi and only needs to serve out static\n  content. Everything runs on the Pi; no third-party services are required.\n- Optional ability to publish the sensor readings to Weather Underground.\n  You can\n  [view my weather station on Weather Underground](https://www.wunderground.com/personal-weather-station/dashboard?ID=KWVMORGA45).\n\n\n## Hardware Information\n\n![Complete Setup](images/weather-station-complete.jpg?raw=1)\n\n\n### Project Box\n\nI used\n[this project box on Amazon](https://www.amazon.com/uxcell%C2%AE-Waterproof-Connect-Junction-200x120x75mm/dp/B00O9YY1G2).\nI was initially a little concerned about the quality of the seal on the box but\nit has held up so after being outside continuously since June 2016.\n\nAll of the external sensors are terminated with a RJ45 connector to make it easy\nto remove the project box without having to bring the entire weather station\ninside. [RJ45 waterproof cable glands](https://www.adafruit.com/products/827)\nare used on the project box to get the connections inside the box. The wire for\nthe solar panel enters the project box using a\n[PG-9](https://www.adafruit.com/products/761) cable gland.\n\nThe box is mounted to the top of my fence using hose clamps with some rubber\nstops that were purchased at a local hardware store.\n\n\n### Solar and Power Setup\n\nThis weather station runs on a Raspberry Pi Zero running the latest Raspbian\nTesting Lite. All of the hardware is powered by a\n[6600mAH 3.7V lithium ion battery](https://www.adafruit.com/products/353)\nthat is [charged](https://www.adafruit.com/products/390) using a\n[6V 9W solar panel](https://www.adafruit.com/products/2747). The 3.7V is\nconverted to 5V using a [PowerBoost 1000](https://www.adafruit.com/products/2465).\nThe solar panel is attached to the top of the project box using several large\npieces of Velcro. More information about the solar setup can be found on\n[Adafruit's Website](https://learn.adafruit.com/usb-dc-and-solar-lipoly-charger/overview).\nBe sure to connect the PowerBoost 1000 to the battery charge output pins; not to\nthe load terminal. This is because the solar panel can put out 6V however the\nPowerBoost can only accept a maximum input voltage of 5.5V. See\n[this post](https://forums.adafruit.com/viewtopic.php?f=19\u0026t=59523) on the Adafruit\nforums for more details. There should not be anything hooked up to the load\nterminal on the charger. I fried a Pi Zero and a PowerBoost 1000 on a bright,\nsunny afternoon with the PowerBoost hooked up to the load terminal.\n\nTo reduce the power usage of the Raspberry Pi, the LED and display on the Pi was\ndisabled. `powertop --auto-tune` was used to enable other power saving features.\nSee the files\n[systemd/power-savings.service](systemd/power-savings.service) and\n[bin/power-savings](bin/power-savings) for details. The power requirements\ncould be reduced even further by desoldering the various LEDs on the solar\ncharger and PowerBoost 1000.\n\nI used a [USB Charger Doctor](https://www.adafruit.com/products/1852) to roughly\nmeasure the power utilization of the entire weather station at 140 mAH with just\nthe wind / rain collector running in the background and 200 mAH when the main\ncollection processes runs every 5 minutes for just a few seconds. This is with a\nUSB WiFi dongle running the entire time. I would expect to get around 35 hours\nof usage on a fully charged battery without any kind of backup from the solar\npanel. See Power Disclaimer section below for more details.\n\nThe end of the solar panel is terminated with one of\n[these waterproof cables](https://www.adafruit.com/products/744) to make it\neasy to detach the solar panel from the box. This would also make it easy to\nrun an extension cord outside and plug the unit in to charge without removing\nor disassembling the project box if there were several days in a row of very\ncloudy weather.\n\nI mounted this [waterproof on / off switch](https://www.adafruit.com/products/917)\non the project box. Two wires from the switch go to the run pins on the\nPowerBoost 1000. I initially had it connected to the run pins on the Raspberry\nPi Zero but I ran into a situation where the weather station battery got very\nlow and I could not reset the Pi using the power button on the outside, even\nafter the battery was fully charged. Being able to completely power off the Pi\nitself resolved that issue.\n\n\n### Sensors\n\nA [MCP3008 analog to digital converter](https://www.adafruit.com/products/856)\nwas soldered onto a [solderable breadboard](https://www.sparkfun.com/products/12070).\nThe ADC is used for the wind vane and obtaining the voltage levels from the\nbattery and PowerBoost 1000. This ADC communicates with the Raspberry Pi\nusing the SPI bus.\n\nThe wind vane supports reporting 16 different positions by using a series of\nreed switches and different size resistors. The wind vane is connected to the\nADC and the voltage indicates the direction. For example, according to the \n[data sheet](http://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf), 0 degrees (N)\nis 3.84V; 45 degrees (NE) is 2.25V; and 90 degrees (E) is 0.45V. I had an issue\nwith getting accurate readings from the wind vane between 270 and 337.5 degrees\nthat was caused by having the reference ADC voltage in software set to 5V\ninstead of 5.1V when converting the value read from the ADC to millivolts.\nAdding the argument `--adc_millivolts 5100` to the yadl binary fixed the issue.\n\nThe anemometer is hooked up to a GPIO pin on the Pi. According to the\n[data sheet](http://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf), one click\nof the reed switch over a second corresponds to a wind speed of 1.492 mph\n(2.4 km/h). A pull down resistor is used and the switch is debounced in\nsoftware. One complete revolution of the anemometer will cause the pin to go\nhigh twice.\n\nThe rain gauge is very similar to the anemometer. Each click of the switch\nover a second corresponds to 0.011 inches (0.2794 mm) of rain according to\nthe [data sheet](http://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf).\nThis also uses a pull down resistor and the switch is debounced in\nsoftware.\n\nThe Stevenson screen (left side of the above picture) contains the temperature,\nhumidity and barometric pressure sensors. A 3D model of the screen was\ndownloaded from\n[https://www.thingiverse.com/thing:158039](https://www.thingiverse.com/thing:158039),\n3D printed using HIPS plastic and spray painted using flat white paint.\n\nThe temperature and humidity is obtained using a DHT22 sensor. The dew point is\ncalculated using the\n[August-Roche-Magnus approximation](http://andrew.rsmas.miami.edu/bmcnoldy/Humidity.html).\nThe DHT sensor communicates with the Pi over one of the GPIO pins.\n\nA BMP180 sensor is used to obtain the barometric pressure and communicates with\nthe Pi over the i2c bus. The BMP180 driver came from\n[this project](https://github.com/lexruee/bmp180).\n\n![Inside](images/weather-station-inside-box.jpg?raw=1)\n\n![Inside](images/weather-station-breadboard.jpg?raw=1)\n\nThe [PIN_LAYOUTS.md](PIN_LAYOUTS.md) file contains the pin layouts of the cables\nthat leave the box.\n\n![Inside](images/weather-station-outside-rj45-cable-glands.jpg?raw=1)\n\n[![Weather Underground PWS KWVMORGA45](http://banners.wunderground.com/cgi-bin/banner/ban/wxBanner?bannertype=pws250\u0026weatherstationcount=KWVMORGA45)](http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KWVMORGA45)\n\n\n## Power Disclaimer\n\nI have received several emails from people asking about using this setup\nunattended in remote locations. The Pi Zero draws far too much power for the\nsize battery that I used to be used unattended in some far away location. At\nthe time that I wrote this (Nov 2016), Winter is approaching in the Northern\nHemisphere, and the solar panel did not completely charge the battery with the\nshorter days, especially with all of the cloudy days in the area that I live.\nI currently have an extension cord running from my house to the weather\nstation outside. At some point, I'm planning to get a large 12V battery, a\nlarger solar panel, associated charger, and a 12V to 5V buck buck converter\nto power the weather station. The other alternative is to go with some low\npowered microcontroller (such as an Arduino or one of the numerous clones),\nhowever none of the code that I have here will run on that platform.\n\n\n## Installation\n\n- Note: This project iniitally started out using Raspian based on Debian\n  Jessie, but the latest version of Raspbian Testing is required for the\n  newer version of rrdtool that supports the `--left-axis-format` argument.\n- Clone this repository and the [pi-yadl](https://github.com/masneyb/pi-yadl)\n  repository.\n- Follow the installation instructions to compile the pi-yadl project.\n- Update the paths in this repository's [systemd service files](systemd/).\n- Run `bin/create-rrds.sh \u003cpath to web/ directory\u003e` to create the initial\n  empty RRD databases.\n- `sudo make install`\n- `sudo apt-get install jq nginx`\n- `sudo ln -s /path/to/web/directory /var/www/html/weather-station`\n\n\n## Contact\n\nBrian Masney \u003cmasneyb@onstation.org\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasneyb%2Fweather-station","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasneyb%2Fweather-station","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasneyb%2Fweather-station/lists"}