Connect pin 1 (on the left) of the DHT11 sensor to +5V
Connect pin 2 of the DHT11 Sensor to pin 12 of Arduino Uno.
Connect pin 3 of DHT11 to the ground.
Now, connect pin 1 of the Soil Moisture Sensor to +5V.
Connect pin 2 of the Soil Moisture sensor to the ground.
And pin3 of the Soil Moisture sensor is not connected.
Connect pin 4 (on the left) of the sensor to pin A0 of the Arduino Uno.
In LDR Sensor, connect a 10K resistor from pin 2 to the ground and pin 2 also with pin A1 of Arduino Uno
Finally, connect pin 1 (power) of the LDR sensor to 3.3V of Arduino Uno.
In Bluetooth Module, connect Vcc and Gnd to +5V and Gnd of Arduino Uno. Tx and Rx to pin 7 and pin 8 of the Arduino pin respectively.
Open Arduino IDE.
Paste the following program.
#include <SoftwareSerial.h>
#include "DHT.h"
#include <Wire.h>
#define DHTPIN 12 // what pin we're connected to
//Uncomment whatever the type of sensor we are using.
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
int sensorPin = A0;
int sensorValue = 0;
int percentValue = 0;
const int ldrPin = A1;
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
char inchar; // Will hold the incoming character from the GSM shield
int bluetoothTx = 7; // bluetooth tx to 7 pin
int bluetoothRx = 8; // bluetooth rx to 8 pin
SoftwareSerial blue( bluetoothTx, bluetoothRx); // bluetooth module will be connected here.
//int bluetoothTx = 7; // bluetooth tx to 7 pin
//int bluetoothRx = 8; // bluetooth rx to 8 pin
//SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
int powerb = 6; // to power up the dht11 sensor, dht11 5v wire is connected with pin6 of the arduino.
String TextForSms ;
String TextForSms2 ;
String TextForSms3 ;
String humidity = " Humidity: %";
String temperature = " Temperature";
String sign = " *C";
void setup() {
Serial.begin(9600);
blue.begin(9600); // original 19200
pinMode(powerb, OUTPUT);
digitalWrite(powerb, HIGH);
dht.begin();
//Setup usb serial connection to computer
Wire.begin();
pinMode(ldrPin, INPUT);
}
void loop() {
if(blue.available() == 0);
if(blue.available() >0)
{
inchar=blue.read();
Serial.println(inchar);
delay(20);
if (inchar=='x')
{
delay(10);
Serial.println(inchar);
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
int h = dht.readHumidity();
// Read temperature as Celsius
int t = dht.readTemperature();
// Read temperature as Fahrenheit
int f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
sensorValue = analogRead(sensorPin);
Serial.print("\n\nAnalogValue:");
Serial.print(sensorValue);
percentValue = map(sensorValue, 1023, 200, 0, 100);
Serial.print("\nPercentValue: ");
Serial.print(percentValue);
Serial.print("%");
Serial.print("Soil Moisture");
Serial.print("Percent: ");
Serial.print(percentValue);
Serial.print("% \n\n\n");
delay(5000);
sensorValue = analogRead(sensorPin);
Serial.print(sensorValue);
// Compute heat index
// Must send in temp in Fahrenheit!
int hi = dht.computeHeatIndex(f, h);
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
int ldrStatus = analogRead(ldrPin);
Serial.print(ldrStatus);
delay(1000);
TextForSms = TextForSms + "AIR HUMIDITY: ";
TextForSms.concat(h);
TextForSms = TextForSms + "% AIR TEMPERATURE: ";
TextForSms.concat(t);
TextForSms = TextForSms + "*C";
blue.print(TextForSms);
Serial.println(TextForSms);
delay(2000);
TextForSms = " ";
TextForSms2 = TextForSms2 + " SOIL HUMIDITY: ";
TextForSms2.concat(percentValue) + "%";
blue.print(TextForSms2 + "%");
Serial.println(TextForSms2 + "%");
delay(2000);
TextForSms2 = " ";
if (ldrStatus > 400) {
TextForSms3 = TextForSms3 + " LUMINOSITY: ";
TextForSms3.concat(ldrStatus);
TextForSms3 = TextForSms3 + " (Good light)\n";
blue.print(TextForSms3);
Serial.println(TextForSms3);
delay(2000);
TextForSms3 = " ";
}
else if (ldrStatus > 150 && ldrStatus < 500) {
TextForSms3 = TextForSms3 + " LUMINOSITY: ";
TextForSms3.concat(ldrStatus);
TextForSms3 = TextForSms3 + " (Medium light)\n";
blue.print(TextForSms3);
Serial.println(TextForSms3);
delay(2000);
TextForSms3 = " ";
}
else {
TextForSms3 = TextForSms3 + " LUMINOSITY: ";
TextForSms3.concat(ldrStatus);
TextForSms3 = TextForSms3 + " (Bad light)\n";
blue.print(TextForSms3);
Serial.println(TextForSms3);
delay(2000);
TextForSms3 = " ";
}
}
}
For receiving data you can use Blueserial app or Serial Bluetooth Terminal. I used the last one. It’s easy to use and has a pretty good interface.