-
-
Save anonymous/4249baedae98eaa54710 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> | |
RTC rtc(DST_ON); | |
byte termometro[8] = //icono para la temperatura | |
{ | |
B00100, | |
B01010, | |
B01010, | |
B01110, | |
B01110, | |
B11111, | |
B11111, | |
B01110 | |
}; | |
byte gota[8] = //icono para la humedad | |
{ | |
B00100, | |
B00100, | |
B01010, | |
B01010, | |
B10001, | |
B10001, | |
B10001, | |
B01110, | |
}; | |
const int rx_pin = 22; | |
const int led_pin = 13; | |
const int baudRate = 800; | |
LiquidCrystal_I2C lcd(0x27, 20,4); | |
void setup() | |
{ | |
delay(1000); | |
Serial.begin(9600); | |
pinMode(led_pin,OUTPUT); | |
digitalWrite(led_pin,LOW); | |
SetupRFDataRxnLink(rx_pin, baudRate); | |
lcd.begin(); // Iinicializa el LCD | |
lcd.backlight(); // Enciende la luz de fondo del LCD | |
lcd.createChar(1,termometro); | |
lcd.createChar(2,gota); | |
for (int x=0; x<5; x++) { | |
delay(500); | |
lcd.setCursor(3,1); | |
lcd.print("TOMANDO DATOS"); | |
lcd.setCursor(2,2); | |
lcd.print("ESPERE POR FAVOR"); | |
delay(1000); | |
lcd.clear(); | |
} | |
} | |
void loop() | |
{ | |
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 | |
if(RFLinkDataAvailable(buf, &buflen)) | |
{ | |
for(int i =0; i< buflen; i++) | |
{ | |
inDataSeq.s[i] = buf[i]; | |
} | |
DecodeRFData(inArray, inDataSeq); | |
Serial.println("Temperatura: "); | |
Serial.print(inArray[0]); | |
Serial.print(" ° Humedad: "); | |
Serial.print(inArray[1]); | |
lcd.setCursor(11,1); | |
lcd.print(inArray[0]); | |
lcd.setCursor(2,3); | |
lcd.print(inArray[1]); | |
} | |
if( millis()%1000 == 0 ) | |
{ | |
Data d = rtc.getData(); | |
lcd.setCursor(0, 0); | |
lcd.print( d.toString("d/m/Y") ); // Print it as an array of characters. | |
lcd.setCursor(11, 0); | |
lcd.print( d.toString("H:i:s").c_str() ); // Prints it as a String. | |
} | |
lcd.setCursor(0,1); // Situamos el cursor en la posicion 0 de la segunda linea | |
lcd.write(1); // Escribimos el icono de la temperatura | |
lcd.setCursor(2,1); | |
lcd.print("Exterior:"); | |
lcd.setCursor(16,1); | |
lcd.print((char)223); | |
lcd.setCursor(17,1); | |
lcd.print("C"); | |
lcd.setCursor(0,3); | |
lcd.write(2); | |
lcd.setCursor(7,3); | |
lcd.print("%"); | |
lcd.setCursor(0,2); | |
lcd.write(1); // Escribimos el icono de la temperatura | |
lcd.setCursor(2,2); | |
lcd.print("Interior:"); | |
lcd.setCursor(11,2); | |
lcd.print(rtc.getTemperature()); | |
lcd.setCursor(16,2); | |
lcd.print((char)223); | |
lcd.setCursor(17,2); | |
lcd.println("C"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment