Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Empfänger:
- #include <Wire.h>
- #include <DS1307new.h>
- #include <LiquidCrystal.h>
- #include <SPI.h>
- #include <nRF24L01.h>
- #include <RF24.h>
- #define CE_PIN 9
- #define CSN_PIN 10
- const uint64_t pipe = 0xE8E8F0F0E1LL;
- RF24 radio(CE_PIN, CSN_PIN);
- int werte[2];
- uint16_t startAddr = 0x0000;
- uint16_t lastAddr;
- uint16_t TimeIsSet = 0xaa55;
- LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
- void setup()
- {
- pinMode(2, INPUT);
- digitalWrite(2, HIGH);
- Serial.begin(9600);
- lcd.begin(16, 2);
- void powerUpRx(void);
- radio.begin();
- radio.openReadingPipe(1,pipe);
- radio.startListening();;
- RTC.setRAM(0, (uint8_t *)&startAddr, sizeof(uint16_t));// Store startAddr in NV-RAM address 0x08
- // Zum ändern der eingestellten Zeit folgende 2 Zeilen wieder "wirksam" machen
- //TimeIsSet = 0xffff;
- //RTC.setRAM(54, (uint8_t *)&TimeIsSet, sizeof(uint16_t));
- RTC.getRAM(54, (uint8_t *)&TimeIsSet, sizeof(uint16_t));
- if (TimeIsSet != 0xaa55)
- {
- RTC.stopClock();
- RTC.fillByYMD(2015,2,7);
- RTC.fillByHMS(23,36,0);
- RTC.setTime();
- TimeIsSet = 0xaa55;
- RTC.setRAM(54, (uint8_t *)&TimeIsSet, sizeof(uint16_t));
- RTC.startClock();
- }
- else
- {
- RTC.getTime();
- }
- RTC.ctrl = 0x00;
- RTC.setCTRL();
- Serial.println("DS1307 Testsketch");
- Serial.println("Format is \"hh:mm:ss dd-mm-yyyy DDD\"");
- uint8_t MESZ;
- MESZ = RTC.isMEZSummerTime();
- Serial.print("MEZ=0, MESZ=1 : ");
- Serial.println(MESZ, DEC);
- Serial.println();
- }
- void loop()
- {
- RTC.getTime();
- {
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.print(RTC.hour, DEC);
- lcd.print(":");
- lcd.print(RTC.minute, DEC);
- lcd.print(":");
- lcd.print(RTC.second, DEC);
- lcd.setCursor(10, 0);
- lcd.print(RTC.day, DEC);
- lcd.print("-");
- lcd.print(RTC.month, DEC);
- lcd.print("-");
- lcd.print(RTC.year - 2000, DEC);
- if ( radio.available() )
- {
- bool done = false;
- while (!done)
- {
- done = radio.read( werte, sizeof(werte) );
- lcd.setCursor(0, 1);
- lcd.print("Lux=");
- lcd.setCursor(4, 1);
- lcd.print(werte[0]);
- lcd.setCursor(11, 1);
- lcd.print(werte[1]);
- lcd.print("C");
- }
- }
- else
- {
- Serial.println("Kein Signal vorhanden");
- lcd.setCursor(0, 1);
- lcd.print("No Signal!");
- }
- }
- Serial.print(" seconds since 1.1.2000:");
- Serial.print(RTC.time2000, DEC);
- uint8_t MESZ = RTC.isMEZSummerTime();
- Serial.print(" MEZ=0, MESZ=1 : ");
- Serial.print(MESZ, DEC);
- Serial.print(" - Address in NV-RAM is: ");
- RTC.getRAM(0, (uint8_t *)&lastAddr, sizeof(uint16_t));
- Serial.print(lastAddr, HEX);
- lastAddr = lastAddr + 1;
- RTC.setRAM(0, (uint8_t *)&lastAddr, sizeof(uint16_t));
- RTC.getRAM(54, (uint8_t *)&TimeIsSet, sizeof(uint16_t));
- if (TimeIsSet == 0xaa55)
- {
- Serial.println(" - Clock was set!");
- }
- else
- {
- Serial.println(" - Clock was NOT set!");
- }
- delay(1000);
- }
- //Sender:
- #include <SPI.h>
- #include <nRF24L01.h>
- #include <RF24.h>
- #include <Wire.h>
- #include <BH1750.h>
- #define CE_PIN 9
- #define CSN_PIN 10
- const uint64_t pipe = 0xE8E8F0F0E1LL;
- RF24 radio(CE_PIN, CSN_PIN);
- int sensorPin = 0;
- BH1750 lightMeter;
- int werte[2];
- void setup(){
- Serial.begin(9600);
- lightMeter.begin();
- void powerUpTx(void);
- radio.begin();
- radio.openWritingPipe(pipe);
- }
- void loop() {
- uint16_t lux = lightMeter.readLightLevel();
- int reading = analogRead(sensorPin);
- float voltage = reading * 5.0;
- voltage /= 1024.0;
- float temperatureC = (voltage - 0.5) * 100;
- {
- Serial.print("Temperatur = ");
- Serial.print(temperatureC);
- Serial.print("Light: ");
- Serial.print(lux);
- Serial.println(" lx");
- }
- werte[0] = (lux);
- werte[1] = (temperatureC);
- radio.write( werte, sizeof(werte)) ;
- }
Advertisement
Add Comment
Please, Sign In to add comment