Automatic fogger with ventilator and arduino cloud

April 13, 2025
Description
Introduction
So first of all I would like to stress out the fact that I'm actually fifteen and this is one of my first big projects. This was very good experience for me and without printer i wouldn't be able to achieve that. I wanted to make automatic fogger for my cubaris panda kings and armadilidium vulgare isopods because isopods are very sensitive to humidity, temperature air quality. Wrong conditions can cause death to whole colony and since it's very hard to keep the same conditions all the time manually, why not make it automatic?
Note: the fogger is ultrasonic atomizer and some species of toad can hear/communicate ultrasonic waves and it can be dangerous for them. So I wouldn't use this device for these animals.
13.4 Cloud update - I have found out that arduino developed their own cloud and is very easy to configure with my projects so I added updated code
What does it do
- Measures humidity and temperature and prints it on oled display
- Turns on fogger when is humidity too low
- Prints last time when was fogger turned on
- Prints message if the fogger isn't working
- Keeps ventilating terrarium all the time
- In case there's a problem reading from DHT11/DHT22 fogger will turn on fully automatic mode. It will bee visible on oled
- Prints time when will fogger turn on (in case of fully automatic mode)
Code
This is the standart version code I made on arduino ide 2.3, updated cloud version is in files
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"
#define DHT11PIN 4
#define gnd 3
#define gndhumid 6 // arduino nano doesn't have enough ground and 5V pins. Current is lower but it's safe
#define vcc 5
#define humidpin 2
#define SCREEN_WIDTH 128 // width, in pixels
#define SCREEN_HEIGHT 64 // height, in pixels
#define typeDHT11 DHT11
DHT myDHT11(DHT11PIN, typeDHT11);
int temperature;
int humidity;
int timer;
unsigned long Time;
int interval;
int oldhum;
// declare an SSD1306 display object connected to I2C
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
Serial.begin(9600);
pinMode(humidpin, OUTPUT);
pinMode(gnd, OUTPUT);
pinMode(gndhumid, OUTPUT);
pinMode(vcc, OUTPUT);
// initialize OLED display with address 0x3C for 128x64
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
while (true);
}
delay(2000); // wait for initializing
oled.clearDisplay();
myDHT11.begin();
}
void loop(){
Time = millis() ;
interval = Time /60000;
digitalWrite(gndhumid, LOW);
digitalWrite(vcc, HIGH); // using digital pin as 5V
digitalWrite(gnd, LOW); // using digital pin as ground
humidity = myDHT11.readHumidity();
temperature = myDHT11.readTemperature();
Serial.println(temperature);
Serial.println(humidity);
Serial.println(timer);
Serial.println(interval);
Serial.println(Time);
if(humidity >= 71)
{
disp();
digitalWrite(humidpin, LOW);
}
if (humidity == 0 and temperature == 0)
{
interval = Time /60000;
oled.clearDisplay();
oled.setTextSize(1);
oled.setTextColor(WHITE);
oled.setCursor(0, 0);
oled.println("No data");
oled.setCursor(0, 20);
oled.print("Fogger turns on in ");
oled.print(60 - (interval - timer));
oled.print(" min");
oled.display();
if (interval - timer >= 60){ // every hour is fogger turned on
digitalWrite(humidpin, HIGH);
delay(2000);
timer = interval;
}
digitalWrite(humidpin, LOW);
}
else if (humidity < 71){
digitalWrite(humidpin, HIGH);
timer = interval;
disp();
}
}
void disp()
{
oled.clearDisplay();
oled.setTextSize(1); // text size
oled.setTextColor(WHITE); // text color
oled.setCursor(0,0); // position to display
oled.print("Temperature C ");// text to display
oled.println(temperature);
oled.setCursor(0, 15);
oled.print("Humidity % ");
oled.println(humidity);
oled.setCursor(0, 30);
oled.println("Last fogged ");
timeCount();
oled.println(" ago");
foggerCheck();
oled.display(); // show on OLED
}
void timeCount()
{
int hoursCount = (interval-timer) / 60;
int minutesCount = (interval-timer) % 60;
if (hoursCount >=1) {
oled.print(hoursCount);
oled.print(" hour/s ");
oled.print(minutesCount);
oled.print(" min");
}
else{
oled.print(interval - timer);
oled.print(" min");}
}
void foggerCheck(){
if (Time > 60000 and interval< 2 ){
if (humidity <= oldhum or humidity < 66){
oled.println("fogger isn't working");
}
}
oldhum = humidity;
}
Components
Since arduino nano doesn't have enough gnd and vcc pins I had to use digital pins instead but it's safe even though digital pins have lower current. Fogger must be powered via transistor and with 5V suply and current smaller then 1A because arduino can't generate such a high current, so some soldering is needed. Vin pin can be used as output for ventilator.
Hardware
Material | Number |
sensor | dht11/dht22 |
Fogger | STDZ-1810 |
Oled display | SSD1306 128x64 |
Transistor npn | S9013 |
Ventilator | SAF 5V DC |
4-5 volts input | - |
Arduino nano(without cloud) | A000005 |
Arduino esp32 or other esp32 device with wifi module (for arduino cloud) | esp-32 |
Other material
Material | Amount |
Sponge or cotton | 3-4 cm2 |
Wires | 10-12 pieces |
Solder | 1 |
Solder materials | 5g |
Flux | 1 |
Tinned breadboard | 3-4 cm2 |
Masking tape | 0.5 m |
Printing
Printed parts can be printed from most of non-flexible filament. I used Prusament woodfill and the quality of the print was slightly worse than regular PLA/ PET-G. I used infill 15% and standart temperature for nozzle 230 and heatbed 60 C for woodfill I used 195 C for nozzle.
The best printing for main box is rotating by 45 degrees in x axis and painting on supports. Box for oled display must be oriented downwards.
Best supports for this print are organic.
Other parts can be printed without supports
Final initialization
- Clean printed parts from supports
2. Glue fogger top to main box
3. Solder transistor with wires and tinned breadboard (dremel/trim it to make it fit into the box)
4. Plug hardware together. Make sure it's same as in wiring diagram picture.
5. Upload the code to arduino. In case you dont want to use cloud upload normal version to arduino nano otherwise upload cloud code to wifi arduino (you need have to arduino cloud account i recommend using their documentation). Aply humidity level corresponding your needs.
6. Fit hardware into main box. Put fogger into fogger holder.
7. Strap sensor wires with masking tape.
8. Add water to container with cotton and plug into the electricity. Good job, now you can enjoy fogging
Fogger will use water from wet cotton/sponge that is in seperate container next to hardware. Lit will protect components from high humidity that is in cotton