-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsenddata.ino
50 lines (35 loc) · 988 Bytes
/
senddata.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
#include <TheThingsNetwork.h>
// Set your AppEUI and AppKey
const char *appEui = "0000000000000000";
const char *appKey = "00000000000000000000000000000000";
#define loraSerial Serial1
#define debugSerial Serial
// Replace REPLACE_ME with TTN_FP_EU868 or TTN_FP_US915
#define freqPlan TTN_FP_EU868
TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan);
void setup()
{
loraSerial.begin(57600);
debugSerial.begin(9600);
// Wait a maximum of 10s for Serial Monitor
while (!debugSerial && millis() < 10000)
;
debugSerial.println("-- STATUS");
ttn.showStatus();
debugSerial.println("-- JOIN");
ttn.join(appEui, appKey);
}
void loop()
{
debugSerial.println("-- LOOP");
int temp = 32.6 * 100;
int ant = 140;
byte payload[3];
payload[0] = (byte)((temp & 0xFF00) >> 8);
payload[1] = (byte)((temp & 0x00FF) );
payload[2] = (byte)(ant);
Serial.print(payload[2]);
// Send it off
ttn.sendBytes(payload, sizeof(payload));
delay(10000);
}