Advertisement
alexpetro000

Untitled

Dec 28th, 2015
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <OneWire.h>
  2. #include <DallasTemperature.h>
  3. #include <Wire.h>
  4. #include <BMP085.h>
  5. #include <DHT.h>
  6. #include <DS1307.h>
  7. #include <EEPROM.h>
  8. #include <SPI.h>
  9. #include <nRF24L01.h>
  10. #include <RF24.h>
  11.  
  12. #define CE_PIN   9
  13. #define CSN_PIN 10
  14. #define ONE_WIRE_BUS 4
  15.  
  16. OneWire oneWire(ONE_WIRE_BUS);
  17.  
  18. DallasTemperature sensors(&oneWire);
  19.  
  20. DeviceAddress Thermometer1 = {
  21.   0x28, 0x00, 0x54, 0xB6, 0x04, 0x00, 0x00, 0x92
  22. };
  23. DeviceAddress Thermometer3 = {
  24.   0x28, 0x94, 0xAC, 0xDF, 0x02, 0x00, 0x00, 0xB5
  25. };
  26.  
  27. BMP085 dps = BMP085();
  28. long Temperature = 0, Pressure = 0, Altitude = 0;
  29.  
  30. DHT dht(8, DHT11);
  31.  
  32. char incomingByte;
  33.  
  34. int x = 0;
  35.  
  36. const uint64_t pipe = 0xE8E8F0F0E1LL;
  37. RF24 radio(CE_PIN, CSN_PIN);
  38. int pack[7] = {0, 0, 0, 0, 0, 0, 0};
  39.  
  40. void setup() {
  41.   sensors.begin();
  42.   sensors.setResolution(Thermometer1, 10);
  43.   sensors.setResolution(Thermometer3, 10);
  44.  
  45.   Wire.begin();
  46.   dps.init(MODE_ULTRA_HIGHRES, 21000, true);
  47.   dht.begin();
  48.  
  49.   Serial.begin(9600);
  50.   radio.begin();
  51.   radio.openWritingPipe(pipe);
  52. }
  53.  
  54. float getTemp(DeviceAddress deviceAddress) {
  55.   float tempC = sensors.getTempC(deviceAddress);
  56.   Serial.println(tempC, 1);
  57.   return tempC;
  58. }
  59.  
  60. void loop() {
  61.  
  62.   sensors.requestTemperatures();
  63.  
  64.   dps.getPressure(&Pressure);
  65.   int h = dht.readHumidity();
  66.   //float t = dht.readTemperature();
  67.  
  68.   delay(100);
  69.   pack[0] = getTemp(Thermometer1);
  70.   pack[1] = getTemp(Thermometer3);
  71.   pack[2] = Pressure / 133.3;
  72.   pack[3] = h;
  73.  
  74.   radio.write( pack, sizeof(pack) );
  75.  
  76.   delay(2000);
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement