Home

Awesome

weatherbit Build Status

To use this package, go to https://makecode.microbit.org, click Add package and search for weatherbit.

Usage

The package adds support for the weather:bit add-on board from SparkFun.

Micro:bit Pins Used

The following micro:bit pins are used for weather, atmospheric and aquaponics monitoring:

Set Up Function

At 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. It is unknown at this time why this block will not work in the "On Start" block.

Start Monitoring Functions

At the start of any program which will use the weather meter data (Wind Speed, Wind Direction, Rain) place the |start wind monitoring| and |start rain monitoring| in a |on start| block.

weatherbit.startWindMonitoring();
weatherbit.startRainMonitoring();
weatherbit.startWeatherMonitoring()

Atmospheric Data (BME280)

The 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.

basic.forever(() => {
    weatherbit.startWeatherMonitoring()
})
basic.showNumber(weatherbit.temperature())
basic.showNumber(weatherbit.pressure())
basic.showNumber(weatherbit.humidity())
basic.showNumber(weatherbit.altitude())

Aquaponics Data

The 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 the soil moisture and temperature of the garden system.

basic.forever(() => {
    basic.showNumber(weatherbit.soilTemperature())
    basic.showNumber(weatherbit.soilMoisture())
})

Weather Meter Data

Using SparkFun's Weather Meters it is possible to obtain wind speed, inches of rain, and wind direction using weather:bit.

basic.forever(() => {
    basic.showNumber(weatherbit.windSpeed())
    basic.showString(weatherbit.windDirection())
    basic.pause(300)
    // serial.writeValue("wind direction",
    // weatherbit.windDirection())
    basic.showNumber(weatherbit.rain())
})
weatherbit.startRainMonitoring()

Serial Logging with OpenLog

OpenLog 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. Using the |serial redirect| block choose TX as P15 and RX as P14 at a baud rate of 9600. The firmware on OpenLog will do the rest! When you want to review the data simple open the txt file created by OpenLog to view the data.

Example Project: The 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 with all values from all sensors logged to OpenLog.

input.onButtonPressed(Button.AB, () => {
    basic.showNumber(weatherbit.soilTemperature())
    serial.writeValue("soil temperature", weatherbit.soilTemperature())
    basic.showNumber(weatherbit.soilMoisture())
    serial.writeValue("soil moisture", weatherbit.soilMoisture())
})
input.onButtonPressed(Button.A, () => {
    basic.showNumber(weatherbit.temperature())
    serial.writeValue("temperature", weatherbit.temperature())
    basic.showNumber(weatherbit.humidity())
    serial.writeValue("humidity", weatherbit.humidity())
    basic.showNumber(weatherbit.pressure())
    serial.writeValue("pressure", weatherbit.pressure())
    basic.showNumber(weatherbit.altitude())
    serial.writeValue("altitude", weatherbit.altitude())
})
input.onButtonPressed(Button.B, () => {
    basic.showNumber(weatherbit.windSpeed())
    serial.writeValue("wind speed", weatherbit.windSpeed())
    basic.showString(weatherbit.windDirection())
    basic.pause(300)
    // serial.writeValue("wind direction",
    // weatherbit.windDirection())
    basic.showNumber(weatherbit.rain())
    serial.writeValue("rain", weatherbit.rain())
})
weatherbit.startRainMonitoring()
weatherbit.startWindMonitoring()
weatherbit.startWeatherMonitoring()
serial.redirect(
SerialPin.P15,
SerialPin.P14,
BaudRate.BaudRate9600
)

License

MIT

Supported targets