# Hayes AT Commands (for RAK811 LoRaWAN) with Node-RED using flow (context) functions and variables

**URL:** <https://discourse.nodered.org/t/hayes-at-commands-for-rak811-lorawan-with-node-red-using-flow-context-functions-and-variables/49248>\
**Category:** Share Your Projects\
**Created:** [3 August 2021 07:07 UTC](https://discourse.nodered.org/t/hayes-at-commands-for-rak811-lorawan-with-node-red-using-flow-context-functions-and-variables/49248 "2021-08-03T07:07:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![btssn988](https://avatars.discourse-cdn.com/v4/letter/b/b19c9b/32.png) [@btssn988](https://discourse.nodered.org/u/btssn988)\
**Post date:** [3 August 2021 07:07 UTC](https://discourse.nodered.org/t/hayes-at-commands-for-rak811-lorawan-with-node-red-using-flow-context-functions-and-variables/49248/1 "2021-08-03T07:07:23Z")

</div>

Hi,

I would like to share my flow to manage AT sequences (array of AT commands) for RAK811 breakout board.  
The RAK811 breakout is a 3.3V LoRaWAN board. It can be connected with a FTDI to a USB port of a PC or a Raspberry Pi. It can also be connected to Rpi UART (Rx/Tx) GPIO (15/14).

The flow is able to manage an array of expected AT answers with an expected timeout for each answer.  
Have fun...

Regards,  
David  
[Link to download the flow](http://mr-techno-988.blogspot.com/2021/08/hayes-at-commands-for-rak811-lorawan.html)

_Exemple of AT sequence :_  
msg.payload=  
[  
{  
"topic": "JOIN OTAA",  
"ATcommand": "at+join=otaa",  
"expectedAnswers": [  
{  
"expected\_answer": "OK",  
"wait\_time\_ms": 2000,  
"error": "Echec authentification otaa (error RAK811)"  
},  
{  
"expected\_answer": "at+recv=3",  
"wait\_time\_ms": 20000,  
"error": "Echec authentification otaa (pas de réponse du concentrateur)"  
}  
]  
},  
{  
"topic": "SEND & RECEIVE",  
"ATcommand": "at+send=0,2,"+msg.payload,  
"expectedAnswers": [  
{  
"expected\_answer": "OK",  
"wait\_time\_ms": 2000,  
"error": "Echec de la transmission (error RAK811)"  
},  
{  
"expected\_answer": "at+recv=2",  
"wait\_time\_ms": 20000,  
"error": "Echec de la transmission (no answer from network)"  
},  
{  
"expected\_answer": "at+recv=0",  
"wait\_time\_ms": 2000,  
"extractOutput" : true, // Find a data in a coma separated payload  
"positionInResponse":3, // Position of data to extract 0 to X  
"responseName":"Réponse RX RAK 811 (Downlink Message)",  
"error": "Pas de message RX (downlink) après transmission",  
"errorReport":false //Just warn after wait-time\_ms if no answer  
}  
]  
}  
]  
;  
return msg;

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [3 August 2021 08:47 UTC](https://discourse.nodered.org/t/hayes-at-commands-for-rak811-lorawan-with-node-red-using-flow-context-functions-and-variables/49248/2 "2021-08-03T08:47:43Z")

</div>

> [@btssn988](#):
>
> [Link to download the flow](http://mr-techno-988.blogspot.com/2021/08/hayes-at-commands-for-rak811-lorawan.html)
> 
> _Exemple of AT sequence :_  
> msg.payload=  
> [  
> {  
> "topic": "JOIN OTAA",  
> ....

Why not share the flow and code in a properly formatted method as per forum requirements?

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…
