🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    LoRaWAN EU868 RAK3172(H) program issue

    PRODUCTS
    1
    2
    145
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      charlesRD
      last edited by

      Hello,

      I’m encountering an issue while using the LoRaWAN EU868 RAK3172(H). I created a program to read temperature data using a KMeterISO sensor in UIFlow2, which works perfectly with the older and simpler LoRaWAN868 ASR6501. However, when I switched to the RAK module and updated the configuration in the "Unit" section of UIFlow2, I encountered the following error: AttributeError: LoRaWANUnit_RUI3
      This error appears to come from a library that is automatically added when I configure the RAK module's pins.

      While searching for a solution, I visited the product's documentation page:

      • https://docs.m5stack.com/en/unit/Unit LoRaWAN-EU868
        There, it states that UIFlow1 and UIFlow2 support is coming soon — meaning it’s not currently available.

      As a result, I decided to switch to the Arduino IDE. I downloaded the appropriate library and attempted to run an example program, but even the basic example fails to work with this module, i got stuck in the 1st while loop.

      According to the official documentation, the library to use is the one following :

      • https://github.com/m5stack/M5-LoRaWAN-RAK

      The example I tried to compile was:
      Examples > LoRaWAN > OTAA,
      with the correct pin configuration and OTAA identification (DevEUI, AppEUI, AppKey).

      So i try on my own a program but here again, i got stuck in the 1st while loop again. Here's the program that i can compile but not working (I know the OTAA identification is not submit here) :


      #include <Wire.h>
      #include <M5Unified.h>
      #include <M5UnitKmeterISO.h>
      #include "rak3172_lorawan.hpp"
      #include <string.h>

      RAK3172LoRaWAN lorawan;
      M5UnitKmeterISO kmeter;

      // Définir les paramètres OTAA
      #define DEVEUI ""
      #define APPEUI "
      "
      #define APPKEY "*********"

      // Déclaration des broches pour LoRa
      #define TX 15
      #define RX 13

      void joinCallback(bool status)
      {
      if (status) {
      Serial.println("[LoRaWAN] Join réseau réussi !");
      } else {
      Serial.println("[LoRaWAN] Échec de la jonction !");
      }
      }

      void sendCallback()
      {
      Serial.println("[LoRaWAN] Envoi confirmé par le serveur");
      }

      void errorCallback(char* error)
      {
      Serial.print("[LoRaWAN] Erreur : ");
      Serial.println(error);
      }

      void setup() {
      M5.begin();
      Serial.begin(115200);

      // Initialisation du capteur KMeterISO
      Wire.begin(9, 7);  // Utilisation des broches spécifiques pour I2C (SCL, SDA)
      while (!kmeter.begin(&Wire, KMETER_DEFAULT_ADDR)) {
          Serial.println("Capteur KMeterISO non trouvé !");
          delay(1000);  // Attente avant de réessayer
      }
      Serial.println("Capteur KMeterISO initialisé.");
      
      // Initialisation du module LoRaWAN
      while (!lorawan.init(&Serial2, RX, TX, RAK3172_BPS_115200)) {
          Serial.println("[Init] Failed to initialize module, retrying...");
          delay(1000);
      }
      Serial.println("Module LoRaWAN initialisé.");
      
      // Configuration LoRaWAN
      lorawan.onJoin(joinCallback);
      lorawan.onSend(sendCallback);
      lorawan.onError(errorCallback);
      
      // Configurer OTAA
      lorawan.setOTAA(DEVEUI, APPEUI, APPKEY);
      
      // Tentative de jonction au réseau LoRaWAN
      if (lorawan.join(true, false, 10, 10)) {
          Serial.println("Start Join...");
      } else {
          Serial.println("Join Fail");
      }
      
      // Configuration du mode LoRaWAN
      lorawan.setMode(CLASS_A);
      lorawan.setLinkCheck(ALLWAYS_LINKCHECK);
      lorawan.setDR(4);  // Data Rate DR4
      
      Serial.println("Initialisation terminée.");
      

      }

      void loop() {
      M5.update();

      // Lire la température du capteur KMeterISO
      float temp = kmeter.getCelsiusTempValue() / 100.0;
      Serial.printf("Température du capteur: %.2f °C\n", temp);
      
      // Préparer le message à envoyer
      String message = "Temp: " + String(temp, 2) + " °C";
      
      // Envoyer le message via LoRaWAN
      if (lorawan.send(message)) {
          Serial.println("Données envoyées avec succès !");
      } else {
          Serial.println("Échec de l'envoi des données.");
      }
      
      delay(15000);  // Attente de 15 secondes avant de lire et envoyer à nouveau
      

      }

      C 1 Reply Last reply Reply Quote 0
      • C
        charlesRD @charlesRD
        last edited by

        @charlesRD said in LoRaWAN EU868 RAK3172(H) program issue:

        As a result, I decided to switch to the Arduino IDE (even if i wanted to stick with UIFlow2). I downloaded the appropriate library and attempted to run an example program, but even the basic example fails to work with this module, i got stuck in the 1st while loop.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post