Posts

Microbit ADC Logger

Image
Introduction This is a simple data logger that reads and logs the voltage on the microbit pins P0 , P1 and P2 every hour. It stores the reading as a text string together with the date and time of each reading. The date/time is kept by a DS3231 Real Time Clock (RTC) board. The readings can be uploaded to a device using the microbit’s USB. An example reading: #count = 3 17/06/2022 11:00,3.28,0,0 17/06/2022 12:00,3.28,0,0 17/06/2022 13:00,3.28,0,0 To allow the measured voltages to be greater than the nominal supply microbit voltage (3.3V) two external resistors are used to divide the measured voltage so that the pin voltage V(Pn) does not exceed 3.3V. The scaling in the code assumes external resistors of 270 kΩ from input to Pn and 330 kΩ from Pn to ground. So full scale is 6.0V . Other ratios require code change. The ADC voltage reference is the microbit “3V” supply (nominally 3.3V), so if the supply drops below this then the ADC readings will be wrong. It is possible to change the...

Microbit radio weather station

Image
I've built a couple of microbit weather stations in the past; the last one used Bluetooth to upload readings to a laptop for further processing. This one is aimed at younger students and uses the microbit's built in radio , which is a bit easier to code. The sender microbit records weather readings every hour or so (your choice). To upload the readings, to make a daily chart or graph perhaps, we use a second receiver microbit to fetch the readings. They can then be sent via USB, or some other means, to a laptop or phone. So the sender can be untouched and in a fairly inaccessible place (depending on the radio range, of course). Powering the sender I didn't want to use non-rechargeable cells, so I tried a power bank . This is a high-capacity rechargeable battery which is normally used to supply energy to a phone. It has some clever circuitry which, among other things, disconnects the battery from its load when the load current has dropped. Power bank But - this particula...

Microbit power bank

Image
Powering microbits outdoors isn't easy: dry cells have quite a low capacity. Typically a microbit battery of 2 AAA cells can provide around 500 mAh, which might power a weather station for a couple of days. Another solution is a power bank. These are rechargeable batteries that are aimed at the mobile phone market - to keep your phone battery topped up.  They are charged from a mains charger  via a USB input port, and deliver 5V from a second port. The one I'm using is an Apachie 5200 mAh , which is available for around £8. It's the size of a typical phone. Power banks are intended to give your phone 's battery a boost - not to power some electronics which need a continuous supply! So they come with a means of testing if the load has been disconnected; the power bank can then switch off its internal circuits to reduce power wastage. This power bank does that by switching off for a short time (about 500 ms), every 5 seconds or so. That will cause the microbit supply to c...

Rain gauge 2

Image
 Rain gauge 2 Update : I've added a chart showing an actual day's recording. A while ago I made a rain gauge based on measuring the resistance of rainwater.  This is an improved version: it should be more accurate because it measures the weight of the water collected in a tank over a given time. The weight can be converted to the depth of rain falling in a given period by simple arithmetic. The diagram below shows the scheme - rain enters the tank which is weighed periodically. When the tank is "nearly" full it is emptied, and the scales are reset. The overall arrangement Lengthy experiments with an electrically operated water valve were not successful! But a submersible pump does work quite well; provided the water tank side wall is quite low we can keep the settling time short. We are using an electronically controlled  pump . So no manual intervention is needed, and we should be able to have an unattended rain gauge! Ideally the process of emptying the tank shou...

Microbit weather station

Image
 Microbit V1 weather station Update: Feb 2021: I've published the microbit V2 version using Bluetooth (BLE) Update 7th Jan 2021 : I've found an error in my DS3231 extension, so now it is feasible to use the microbit's Bluetooth (BLE) - which means the second microbit won't be necessary. And I fixed my Google Apps Script code for the chart! This project lets you make regular hourly readings of weather measurements, store them, and upload them to a phone or computer. The date and time of each reading are also recorded. You can use the readings to plot a chart, for example, to show how the weather changed over time. Here's a set of readings over 24 hours: These are the measurements I am using for this project: Barometric air pressure Temperature Humidity You can add more "instruments" - for example, I plan to add a home-made rain gauge, as described in this blog. The weather station can be self-contained, powered from a couple of batteries perhaps. You can...

Using weather forecast data

Image
 Using weather forecast data Compare your readings with a forecast Having built a microbit-based weather station , I was keen to see how its readings compared with forecasts (in my case I used Met Office data). I quickly got bored with downloading the forecast manually, so here's a way of doing it with a Google spreadsheet and some GAS (Google Apps Script - which is really JavaScript plus some handy libraries). Here are some example charts: Accessing Met Office forecasts The first thing is to get yourself access to the Met Office forecasts, at Met Office DataPoint . Here you can register and get your own API Key - a kind of password that will be used in the URL you use to fetch the forecast data. Google Apps Script Now you can create your spreadsheet and script. If this is new to you, try this article . I'll describe my own script below. The entire code is written as one function: getTH(). It starts like this:

Microbit (V2) weather station

Image
  Microbit weather station mk2 This project builds on my experience ( here ) with a microbit. This version uses Bluetooth Low Energy (BLE) to upload readings to a device, such as a phone - this is a much more convenient upload method than USB. I have also had reliability problems with the DHT11 temperature and humidity sensor. It seems this isn't uncommon! So I am using the BME280 device to measure all 3 parameters: air pressure, temperature and humidity. This device has rather good accuracy: ±1.25℃ (temperature), ±3% (humidity), and ± 1 mbar (pressure). ❗At the moment the MakeCode extension for the BME280 only returns integers for the readings. The author is planning to update it so please check back here for blog updates! The weather station lets you make regular hourly readings of weather measurements, store them together with the date and time, and upload them to a device. You can use the readings to plot a chart, for example, to show how the weather changed over time. Here...