Mini Greenhouse Set-up using Arduino Beetle (Temperature, Humidity, and Soil Moisture)


Monitoring environmental factors such as temperature, humidity and soil moisture levels are important ensure that plants are in the optimal conditions for growth. If you have plants at your home and want to keep a close eye on them, then this project is for you! 

Gathering data for these three factors (temperature, humidity and soil moisture) can be easily automated using DFRobot Beetle, a very small-form factor Arduino board that's the size of your thumb!  

Hardware Used: 

  • DFRobot Beetle
  • Temperature and Humidity Sensor
  • Soil Moisture Sensor
  • Breadboard
  • Jumper Wires
  • Micro USB to USB cable

    Software Used: 

    Libraries Used: 

    Application Description: 

    • DFRobot Beetle

    DFRobot Beetle is one of the smallest Arduino compatible boards in the market. It is a miniature version (20mm x 22mm) of the Arduino Leonardo (70mm x  55mm) while maintaining similar functionalities. The beetle has V-shaped IO ports which the user can use to twist the wires upon. This feature also allows for it to be directly sewn on clothes with conductive threads.
    The DFRobot Beetle comes with Atmel ATmega32U4 at 16MHz clock time and has 10 digital pins, 5 analog pins, and 4 PWM pins. To further make it user-friendly, it is compatible with Micro USB so that direct programming and testing can be done easily.
    Below is a table of the IO Port Mapping in correspondence with Arduino Port:
    • DHT11

    The DHT11 is a 4-pin digital sensor used to measure temperature and ambient humidity. This sensor can measure temperature that ranges from 0°C - 50°C (± 2°C accuracy), and can measure ambient humidity that ranges from 20% RH - 90% RH (± 5% accuracy).

    It's fairly simple to use but requires careful timing to grab data. This sensor can only get new data every two seconds, so it is important to take note of this.

    • Soil Moisture Sensor 

    The soil moisture sensor is a 3-pin analog sensor can read the amount of moisture present in the soil surrounding it. The sensor uses the two probes to pass current through the soil, and then it reads that resistance to get the moisture level. More water makes the soil conduct electricity more easily (less resistance), while dry soil conducts electricity poorly (more resistance).

    Value Ranges 

        • 0 ~300 : dry soil
        • 300~700 : humid soil
        • 700~950 : in water

    Hardware Setup: 

    Pin Configuration
    • A0 hole on DFRobot Beetle to pin on DHT11 sensor
    • A1 hole on DFRobot Beetle to pin on soil moisture sensor
    • Connect connect VCC (+) pins and Ground (-) pins of the sensors to the VCC and Ground holes of the DFRobot Beetle

    Software setup: 

    How to setup your Arduino IDE for DFRobot Beetle 

    To setup your Arduino IDE for Beetle, you must select your board as Arduino Leonardo first. This can be done by going to Tools -> Board and selecting Arduino Leonardo.


      How to include Arduino libraries

      These modules would require long codes to make it function accordingly. However, there is also the option of using libraries to make these modules work with far lesser code.

      Before the Arduino library tutorial, make sure you download these libraries into your computer:

          • DHT by ElectroSchematics

      In order to use the libraries downloaded above, it should be included by going to Sketch -> Include Library -> Add .ZIP Library...

      Next, is to locate the folder where you downloaded the library on and Double-click the library ZIP file. 

      Afterwards, you can verify if you had included the library by going back to Sketch -> Include Library then scroll down until you find the Contributed libraries block and see your included user-library. Click on the DHT library so that it is included in your code. 

      Open the Arduino IDE and upload the code on the DFRobot Beetle Board.



      #include "dht.h"
      dht DHT;
      #define dht_apin A0 
      #define soilmoist_apin A1
      int soilMoisture;
      double percent_soilMoisture;
      void setup(){
      void loop(){ 
        Serial.println("  ");
        delay(5000); //delay from 5 seconds and get a reading again
      void DisplayTemp(){
        DHT.read11(dht_apin); //Use DHT library and read the signal from pin A0
        Serial.print("temperature = ");
        Serial.println("C  ");
      void DisplayHumidity(){
        DHT.read11(dht_apin); //Use DHT library and read the signal from pin A0
        Serial.print("humidity = ");
        Serial.println("%  ");
      void DisplaySoilMoisture(){
        soilMoisture = analogRead(soilmoist_apin);
        // A value of 0 = no water in soil
        // A value of 950 = wet soil with overflowing water
        percent_soilMoisture = (soilMoisture/950.0)*100.0; //get percentage value for moisture level in soil
        Serial.print("Soil Moisture: ");


      Code Breakdown:

      • setup()
      This is a default Arduino function. In this function the Serial.begin(9600);  This tells the Arduino to get ready to exchange messages with the Serial Monitor at a data rate of 9600 bits per second.
      • loop()

      This is also a default Arduino function. Any commands set here will be looped indefinitely. Three seperate functions area called here DisplayTemp(), DisplayHumidity(), and DisplaySoilMoisture()

      • DisplayTemp()
      This function uses the DHT library we previously imported onto our code and uses it to read the signal coming from the signal pin connected to the DHT11. It prints the ambient temperature reading from the signal.
        • DisplayHumidity()
        Similar to the DisplayTemp() function, this function prints the ambient humidity reading from the signal. 
        • DisplaySoilMoisture()

        This function gets the reading for the soil moisture sensor. As stated in the Application Description, the values received from a soil moisture sensor vary from 0 - 950. Using these values a percentage equivalent was calculated for easy understanding. 


        The outputs of this project is printed to the serial monitor of the Arduino IDE. To access the serial monitor, in your IDE go to Tools > Serial Monitor or use the shortcut Ctrl + Shift + M.

        Due to the delay(5000); in the code the sensors are used once every 5 seconds and the values are displayed. The screenshot below shows the outputs from the sensors. 

        Below is a link to a video demonstration of the working project. 




        This project shows how to use two of the simplest and most popular sensor modules together with the tiny but versatile Arduino Beetle. Using these obtained values, you can scale your project to include a water sprinkler and heater that turns on when a threshold value for the ambient temperature and soil moisture is reached. 



        Adruino beetleArduinoArduino starter kitDfr robotDhtDht11PlantSensorSoilSoil moisture

        Leave a comment

        All comments are moderated before being published