Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <OneWire.h>
- #include <DallasTemperature.h>
- #include <Wire.h>
- #include <BMP085.h>
- #include <DHT.h>
- #include <DS1307.h>
- #include <EEPROM.h>
- #include <SPI.h>
- #include <nRF24L01.h>
- #include <RF24.h>
- #define CE_PIN 9
- #define CSN_PIN 10
- #define ONE_WIRE_BUS 4
- OneWire oneWire(ONE_WIRE_BUS);
- DallasTemperature sensors(&oneWire);
- DeviceAddress Thermometer1 = {
- 0x28, 0x00, 0x54, 0xB6, 0x04, 0x00, 0x00, 0x92
- };
- DeviceAddress Thermometer3 = {
- 0x28, 0x94, 0xAC, 0xDF, 0x02, 0x00, 0x00, 0xB5
- };
- BMP085 dps = BMP085();
- long Temperature = 0, Pressure = 0, Altitude = 0;
- DHT dht(8, DHT11);
- char incomingByte;
- int x = 0;
- const uint64_t pipe = 0xE8E8F0F0E1LL;
- RF24 radio(CE_PIN, CSN_PIN);
- int pack[7] = {0, 0, 0, 0, 0, 0, 0};
- void setup() {
- sensors.begin();
- sensors.setResolution(Thermometer1, 10);
- sensors.setResolution(Thermometer3, 10);
- Wire.begin();
- dps.init(MODE_ULTRA_HIGHRES, 21000, true);
- dht.begin();
- Serial.begin(9600);
- radio.begin();
- radio.openWritingPipe(pipe);
- }
- float getTemp(DeviceAddress deviceAddress) {
- float tempC = sensors.getTempC(deviceAddress);
- Serial.println(tempC, 1);
- return tempC;
- }
- void loop() {
- sensors.requestTemperatures();
- dps.getPressure(&Pressure);
- int h = dht.readHumidity();
- //float t = dht.readTemperature();
- int rainSensor = analogRead(A0);
- delay(100);
- pack[0] = getTemp(Thermometer1);
- pack[1] = getTemp(Thermometer3);
- pack[2] = Pressure / 133.3;
- pack[3] = h;
- pack[4] = rainSensor;
- radio.write( pack, sizeof(pack) );
- delay(2000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement