Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include "dht.h"
  2. #define dhtApin A0 // Analog Pin sensor is connected to
  3. #define phApin A1 //This is the pin number connected to Po
  4. #define levelApin A2
  5. #define waterTempApin A3
  6.  
  7. dht DHT;
  8.  
  9. void setup() {
  10. Serial.begin(9600);
  11. delay(500);//Delay to let system boot
  12. Serial.println("DHT11 Humidity, temperature Sensor, and pHProde\n\n");
  13. delay(1000);//Wait before accessing Sensor
  14. pinMode(levelApin, INPUT);
  15. }
  16.  
  17. void loop() {
  18. // PH prode loop
  19. int measure = analogRead(phApin);
  20. double voltage = 5 / 1024.0 * measure; //classic digital to voltage conversion
  21. // PH_step = (voltage@PH7 - voltage@PH4) / (PH7 - PH4)
  22. // PH_probe = PH7 - ((voltage@PH7 - voltage@probe) / PH_step)
  23. float Po = 7 + ((2.5 - voltage) / 0.18);
  24.  
  25. // Temp/Hum Sensor
  26. DHT.read11(dhtApin);
  27.  
  28. //Level Sensor
  29. int levelVoltage = analogRead(levelApin);
  30.  
  31. //Water Temp
  32. int waterTempReading = analogRead(waterTempApin);
  33.  
  34. // Temp/Hum print out
  35. Serial.print("Current humidity = ");
  36. Serial.print(DHT.humidity);
  37. Serial.print("% ");
  38. Serial.print("temperature = ");
  39. Serial.print(DHT.temperature);
  40. Serial.println("C ");
  41.  
  42. // pH print out
  43. //Serial.print("pH Measure: \t");
  44. //Serial.print(measure);
  45. Serial.print("Voltage: ");
  46. Serial.print(voltage, 3);
  47. Serial.print("\tPH: ");
  48. Serial.print(Po, 3);
  49. Serial.println("");
  50.  
  51. // Level sensor print out
  52. Serial.print("Level: ");
  53. Serial.print(levelVoltage/204);
  54. Serial.print("\n");
  55.  
  56. //Water Temp Reading
  57. //Serial.print("Water Temp: ");
  58. //Serial.println(waterTempReading);
  59. //Serial.print("\n");
  60. Serial.print("\n");
  61.  
  62. //Delay to access sensors
  63. delay(2000);
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement