Humidity Meter - With a SHAKE!

by dsberman in Circuits > Electronics

8 Views, 0 Favorites, 0 Comments

Humidity Meter - With a SHAKE!

screenshot_2018-01-26-12-01-27_fUhBMFcmye.jpg

Super simple yet fun humidity project. Easy assembly and programming, you'll be ready to shake in 5 minutes.

Things Used in This Project

Hardware components

Software apps and online services

Story

About this project

Using the Micro:bit & xChips, assembly of this humidity meter is effortless. Coding is a piece of cake with the blocks software too! This project can be completed in under 5 minutes.

Introduction

I built this humidity meter using the Micro:Bit and a couple of xChips from XinaBox. The XinaBox technology made this project extremely easy to do by eliminating the need for soldering and extra tools. The Micro:bit interface allows me to program easily. This project is an adaption of my previous Micro:bit Temperature Monitor project, showcasing another application of the SW01 sensor.

Assemble the Circuit

  • Click the OD01 and SW01 together using an xBUS connector (from the XC10 pack).

Figure 1: Connected OD01 and SW01

  • Click 2 xBUS connectors to the left side of the IM02 then click on the connected SW01 and OD01. Make sure that the xChips faces the same way up, so you can see the SW01 name and the IM02 name both facing up.
  • Use another xBUS connector to connect the MD01 to the PB04. Set aside the connected PB04 and MD01 with 3 xBUS connectors and the AA batteries.
  • Click the Micro:Bit into the IM02. Make sure the LEDs faces up - same way as the SW01 name and the IM02 name.

Figure 2: Connected OD01, SW01, IM02 and Micro:bit

  • Attach a Micro-USB connection from your computer to the Micro:Bit. Notice the yellow LED on the bottom side turning on.

Install Package

  • Open a browser and go to makecode.microbit.org
  • Scroll down to "Advanced"
  • Then Scroll down to "Add Package"

Figure 3: Finding "Add Package"

  • Search for "weather" and click on "weather-bit" to add the package
  • Repeat points 2 and 3
  • Then paste this URL into the search bar : https://github.com/xinabox/pxt-OD01 then click on OD01 to add the package

Figure 4: Adding the packages

  • You now have all the necessary packages.

Programming

  • Drag and drop code elements until you get something that looks like the image below.

Figure 5: The code in Blocks

  • You can also cheat and click on the "{ } JavaScript" button on the top and simply copy and paste the code into the code section below. Click on "Blocks" again to see the result.

Compile and Test

  • Click on "Download"
  • Drag the downloaded file, typically named: microbit-Untitled.hex, to your Micro:Bit drive, typically name: MICROBIT.
  • You should see the "X" on the rolling LED display on the Micro:bit and the string "Humidity Project" on the OLED screen on the OD01
  • Shake the unit. The Humidity reading should show as seen below. If it does then your project is working.

Figure 6: First Reading

  • Press button "A" on the Micro:bit to receive a humidity range. As seen below. The ranges are: "DRY" - when relative humidity is below 30%; "Moderate" - when relative humidity is above 30% but below 70% and "HUMID!!!" - when relative humidity is above 70%

Figure 7: Humidity range example

  • If it doesn't show appropriately, retrace your steps to pick up the mistake.

Complete Temperature Monitor

  • Disconnect the Micro:bit from the Micro-USB connection.
  • Insert the AA batteries into the PB04
  • Use the 3 xBUS connectors to connect the PB04 and MD01 to the IM02and SW01 as seen in the picture below.
  • Turn the switch on the PB04 on.
  • Now your Micro:bit humidity meter is portable and ready to be placed/used wherever you choose.

Code

Micro:bit Humidity Project Code JavaScript
It is JavaScript code that can be converted into blocks using the makecode.microbit.org webpage. This code allows you to measure the humidity levels with the circuit built in the above tutorial. It can easily be adjusted to your own preferences within the parameters allowed in the micro:bit software

let Humidity = 0
input.onButtonPressed(Button.A, () => {
    if (Humidity < 30) {
        OLED.showString("DRY")
    } else {
        OLED.showString("Moderate")
    }
    if (Humidity > 70) {
        OLED.showString("HUMID!!!")
    } else {
        OLED.showString("Moderate")
    }
})
input.onGesture(Gesture.Shake, () => {
    OLED.showString("Humidity")
    OLED.showNumber(Humidity)
    basic.pause(100)
})
basic.showLeds(`
    # . . . #
    . # . # .
    . . # . .
    . # . # .
    # . . . #
    `)
OLED.init(64, 128)
weatherbit.startWeatherMonitoring()
OLED.showString("Humidity Project")
Humidity = weatherbit.humidity() / 1024