Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "dht.h"
- #define dhtApin A0 // Analog Pin sensor is connected to
- #define phApin A1 //This is the pin number connected to Po
- #define levelApin A2
- #define waterTempApin A3
- dht DHT;
- void setup() {
- Serial.begin(9600);
- delay(500);//Delay to let system boot
- Serial.println("DHT11 Humidity, temperature Sensor, and pHProde\n\n");
- delay(1000);//Wait before accessing Sensor
- pinMode(levelApin, INPUT);
- }
- void loop() {
- // PH prode loop
- int measure = analogRead(phApin);
- double voltage = 5 / 1024.0 * measure; //classic digital to voltage conversion
- // PH_step = (voltage@PH7 - voltage@PH4) / (PH7 - PH4)
- // PH_probe = PH7 - ((voltage@PH7 - voltage@probe) / PH_step)
- float Po = 7 + ((2.5 - voltage) / 0.18);
- // Temp/Hum Sensor
- DHT.read11(dhtApin);
- //Level Sensor
- int levelVoltage = analogRead(levelApin);
- //Water Temp
- int waterTempReading = analogRead(waterTempApin);
- // Temp/Hum print out
- Serial.print("Current humidity = ");
- Serial.print(DHT.humidity);
- Serial.print("% ");
- Serial.print("temperature = ");
- Serial.print(DHT.temperature);
- Serial.println("C ");
- // pH print out
- //Serial.print("pH Measure: \t");
- //Serial.print(measure);
- Serial.print("Voltage: ");
- Serial.print(voltage, 3);
- Serial.print("\tPH: ");
- Serial.print(Po, 3);
- Serial.println("");
- // Level sensor print out
- Serial.print("Level: ");
- Serial.print(levelVoltage/204);
- Serial.print("\n");
- //Water Temp Reading
- //Serial.print("Water Temp: ");
- //Serial.println(waterTempReading);
- //Serial.print("\n");
- Serial.print("\n");
- //Delay to access sensors
- delay(2000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement