Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>
- RF24 libraries and code
- Copyright 2009 Jonathan Oxer <jon@oxer.com.au>
- SHT1x library and code
- Copyright ???? ???? ???? ???????
- DallasTemperature library and code
- Copyright 2012 C. LeBlanc <ominously.chaotic@gmail.com>
- Mashing it all together
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
- */
- #include <RF24Network.h>
- #include <RF24.h>
- #include <SPI.h>
- #include <LiquidCrystal_I2C.h>
- #include <SHT1x.h>
- #include <Wire.h>
- #include <OneWire.h>
- #include <DallasTemperature.h>
- #define ONE_WIRE_BUS 10 //DS18B20 data to pin 10
- #define dataPin 9 //SHT data to pin 9
- #define clockPin 8 //SHT clock to pin 8
- RF24 radio(2,3); // nRF24L01(+) radio CE/CSN to pins 2 and 3
- RF24Network network(radio);
- SHT1x sht1x(dataPin, clockPin);
- LiquidCrystal_I2C lcd(0x27,16,2);
- OneWire oneWire(ONE_WIRE_BUS);
- DallasTemperature sensors(&oneWire);
- DeviceAddress insideTemp = {0x28, 0x9B, 0x26, 0xDF, 0x03, 0x00, 0x00, 0x4C};
- const uint16_t base = 0;
- const uint16_t outside = 1;
- struct payload_t
- {
- float temp;
- float humid;
- };
- void setup(void)
- {
- sensors.begin();
- sensors.setResolution(insideTemp, 10);
- SPI.begin();
- radio.begin();
- network.begin(90, base);
- lcd.init();
- lcd.backlight();
- }
- void printTemperature(DeviceAddress insideTemp)
- {
- float humidity = sht1x.readHumidity();
- float tempC = sensors.getTempC(insideTemp);
- float tempF = DallasTemperature::toFahrenheit(tempC);
- sensors.requestTemperatures();
- delay(500);
- lcd.setCursor(0,0);
- lcd.print(tempF);
- lcd.print(" F ");
- lcd.print(humidity);
- lcd.print(" H");
- }
- void loop(void)
- {
- printTemperature(insideTemp);
- network.update();
- while ( network.available() )
- {
- RF24NetworkHeader header;
- payload_t payload;
- network.read(header,&payload,sizeof(payload));
- lcd.setCursor(0,1);
- lcd.print(payload.temp);
- lcd.print(" F ");
- lcd.print(payload.humid);
- lcd.print(" H");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement