-
Notifications
You must be signed in to change notification settings - Fork 0
/
Weather_Station_Transmitter_v1.0.ino
93 lines (65 loc) · 1.72 KB
/
Weather_Station_Transmitter_v1.0.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <dht.h>
#include <VirtualWire.h> //Load the library
#define dht_dpin A0 //no ; here. Set equal to channel sensor is on
dht DHT;
String tempVal;
String humVal;
String rainVal;
int rainSensor;
int tempSensor;
int humidSensor;
int rainNum = 0;
String message;
char sentvalues[27];
float temp; //Define the temp float variable
int sensor = 0; // sensor middle pin on analog pin 0
char msg[6];
void setup() {
Serial.begin(9600);
vw_set_tx_pin(12); // Sets pin D12 as the TX pin
vw_setup(2000); // Bits per sec
pinMode(13, OUTPUT); //RED LED
pinMode(8, OUTPUT); //YELLOW LED
pinMode(7, OUTPUT); //GREEN LED
digitalWrite(13, HIGH); //Red LED on
}
void loop() {
digitalWrite(8, HIGH); //Yellow LED on
//===== Get the sensor values =====
temperature();
tempVal = "0";
tempVal += tempSensor;
humVal = "0";
humVal += humidSensor;
rain();
rainVal = "0";
rainVal += rainNum;
Serial.println("");
Serial.println("====String values====");
Serial.print("temp: ");
Serial.print(tempVal);
Serial.print(" hum: ");
Serial.print(humVal);
Serial.print(" rain: ");
Serial.println(rainVal);
Serial.println("");
//===== Send the sensor values ====
// construct the message
message = "T" + tempVal + "H" + humVal + "R" + rainVal;
message.toCharArray(sentvalues, 27);
//reset the strings to empty
tempVal = "";
humVal = "";
rainVal = "";
Serial.println("====message==== ");
Serial.println(message);
Serial.println("========");
Serial.println("");
//send the message
vw_send((uint8_t *)sentvalues, strlen(sentvalues));
vw_wait_tx();
//=================================
delay(50);
digitalWrite(8, LOW); //YellowLED off
delay(200);
}