9. iot:kit case03: An environmental quality monitoring station

9.1. Our goal


  • Let’s make an environmental quality monitoring station.

9.2. Required materials


9.3. Background


What is the environmental monitoring

  • Environmental monitoringn Environmental monitoring is to design environemntal monitoring and display & save the collected information by using of GIS, it can also give a detailed analysis towards it’s monitoring spot.

9.4. Hardware connection


As below picture, let the light sensor be connected to P1.

Let the BME280 module be connected to SCL-P19 SDA-P20 of the IIC.

Let the onboard RTC be connected to IIC.

../../_images/case_03_01.png

9.5. Software


makecode

9.6. Coding


Step 1

  • Click on “Advanced” in the MakeCode Drawer to see more code sections.

../../_images/iot_bit_11.jpg

  • We need to add an extension for coding to the IOT. Click on the “Extension” at bottom of coding drawer, then Search for “IOT” and click on the IOT package to add it to your project. (As below picture)

../../_images/iot_bit_12.jpg

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 in to the on start, initialize OLED screen pixels to 64*128.

../../_images/case_03_02.png

Step 2

Snap the show string and show number blocks into the forever in turn.

Display current light intensity, humidity and temperature.

Then, snap into the insert newline.

../../_images/case_03_03.png

Program

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

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

Result


The light intensity, temperature and humidity are displayed every minute.

9.7. Think


How do you count the data in a day ?

9.8. Questions


9.9. More Information