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.


  • M5Stack

    @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);
    }
    }


登录后回复
 

与 M5Stack Community 的连接断开,我们正在尝试重连,请耐心等待