Thursday, 12 March 2026

DIY Data Science with microbits

DIY Data Science: A Complete Guide to Data Logging with the Micro:bit V1

Whether you are a STEM teacher looking for a classroom lab solution, a parent seeking a weekend project, or a maker building an environmental monitor, the Micro:bit V1 is a hidden gem for data logging.

While the newer V2 has built-in logging memory, the V1 is incredibly capable when paired with a computer. By using the Serial (USB) Connection and Radio Communication, you can turn these pocket-sized boards into useful sensors.

The Equipment List

To get started, you will need:

  • For Local Logging:

    • 1x Micro:bit V1.

    • 1x Micro-USB cable (high quality, data-capable).

    • A computer with a Chrome-based browser (to use the WebUSB feature in MakeCode).

  • For Remote Logging:

    • 2x Micro:bit V1s.

    • 1x Battery pack (2xAAA) for the "Remote" Micro:bit.

    • 1x Micro-USB cable for the "Receiver" Micro:bit.

  • Optional (For Experiments):

    • A strong magnet (to test the Compass/Magnetometer (see later in this post).

    • A flashlight (to test Light Level).

    • An ice pack or hair dryer (to test the Temperature sensor).



Method 1: The "Direct Link" (Local Logging)

The simplest way to log data is to keep your Micro:bit tethered to your computer. The Micro:bit senses the environment and "talks" back to the computer through the USB cable using Serial Communication.

The Setup:

  1. Code it: In MakeCode, go to Advanced > Serial. Use the serial write value "label" = [sensor] block.

  2. Flash it: Connect your Micro:bit via USB and download the code.

  3. View it: A purple "Show Data Device" button will appear under the simulator. Click it to see a live scrolling graph of your data!

  4. Save it: Use the "Export" button in the top right to download your data as a CSV file, which can be opened in Excel or Google Sheets for analysis.



Method 2: The "Messenger" (Remote Logging)


What if you want to measure something 20 feet away from your laptop? We can use two Micro:bits: a Sender and a Receiver.

1. The Sender (The Remote "Probe")

This Micro:bit is powered by a battery pack and placed wherever the "action" is.

  • The Logic: It reads a sensor and broadcasts it over the radio.

  • Key Blocks: radio set group [number] and radio send value "name" = [value].

2. The Receiver (The Data Bridge)

This Micro:bit stays plugged into your computer via USB. It acts as a translator, listening for radio signals and passing them to the PC.

  • The Logic: "When I hear a radio message, write that value to the Serial (USB) port."

  • Key Blocks: on radio received name valueserial write value [name] = [value].



Project Spotlight: Detecting and Logging Magnetism

One of the most exciting uses for this setup is exploring invisible forces. By using the built-in magnetometer (compass sensor), you can track the strength of magnetic fields as a magnet moves closer or further away.

For a specific step-by-step on setting up this experiment, check out our deep dive: Detecting and Logging Magnetism with the Micro:bit V1.


Teacher & Parent Pro-Tip: The "CSV" Advantage

The real magic happens when students export their data. Instead of just looking at a screen, they can:

  • Calculate the Average, Min, and Max in Excel.

  • Create charts for a science event or just for interest.


Conclusion

The Micro:bit V1 may be the "older" model, but for data logging, it remains a powerhouse. By teaching kids how to move data from a sensor to a radio, then to a cable, and finally into a spreadsheet, you are teaching them the fundamentals of the Internet of Things (IoT) and data capture.


For more detailed technical steps and code snippets, visit the original guides:

 



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

Thursday, 5 March 2026

Detecting and logging magnetism with a microbit

Producing a data logger using the microbit to detect and log changes in the magnetic field.

Traces

The micro:bit includes a built-in compass that can also be used as a magnetic field detector. With a small amount of code, we can use this sensor to measure changes in the magnetic field and log the data to a computer.

If you are new to this idea, a useful introduction is the video from Mr Morrison below, which explains the basic concept.





The video demonstrates how the micro:bit can detect magnetic fields and display the readings on the device itself. Let’s extend that idea by turning the micro:bit into a data logger that continuously records magnetic field changes.


Coding and Sending data to a Computer

Instead of displaying the magnetic readings directly on the micro:bit’s LEDs, we can send the data through the USB cable to a computer.

The MakeCode editor already provides blocks that allow data to be sent using the serial connection. By placing the magnetic measurement inside a command that continuously sends serial data, we can stream the readings to the computer.

In the example code, two values are transmitted:

  • X-axis magnetic field

  • Y-axis magnetic field

These correspond to two directions in which the magnetic field can change. Each measurement is sent repeatedly through the USB cable so the computer can record it.

From a coding perspective, this modification is very simple: instead of showing the value on the device, we send it through the serial interface.


Code needed


After downloading the program to the micro:bit, keep the USB cable connected, as this is how the data is transmitted.

Once the program starts running, the MakeCode interface should display a “Show Data Device” button similar to the one shown below.

On the Computer ready for data logging


Clicking this button opens a data viewer that shows the incoming magnetic readings in real time.

Data logging in action

Example: rocking the magnets
The graph above shows data recorded when a small set of circular magnets was rolled towards the micro:bit and then allowed to rock back and forth.

The rocking motion produces a clear oscillating pattern in both the X and Y magnetic field graphs. As the magnets move, the magnetic field detected by the sensor changes direction and strength, producing the wave-like traces you can see.

It’s a simple experiment, but it demonstrates how the micro:bit can be used as a low-cost scientific data logger for investigating magnetic fields and motion.


Doing it in python!

Using the same makecode editor (the same editor as above for the blocks) click on the Python tab after code has been produced and it should now change to:

def on_forever():
    serial.write_value("x"input.magnetic_force(Dimension.X))
    serial.write_value("y"input.magnetic_force(Dimension.Y))
basic.forever(on_forever)

After it is downloaded; running it is exactly the same as running the blocks version earlier - here is an example of it in action


Running using Python



Have fun - I am :-)




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, 23 February 2026

What does Gen AI 'think' of this blog?


Ok, no surprise that I enjoy playing with Generative AI :-) A few of the recent posts are around this. Here is the question, though: what does Generative AI pick out from the blog when asked?

Using the Gemini and the following two prompts:
Prompt 1: Go to the following blog https://robotsandphysicalcomputing.blogspot.com/ read it in and summarises it as a 400 word blog post to go on the blog and urls will not count in the word limit

Prompt 2:Embed urls to make it easier for the reader to access the posts

The result

Exploring the Intersection of Code and Hardware: A Look at "Robots and Physical Computing"

Welcome to a comprehensive overview of Robots and Physical Computing, a dedicated space where the digital realm directly meets the physical world. Authored by Dr. Scott Turner, this blog operates on a delightfully simple yet profound premise: getting computers to interact with their physical environment is incredibly fun. It serves as an ongoing digital notebook that documents personal experiments, educational coding projects, and hands-on building experiences in the ever-expanding field of physical computing.

For educators, hobbyists, and STEM advocates, the blog is an absolute treasure trove of accessible, step-by-step tutorials. The core philosophy here centers on lowering the barrier to entry for coding and electronics. By heavily featuring user-friendly platforms like the micro:bit, TinkerCad, and various smart electronics kits, the blog demystifies the often-intimidating world of hardware design. Whether you are looking to integrate physical computing into a university computing curriculum or just tinkering on your workbench over the weekend, the content is consistently geared toward practical and immediate application.

A quick dive into the most recent posts perfectly highlights the blog’s dynamic range. In early 2025, the focus successfully bridged simulated environments with smart technology. For instance, a recent tutorial explores how to build a TinkerCad microbit traffic light simulator (note: exact URL path based on blog archives). This post beautifully illustrates how free, online CAD systems can be leveraged to prototype electronic circuits and test neural networks before you ever touch a physical wire. Similarly, a review of the Elecfreaks micro:bit Smart Home kit walks readers through creating a voice-activated light solution, demonstrating how simple code and accessible sensors can mimic real-world smart building technology.

Interestingly, the blog also seamlessly ventures beyond traditional hardware. A late 2024 post explores producing AI-generated cartoon strips, proving that the blog's scope continuously evolves alongside modern technology trends. Additionally, practical data applications remain a recurring theme, as seen in the detailed tutorials on setting up remote data logging systems using older V1 micro:bits and local Microbit V1 datalogging to monitor environmental conditions.

Ultimately, Robots and Physical Computing is much more than just a technical guide; it is a celebration of curiosity and maker culture. It encourages readers to pick up a microcontroller, write a few lines of block code, and watch an LED light up or a motor spin. If you are eager to bridge the gap between software and hardware, delving into this blog’s rich archives will undoubtedly spark your next great project.


Not bad as a summary! Little more gushing than I would have written.


Next task: summarise this as an image. Still using Gemini (and automatically Nano Banna) the following prompts were used
Prompt 1:Use the text produce an image that encapsulates what was summarised and make the image downloadable

Prompt 2: Compress the image so it is suited to the web and allow it to be downloaded

The result, in my opinion, was good and can be seen as the image at the top of the post.

This is just a bit of fun and normal service with Physical Computing will be resumed soon.



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

Wednesday, 9 April 2025

TinkerCad microbit traffic light simulator (now with video)

Have you ever wondered how the traffic lights at the end of your street actually work? They aren’t just on timers; they are controlled by small computers. Today, we’re going to build and code our own traffic light system using a free online tool called Tinkercad.

The best part? You don’t need to buy any expensive equipment. You can build the whole thing virtually on your computer.

What is Tinkercad?

Tinkercad is a free, web-based tool from Autodesk. While many people use it for 3D design, it also has a "Circuits" section where you can drag and drop electronic components—like batteries, LEDs, and micro-computers—to see if they work before building them in real life.

The Project: The Micro:bit Traffic Light

In this project, we use a BBC micro:bit (a pocket-sized computer) to control three lights: Red, Orange, and Green.

To make this work, we connect the micro:bit to a "breadboard" (a plug-and-play board for electronics) or can get away with just wiring them togther with wires (as seen in the circuit below).

  • The Lights: We use three LEDs (Light Emitting Diodes).

  • The Safety: We add resistors.

  • The Connections: * Pin 0 controls the Red light.

    • Pin 1 controls the Orange light.

    • Pin 2 controls the Green light



So here is a circuit with a microbit. The anode (the one with the bent leg)connects to the microbit pins through resistors. The cathode goes to the ground connection.





Here is the code for the microbit turning the LEDs on and off, and when it starts up by putting a smiley face onto the microbit.









For those who like circuit diagrams, it can produce a more formal circuit diagram and the parts list (see below)- nice feature.









Have a play with the simulator below it goes a little bit further and changes the smiley face to letters (see the code below)


Here is how the logic works:

  • The Start: When the micro:bit turns on, it displays a Smiley Face on its screen to show it’s ready.

  • The Loop: 1. Green Light: The micro:bit sends a signal to Pin 2 to turn the Green light on. It shows the letter "G" on its screen. 2. Orange Light: After a few seconds, it turns Green off and turns Pin 1 (Orange) on. It shows the letter "A" (for Amber). 3. Red Light: Finally, it turns Orange off and turns Pin 0 (Red) on. It shows the letter "R".

  • Repeat: The code "loops" forever, just like a real traffic light!









Why Give This a Go?

  • It’s Safe: Since it’s a simulation, you can’t break anything or cause a short circuit.

  • Professional Tools: Tinkercad can automatically generate a "Parts List" and a professional "Circuit Diagram" for you—great for school projects or portfolios.

  • Endless Creativity: Once you master the traffic light, you can change the timings, add a "Pedestrian Walk" button, or even change the colors of the LEDs.

