Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <TheThingsNetwork.h>
- // Set your AppEUI and AppKey
- const char *appEui = "70B3D57ED0017DB0";
- const char *appKey = "XXXXXXXXXXXXXXXXXXXXXXXXX";
- #ifndef HAVE_HWSERIAL1
- #include "SoftwareSerial.h"
- SoftwareSerial Serial1(10, 11); // RX, TX
- #endif
- #define RST 12
- #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");
- // Prepare payload of 1 byte to indicate LED status
- byte payload[1];
- payload[0] = (digitalRead(LED_BUILTIN) == HIGH) ? 1 : 0;
- // Send it off
- ttn.sendBytes(payload, sizeof(payload));
- delay(10000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement