Micro:bit MU Vision Sensor - Serial Connection and OLED Screen

Introduction: Micro:bit MU Vision Sensor - Serial Connection and OLED Screen

About: Thorsgaard is an efterskole in Denmark that works with technology and innovation amongst other things. The instructables here are mainly made by the teachers, but a few of them are made by students.

This is my third guide to the MU vision sensor. So far we have tried using the MU to recognize cards with numbers and shapes, but to explorer our MU sensor with more complex project we would like to get a better output. We can't get that much information from the LED's alone.

So in this project we will program the micro:bit to take the information we get from the MU sensor and output it on an OLED. Since the OLED requires an I2C connection, we need to setup a serial connection betwen the MU and our mirco:bit.

Supplies

1 x BBC micro:bit

1 x Morpx Mu Vision Sensor 3

1 x Micro:bit breakout board - It needs to have access to pin 19&20, which not all breakout boards have. I use elecfreaks motorbit, because I like that board.

8 x Jumper wires (Female-Female)

1 x OLED screen

Step 1: Setting Up the Sensor

Before we start connecting anything we want to setup the sensor properly.

The Mu Vision sensor have 4 switches.

The two on the left decides its output mode and the two one the right decides its address.

Since we want the address to be 00, both switches on the right should be turned off.

The different output modes are:

00 UART

01 I2C

10 Wifi data tansmission

11 Wifi picture transmission

We want to have a serial connection so we are going to work in the UART mode. That means that the two switches should be on 00, so both should be on off.

Step 2: Wiring

Wiring is pretty easy, just use four jumper wires to connect the Mu sensor with your breakout board.

Mu sensor -> Breakout board

RX-> pin 13

TX -> pin 14

G -> Ground

V -> 3.3-5V

Step 3: Getting the First Extension

First we go to the Makecode editor and start a new project. We then go to "Advanced" and select "Extensions". Be aware that since I am danish, these buttons have slightly different names in the pictures. In extensions we search for "Muvision" and select the only result we get.

Step 4: Initializing Connection and Enabling the Algorithm

When you use this extension you will get some "Cannot read property of undefined" errors. That is just because the micro:bit animation is missing. It doesn't affect the compilation and runing of the program.

The first dark blue box tells the Micro:bit which pins to use for the serial connection.

The first orange part of the code initialize the serial connection.

The second orange part of the code enables the number card recognition algorithms.

Showing numbers is used to trouble shoot. If the micro:bit doesn't count to three when you run the program, then check that your wires are connected properly to the right pins.

Step 5: First Program

Detect number card gives either a 0 or 1. If a number card is detected we get a 1(true) and a 0(false) if a number card is not detected. So here we would expect a smily face if a number card is detected and a frowny face if it is not detected.

The code can be found here.

Step 6: Testing

We test first part of the program.

Step 7: Connecting the OLED

Wiring is again rather easy, we use four jumper wires to connect the OLED with your breakout board.

OLED -> Breakout board

Vin -> 3.3 v

GND -> GND

SCL -> Pin19

SCD -> Pin20

Step 8: Get the Second Extension

We go to our program in Makecode and go under "Advanced" and select "Extensions". There we search for Oled12864 and select the OLED12864_I2C extension.

Step 9: The Final Program

In the setup we add a block to initialize the OLED.

In the main program we add a block to make the OLED give us the label value of the number card. Remember that for the number cards the label value is also the value on the card.

We can change the position of the number by changing the x and y value.

The final program can be found here.

Step 10: Runing the Program

When you run the program, the micro:bit should smile when the MU sensor detects a number card and frown the rest of the time, while the OLED writes the number of the last detected card.

Be the First to Share

    Recommendations

    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Retro Tech Challenge

      Retro Tech Challenge
    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge

    Comments