Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
christina chen
Published

Automatic Humidifier

An automatic humidifier makes your winter more comfortable

BeginnerProtip6 hours649
Automatic Humidifier

Things used in this project

Hardware components

Seeed Studio Grove - Water Atomization
×1
Seeeduino XIAO Expansion board
Seeed Studio Seeeduino XIAO Expansion board
https://www.seeedstudio.com/Seeeduino-XIAO-Expansion-board-p-4746.html?queryID=81765fc1ffb5ff0652d22358b0740401&objectID=4746&indexName=bazaar_retailer_products
×1
Seeed Studio XIAO SAMD21 (Pre-Soldered) - Seeeduino XIAO
Seeed Studio XIAO SAMD21 (Pre-Soldered) - Seeeduino XIAO
×1
Seeed Studio Grove - Temperature&Humidity Sensor(DHT11)
×1
Seeed Studio Grove - RGB LED Ring (16-WS2813 Mini)
×1

Story

Read more

Code

Code

Arduino
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include "Adafruit_NeoPixel.h"
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN            7
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      20
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#include "DHT.h"

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT11   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
//#define DHTTYPE DHT10   // DHT 10
//#define DHTTYPE DHT20   // DHT 20

/*Notice: The DHT10 and DHT20 is different from other DHT* sensor ,it uses i2c interface rather than one wire*/
/*So it doesn't require a pin.*/
#define DHTPIN 5     // what pin we're connected to(DHT10 and DHT20 don't need define it)
DHT dht11(DHTPIN, DHTTYPE);   //   DHT11 DHT21 DHT22
 
int delayval = 500; // delay for half a second



#if defined(ARDUINO_ARCH_AVR)
    #define debug  Serial

#elif defined(ARDUINO_ARCH_SAMD) ||  defined(ARDUINO_ARCH_SAM)
    #define debug  SerialUSB
#else
    #define debug  Serial
#endif
// Pin Definitions   

// Variable Definitions
int sensorValue = 0;  

void setup() {
    Serial.begin(9600);
    pinMode(0,OUTPUT); //Set pin 4 as OUTPUT pin
    dht11.begin();

#if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  // End of trinket special code
  pixels.setBrightness(255);
  pixels.begin(); 

  
    
}
void loop() {
    // read the value from soil moisture sensor:
    sensorValue = dht11.readHumidity();
  
    Serial.println(sensorValue);

    // determine when to open the relay:
    if(sensorValue<90){
      digitalWrite(0,HIGH);
           
    for(int i=0;i<NUMPIXELS;i++){
 
    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
 
    pixels.show(); // This sends the updated pixel color to the hardware.
 
    delay(10); // Delay for a period of time (in milliseconds).
 
  }
    }
    
    else{
      digitalWrite(0,LOW);
           
    for(int i=0;i<NUMPIXELS;i++){
 
    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,150,150)); // Moderately bright green color.
 
    pixels.show(); // This sends the updated pixel color to the hardware.
 
    delay(10); // Delay for a period of time (in milliseconds).
 
  }
      
    }
    //read the value every 10 minutes
    delay(10);
}

Credits

christina chen
1 project • 3 followers

Comments