433MhZ receiver and transmitter from eBay. Each (both receiver+transmitter)cost $1.
DHT11 also from eBay which cost $1.25.
Transmit code:
#include <dht.h>
#include <VirtualWire.h>
#include <avr/sleep.h>
#include <util/delay.h>
int led=0;
const int transmit_pin = 4;
dht DHT;
#define DHT11_PIN 3
void setup(){
vw_set_tx_pin(transmit_pin);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
}
byte count = 1;
void loop(){
int chk = DHT.read11(DHT11_PIN);
int t=0;
int h=0;
//_delay_ms(200);
t=DHT.temperature;
h=DHT.humidity;
char myBigArray[128];
char temp[4];
itoa( t, temp, 10);
//char razib[1]={'k'};
//char msg[7] = {'H','e','l','l','o',' ','#'};
myBigArray[0] = '\0';
//strcat(myBigArray, "T:");
strcat(myBigArray,temp );
strcat(myBigArray, ":");
itoa( h, temp, 10);
//strcat(myBigArray, razib);
strcat(myBigArray, temp);
//msg[6] = count;
//digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
vw_send((uint8_t *)myBigArray, strlen(myBigArray));
vw_wait_tx(); // Wait until the whole message is gone
//digitalWrite(led_pin, LOW);
// delay(100);
count = count + 1;
//system_sleep();
//delayMicroseconds(20);
_delay_ms(1000);
}
No comments:
Post a Comment