Our goal


Required materials


Background


What is the IOT

Hardware connection


As below picture, connect LED IN of the dust sensor to P9 and OUT to P10.

Connect the OLED screen to the IIC interface.

Software


makecode

Coding


Step 1

Note:If you get a warning telling you some packages will be removed because of incompatibility issues, either follow the prompts or create a new project in the Project file menu.

Step 2

Snap the initialize OLED block into the on start and write parameters 64*128.

Initialize the OLED screen to 64* 128 pixel.

Step 2

Snap the clear OLED display, show string and show number blocks into the forever as below picture.

Showing string Dust(ug/m3):to display returned value of the dust sensor.

Pause 60s, once a minute.

Program

Program link:https://makecode.microbit.org/_7EPDui88d7v3

If you don’t want to type these code by yourself, you can directly download the whole program from the link below:

Result


The dust particle number will be displayed every minute.

Think


How do you do to make it alarm when the air is in bad quality?

Questions


More Information