/gist:9ee614cd717c3cc31623 Secret
Last active
August 29, 2015 14:16
-
-
Save giltesa/9ee614cd717c3cc31623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal_I2C.h> | |
#include <Wire.h> | |
#include <RTC.h> | |
#include <DataCoder.h> | |
#include <VirtualWire.h> | |
//LCD: | |
LiquidCrystal_I2C lcd(0x27, 20, 4); | |
#define icoTemperature 1 | |
#define icoHumidity 2 | |
byte termometro[] = { B00100, B01010, B01010, B01110, B01110, B11111, B11111, B01110 }; //icono para la temperatura | |
byte gota[] = { B00100, B00100, B01010, B01010, B10001, B10001, B10001, B01110 }; //icono para la humedad | |
//RTC: | |
RTC rtc(DST_ON); | |
Data dataRTC; | |
//RF: | |
#define baudRate 800 | |
#define pRX 22 | |
#define pLED 13 | |
uint8_t buf[VW_MAX_MESSAGE_LEN]; | |
uint8_t buflen = VW_MAX_MESSAGE_LEN; | |
union RFData inDataSeq;//To store incoming data | |
float inArray[2];//To store decoded information | |
float temperature=0.0, humidity=0.0; | |
void setup() | |
{ | |
pinMode(pLED, OUTPUT); | |
digitalWrite(pLED, LOW); | |
SetupRFDataRxnLink(pRX, baudRate); | |
Serial.begin(9600); | |
while(!Serial); | |
lcd.begin(); // Iinicializa el LCD | |
lcd.backlight(); // Enciende la luz de fondo del LCD | |
lcd.createChar(1, termometro); | |
lcd.createChar(2, gota); | |
lcd.setCursor(3,1); | |
lcd.print("TOMANDO DATOS"); | |
lcd.setCursor(2,2); | |
lcd.print("ESPERE POR FAVOR"); | |
delay(7500); | |
lcd.clear(); | |
} | |
void loop() | |
{ | |
if( RFLinkDataAvailable(buf, &buflen) ) | |
{ | |
for( int i =0 ; i<buflen ; i++ ) | |
inDataSeq.s[i] = buf[i]; | |
DecodeRFData(inArray, inDataSeq); | |
temperature = inArray[0]; | |
humidity = inArray[1]; | |
Serial.print("RF DATA: Temperatura: "); | |
Serial.print(temperature); | |
Serial.print(" C, Humedad: "); | |
Serial.print(humidity); | |
Serial.println(" %"); | |
} | |
if( millis()%1000 == 0 ) | |
{ | |
dataRTC = rtc.getData(); | |
lcd.setCursor(0,0); | |
lcd.print( dataRTC.toString(" d/m/Y H:i:s ") ); | |
lcd.setCursor(0,1); | |
lcd.write(icoTemperature); | |
lcd.print(" Exterior: "); | |
lcd.print(temperature, 1); | |
lcd.print(" "); | |
lcd.print((char)223); | |
lcd.print("C"); | |
lcd.setCursor(0,2); | |
lcd.write(icoTemperature); | |
lcd.print(" Interior: "); | |
lcd.print(rtc.getTemperature(), 1); | |
lcd.print(" "); | |
lcd.print((char)223); | |
lcd.print("C"); | |
lcd.setCursor(2,3); | |
lcd.write(icoHumidity); | |
lcd.print(" Humedad: "); | |
lcd.print(humidity, 1); | |
lcd.print(" %"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment