My Terrarium: Using Arduino Programming System to Control Humidity and Temperature in Tank

by voronmar26 in Circuits > Arduino

13 Views, 0 Favorites, 0 Comments

My Terrarium: Using Arduino Programming System to Control Humidity and Temperature in Tank

IMG_3194.jpeg

This is a project I chose based off of personal interest for my Computer Engineering course. The goal of this project was to create a terrarium that held two slow browning plants, a aloe and succulent and create a programming system that would notify me, by flashing a red light, when the moisture was too low or the temperature was too high etc.



Supplies

IMG_3299.jpeg
IMG_3298.jpeg
IMG_3297.jpeg

Arduino

Fish Tank/bowl

plants of choice-preferably slow growing)

Soil moisture sensor

Humidity sensor

Breadboard

Jumper wires


Understanding the Digital Components of the Program

IMG_3301.jpeg
IMG_3300.jpeg

My first big step in this project was figuring out how each sensor corresponded and helped keep my terrarium alive. Reading into how the humidity sensor was very necessary in order for the plant to not overheat due to it being an I closed area. Therefore a FAN might have come into play at some point.

Humidity sensor: Overall these are pretty common and easy to purchase, I just needed to do some background research regarding what this sensor needs, its programs and more.

Something to pay attention to: Looking close into the Humidity sensor, I acknowledged that the whole arduino would now have to be placed INSIDE of my terrarium which wasn’t a bit issue but there was water particles in the air and at the bottom of the tank which showed me I need to be very careful when placing electronic components inside.

CODE SEGMENTS:

if (checksum_byte == data_byte[4] && checksum_byte != 0) {

Serial.println("Humidity: ");

for (int c = 0; c <= 7; c++) {

Serial.print(data_packet[c]);

}

Serial.print("\t");

for (int c = 0; c <= 7; c++) {

Serial.print(data_packet[c + 8]);

}

Serial.print("\t");

Serial.print(data_byte[0]);

Serial.print("%");

Serial.println(" ");


Serial.println("Temperature: ");

for (int c = 0; c <= 7; c++) {

Serial.print(data_packet[c + 16]);

}

Serial.print("\t");

for (int c = 0; c <= 7; c++) {

Serial.print(data_packet[c + 24]);

}

Serial.print("\t");

Serial.print(data_byte[2]);

Serial.print("C");

Serial.println(" ");


Serial.println("Checksum Byte: ");

for (int c = 0; c <= 7; c++) {

Serial.print(data_packet[c + 32]);

}

Serial.println(" ");

Serial.print("CHECKSUM_OK");

Serial.println("");

Serial.println("");

}

What Is the Outcome When Using These Sensors?

I looked through many Instructables and pages online to give me ideas for how I could make these sensors show that the temperature or moisture is off. They gave the idea of using a red blinking LED for when something needs adjustment and a green LED when everything is in its right state.


Wiring

IMG_3249.jpeg
IMG_3252.jpeg

This was a key step to success and moving forward in the project. When I was writing up my arduino to the breadboard I had to make sure all pins were correctly written/corresponding in the code(as I did take some of my code from online resources).

Over all step up:

Blue wire was connected to 5V and connected straight to one end of the resistor and one leg of the Moisture sensor(white square).


Yellow wire was placed to connect the other side of their resistor to the Moisture sensor(white Square). Which completed the used of the 10K resistor


It is clear that the orangish tan wire is mainly for connection from ground to arduino to make that complete connection.


The green wire is connected from port 13 to one of the legs of the red LED light. While the Purple Wire is connecting from port 9 to one of the legs of the green LED.


The white wire is connected to another resistor which is in like with the red LED notifying it when the Moisture Sensor is going off.


Orange pin form A0: This pin gives a variable voltage that corresponds to the moisture level in the soil—the wetter the soil, the lower the output voltage.


