Thursday, 22 August 2024

Microbit V1 datalogging

Often we need applications that allow collection of data over time, for example temperature or light levels through the day. Allowing us potentially analyse the data for trends. The microbit is a fantastic tool, with some of these sensors already in place (e.g. light and temperature) or can be added to with extra sensors from add-on boards (such as Kitronik Air Quality and Environmental Board for micro:bit https://shop.pimoroni.com/products/kitronik-air-quality-and-environmental-board-for-micro-bit?variant=39475687227475 )

 

Datalogging with a V2 microbit is relatively easy all the details are available here: https://microbit.org/get-started/user-guide/data-logging/ to get started.

 

But what about the older V1 can it do it?

 

The answer is yes but it is a little more work and is generally a little more limited but still very worth while. In this post we are going to look at doing this.

 

In Figure 1 starting the process off in MakeCode (https://makecode.microbit.org/#editor) is shown below. Basic mechanism every 1sec

  • -            The light level is write from the microbit to the computer (via the USB) a value at a time – serially
  • -            Same thing will be done for temperature

That is it to start with.

Figure 1

Figure 2 shows where various elements are in menu. To get the Serial ones you will need to open up the Advanced menu and then Serial menu options (see figure 3)

Figure 2

 

Figure 3


Figure 4


Once everything is set up,  under the similar microbit (Figure 4) you will see another button “Show data Simulator” We can play with the microbit simulator to simulate light and temperature levels; click on new data simulation button and graphs starts rolling across the screen – drag the temperature and light levels on the microbit simulator and you see the graphs change – it is logging the simulate data – it works!

Now for the fun bit.

Click on Download we need to pair the computer and microbit. Figures 5 to 8 show the steps.

Figure 5


Figure 6


Figure 7


Figure 8





We can now take values from the real device. A new button should have appeared along with the “Show data Simulator” button; “Show data Device” Click on this button and instead of simulated data we get data from the  microbit (see figure 9)

Figure 9

 

So in figure 9, the top graph is light level the bottom is temperature taken from the room. Play with covering the sensor the LED grid and light levels change.

 

Collecting data is great, but we are taking it one step further logging the data over time and then sharing it To do this click on the blue download button above the graphs to save the logged data as a CSV file. Once it is in CSV format it is yours to play with in other tools such as spreadsheets.

 

 

Activity

-            how can this be more meaningful?

-            How do we do this with so a microbit can see data – some more remote monitoring (see https://microbit.org/projects/make-it-code-it/makecode-wireless-data-logger/ )

-            How could you do this in Python





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

No comments:

Post a Comment

Who wants to produce AI produced cartoon strips

Question: How easy is it produce a comic/cartoon using genetative AI? Let's start with  using ChatGPT4o to produce cartoons. The idea wa...