{"id":21228851,"url":"https://github.com/anras5/greenico","last_synced_at":"2026-05-16T23:16:41.895Z","repository":{"id":155441773,"uuid":"600737740","full_name":"anras5/Greenico","owner":"anras5","description":"Weather station with Raspberry Pi Pico","archived":false,"fork":false,"pushed_at":"2023-02-12T13:36:45.000Z","size":148,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T17:49:58.423Z","etag":null,"topics":["iot","micropython","rest","rpi-pico-w"],"latest_commit_sha":null,"homepage":"","language":"Python","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/anras5.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":"2023-02-12T13:00:04.000Z","updated_at":"2024-06-19T19:34:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"7e672596-3db0-4231-9e74-45580d99de71","html_url":"https://github.com/anras5/Greenico","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/anras5%2FGreenico","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anras5%2FGreenico/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anras5%2FGreenico/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anras5%2FGreenico/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anras5","download_url":"https://codeload.github.com/anras5/Greenico/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243672380,"owners_count":20328762,"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":["iot","micropython","rest","rpi-pico-w"],"created_at":"2024-11-20T23:22:32.147Z","updated_at":"2026-05-16T23:16:36.873Z","avatar_url":"https://github.com/anras5.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Greenico on Raspberry Pi Pico\n\nWeather station with Raspberry Pi Pico - \"Greenico\"\n\n[Greenico on Raspberry Pi Pico](https://github.com/anras5/Greenico) is only a part of `Greenico` project.\n\nThe second part is [GreenicoAPI](https://github.com/anras5/GreenicoAPI). Be sure to check it out also.\n\n## Table of contents\n\n1. [The purpose of the project](#Purpose)\n2. [Schema](#Schema)\n3. [Description](#Description)\n4. [Technical information](#Technical)\n5. [Contact](#Contact)\n\n## Purpose\n\nThe aim of the project is to allow the user to view the current state of the weather by designing and building a weather\nstation. The preview will be possible through a browser, i.e. a web application in the form of clear graphs and on the\ndisplay attached to the weather station.\n\n## Schema\n\n![img.png](images/schema.png)\n\nSchema is in polish\n\n## Description\n\nThe purpose of the project was to build a platform that allows the user to observe the current conditions of weather.\nFor this purpose, it was decided to use the Raspberry Pi Pico W microcontroller with the kit of environmental sensors\nand an OLED display. In addition, to make it easier to view the results, they were supposed to be sent over the network\nto a server where the results would be stored in a database and displayed in an accessible way in the form of graphs. As\npart of the project, it was possible to build and program a weather station that performs measurements with appropriate\nsensors. These are measurements of air pollution, temperature, humidity, illuminance, atmospheric pressure and UV.\nCurrent measurements are displayed on the OLED display attached to the weather station and sent over the network to the\nserver via the HTTP protocol (REST).\n\n## Technical\n\n### Technologies used\n\n**Hardware platform used** \\\nRaspberry Pi Pico W programmed in [MicroPython](https://micropython.org/)\n\n**Sensors** \\\nTSL25911FN, BME280, LTR390-UV-1, SGP40\n\n**Display** \\\n2.23inch OLED Display Module for Raspberry Pi Pico\n\n### The most important code snippets with comments\n\n```python\nimport network\nimport urequests\nimport ujson\nimport utime\nfrom machine import I2C, Pin\nimport config\nfrom oled_display.oled_spi import OLED_2inch23\nfrom environmentSensor.BME280 import BME280  # pressure, temp, hum\nfrom environmentSensor.LTR390 import LTR390  # UV\nfrom environmentSensor.SGP40 import SGP40\nfrom environmentSensor.TSL2591 import TSL2591\nfrom environmentSensor.voc_algorithm import VOCAlgorithm\n```\n\nAt the beginning of the program, the appropriate libraries should be imported - first available directly in MicroPython\nand then files from the project:\n\n- config, which contains the SSID and password for the wifi network, as well as the server address\n- oled_spi from the oled_display directory, where there is a class that facilitates work with the OLED display\n- classes from the environmentSensor directory that facilitate working with sensors\n- voc_algorithm from the environmentSensor directory where the responsible class is located converting readings from\n  SGP40 sensor to VOC index\n\n```python\nbme280 = BME280()\nbme280.get_calib_param()\nlight = TSL2591()\nsgp = SGP40()\nuv = LTR390()\nvoc = VOCAlgorithm()\nvoc.vocalgorithm_init()\n```\n\nCreate appropriate objects for sensors and initialize them if necessary\n\n```python\nscreen = OLED_2inch23()\nscreen.fill(screen.black)\nscreen.text(f'Conn to wifi...', 1, 12, screen.white)\nscreen.show()\n```\n\nCreating an object for the OLED display and displaying the inscription about connecting to the network wireless.\n\n```python\nlan = network.WLAN(network.STA_IF)\nwlan.active(True)\nwlan.connect(config.ssid, config.password)\n```\n\nConnecting to the wireless network (later in the program, the correctness of the connection is checked)\n\n**Main loop:**\n\n```python\nfor i in range(20):\n    bme = bme280.readData()\n    pressure.append(round(bme[0], 2))\n    temp.append(round(bme[1], 2))\n    hum.append(round(bme[2], 2))\n    lux.append(round(light.Lux(), 2))\n    uvs.append(round(uv.UVS(), 2))\n    gas_raw.append(round(sgp.raw(), 2))\n    screen.fill(screen.black)\n    screen.text(f'Data gathering' + '.' * (i % 3), 1, 12, screen.white)\n    screen.show()\n    utime.sleep(4)\n```\n\nGetting the readings from the sensors (then the program rejects the values of the largest and the smallest and averaging\nof the readings taken) and displaying information about data collection on display.\n\n```python\npost_data = ujson.dumps({\n    \"id\": 1,\n    \"temperature\": temp,\n    \"humidity\": hum,\n    \"pressure\": pressure,\n    \"voc\": gas,\n    \"uv\": uvs,\n    \"light\": lux\n})\nr = urequests.post(f\"{config.URL_API}/api/reading\", headers={'content-type':\n                                                                 'application/json'}, data=post_data)\nr.close()\n```\n\nPreparing data to be sent to the server using the `ujson` library and sending them using\n`urequests` library. Closing the variable storing data obtained in response from the server.\n\n```python\nfor i in range(48):\n    if i % 2:\n        screen.fill(screen.black)\n        screen.text(f'Temp: {temp}', 1, 2, screen.white)\n        screen.text(f'Hum: {hum}', 1, 12, screen.white)\n        screen.text(f'Pres: {pressure}', 1, 22, screen.white)\n        screen.show()\n    else:\n        screen.fill(screen.black)\n        screen.text(f'VOC: {gas}', 1, 2, screen.white)\n        screen.text(f'UV: {uvs}', 1, 12, screen.white)\n        screen.text(f'Light: {lux}', 1, 22, screen.white)\n        screen.show()\n    utime.sleep(5)\n```\n\nDisplaying of retrieved values on the display.\n\n**End of main loop**\n\n### How to run the app\n\n1. Download `.uf2` file with *MicroPython* for *Raspberry Pi Pico W* binary on your computer\n   from [Micropython with urequests and upip](https://micropython.org/download/rp2-pico-w/rp2-pico-w-latest.uf2)\n2. Follow steps from [documentation](https://www.raspberrypi.com/documentation/microcontrollers/micropython.html#:~:text=and%20upip%20preinstalled)-,Then%20go%20ahead%20and%3A,-Push%20and%20hold)\n3. Upload `environmentSensor` and `oled_display` folders to your *Pico*.\n4. Create `config.py` file which should look like this:\n```python\nssid = \"YOUR_SSID\"\npassword = \"YOUR_PASSWORD\"\nURL_API = \"URL_OF_SERVER\"\n```\n5. Flash `main.py` file to your *Pico*.\n6. Done!\n\n# Contact\n\nContact me at: \\\nanras1filip@gmail.com","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanras5%2Fgreenico","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanras5%2Fgreenico","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanras5%2Fgreenico/lists"}