Hey guys
I've been trying for a while to make my program for a DHT22 and soil moisture sensor work.
Both sensors worked on their own but I can't integrate them together- I don't know much about Arduino
At the moment I have powered both the sensors through the 5V pin, and connect the soil moisture to ground and A, and the temp sensor to D and ground.
My code keeps coming up with this:
error: expected unqualified-id before '{' token
{
^
exit status 1
expected unqualified-id before '{' token
Is there anything wrong with my code? and how do i fix it?
int val = 0; //value for storing moisture value
int soilPin = A0;//Declare a variable for the soil moisture sensor
int soilPower = 7;//Variable for Soil moisture Power
int tempPower = 11;
#define DHTPIN 11
#include "DHT.h"
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600); // open serial over USB
dht.begin();
pinMode(soilPin, INPUT);
pinMode(tempPower, INPUT);
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
}
{
Serial.print("Soil Moisture = ");
Serial.println(readSoil());
int readSoil();
val = analogRead(soilPin);//Read the SIG value form sensor
delay(100);
return val;//send current moisture value
delay(2000);
}