Guest User

Untitled

a guest
Apr 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <Adafruit_BMP085.h>
  3.  
  4. #include "DHT.h"
  5.  
  6. #define DHTPIN 2 // what digital pin we're connected to
  7.  
  8. #define DHTTYPE DHT11 // DHT 11
  9. //#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
  10. //#define DHTTYPE DHT21 // DHT 21 (AM2301)
  11.  
  12. DHT dht(DHTPIN, DHTTYPE);
  13.  
  14.  
  15. // Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)
  16. // Connect GND to Ground
  17. // Nano
  18. // SDA to A4
  19. // SCL to A5
  20.  
  21. Adafruit_BMP085 bmp;
  22.  
  23. int photocellPin = 0;
  24. int photocellReading;
  25.  
  26. void setup() {
  27. Serial.begin(9600);
  28. if (!bmp.begin()) {
  29. Serial.println("Could not find a valid BMP085 sensor, check wiring!");
  30. while (1) {}
  31. }
  32. }
  33.  
  34. void loop() {
  35. photocellReading = analogRead(photocellPin);
  36. float humidity = dht.readHumidity();
  37. // Read temperature as Celsius (the default)
  38. float temperature = dht.readTemperature();
  39. Serial.print("humidity:");
  40. Serial.print(humidity);
  41. Serial.println();
  42.  
  43. Serial.print("light:");
  44. Serial.print(photocellReading);
  45. Serial.println();
  46. Serial.print("temperature:");
  47. // Serial.print(bmp.readTemperature());
  48. Serial.print(temperature);
  49. Serial.println();
  50. Serial.print("pressure:");
  51. Serial.print(bmp.readPressure());
  52. Serial.println();
  53. delay(1000);
  54. }
Add Comment
Please, Sign In to add comment