J’ai commandé pour tester un noeud Lora RAK811 en format de connexion compatible Xbee.
Le RAK811 est un module OpenSource compatible LoRaWAN 1.02
https://doc.rakwireless.com/rak811-lora-breakout-module
- Product Features
Based on Semtech SX1276
Full LoRaWAN® 1.0.2 stack support
Supported bands: (EU433, CN470, IN865, EU868, AU915, US915, KR920, AS920 and AS923)
Output power: 5-20dBm adjustable
Max sensitivity: -130dBm @ 0.3kps
Open source firmware with built-in AT command functionality for easy setup with UART interface.
Theoretical max range of 2km in Urban and 15km in open areas
Integrates both SMA and iPEX antenna connectors
Operating temperature: -40°C ~ 85°C (industrial grade)
Storage temperature: -40°C ~ 85°C (non-condensing)
Supports P2P communication
Activation available through OTAA/ABP
Long battery life – over 10 years
Low power consumption with 500nA on standby and in-air wake-up capability.
RAK811 LPWAN Breakout Module – EU868
https://store.rakwireless.com/collections/boards-nodes/products/rak811-lpwan-breakout-module?variant=22375354302564
Aliexpress RAK811 EU868
https://fr.aliexpress.com/item/32897164738.html?spm=a2g0s.9042311.0.0.2be86c37xQRdS3
Aliexpress Antenne EU868
https://fr.aliexpress.com/item/33030021924.html?spm=a2g0s.12269583.0.0.628149be8mH8Fk
Amazon adaptateur Xbee
https://www.amazon.fr/gp/product/B017KGBP6Y/ref=ppx_yo_dt_b_asin_title_o03_s03?ie=UTF8&psc=1
Ma version sur son adaptateur Xbee
RAK811 Pinout.
Sa mise en œuvre est relativement facile, le connecter sur l’adaptateur Xbee (faire attention au sens), le connecter une USB, je vais le tester via l’IDE Arduino.
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
Envoyez un: at+run (pour sortir du mode boot) et passer en mode « AT » compatible LoRaWAN 1.2
1 |
at+run |
Vous pouvez aussi utiliser la commance « AT » suivante qui declenchera aussi un reboot et vous passera en mode AT + LoRaWAN après un appui sur reset.
1 |
at+set_config=lora:work_mode:0 |
Puis appuyez sur le bouton « RESET » de l’adaptateur Xbee (ne fonctionne pas sous linux avec IDE Arduino, voir en bas de page).
En appuyant sur « reset » vous recevrez dans la console Arduino le message:
1 2 3 4 |
RAK811 Version:3.0.0.14.H.beta2 UART1 work mode: RUI_UART_NORAMAL LoRa work mode:LoRaWAN, join_mode:OTAA, : false, Class: A Initialization OK |
Tout va bien pour moi on est bien dans les bons modes…
Premier test on envoie un at+version, il devrait répondre (dans mon cas):
1 2 |
at+version OK V3.0.0.14.H.beta2 |
Pour voir toute les commandes disponibles en fonction de la version de votre firmware on envoie un at+help:
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 |
at+help OK Device AT commands: at+version at+help at+set_config=device:restart at+set_config=device:sleep:X at+get_config=device:status at+set_config=device:uart:X:Y at+set_config=device:uart_mode:X:Y at+send=uart:X:YYY at+set_config=device:gpio:X:Y at+get_config=device:gpio:X at+get_config=device:adc:X LoRaWAN AT commands: at+set_config=lora:default_parameters at+join at+send=lora:X:YYY at+set_config=lora:region:XXX at+get_config=lora:channel at+set_config=lora:dev_eui:XXXX at+set_config=lora:app_eui:XXXX at+set_config=lora:app_key:XXXX at+set_config=lora:dev_addr:XXXX at+set_config=lora:apps_key:XXXX at+set_config=lora:nwks_key:XXXX at+set_config=lora:multicastenable:X at+set_config=lora:multicast_dev_addr:XXXX at+set_config=lora:multicast_apps_key:XXXX at+set_config=lora:multicast_nwks_key:XXXX at+set_config=lora:join_mode:X at+set_config=lora:work_mode:X at+set_config=lora:ch_mask:X:Y at+set_config=lora:class:X at+set_config=lora:confirm:X at+set_config=lora:dr:X at+set_config=lora:tx_power:X at+set_config=lora:adr:X at+get_config=lora:status at+set_config=lora:dutycycle_enable:X at+set_config=lora:send_repeat_cnt:X LoRaP2P AT commands: at+set_config=lorap2p:XXX:Y:Z:A:B:C at+set_config=lorap2p:transfer_mode:X at+send=lorap2p:XXX |
Autres commandes utiles at+get_config=lora:channel:
1 2 3 |
at+get_config=lora:channel OK *0,on,868100000,0,5; *1,on,868300000,0,5; *2,on,868500000,0,5; 3,off,0,0,0; 4,off,0,0,0; 5,off,0,0,0; 6,off,0,0,0; 7,off,0,0,0; *8,on,867100000,0,5; *9,on,867300000,0,5; *10,on,867500000,0,5; *11,on,867700000,0,5; *12,on,867900000,0,5; 13,off,0,0,0; 14,off,0,0,0; 15,off,0,0,0 |
at+get_config=device:status:
1 2 3 4 5 |
at+get_config=device:status OK Board Core:RAK811 MCU:STM32L151CB_A LoRa chip:SX1276 |
Je souhaite le tester en objet sur The Things Network il va donc falloir récupérer et/ou changer les DevEui/AppEui/AppKey, pour ce faire on va envoyer un at+get_config=lora:status
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 |
at+get_config=lora:status OK Work Mode: LoRaWAN Region: EU868 MulticastEnable: false DutycycleEnable: false Send_repeat_cnt: 1 Join_mode: OTAA DevEui: 60C5A8FFFE798XXX AppEui: 70B3D57ED0033XXX AppKey: 60C5A8FFFE7983D3AC1F09FFF8680XXX Class: A Joined Network:true IsConfirm: unconfirm AdrEnable: true EnableRepeaterSupport: false RX2_CHANNEL_FREQUENCY: 869525000, RX2_CHANNEL_DR:3 RX_WINDOW_DURATION: 3000ms RECEIVE_DELAY_1: 1000ms RECEIVE_DELAY_2: 2000ms JOIN_ACCEPT_DELAY_1: 5000ms JOIN_ACCEPT_DELAY_2: 6000ms Current Datarate: 5 Primeval Datarate: 5 ChannelsTxPower: 0 UpLinkCounter: 6 DownLinkCounter: 0 |
Notez les valeurs de:
DevEui: 60C5A8FFFE798XXX
AppEui: 70B3D57ED0033XXX
AppKey: 60C5A8FFFE7983D3AC1F09FFF8680XXX
Nous allons en avoir besoin pour l’ajouter dans la console de ttn.
Les documentations existent déjà, je ne vais donc pas détailler cette partie.
Connecting to The Things Network (TTN):
https://www.thethingsnetwork.org/docs/devices/rak811-wisnode-lora-module/connecting-to-ttn.html
J’ai mis dans: https://console.thethingsnetwork.org/applications/ ==> Son-Petit-Nom ==> payload-formats a fin de décoder la commande envoyée en Hexadécimal le bout de JavaScript suivant:
1 2 3 4 5 6 |
function Decoder(bytes, port) { var decoded = { Texte: "" }; // if (port === 1) decoded.led = bytes[0]; decoded.Texte = String.fromCharCode.apply(null, bytes) return decoded; } |
A partir de là nous sommes prêt a communiquer entre notre objet et ttn, pour tester on va envoyer un: at+join
1 2 3 |
at+join OK Join Success |
Dialogue ok 🙂
On va maintenant envoyer un « Hello World! » encodé en Hexadécimal: at+send=lora:2:48656C6C6F20576F726C6421
1 2 3 |
at+send=lora:2:48656C6C6F20576F726C6421 OK |
On as bien reçu la confirmation « OK« .
Maintenant pour vérifier on se rend dans la console de ttn.
https://console.thethingsnetwork.org/applications/ ==> Son-Petit-Nom ==> data
On voit bien le texte « Hello World! » décodé 🙂
ADRESSES UTILES:
Connecting to The Things Network (TTN)
https://www.thethingsnetwork.org/docs/devices/rak811-wisnode-lora-module/connecting-to-ttn.html
Configuring the RAK811 WisNode LoRa Module
https://www.thethingsnetwork.org/docs/devices/rak811-wisnode-lora-module/configuring-wisnode.html
Device Firmware Upgrading
https://www.thethingsnetwork.org/docs/devices/rak811-lora-module-breakout-board/device-firmware-upgrading.html
RAK811_LoRaNode (docs, firmware, softwares sur github)
https://github.com/RAKWireless/RAK811_LoRaNode
RAK811
https://downloads.rakwireless.com/LoRa/RAK811/
Tools
https://downloads.rakwireless.com/LoRa/Tools/
- J’ai fait mes premiers tests du RAK811 sous Windows, et bizarrement j’ai rencontré des soucis sous Linux avec l’IDE Arduino ? , pas moyen via l’IDE Arduino de le passer en mode « AT » via la commande « at+run » du coup je me suis fait un petit script .
Le script en question permet de passer en mode AT, et d’envoyer des messages sur ttn.
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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
#! /bin/bash chemin="$(cd "$(dirname "$0")";pwd)/$(basename "$0")"; dossier="$(dirname "$chemin")" export chemin dossier cd "${dossier}" #Détecter dernier /dev/ttyUSB? dans dmesg (pas fiable à 100% , a revoir ...) ttyUSB="$(dmesg | grep "cp210x converter now attached to ttyUSB*" | awk 'END {print}' | awk -F" " '{print $(NF)}')" if [ ! "$ttyUSB" ]; then echo -e "\033[1;47;31m Erreur /dev//ttyUSB? \033[0m" exit 0 fi stty -F /dev/$ttyUSB 115200 raw -echo exec 3<"/dev/$ttyUSB" cat <&3 > "/tmp/ttyDump.dat" & PID="$!" #▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ #at+version On verifie si connexion est OK ? function FCT_version() { echo -e "at+version\r\n" >/dev/$ttyUSB echo -e "at+version ... ATTENTE Réponse 2 Secondes !" sleep 2 cat "/tmp/ttyDump.dat" RECHERCHE="$(cat "/tmp/ttyDump.dat" | grep OK)" } FCT_version #▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ #▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ # at+run ATTENTE de Reset ! function FCT_run() { if [ ! "$RECHERCHE" ]; then RECHERCHE="" echo -e "at+run\r\n" >/dev/$ttyUSB echo -e "at+run ... ATTENTE Réponse 2 Secondes !" #sleep 2 while true; do RECHERCHE="$(cat "/tmp/ttyDump.dat" | grep OK)" if [ "$RECHERCHE" ]; then echo -e "Ok !" break else echo -e "Appuyez sur le bouton reset du RAK811 !" sleep 1 fi done fi } FCT_run #▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ #▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ # at+help function FCT_help() { echo -e "at+help\r\n" >/dev/$ttyUSB echo -e "at+help ... ATTENTE Réponse 2 Secondes !" sleep 2 cat "/tmp/ttyDump.dat" sleep 1 #echo -e "ATTENTE 2" #read } #FCT_help #▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ #▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ # at+join function FCT_join() { RECHERCHE="" echo -e "" >/tmp/ttyDump.dat echo -e "at+join\r\n" >/dev/$ttyUSB echo -e "at+join ... ATTENTE Réponse 12 Secondes !" sleep 12 #cat "/tmp/ttyDump.dat" RECHERCHE="$(cat "/tmp/ttyDump.dat" | grep OK)" # join OK on envoie un Hello World! :) if [ "$RECHERCHE" ]; then echo -e "\E[37;44m\033[1m join ok :) \033[0m" echo -e "at+send=lora:2:$1\r\n" >/dev/$ttyUSB echo -e "at+send ... ATTENTE Réponse 12 Secondes !" sleep 12 RECHERCHE="" RECHERCHE="$(cat "/tmp/ttyDump.dat" | grep OK)" if [ "$RECHERCHE" ]; then echo -e "\E[37;44m\033[1m ok Message est bien passé ! ($1) \033[0m" else echo -e "\033[1;47;31m Message non reçu ? \033[0m" fi else echo -e "\033[1;47;31m ERREUR non join ! \033[0m" fi } # https://www.rapidtables.com/convert/number/ascii-to-hex.html #FCT_join "48656C6C6F20576F726C6421" #FCT_join "426f6e6a6f7572206c65204d6f6e646521" i=0 while [ $i -lt 5 ] do echo "Msg: $i" FCT_join "$(echo -n "Bonjour il est: $(date +%r)" | sed 's/ $//g' | xxd -p)" sleep 5 ((i++)) done #▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ kill "$PID" exec 3<&- exit 0 #F.I.N #▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄F.I.N#▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ |