Showing posts with label sensor. Show all posts
Showing posts with label sensor. Show all posts

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

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