Ready to Build?

Head over to Tinkercad.com, create a free account, and look for the Circuits tab. Search for "micro:bit" and start dragging components onto your workspace.


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

Friday, 28 February 2025

Using Elecfreaks microbit Smart home kit

Whether you're a student looking for a cool weekend project, a parent wanting to spark a child's interest in engineering, or a STEM maker exploring IoT (Internet of Things), the Elecfreaks Micro:bit Smart Home Kit http://bit.ly/43ooJF is a fantastic gateway

Smart home technology isn't just for big tech companies; it’s something you can build on your dining room table. In this post, we’re refining a project that mimics real-world smart building technology: a Voice-Activated Night Light.

What is the Elecfreaks Smart Home Kit?

The Elecfreaks Smart Home Kit is an all-in-one ecosystem designed to work with the BBC micro:bit (both V1 and V2). It comes packed with sensors—temperature, sound, soil moisture, and light—as well as actuators like servos and motors. It’s designed to be "plug, code, and play," removing the frustration of messy wiring so you can focus on the logic and creativity



The Challenge: The Smart "Energy-Saving" Light

Imagine a light that only turns on when it’s dark and when it hears someone in the room, then automatically turns off to save power. This is a classic "Smart Home" scenario.

What You’ll Need:


Step 1: Setting Up the Environment

Before coding, you need to tell MakeCode how to talk to the Smart Home sensors.

  1. Open a new project in .

  2. Click on Advanced, then Extensions.

  3. Search for "smarthome" and select the official Elecfreaks library. This adds new blocks specifically for the kit's components.







Step 2: The Logic (The "Brain" of the House)

For this project, we need the micro:bit to make a decision based on two conditions:

  1. Is it dark? (Light level is low)

  2. Is there noise? (Someone is moving or talking)

Pro-Tip for Makers: To get the most out of your LED strip, you might need to enable it. In MakeCode, click the LED category, then click the [+] or "More" option to find the led enable block.

The Variables

Create three variables to keep your code clean:

  • light: To store the brightness reading.

  • noise: To store the sound level.

  • strip: To control your Rainbow LED.


Step 3: The Code

Here is the logic you’ll build:

  • On Start: Initialise your LED strip to the correct pin (usually P1 in the Smart Home kit).

  • Forever Loop:  Set the light variable to the value of the light sensor.

    • Set the noise variable to the value of the noise sensor.

    • The "If" Statement: If light is less than a certain threshold (e.g., 50) AND noise is greater than 78dB, then turn the LEDs on.

    • The Timer: Use a pause block for 10,000ms (10 seconds) so the light stays on while you walk through the room, then turn it off.

Attach the microbit to the sensorbit


Making the voice activated light solution - the first activity follow the circuit in the book


To get "led enable" you will need to click in makecode like on LED option and then + to find it. You will also need to set up three variables light, strip and noise.
Here is the code

Only turns on the LED for 10 seconds when the light level is low and noise is above 78dB.


A slight adaptation to the code, to makes the LED change with sound level
The circuit is the same.


Why This is Useful for STEM Learning

This project isn't just about making an LED blink; it teaches the fundamental pillars of modern engineering:

  • Sensor Integration: Understanding how machines "sense" the physical world.

  • Boolean Logic: Using "AND/OR" statements to create complex triggers.

  • Threshold Calibration: Students learn that "78dB" or "Light level 50" are variables they must test and adjust based on their specific environment (a great introduction to the scientific method!).


Final Thoughts

The Elecfreaks kit is a "cool set of components" that bridges the gap between screen-based coding and physical reality. Once you've mastered the voice-activated light, try adding the OLED display to show the noise level in real-time, or use the Servo to create an automatic door opener!

Ready to start? Head over to and start building your future home today.







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

DIY Data Science with microbits

DIY Data Science: A Complete Guide to Data Logging with the Micro:bit V1 Whether you are a STEM teacher looking for a classroom lab solution...