Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <OneWire.h>
- #include <DallasTemperature.h>
- #define ONE_WIRE_BUS 2 // 1-wire pin
- #include <DHT.h>
- #define DHTPIN 3 // DHT pin
- #define DHTTYPE DHT22 // DHT 11/22?
- DHT dht(DHTPIN, DHTTYPE);
- OneWire oneWire(ONE_WIRE_BUS);
- // Pass our oneWire reference to Dallas Temperature.
- DallasTemperature sensors(&oneWire);
- int anturit = sensors.getDeviceCount();
- // LDR
- const int ldrPin = A0;
- int ldr = 0;
- // SETUP ---------------------------------------------
- void setup() {
- dht.begin(); // DHT
- sensors.begin(); //1-wire
- Serial.begin(9600);
- delay(1000);
- }
- //SETUP -----------------------------------------------
- void loop() {
- // While theres no 'r'equest, do nothing
- while (Serial.read() != 'r'){}
- // Theres been a request, so lets take readings
- ldr = analogRead(ldrPin);
- int h = dht.readHumidity();
- int t = dht.readTemperature();
- // call sensors.requestTemperatures() to issue a global temperature
- // request to all devices on the bus
- sensors.requestTemperatures(); // Send the command to get temperatures
- delay(750);
- float anturi1 = sensors.getTempCByIndex(0);
- float anturi2 = sensors.getTempCByIndex(1);
- // and send them back
- Serial.print(anturi1);
- Serial.print("\n");
- Serial.print(anturi2);
- Serial.print("\n");
- Serial.print(ldr);
- Serial.print("\n");
- //dht
- Serial.print(h);
- Serial.print("\n");
- Serial.print(t);
- Serial.print("\n");
- // We're done, write 255.
- Serial.write(255);
- }
Advertisement
Add Comment
Please, Sign In to add comment