Approved content

The content below is provided by a partner.

hardwario/pxt-microbit-hardwario 1.0.1 GitHub

HARDWARIO - micro:bit Integration

Travis Release License

Twitter

This documet describes the concept of the micro:bit integration into the HARDWARIO IoT Kit (further referred to just as “IoT Kit”). The IoT Kit offers a huge variety of pluggable modules that can be easily used not for educational purposes, but also for industrial applications and have been battle-tested in a number of pilot projects.

Examples

If you want to see how to begin with the micro:bit Module and HARDWARIO TOWER - Industrial IoT Kit, please visit the documentation where you can get a DETAILED TUTORIAL

Simple Thermostat

Code example for making a simple Thermostat with micro:bit showing an icon on LED matrix and HARDWARIO modules measuring the temperature and providing a Relay impulse.

Requirements

let temperature_threshold = 0
input.onButtonPressed(Button.A, function () {
    temperature_threshold += 1
})
input.onButtonPressed(Button.B, function () {
    temperature_threshold += -1
})
basic.forever(function () {
    if (hardwario.temperature() < temperature_threshold) {
        hardwario.setPowerModuleRelay(RelayState.On)
        basic.showIcon(IconNames.Yes)
    }
    if (hardwario.temperature() > temperature_threshold + 2) {
        hardwario.setPowerModuleRelay(RelayState.Off)
        basic.showIcon(IconNames.No)
    }
    basic.pause(2000)
})

Intruder Alarm

With this example you will be able to place your alarm inside your drawer to guard all your stuff

Requirements

hardwario.onMovement(function () {
    basic.showIcon(IconNames.Angry)
    for (let index = 0; index < 4; index++) {
        music.playMelody("C - C - C - C - ", 150)
    }
})
hardwario.motionDetectorTask(
)

Reference

co2

Starts periodic measurement on HARDWARIO CO2 Module and returns the value of CO2 in the air. The first initialization takes around 1 minute then it measures every 3 seconds by default, you can change the time with the special block.

hardwario.co2()

illuminance

Starts periodic measurement on HARDWARIO Lux Meter Tag and returns the value of light intensity in the lux. It updates the value every 3 seconds by default, you can change the time with the special block.

hardwario.illuminance()

temperature

Starts periodic measurement on HARDWARIO Temperature Tag and returns the value of temperature in Celsius. It updates the value every 3 seconds by default, you can change the time with the special block.

hardwario.temperature()

voc

Starts periodic measurement on HARDWARIO VOC Tag and returns the value of voc(volatile organic compound) in tvoc. It updates the value every 3 seconds by default, you can change the time with the special block.

hardwario.voc()

We also have a Low Power version so if you have this Tag you have to use this code:

hardwario.vocLP()

humidity

Starts periodic measurement on HARDWARIO Humidity Tag and returns the percentage of humidity in the air. It updates the value every 3 seconds by default, you can change the time with the special block.

hardwario.humidity()

altitude

Starts periodic measurement on HARDWARIO Barometer Tag and returns the meters above sea level. It updates the value every 3 seconds by default, you can change the time with the special block.

hardwario.altitude()

change measurement delay

Change the measurement delay on selected sena.s. on all of them to selected value in ms. There can be some delays between the measurements if you use multiple sensors but it will be mostly precise.

hardwario.measurementDelay(MeasurementDelays.Light, 3000)

pressure

Starts periodic measurement on HARDWARIO Barometer Tag and returns the atmospheric pressure in Pascal. It updates the value every 3 seconds by default, you can change the time with the special block.

hardwario.pressure()

battery

Starts periodic measurement on HARDWARIO Battery Module or HARDWARIO Mini Battery Module and returns Voltage on all the cells in Volts. It updates the value every 3 seconds by default, you can change the time with the special block.

hardwario.batteryVoltage(BatteryModuleType.Mini)

infragrid

Starts measurement on HARDWARIO Infragrid Module and ploting it onto the Micro:bit LED display.

hardwario.infragrid()

configure PIR module # hardwario-motionDetectorTask

This block starts motion detection on the HARDWARIO PIR Module, you can also set some advanced configuration by pressing the plus on the block if you want to.

hardwario.motionDetectorTask()

on movement # hardwario-onMovement

You can put more blocks into this one and it will fire every time the movement is detected on the PIR Module. YOU HAVE TO RUN A CONFIGURE PIR MODULE BLOCK FOR THIS ONE TO WORK!

hardwario.onMovement(function () {
    serial.writeLine("Movement detected")
})

relay

Set the state of Bi-stable relay on HARDWARIO Relay Module to selected state(On/Off).

hardwario.setRelay(RelayState.On)

System Concept

The IoT Kit uses Core Module as its main control element. It has its own MCU and radio to exchange data with a wireless gateway. Contrary to that, the micro:bit could replace its role and IoT Kit would represent an accessory extension to the micro:bit mainboard.

Mechanical Concept

A nice feature of the micro:bit board is the LED matrix and the fact it has 2 push buttons. Hereby the module should be visible - basically, stay on the top of the other components in the ecosystem.

Therefore we should create the micro:bit adapter that will sit above the HARDWARIO IoT Kit assembly. Such composition will be bold and attractive for the micro:bit enthusiasts.







Signal Mapping

Obviously, the signal mapping will not cover 100% of the IoT Kit use-cases. The following suggestion focuses on the most prominent scenarios.

Domain micro:bit IoT Kit Header
Power GND
+3v3
GND
VDD
I2C P20
P19
SDA0
SCL0
SPI P16
P13/SCK
P15/MOSI
P14/MISO
P15/CS
P14/SCLK
P13/MOSI
P12/MISO
Battery measurement P0
P1
P0/A0
P1/A1
PIR Module P8
P2
P8
P9

Module Compatibility

The following IoT Kit modules will be compatible with the Microbit Module:

// Items with “#” are in developement

Only large 3D-printed enclosures can be used for the micro:bit integration. The whole collection with the slot for the micro:bit connector from the top side can be prepared effortlessly.

First Steps

The Microbit Module will be designed first. Based on the sample, HARDWARIO will fine-tune the 3D-printed enclosures.

On the firmware side, the initial integration will be done for the CO2 Module, Humidity Tag, Barometer Tag, Lux Meter Tag, and LCD Module. On this kit, the basics of the air quality monitoring can be explained with the possibility to alert excessive values on the micro:bit LED matrix.


Made with ❤  by HARDWARIO a.s. in the heart of Europe.

makeCodeRender(“{{ site.makecode.home_url }}”, “{{ site.github.owner_name }}/{{ site.github.repository_name }}”);

microbit-hardwario=github:hardwario/pxt-microbit-hardwario#v1.0.1