Blue Lorawan Module
-
Hi
Is there a example to connect a M5stack to the TTN network?
https://m5stack.github.io/m5-docs/#/en/product_documents/modules/module_lorawan
Thanks.
-
@qlion
Sorry, we do not have example about TTN -
Hi
I managed to get connected with the following.
Thanks
#include <M5Stack.h>
HardwareSerial Serial2(2);
int period = 158000;
unsigned long time_now = 0;String cmd_DEF = "AT+FDEFAULT";
String cmd_OTTA_mode = "AT+MODE=LWOTAA";
String cmd_DevEui = "AT+ID=DevEui";
String cmd_JOIN = "AT+JOIN=FORCE";
String cmd_send_data = "AT+MSG="Data to send"";void setup() {
M5.begin();
Wire.begin();
// Lcd display
M5.Lcd.setBrightness(100);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(10, 10);
M5.Lcd.setTextColor(WHITE);
M5.Lcd.setTextSize(1);
M5.Lcd.printf("LoraWAN Network");
delay(300);
M5.Lcd.fillScreen(BLACK);
delay(150);
M5.Lcd.setCursor(0, 10);
M5.Lcd.fillScreen(BLACK);
for(int i=0; i<200; i++) {
M5.Lcd.setBrightness(i);
delay(2);
}Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, 16, 17);
Serial2.flush();
/* LoRaWAN Init */
M5.Lcd.println("Setting up the LoraWAN Connetion");
Serial2.println(cmd_DEF);
delay(2000);
Serial2.println(cmd_OTTA_mode);
delay(1000);
Serial2.println(cmd_DevEui);
delay(1000);
Serial2.println(cmd_OTTA_mode);
delay(3000);
M5.Lcd.println("Joining Network.");
Serial2.println(cmd_JOIN);
delay(3000);
M5.Lcd.println("Message will be send in 155000ms, when next Band is availible");
}void loop() {
if(millis() > time_now + period){
time_now = millis();
M5.Lcd.println("Sending Data.");
Serial2.println(cmd_send_data);
}
if(Serial2.available()) {
int ch = Serial2.read();
Serial.write(ch);
}
}
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login