Arduino
Receptor temperatura y humedad
433MHz - MX-05V
Programa |
//------------- // SETA43 // 07/05/2014 //------------- // //Receptor // #include <VirtualWire.h> const int RX_DIO_Pin = 2; float h,humedad,temperatura; int dato1,dato2; byte indice; void setup() { pinMode(13, OUTPUT); Serial.begin(9600); /* Initialises the DIO pin used to receive data from the Rx module */ vw_set_rx_pin(RX_DIO_Pin); /* Receive at 2000 bits per second */ vw_setup(2000); /* Enable the receiver */ vw_rx_start(); } /* Main program */ void loop() { uint8_t Buffer_Size = 2; unsigned int Data; int Data1; uint8_t RxBuffer[Buffer_Size]; if (vw_get_message(RxBuffer, &Buffer_Size)) // Non-blocking { digitalWrite(13, HIGH); Data = RxBuffer[0] << 8 | RxBuffer[1]; h=Data; h=h/100; if(h==333.33) { indice=0; Serial.print("Humedad: "); Serial.print(humedad); Serial.print(" % "); Serial.print("Temperatura: "); Serial.print(temperatura); Serial.print(" C "); Serial.print(dato1); Serial.print(" "); Serial.println(dato2); } else { indice++; if(indice==1) humedad=h; if(indice==2) { if (Data>=35000) { Data1=Data-65536; h=Data1; } else { h=Data; } h=h/100; temperatura=h; } if(indice==3) dato1=Data; if(indice==4) dato2=Data; } digitalWrite(13, LOW); } } |