Mise en œuvre d’un RAK 811 en 868 Mhz de Rakwireless + M5StickC.
- RAK811 EU868
https://fr.aliexpress.com/item/32845848512.html
- + Un adaptateur Xbee USB
https://fr.aliexpress.com/item/4000029506790.html
- + Une bonne antenne.
https://fr.aliexpress.com/item/32897160688.html
- + Une M5StickC.
https://m5stack.com/products/stick-c

Le code Arduino pour le M5StickC:
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
#include <M5StickC.h> const byte led = G10; // G10 = La pin de la led interne du M5StickC. void setup() { M5.begin(true, true, true); Serial.begin(115200); // Serial2.begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert) Serial2.begin(115200, SERIAL_8N1, 0, 26); pinMode(M5_BUTTON_HOME, INPUT_PULLUP); pinMode(led , OUTPUT); digitalWrite(led , HIGH); // Eteindre M5.Lcd.setRotation(1); M5.Lcd.setTextSize(2); M5.Lcd.setTextColor(ORANGE); M5.Lcd.setCursor(0, 0); M5.Lcd.print("RS485 Ob.i LAB"); Serial.println("RS485"); M5.Lcd.setTextSize(1); M5.Lcd.setCursor(10, 20); M5.Lcd.print("AutoSend AT+ CMD!"); M5.Lcd.setCursor(10, 30); M5.Lcd.print("AutoPrint Receive AT+ CMD"); M5.Lcd.setCursor(10, 48); // Serial2.print("at+join\r\n"); // Envoi ==> at+join delay(8000); String response = ""; // Se met en attente de réponse while (Serial2.available()) { char ch = Serial2.read(); response += ch; } if (response.substring(0, 2) != "OK") { // Si KO on reboot ! M5.Axp.DeepSleep(); } M5.Lcd.setTextSize(2); M5.Lcd.setTextColor(ORANGE); M5.Lcd.print(response); delay(4000); M5.Lcd.fillScreen(BLACK);//Nettoyer écran } // End setup void loop() { M5.update(); // indispensable pour boutons M5.BtnA/B/C ... // Reboot rester appuyé ! if (digitalRead(M5_BUTTON_HOME) == LOW) { Serial.println("M5_BUTTON_HOME"); M5.Axp.DeepSleep(); } M5.Lcd.setTextColor(BLUE); M5.Lcd.setCursor(10, 0, 2); M5.Lcd.print("Envoi MSG"); M5.Lcd.setCursor(10, 26, 2); M5.Lcd.print("Attente"); M5.Lcd.setCursor(10, 52, 2); M5.Lcd.print("Reponse"); //Serial2.print("at+version\r\n"); Serial2.print("at+send=lora:2:426f6e6a6f7572206c65204d6f6e646521\r\n"); // Envoyer Message "Bonjour le Monde!" en hexadecimal Serial.println("RS485"); delay(4000); M5.Lcd.fillScreen(BLACK);// Nettoyer écran digitalWrite(led , LOW); // Allumer Led Serial.println(readLora()); // Afficher Message delay(2000); digitalWrite(led , HIGH); // Eteindre Led M5.Lcd.fillScreen(BLACK);// Nettoyer écran } // End loop // Attente réponse String readLora() { String response = ""; M5.Lcd.setRotation(1); while (Serial2.available()) { char ch = Serial2.read(); response += ch; } if (response.substring(0, 2) == "OK") { M5.Lcd.setTextColor(GREEN); M5.Lcd.setCursor(25, 20, 4); M5.Lcd.print(response); } else if (response.substring(0, 2) == "") { M5.Lcd.setTextColor(GREEN); M5.Lcd.setCursor(2, 0, 2); M5.Lcd.print("Erreur Vide!"); } else { M5.Lcd.setTextColor(RED); M5.Lcd.setCursor(2, 0, 2); M5.Lcd.print(response); } return response; } // End readLora |
- Connectez le RAK811 en USB a votre PC démarrez l’IDE Arduino, réglez le port com, puis ouvrez le moniteur série et réglez-le en 115200 et double retour de chariot \r\n et changez dev_eui/app_eui/app_key à l’aide des commandes suivantes:
1 2 3 |
at+set_config=lora:dev_eui:**************** at+set_config=lora:app_eui:**************** at+set_config=lora:app_key:******************************** |
- Branchements
Connectez, la masse, le +5V, RX, TX.