{"id":14437147,"url":"https://github.com/sparkfun/pxt-weather-bit","last_synced_at":"2025-04-14T21:42:29.152Z","repository":{"id":21689103,"uuid":"87213052","full_name":"sparkfun/pxt-weather-bit","owner":"sparkfun","description":"MakeCode package for the SparkFun weather:bit board  - beta","archived":false,"fork":false,"pushed_at":"2022-05-26T17:11:31.000Z","size":5468,"stargazers_count":11,"open_issues_count":6,"forks_count":22,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-04-15T00:11:18.262Z","etag":null,"topics":["makecode","microbit","soil-moisture","soil-moisture-sensor","weather","wind-speed"],"latest_commit_sha":null,"homepage":"https://makecode.microbit.org/pkg/sparkfun/pxt-weather-bit","language":"TypeScript","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/sparkfun.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}},"created_at":"2017-04-04T16:57:30.000Z","updated_at":"2023-12-28T21:24:24.000Z","dependencies_parsed_at":"2022-09-08T15:20:56.155Z","dependency_job_id":null,"html_url":"https://github.com/sparkfun/pxt-weather-bit","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparkfun%2Fpxt-weather-bit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparkfun%2Fpxt-weather-bit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparkfun%2Fpxt-weather-bit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparkfun%2Fpxt-weather-bit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sparkfun","download_url":"https://codeload.github.com/sparkfun/pxt-weather-bit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224886719,"owners_count":17386422,"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":["makecode","microbit","soil-moisture","soil-moisture-sensor","weather","wind-speed"],"created_at":"2024-08-31T08:00:24.280Z","updated_at":"2024-11-16T07:19:50.340Z","avatar_url":"https://github.com/sparkfun.png","language":"TypeScript","funding_links":[],"categories":["编程"],"sub_categories":["JavaScript 和 MakeCode"],"readme":"# weatherbit [![Build Status](https://travis-ci.org/sparkfun/pxt-weather-bit.svg?branch=master)](https://travis-ci.org/sparkfun/pxt-weather-bit)\n\nTo use this package, go to https://makecode.microbit.org, click ``Add package`` and search for **weatherbit**.\n\n## Usage\n\nThe package adds support for the **weather:bit** add-on board from SparkFun.\n\n* [Weather Meters](https://www.sparkfun.com/products/8942)\n* [Soil Moisture Sensor](https://www.sparkfun.com/products/13322) (Analog Read) \u0026 [DS18B20 Soil Temperature Sensor](https://www.sparkfun.com/products/11050) (1-wire Digital Read)\n* Atmospheric Monitoring with the onboard [BME280](https://cdn.sparkfun.com/assets/learn_tutorials/4/1/9/BST-BME280_DS001-10.pdf) sensor (I2C)\n\t* Temperature\n\t* Humidity\n\t* Pressure\n\t* Altitude\t\n\n### Micro:bit Pins Used \n\nThe following micro:bit pins are used for weather, atmospheric and aquaponics monitoring:  \n\n* ``P0`` -- Soil Mositure Data \n* ``P1`` -- Wind Direction \n* ``P2`` -- Rain Data (in inches)\n* ``P8`` -- Wind Speed Data \n* ``P12`` -- Temperature Data \n* ``P14`` -- RXI (UART)\n* ``P15`` -- TXO (UART)\n* ``P16`` -- Soil Moisture Power \n* ``P19`` -- BME280 I2C - SCL\n* ``P20`` -- BME280 I2C - SDA \n\n### Set Up Function\nAt the start of any program which will use the BME280 Sensor data (Pressure, Humidity, Altitude, Temperature) place the \"Set up Weather Monitoring\" in a \"Forever\" block. \nIt is unknown at this time why this block will not work in the \"On Start\" block. \n\n### Start Monitoring Functions \n\nAt the start of any program which will use the \nweather meter data (Wind Speed, Wind Direction, Rain) \nplace the ``|start wind monitoring|`` and ``|start rain monitoring|`` \nin a ``|on start|`` block. \n\n```blocks\nweatherbit.startWindMonitoring();\nweatherbit.startRainMonitoring();\nweatherbit.startWeatherMonitoring()\n```\n\n### Atmospheric Data (BME280)\n\nThe BME280 sensor onboard the weather:bit communicates via I2C. The data is returned as a number which can be stored in a variable, shown on the LED matrix, or sent serially to OpenLog. \n* ``|temperature|``block returns a 4 digit number, when divided by 100 will provide the temperature in degree C with two decimals.\n* ``|humidity|`` block returns a 5 digit number, when divided by 1024 will provide the percent Relative Humidity.\n* ``|altitude|`` block returns altitude in meters rounded to the nearest whole number-given P0=1013.25hPa at seal level. (Absolute Altitude)\n* ``|pressure|``block returns an 8 digit number, when divided by 256 will provide the pressure in Pa. Diving again by 100 will provide measurement in hPa.\n\n\n```blocks\nbasic.forever(() =\u003e {\n    weatherbit.startWeatherMonitoring()\n})\nbasic.showNumber(weatherbit.temperature())\nbasic.showNumber(weatherbit.pressure())\nbasic.showNumber(weatherbit.humidity())\nbasic.showNumber(weatherbit.altitude())\n\n```\n\n### Aquaponics Data \n\nThe two central screw terminal blocks on the weather:bit provide space for the Soil Moisture Sensor and the DS18B20 Waterproof Temperature Sensor. Use the logical plug-in blocks to read \nthe soil moisture and temperature of the garden system.\n* ``|soil moisture|`` block returns a value between 0 and 1023. 0 being totally dry and 1023 being as wet as water. \n* ``|soil temperature|`` block a 4 digit number, when divided by 100 provides the temperature in hundreths of a degree centigrade. \n\n```blocks\nbasic.forever(() =\u003e {\n    basic.showNumber(weatherbit.soilTemperature())\n    basic.showNumber(weatherbit.soilMoisture())\n})\n```\n\n### Weather Meter Data\n\nUsing SparkFun's Weather Meters it is possible to obtain wind speed, inches of rain, and wind direction using weather:bit. \n* ``|wind speed|`` returns an integer-the wind speed in mph.\n* ``|wind direction|`` returns a string corresponding to the direction of the wind. (N, S, E, W, NE, NW, SE, SW)\n* ``|rain|`` returns an integer - inches of rain.\n\n```blocks\nbasic.forever(() =\u003e {\n    basic.showNumber(weatherbit.windSpeed())\n    basic.showString(weatherbit.windDirection())\n    basic.pause(300)\n    // serial.writeValue(\"wind direction\",\n    // weatherbit.windDirection())\n    basic.showNumber(weatherbit.rain())\n})\nweatherbit.startRainMonitoring()\n```\n\n### Serial Logging with OpenLog\n\nOpenLog is meant to be mated with the weather:bit with the SD card facing into the board. Make sure the RXI on Openlog connects to TXO on the weather:bit. \nUsing the ``|serial redirect|`` block\nchoose TX as P15 and RX as P14 at a baud rate of 9600. \nThe firmware on OpenLog will do the rest! \nWhen you want to review the data simple open the txt file created by OpenLog to view the data. \n\nExample Project:\nThe following project will read all atmospheric sensor data from the BME280 on button A press, will read all weather meter data on button B press, and aquaponics data on Button A+B press \nwith all values from all sensors logged to OpenLog. \n\n```blocks\ninput.onButtonPressed(Button.AB, () =\u003e {\n    basic.showNumber(weatherbit.soilTemperature())\n    serial.writeValue(\"soil temperature\", weatherbit.soilTemperature())\n    basic.showNumber(weatherbit.soilMoisture())\n    serial.writeValue(\"soil moisture\", weatherbit.soilMoisture())\n})\ninput.onButtonPressed(Button.A, () =\u003e {\n    basic.showNumber(weatherbit.temperature())\n    serial.writeValue(\"temperature\", weatherbit.temperature())\n    basic.showNumber(weatherbit.humidity())\n    serial.writeValue(\"humidity\", weatherbit.humidity())\n    basic.showNumber(weatherbit.pressure())\n    serial.writeValue(\"pressure\", weatherbit.pressure())\n    basic.showNumber(weatherbit.altitude())\n    serial.writeValue(\"altitude\", weatherbit.altitude())\n})\ninput.onButtonPressed(Button.B, () =\u003e {\n    basic.showNumber(weatherbit.windSpeed())\n    serial.writeValue(\"wind speed\", weatherbit.windSpeed())\n    basic.showString(weatherbit.windDirection())\n    basic.pause(300)\n    // serial.writeValue(\"wind direction\",\n    // weatherbit.windDirection())\n    basic.showNumber(weatherbit.rain())\n    serial.writeValue(\"rain\", weatherbit.rain())\n})\nweatherbit.startRainMonitoring()\nweatherbit.startWindMonitoring()\nweatherbit.startWeatherMonitoring()\nserial.redirect(\nSerialPin.P15,\nSerialPin.P14,\nBaudRate.BaudRate9600\n)\n```\n\n## License\n\nMIT\n\n## Supported targets\n\n* for PXT/microbit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparkfun%2Fpxt-weather-bit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsparkfun%2Fpxt-weather-bit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparkfun%2Fpxt-weather-bit/lists"}