Trying to setup MQTT Server for RAK 4630 Weather Station

Hey everyone I am trying to access the weather data from the Rak 4630 from the developers kit in my python code on my computer. I have been told that if I setup an MQTT server, I would be able to access the data that is currently in my serial output in arduino such as:
result: Tem:21.57C Hum:49.00% Pres:100.43KPa Lig:31.11lux
In the future though, this device will not be connected to my laptop anymore and there will be no way to view that data unless I setup something for it. So I have been looking around and haven’t seen much information with Rak IOT and MQTT. How do I set this up and which MQTT Software do you guys recommend? I know that Helium Console has an MQTT Solution, so it would just be a matter of configuration after I get my software setup. I have a couple options I am aware of right now such as Node Red and Datacake. Can anyone recommend a software and maybe point me in the right direction on how to set it up with the weather monitoring example here? WisBlock/examples/RAK4630/solutions/Weather_Monitoring at master · RAKWireless/WisBlock · GitHub

Hi @a1projects , welcome to RAK forum.

I think you already have an idea on it.

It is just a matter of how you want to implement it. If you’ll look at our LoRaWAN devices, you won’t see any MQTT in documentation because MQTT integration is done in the LoRaWAN network server (LNS) side.

So it really depends on the LoRaWAN gateway you are using if it has built-in LNS and want to use that or you want to use external LNS like TTN, Chirpstack, AWS, Helium, etc.

Once you decided, you will need to have the proper payload decoder depending on your network server. TTN and Helium share common decoder. Chirpstack is a little bit different. The decoder is a small javascript that will convert your LoRawan packets to more meaningful data like what you see in Arduino serial output.

After the payload is decoded, you need to integrate it via MQTT.

If you are using TheThingsStack (TTN V3), this is a very comprehensive tutorial - LoRa/LoRaWAN tutorial 58: Uplink and downlink messages using the Paho MQTT Python client library - YouTube

I can find any same video for Chirpstack but the concept remains the same. Here is the MQTT integration for chirpstack documentation - MQTT - ChirpStack open-source LoRaWAN<sup>®</sup> Network Server

1 Like

Ok, so I am using Helium. The first thing I tried was Datacake. I was able to connect the device to Datacake, but I can only see the RSSI and SNR info. The sensor data is not showing up. When I open the helium console and click debug, I can see that the sensor data is transferring over the network though, but the data does not show up in the debug in Datacakes website. I am not sure if Datacake just has a bug, or what. I know that the function button you can put in some Javascript for the environment example from the Environmental Monitoring Decoder. Someone recommended maybe that I try Node Red, InfluxDB & Grafana out for this project. Do you have any guides for a Grafana/Influx/Node Red setup? Also do you have some more information on how to use the function for Helium for this Rak Environmental Monitoring Example? I have no clue what the hexadecimal is for and how to find it to put it in the payload input; a little clarity on this would be super helpful too! Thanks for your time, Sam

About Datacake:
Did you setup the payload decoder in Datacake? We have a tutorial for Datacake here: How to Visualize Your Sensor Data on Datacake Using the Chirpstack Server
The Datacake decoder is different from TTN and Chirpstack. In above tutorial is an example for a decoder.

1 Like

Got everything figured out, thanks for your help! How can I control the speed of the packets that are going over the network for the environment monitoring example?

Nice @a1projects . Did you use Datacake or Influx-Grafana?

For modifying the transmission interval, you need to change this macro.


1 Like

I ended up going with Pipe Dream / Datacake for now. I plan on trying out some stuff with influx later though! Ok great what does the 20000 represent? So changing it to 10000 changes it to 10 seconds? 20 seconds every what, minute? Kind of confused on the interval logic here

It is simply the time between packets send in milliseconds. 20000 means every 20 seconds a packet is sent.

1 Like

I was just about to get on here and say I realized what y’all were saying! Ok got it, thank you for your help everyone. I will let you know if anything else comes up. Your team has been very helpful, thank you!

Can we reset the device via a down link? I have noticed when I power the device back up that sometime it has trouble connecting and I have to restart the device a few times. If this was in a place that was not physically accessible, is there a way to restart it remotely?

Screen Shot 2021-09-10 at 1.14.15 PM

Hi @a1projects ,

What do you mean with power the device back up?

When it comes to reset, the reset pin of the RAK4631 WisBlock Core is not connected physically to any IO pin so it is impossible to do that without doing some soldering then add a with tiny mosfet to reset the pin. If you want to try software reset, you can use generic reset for ARM MCUs. Just add this line whenever you want a reset, NVIC_SystemReset();. This will make RAK4631 reset.

Btw, if you are going to reset because you can’t join. That is ok. But please note that in LoRaWAN architecture, the end-device should try to have only one join request in its lifetime (ideally) unless the device is moving to another network or LoRaWAN network server. This is to ensure the scalability of the IoT network since each join request will result to a join accept downlink.

If you want to reset the device via downlink, that is possible. You just need to get the downlink message which depends on you. You can just send 1 character via downlink and if that is what the end-device receives, then it will initiate software reset or hw if you implemented one.


If your node cannot connect to the server, how would you send a “reset” command to it? Remote reset from the LoRaWAN server does not work when you node is not connected to the server.

As Carl said, an option is to use MCU reset command to restart the device if it cannot join.
To what value did you set join retrials? Look in the code for
that is how often the node retries to join if it fails. You can try to put a higher number there, e.g. 10.
And you can use the static void lorawan_join_failed_handler(void) callback to retry to join or use the MCU reset command to start from scratch.

Could I connect it to a raspberry pi for power and disconnect/reconnect that port to power cycle it?

Sure you can use a RPi.

But the correct solution would be to find out why your WisBlock has sometimes problems to join. Here are some reasons I can think of:

  • Gateway too far away
  • Gateway too close (sound strange, but happened before)
  • Antenna inside an enclosure is too close to metal parts, hidden under the battery, wrong type)
  • Communication lag between LoRaWAN server and gateway (cellular connection for example)

I am doing a lot of applications for WisBlock and there are no problems with the join process.

How close is too close? Is 10-20 feet too close or are you talking about within a foot of the hotspot? I have a node in the apartment here but the device also connects to another node a few blocks down so I don’t know if that is the issue. Also could I setup the wind speed project to run with the environment monitoring project on the same device, at the same time?

3m should be ok. I got strange reactions when I had the node laying on my table 1m below the gateway on the wall.

The wind speed project and the environment project can be combined, but the payload might get quite large. You might need to set a fixed data rate to be able a large payload.
See our payload/region/datarate tables here: RAK811 Module AT Command Manual | RAKwireless Documentation Center

Ok so I have been unable to connect to the helium network in a week. I have restarted the example project and the board just fails to join over and over. How do I use the mcu reset command? Anything else I can try?

Also, when the device “shuts off” from me unplugging it, does the dev board keep a memory of it trying to join earlier? We are trying to problem solve what could be going on here

I tried it on a brand new 4630 I haven’t even used yet, so I can confirm it’s not a hardware issue. It also can’t be a rejoin issue because it’s never join? I even retried a fresh example and only updated the keys and the region and still got this again on the new board. I have also tried to connect around a different hotspot, and can confirm this is also not the issue. I don’t know what else to do to even problem solve this at this point

Welcome to RAK4630 LoRaWan!!!
Type: OTAA
Region: US915

OTAA join failed!