# RAK811-Trackerboard with mbed & Arduino frameworks

**URL:** <https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571>\
**Category:** End Devices (Nodes)\
**Created:** [May 1, 2018, 1:09pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571 "2018-05-01T13:09:48Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![OlofAst](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/olofast/32/25844_2.png) [@OlofAst](https://www.thethingsnetwork.org/forum/u/OlofAst)\
**Post date:** [May 1, 2018, 1:09pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/1 "2018-05-01T13:09:49Z")

</div>

The RAK811 Trackerboard thread i getting quite big.  
If you want to add hardware you might want to consider using the Arduino or mbed frameworks.

This guy is working on an Arduino port, [https://github.com/stm32duino/Arduino\_Core\_STM32](https://github.com/stm32duino/Arduino_Core_STM32)

Also some people are looking at the mbed framework that recently has added support for the RAK811 board.

> **[What is Mbed? | Mbed](https://www.mbed.com/en/about-mbed/what-mbed/)**
>
> The Arm® Mbed™ IoT Device Platform provides the operating system, cloud services, tools and developer ecosystem to make the creation and deployment of commercial, standards-based IoT solutions possible at scale.

However using the mbed framework with OS fills the entire flash and not the basic support for the gps and sensor. I would like to get the people interested in this to write in this thread.

I will do my best to get the GPS and mems sensor working here,

> **[Ebiroll/RAK811-mbed](https://github.com/Ebiroll/RAK811-mbed)**
>
> Rak811 trackerboard compiled with the mbed framework - Ebiroll/RAK811-mbed

---

<div class="post-metadata">

**Author:** ![OlofAst](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/olofast/32/25844_2.png) [@OlofAst](https://www.thethingsnetwork.org/forum/u/OlofAst)\
**Post date:** [May 1, 2018, 1:19pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/2 "2018-05-01T13:19:18Z")

</div>

When I compile I get,  
Link: RAK811-mbed  
Elf2Bin: RAK811-mbed

Total Static RAM memory (data + bss): 3464 bytes  
Total Flash memory (text + data): 41070 bytes

Image: ./BUILD/MTB\_RAK811/GCC\_ARM/RAK811-mbed.bin

---

<div class="post-metadata">

**Author:** ![chaolue](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/c/f6c823/32.png) [@chaolue](https://www.thethingsnetwork.org/forum/u/chaolue)\
**Post date:** [April 30, 2018, 10:35pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/3 "2018-04-30T22:35:22Z")

</div>

I was able to get mbed working with the RAK811 (Trackerboard) without much extra work, following your instructions on your blog ([https://nicbkw.com/stmicro-nucleo-disco-l072cz-lrwan1-quickstart-mbed-os/](https://nicbkw.com/stmicro-nucleo-disco-l072cz-lrwan1-quickstart-mbed-os/)) and reducing the size of the image by turning off RTOS and changing to minimal-printf

```
Mbed LoRaWANStack initialized 
CONFIRMED message retries : 3 
Adaptive data rate (ADR) - Enabled 
Connection - In Progress ...
Connection - Successful 
Dummy Sensor Value = %3.1f 
27 bytes scheduled for transmission 
Message Sent to Network Server 

```

@BoRRoZ as this thread is already getting confusing with the different options for the RAK811, could you split off the mbed question from @OlofAst and reply from @nicbkw above.

---

<div class="post-metadata">

**Author:** ![nicbkw](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nicbkw/32/44893_2.png) [@nicbkw](https://www.thethingsnetwork.org/forum/u/nicbkw)\
**Post date:** [May 1, 2018, 7:12am UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/4 "2018-05-01T07:12:38Z")

</div>

Hi @chaolue, good news! I am glad that my post helped you to reduce build size.  
Did you use the target MTB\_RAK811 and the demo code without change?

---

<div class="post-metadata">

**Author:** ![jojo83](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jojo83](https://www.thethingsnetwork.org/forum/u/jojo83)\
**Post date:** [May 1, 2018, 2:36pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/5 "2018-05-01T14:36:41Z")

</div>

I’m starting to study I still do not understand but I will try to understand.

Thank you for share  
[jojo](https://www.thethingsnetwork.org/forum/u/jojo83) [ballinw](https://www.ballinw.com/)

---

<div class="post-metadata">

**Author:** ![OlofAst](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/olofast/32/25844_2.png) [@OlofAst](https://www.thethingsnetwork.org/forum/u/OlofAst)\
**Post date:** [May 1, 2018, 2:50pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/6 "2018-05-01T14:50:22Z")

</div>

The first compile was with an emply main() function.  
Now when I compile I get,

Total Static RAM memory (data + bss): 8716 bytes  
Total Flash memory (text + data): 108304 bytes

Image: ./BUILD/MTB\_RAK811/GCC\_ARM/RAK811-mbed.bin  
Not possible to compile with debug info but probably enough.

---

<div class="post-metadata">

**Author:** ![chaolue](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/c/f6c823/32.png) [@chaolue](https://www.thethingsnetwork.org/forum/u/chaolue)\
**Post date:** [May 1, 2018, 9:45pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/7 "2018-05-01T21:45:22Z")

</div>

Yeah thanks,

No changes to main.cpp. Built RAK target.

Adjusted mbedapp.json

- my TTN details
- my correct region (lora.phy: 0-8)
- turned off duty for testing (lora.duty-cycle-on: false)
- and also reduced the stack size (main\_stack\_size: 1024) but not sure whether that was important

And as I said above, remove RTOS ([https://os.mbed.com/blog/entry/Reducing-memory-usage-by-tuning-RTOS-con/](https://os.mbed.com/blog/entry/Reducing-memory-usage-by-tuning-RTOS-con/)) but without ignoring the events (mbed-os/events/\*)

And using minimal-printf - [https://github.com/ARMmbed/minimal-printf](https://github.com/ARMmbed/minimal-printf)

This was my first use of mbed-os and I’m reasonably impressed with it. Will wait to see how @OlofAst gets on with it, his git looks promising so far.

---

<div class="post-metadata">

**Author:** ![chaolue](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/c/f6c823/32.png) [@chaolue](https://www.thethingsnetwork.org/forum/u/chaolue)\
**Post date:** [May 1, 2018, 9:47pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/8 "2018-05-01T21:47:52Z")

</div>

If anyone was interest in the Arduino port for RAK811… here is the link to it - [https://github.com/sabas1080/Arduino\_Core\_STM32](https://github.com/sabas1080/Arduino_Core_STM32)

---

<div class="post-metadata">

**Author:** ![OlofAst](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/olofast/32/25844_2.png) [@OlofAst](https://www.thethingsnetwork.org/forum/u/OlofAst)\
**Post date:** [May 2, 2018, 9:45pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/9 "2018-05-02T21:45:55Z")

</div>

I have added MEMS and GPS support and it seems to work.  
I still just send 4 bytes. 00010203 and the data gets through but it sends way too fast and too often. Maybe someone can help me understand the results.

Why does payloadsize vary so much? Why all the zero size downlinks?

![app](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/9/91f44ce4bdc7c8f6e6012e496b65fe0ce43a3ba0.png)

![gateway](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/9/99e30c5d49f158db9f93c79a9df4ba886c332033.png)

---

<div class="post-metadata">

**Author:** ![OlofAst](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/olofast/32/25844_2.png) [@OlofAst](https://www.thethingsnetwork.org/forum/u/OlofAst)\
**Post date:** [May 2, 2018, 11:36pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/10 "2018-05-02T23:36:17Z")

</div>

It was “lora.duty-cycle-on”: true,  
When I set it to false, sending was ok.  
However I would have guessed that the lorawan stack should have kept the data rate at a lower level.

I also added a 1306 display. Tomorrow I will add data from the gps.

---

<div class="post-metadata">

**Author:** ![woollettg](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/woollettg/32/35697_2.png) [@woollettg](https://www.thethingsnetwork.org/forum/u/woollettg)\
**Post date:** [May 4, 2018, 7:41am UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/11 "2018-05-04T07:41:19Z")

</div>

Really interested on getting [https://github.com/ARMmbed/mbed-os-example-lorawan](https://github.com/ARMmbed/mbed-os-example-lorawan)  
going on either an mDot or RAK811. The problem I have is that when I set the lora.phy value to 2 (AU915) the compiler gives this error-

Error: Declaration does not declare anything in “extras/mbed-os.lib/features/lorawan/LoRaWANStack.h”, Line: 446, Col: 6 and-  
Error: Declaration does not declare anything in “extras/mbed-os.lib/features/lorawan/LoRaWANStack.h”, Line: 446, Col: 6

All other PHY numbers compile fine ☹  
Because I have an 8 channel gateway I also need to select sub band 2, which the MBed docs don’t seem to mention how to do.

---

<div class="post-metadata">

**Author:** ![OlofAst](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/olofast/32/25844_2.png) [@OlofAst](https://www.thethingsnetwork.org/forum/u/OlofAst)\
**Post date:** [May 4, 2018, 12:34pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/12 "2018-05-04T12:34:56Z")

</div>

Thats the example I have used.

> **[ARMmbed/mbed-os-example-lorawan](https://github.com/ARMmbed/mbed-os-example-lorawan)**
>
> Simple LoRaWAN example application for mbed OS. Contribute to ARMmbed/mbed-os-example-lorawan development by creating an account on GitHub.

You should write an issue on their github page.

If you want to fix it yourself.  
You can compile with lora.phy = 0 and save the result in one directory then compile with lora.phy=2 and see what defines are missing.  
Its probably something easy to fix.

---

<div class="post-metadata">

**Author:** ![OlofAst](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/olofast/32/25844_2.png) [@OlofAst](https://www.thethingsnetwork.org/forum/u/OlofAst)\
**Post date:** [May 7, 2018, 8:48am UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/13 "2018-05-07T08:48:44Z")

</div>

Hello,  
I Implemented the GPS function in my example, but it is not working.  
I am not sure what is the problem but there does not seem like I get any serial data from the GPS.  
If anyone with more experience could look at this, I would be greatful.

Lora OTAA and sending seems to work fine

This code could come handy.

> **[goran-mahovlic/RAK811-GPS-FORWARDER](https://github.com/goran-mahovlic/RAK811-GPS-FORWARDER)**
>
> Contribute to goran-mahovlic/RAK811-GPS-FORWARDER development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![OlofAst](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/olofast/32/25844_2.png) [@OlofAst](https://www.thethingsnetwork.org/forum/u/OlofAst)\
**Post date:** [May 7, 2018, 8:59pm UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/14 "2018-05-07T20:59:47Z")

</div>

FYI. Now it works.  
I think it was that Gps.service(); was not called often enough.  
The payload format still needs some fixing.  
If you have an 1306 I2C display, checn #define HAS\_DISPLAY 1 in main.cpp

---

<div class="post-metadata">

**Author:** ![jmarcelino](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jmarcelino/32/46753_2.png) [@jmarcelino](https://www.thethingsnetwork.org/forum/u/jmarcelino)\
**Post date:** [May 16, 2018, 9:21am UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/15 "2018-05-16T09:21:09Z")

</div>

Hi,

I just started “playing” more with this module on the mbed OS environment. Has anyone got deepsleep working successfully on it?

---

<div class="post-metadata">

**Author:** ![woollettg](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/woollettg/32/35697_2.png) [@woollettg](https://www.thethingsnetwork.org/forum/u/woollettg)\
**Post date:** [May 24, 2018, 6:55am UTC](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/16 "2018-05-24T06:55:13Z")

</div>

Continuing the discussion from [RAK811-Trackerboard with mbed & Arduino frameworks](https://www.thethingsnetwork.org/forum/t/rak811-trackerboard-with-mbed-arduino-frameworks/13571/12):

I ended up creating an issue on github. The cause turned out to be an semicolon typo.  
I’m now trying to get the RAK811 to sleep using -  
…  
case TX\_DONE:  
dbg.printf("\r\n Message Sent to Network Server\r\n");  
if (MBED\_CONF\_LORA\_DUTY\_CYCLE\_ON) {  
dbg.printf("\r\n Sleeping for %d seconds, sleep allowed %i \r\n",SEND\_INTERVAL,sleep\_manager\_can\_deep\_sleep());  
wait(SEND\_INTERVAL);  
send\_message();  
…  
sleep\_manager\_can\_deep\_sleep() returns 0, the processor doesn’t sleep.  
Is there a better place to stick the wait statement?  
Sorry for the borked code formatting.
