# How do I make a auto on/off humidifier with microbit

**URL:** <https://forum.makecode.com/t/how-do-i-make-a-auto-on-off-humidifier-with-microbit/9870>\
**Category:** micro:bit\
**Created:** [September 3, 2021, 5:52pm UTC](https://forum.makecode.com/t/how-do-i-make-a-auto-on-off-humidifier-with-microbit/9870 "2021-09-03T17:52:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![newie](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@newie](https://forum.makecode.com/u/newie)\
**Post date:** [September 3, 2021, 5:52pm UTC](https://forum.makecode.com/t/how-do-i-make-a-auto-on-off-humidifier-with-microbit/9870/1 "2021-09-03T17:52:36Z")

</div>

I have a dfrobot environmental board v2.0 and a delay board on hand.  
Which model of humidifier preferred?  
How can i make a auto on humidifier when the room too dry and off when the room too humid.  
Thanks a lot

---

<div class="post-metadata">

**Author:** ![frank\_schmidt](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@frank\_schmidt](https://forum.makecode.com/u/frank_schmidt)\
**Post date:** [September 6, 2021, 10:19pm UTC](https://forum.makecode.com/t/how-do-i-make-a-auto-on-off-humidifier-with-microbit/9870/2 "2021-09-06T22:19:55Z")

</div>

There appears to be 2 types of consumer grade room humidifier: Steam or Ultrasonic. Here’s some information on the differences. I have used the DHT11 humidity/temperature sensor with MakeCode Microbit and DFRobot Micro:IoT board . It may be possible to make a switching system to turn on/off your choice of humidifier once you have bought it: [https://www.goodairgeeks.com/steam-humidifier-vs-ultrasonic/](https://www.goodairgeeks.com/steam-humidifier-vs-ultrasonic/)

---

<div class="post-metadata">

**Author:** ![bsiever](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bsiever/32/1032_2.png) [@bsiever](https://forum.makecode.com/u/bsiever)\
**Post date:** [September 7, 2021, 5:18pm UTC](https://forum.makecode.com/t/how-do-i-make-a-auto-on-off-humidifier-with-microbit/9870/3 "2021-09-07T17:18:02Z")

</div>

An alternative to the DFRobot relay would be the [IoT Power Relay](https://www.sparkfun.com/products/14236) sold by SparkFun. It provides a pretty safe way to interface to high power devices.

You could do something like the following:

1. Use the Micro:bit with an existing extension for a humidity and temperature sensor. There are several available. I haven’t used it, but SparkFun’s [gator:environment](https://www.sparkfun.com/products/15269?_ga=2.57841325.601968607.1630972668-634934035.1624724828) looks promising.
2. Read the sensor at a regular rate, but you may want to ensure there’s a bit of a delay, like 1 minute. Start by just controlling something on the display to see if it’s working as expected.
3. Once you’re sure the sensor is working and would turn the humidifier on/off as you’d expect, update the code to use a digital output to control the IoT Power Relay. (I wouldn’t yet connect a humidifier…I’d start with a simple lamp and test your work again). For example, you could select P0 to be the output. P0 and GND would be connected to the IoT Relay. You’d use the `digital write` in the `Pins` palette of the `Advanced` menu to turn it on (1) or off (0).
4. Once you’re pretty sure everything is working, add the humidifier. You could probably set the humidifier to a setting that would ensure it was always on when there’s power. That way the micro:bit is just essentially “plugging it in” based on the sensor value.
5. I’d maybe update the delay to ~5 minutes or so once you know it works.

I suggest the delay because the micro:bit will be able to change the output controlling the IoT Relay quite quickly — probably a lot faster than you’d want to turn a humidifier on/off. Humidifiers probably shouldn’t be turned on/off multiple times a second.

Bill