CODE SEGMENTS:void loop() {

pinMode(DHT11_PIN, OUTPUT);

digitalWrite(DHT11_PIN, LOW);

delay(18);

digitalWrite(DHT11_PIN, HIGH);

pinMode(DHT11_PIN, INPUT_PULLUP);


TOFF_TIME = pulseIn(DHT11_PIN, LOW);

if (TOFF_TIME <= 84 && TOFF_TIME >= 76) {

while (1) {

TON_TIME = pulseIn(DHT11_PIN, HIGH);

if (TON_TIME <= 28 && TON_TIME >= 20) {

bit_data = 0;

}

else if (TON_TIME <= 74 && TON_TIME >= 65) {

bit_data = 1;

}

else if (bit_counter == 40) {

break;

}

data_byte[bit_counter / 8] |= bit_data << (7 - (bit_counter % 8));

data_packet[bit_counter] = bit_data;

bit_counter++;

}

}

checksum_byte = data_byte[0] + data_byte[1] + data_byte[2] + data_byte[3];


Polish Up and Insert Code

Below is all my code in one area(although as you may see there isn't Specific code for the Soil Moisture sensor YET).

FINAL CODE:

#define DHT11_PIN 2


unsigned long TON_TIME = 0;

unsigned long TOFF_TIME = 0;


unsigned char data_byte[5];

unsigned int data_packet[40];

unsigned char bit_data = 0;

unsigned char checksum_byte = 0;

int bit_counter = 0;


void setup() {

Serial.begin(9600);

Serial.println("DHT11 Humidity & Temperature Sensor\n");

delay(1000);//Wait before accessing Sensor

}


void loop() {

pinMode(DHT11_PIN, OUTPUT);

digitalWrite(DHT11_PIN, LOW);

delay(18);

digitalWrite(DHT11_PIN, HIGH);

pinMode(DHT11_PIN, INPUT_PULLUP);


TOFF_TIME = pulseIn(DHT11_PIN, LOW);

if (TOFF_TIME <= 84 && TOFF_TIME >= 76) {

while (1) {

TON_TIME = pulseIn(DHT11_PIN, HIGH);

if (TON_TIME <= 28 && TON_TIME >= 20) {

bit_data = 0;

}

else if (TON_TIME <= 74 && TON_TIME >= 65) {

bit_data = 1;

}

else if (bit_counter == 40) {

break;

}

data_byte[bit_counter / 8] |= bit_data << (7 - (bit_counter % 8));

data_packet[bit_counter] = bit_data;

bit_counter++;

}

}

checksum_byte = data_byte[0] + data_byte[1] + data_byte[2] + data_byte[3];


if (checksum_byte == data_byte[4] && checksum_byte != 0) {

Serial.println("Humidity: ");

for (int c = 0; c <= 7; c++) {

Serial.print(data_packet[c]);

}

Serial.print("\t");

for (int c = 0; c <= 7; c++) {

Serial.print(data_packet[c + 8]);

}

Serial.print("\t");

Serial.print(data_byte[0]);

Serial.print("%");

Serial.println(" ");


Serial.println("Temperature: ");

for (int c = 0; c <= 7; c++) {

Serial.print(data_packet[c + 16]);

}

Serial.print("\t");

for (int c = 0; c <= 7; c++) {

Serial.print(data_packet[c + 24]);

}

Serial.print("\t");

Serial.print(data_byte[2]);

Serial.print("C");

Serial.println(" ");


Serial.println("Checksum Byte: ");

for (int c = 0; c <= 7; c++) {

Serial.print(data_packet[c + 32]);

}

Serial.println(" ");

Serial.print("CHECKSUM_OK");

Serial.println("");

Serial.println("");

}


bit_counter = 0;

data_byte[0] = data_byte[1] = data_byte[2] = data_byte[3] = data_byte[4] = 0;

delay(1000);

Final Step: Assemble

IMG_3254.jpeg
IMG_3251.jpeg
IMG_3194.jpeg

Place the Arduino and breadboard into the tank and make sure it is placed in such a manner that will allow it to stay and not fall into the soil etc.

-The plant place into the terrarium in these pictures is just a practice plant, other plants will be actually growing in this soon-

Things to Watch Out For:

Make sure you buy a container the correct size for your plant and the aturdido and breadboard take up a good amount of space


Understand the impact technology and the arduino may have around water and moisture:keep that in mind!

Figure out which sensors are most important in your case and focus on programming for that one, the more you may add the more error and confusion there might be on the board.