Project Aim
This monitoring system is made for clients who are having a small/big farms, nursery and estate plantation. The aim is to create a user friendly based system for the users to view the level and indicator of air quality in greenhouse. The function of this monitoring system is to transmit and receive data from greenhouse. The data will be used as the target for analysis for the efficient use of the running the greenhouse, it is useful for analysis of the factors to ensure a proper greenhouse system. The system will monitor the air quality such as temperature, humidity and carbon dioxide which are very important factor for plants growth.
Whats needed:
DHT11 is connected to digital pin 7 while MQ135 is connected to analog pin A0
the arduino code for the sensor is as below: #include <dht.h> #include "MQ135.h" dht DHT; #define DHT11_PIN 7 int analogPin = 0; MQ135 gasSensor = MQ135(analogPin); long prevMillisDHT11 = 0; long DHT11Interval = 1000; #define RZERO 310 //76.63 int i = 0; double result; double rzero; void setup(){ Serial.begin(9600); } void loop() { unsigned long currentMillis = millis(); if(currentMillis - prevMillisDHT11 > DHT11Interval){ if (i==0) { rzero = gasSensor.getRZero(); // float } if (i>0) { result = gasSensor.getRZero(); rzero = (rzero + result)/2; } i++; float ppm = gasSensor.getPPM(); int CO2 = (int)(ppm*1000); int chk = DHT.read11(DHT11_PIN); char text[40]; int humidity = DHT.humidity; int temperature = DHT.temperature; sprintf(text, "%d,%d,%d\n",temperature, humidity,CO2); Serial.println(text); prevMillisDHT11 = currentMillis; } }
in the eclipse I create a telemetry viewer like so:
the important codes to get the data from arduino serial monitor in java
This connect function is the heart of our software. The function is to detect the connection of Arduino from the Pc USB port and displaying the real-time graph, storing the data in database and displaying suggestion appropriately. On line 8 to 12 is to get all available port and to connect to open port which is supposedly the Arduino. Line 16 to 43 is a new thread where all the main function lies. The scanner on line 21 will read all incoming line from Arduino which consist of three coma separated values, this will be assigned to dataset array. Line 23 to 25 will assigned those value to appropriate variables. Line 26 retrieve the current date and time value from the system. While line 27 to 28 add the three values to the respective charts. On line 30 the function ‘calculate’ takes 3 parameters from temperature, humidity and CO2 to calculate the air quality value which will be assigned to double variables AQI.
The dial on line 412 will take the parameter AQI to be displayed on the dial. The ‘suggestionview’ function handles which suggestion to show accordingly. while, ‘intervalMail’ function checks whether the indicator is at critical level for specific duration set by the admin. ‘sendMail’ function will send e-mail to the targeted recipient when allowed by the ‘intervalMail’ function. On line 37 the whole window refreshed. On line 38 the data measured by all three sensors will be uploaded to database. On line 48 the else block will trigger if the disconnect button is clicked. Results will be chosen port closing and all 3 graph will be reset.
I enclose the arduino and its sensors using some cereal box and dish-washing sponge to make it less fragile and more managable
0 Comments
Leave a Reply. |
Project portofolioShowcasing some personal projects, example or tutorial related to programming and IOT throughout competitions and assignments. ArchivesCategories |