Tuesday, 29 June 2021

Microbit and Environment Measurement - Using Python

In two recent posts, Makecode was used with the Enviro:bit from Pimoroni to try out a few ideas (https://robotsandphysicalcomputing.blogspot.com/2021/06/pimoroni-envirobit.html and  https://robotsandphysicalcomputing.blogspot.com/2021/06/pimoroni-envirobit-light-and-led.html ). In this post Pyton using the Mu editor was used to try out the Enviro:bit.




As in the makeCode version, Pimoroni has provided both a python library (via Github) but also within the Readme.md useful installation instructions. There is at the time of writing a possible typo; to get the BME280 sensor (temperature, pressure, humidity sensor) to work; you need to add parenthesis in the line bme = bme280.bme280()

After that, it works fine and includes potential altitude measurement which I don't think is in the Makecode version (though I could be wrong); I need to play with it a bit more.

To experiment the code below was used test reading temperature (in Centigrade), humidity (%), and altitude (feet). In the examples, currently provided with the library, I couldn't find a BME280 example but it was fairly easy to adapt the examples included to get something going.

import microbit
import bme280

bme = bme280.bme280()

while True:

    reading = bme.temperature()
    microbit.display.scroll("temp: ")
    microbit.display.scroll(str(reading))
    microbit.sleep(3000)
    reading = bme.humidity()
    microbit.display.scroll("humidity: ")
    microbit.display.scroll(str(reading))
    microbit.sleep(3000)
    reading = bme.altitude()
    microbit.display.scroll("Alt: ")
    microbit.display.scroll(str(reading))
    microbit.sleep(3000)


It is a cool and fun device to play with, though I not sure the precision of the readings shown on the microbit LEDs is really necessary :-) 
 

 



All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Monday, 28 June 2021

Pimoroni Envirobit - Light and LED

In a previous post, the Envirobit ( https://shop.pimoroni.com/products/enviro-bit )  for the Microbit was played with getting temperature, humidity and pressure  (https://robotsandphysicalcomputing.blogspot.com/2021/06/pimoroni-envirobit.html). 

In this short post a quick experiment using the sound and light sensor, to turn LEDs on the board to turn off and on beyond on light level. The code is set up when a clap happens nearby, light level is used to 'decide' whether the LEDs are turned on or off, below a threshols the LEDs go on above it the LEDs are turned off,

Makeecode 


Using Makecode makes this relatively easy to implement and fun.








All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Monday, 21 June 2021

Pimoroni Enviro:bit -

Finally got to play with something that has been my list of things to play with, the Pimoroni Enviro:bit Weather Kit https://learn.pimoroni.com/tutorial/tanya/building-the-enviro-bit-kit (see below)- a nice kit based around Pimoroni's enviro:bit device which uses microbit and adds a number of sensors including temperature, pressure and humidity; as well as a microphone.


Programming is via MakeCode; extensions can be added using the Extension option and searching for envirobit.




Getting sensor information:
So a quick experiment to work through the temperature, pressure and humidity sensors, a brief bit of code to do this is shown below:


Responding to sound
The microbit used with the kit was a V1, so this device added a microphone to the systems (V2 already has the microphone built-in). In the code below the microbit to react to a clapping sound.

To develop further.

There is still various things to try out the like the light sensors. As well as the expert blocks - what their functions are. 

Fun and easy to play with.



Code available:




All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Saturday, 12 June 2021

4tronix Eggbit - cute and wearable - hug avoider

/


The ever-brilliant 4tronix have produced Eggbit https://shop.4tronix.co.uk/collections/microbit-accessories/products/eggbit; a cute, wearable device, with ultrasonic sensors, buttons and LEDs for the microbit - I couldn't resist.

Programming is through Makecode and an extension is available, to download and install. To use the extension, at the time of writing this, go through the add extension option and use the search box to add it  from https://github.com/4tronix/EggBit



So what to do with it? Inspired by social distancing  (or not being a 'hugger')  created it so that when people get too close the RGB LEDs go out - simple but fun. The distance is set at 20cm for testing. The code is shown below.




It was fun to do and perhaps swapping the settings around so the lights come on when people at too close might be more fun or using sound. This is a lovely device to play with and the look encourages play - just look how cute it is! The price is reasonable and the look means it has the potential to encourage a wide range of people to experiment with it.





All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Remote Data Logging with V1 Microbit

In an earlier post  https://robotsandphysicalcomputing.blogspot.com/2024/08/microbit-v1-datalogging.html  a single microbit was used to log ...