# Getting Badgerboard to work with TTN

**URL:** <https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224>\
**Category:** End Devices (Nodes)\
**Created:** [February 5, 2017, 1:48pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224 "2017-02-05T13:48:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [February 5, 2017, 1:48pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/1 "2017-02-05T13:48:51Z")

</div>

For those who received their [Badgerboard](http://badgerboard.io) last week: the hardware seems nice, but [its Arduino library](https://github.com/nasys/badgerboard) seems to be in some beta state (if only given the many commented/disabled lines of code), for which nothing really changed since December 13th.

I wonder if their frequency plan is set up correctly. (See errors below; no documented way to select a plan, I think, but maybe that should be in the firmware?) Also, its core library includes helpers that send the temperature and humidity readings or status messages. Those are not only [~~quite funny~~ needlessly complex](https://github.com/nasys/badgerboard/blob/a2b1dfe1d00efa44664a8a5b05fd8074b4d61771/src/badger.cpp#L541-L553), but also reserve a whopping 60 bytes to send JSON ([not a good practice](https://www.thethingsnetwork.org/forum/t/best-practices-to-limit-application-payloads/1302)) and are sent as confirmed uplinks ([very limited](https://www.thethingsnetwork.org/forum/t/limitations-data-rate-packet-size-30-seconds-uplink-and-10-messages-downlink-per-day-fair-access-policy/1300)). ~~And worst of all: it includes a duplicate of the FaBo HTS221 library, which breaks compiling other Arduino sketches that use the original.~~

So, forget about trying to fix that, but get the TTN Arduino library to run on it.

### Running the TTN library on Badgerboard

Main problem: **one needs to reset the RN2483 after powering or flashing the board** , otherwise it will just not respond to any command (or any `Serial1.write`) and the TTN library will seem to wait forever. (I guess the board’s electronics could have done that too, but well. [Still no schematics](https://www.thethingsnetwork.org/forum/t/open-source-hardware-lora-development-board-launched-on-kickstarter/4178/12), I think.)

1. Install the TTN library following [its documentation](https://www.thethingsnetwork.org/docs/devices/arduino/ide.html).

2. Install [the FaBo 208 Humidity library](https://github.com/FaBoPlatform/FaBoHumidity-HTS221-Library), which also supports the temperature. (Using [the “SmartEverything ST HTS221” library](https://github.com/ameltech/sme-hts221-library) gives me warnings on the latest Arduino IDE; it _will_ work, but the warnings are annoying, and the FaBo library gives the same results though it’s a bit older.)

3. ~~Uninstall any Badgerboard library (its included duplicate of the FaBo library throws errors; see below).~~

4. In the Tools menu, set the board type to “LilyPad Arduino USB”, as [documented](https://github.com/nasys/badgerboard) for the board, and select its port.

5. From the File, Examples menu, load one of the TTN example sketches.

6. Somewhere above `setup()`, add:

7. In `setup()`, call that function:

That’s it. Your TTN example sketch should work now. (Of course, set your keys and `freqPlan`.)

### Getting temperature, humidity and battery level

Assuming you installed the FaBo HTS221 library above:

1. Add the library to the top of your sketch (alternatively see menu Sketch, Include Library), and define a variable to use it:

2. In `setup()` add:

3. Somewhere above `loop()`, define a function to send the readings. The battery level is taken from `badger_read_vcc_mv` in [the Badgerboard library](https://github.com/nasys/badgerboard/blob/a2b1dfe1d00efa44664a8a5b05fd8074b4d61771/src/badger.cpp#L733-L758), but only supporting LilyPad’s ATmega32U4. It yields higher values than the one TTN’s `ttn.showStatus()` prints.

4. In `loop()`, send the readings; change `false` to `true` to include the battery level:

5. In the application’s payload function in TTN Console, decode using:

If the temperature readings seem high: of course, it’s an on-board sensor, and the board might be above room temperature. If things don’t work for low temperatures, then see [RN2483 problem temperature](https://www.thethingsnetwork.org/forum/t/rn2483-problem-temperature/3690).

### Known issues with the original Badgerboard library

Just for future readers/Google, some errors I got with the original library:

- `badger_print_EUI(devEUI)` only prints the last two bytes?

- Log shows (same for SF11) ([solved?](https://github.com/nasys/badgerboard/issues/4)):

- ~~The Fabo HTS221 library duplicated in the Badgerboard library may invalidate other non-Badgerboard sketches that use the FaBo library as well:~~ This [is solved](https://github.com/nasys/badgerboard/issues/3), but I did not test it:

And some warnings:

- I’m not an Arduino nor RN2483 expert.
- I wonder if the original Badgerboard library does better for battery live, and/or watchdog timers, and/or when waking from sleep.
- I’ve not yet checked if battery level is reported correctly by the TTN library, nor what happens after sleep.
- Most TTN code uses `loraSerial.begin(57600)` which works fine, and is Microchip’s documented default. The Badgerboard library uses 19200, but it seems [they are in doubt](https://github.com/nasys/badgerboard/blob/a2b1dfe1d00efa44664a8a5b05fd8074b4d61771/src/Sodaq_RN2483.h#L53-L55).

---

<div class="post-metadata">

**Author:** ![Caspar](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/caspar/32/46719_2.png) [@Caspar](https://www.thethingsnetwork.org/forum/u/Caspar)\
**Post date:** [February 5, 2017, 6:22pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/2 "2017-02-05T18:22:43Z")

</div>

To add: I got errors compiling older sketches after installing the badgerboard library because they included some kind of incompatible LowPower library. I had to remove the badgerboard/src/lowpower.h and badgerboard/src/lowpower.cpp file to get my old sketches to work again.

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [February 5, 2017, 8:50pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/3 "2017-02-05T20:50:06Z")

</div>

> [@arjanvanb](#):
>
> The battery level is taken from `badger_read_vcc_mv` in [the Badgerboard library](https://github.com/nasys/badgerboard/blob/a2b1dfe1d00efa44664a8a5b05fd8074b4d61771/src/badger.cpp#L733-L758), but only supporting LilyPad’s ATmega32U4. It yields higher values than the one TTN’s `ttn.showStatus()` prints.

~~I’m not sure what the battery function is measuring. Maybe only the LiPo connector, which I’m not currently using.~~ [Apparently](https://github.com/nasys/badgerboard/issues/7):

> this function measures MCU supply voltage (after LDO) so this can’t be over 3.3 but it starts falling if battery is emptying until 2.7V which is marked as MCU minimum operating voltage

When using the USB port, or when connecting a battery pack to `Vin` and `GND`, I always get 3.339 for the Badgerboard function, and always 3.283 for the response of the RN2483 `sys get vdd` command. (Another Badgerboard always reports 3.41 for the Badgerboard function and 3.325 for `Vdd`.)

The `sys get vdd` command is [documented by Microchip as](http://ww1.microchip.com/downloads/en/DeviceDoc/40001784B.pdf#page=16):

> 2.3.6.3 `sys get vdd`
> 
> Response: 0-3600 (decimal value from 0 to 3600)
> 
> This command informs the RN2483 module to do an ADC conversion on the VDD. The measurement is converted and returned as a voltage (mV).

[Badgerboard’s technical specifications](http://badgerboard.io/wp-content/uploads/2016/11/Badgerboard_UX2001A.pdf) do not indicate how `Vdd` is connected, but such a constant value would indicate a very good voltage regulator? 😉

> [@Caspar](#):
>
> I had to remove the badgerboard/src/lowpower.h and badgerboard/src/lowpower.cpp file to get my old sketches to work again.

Then I’m afraid the same applies to [the Sodaq\_RN2483 library](https://github.com/SodaqMoja/Sodaq_RN2483). (So: [reported](https://github.com/nasys/badgerboard/issues/3).)

---

<div class="post-metadata">

**Author:** ![Geab](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/geab/32/11631_2.png) [@Geab](https://www.thethingsnetwork.org/forum/u/Geab)\
**Post date:** [February 8, 2017, 7:20pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/4 "2017-02-08T19:20:16Z")

</div>

got this input from NAS [http://badgerboard.io/](http://badgerboard.io/) today:

> The first (hardware specific) steps of the tutorial [https://www.thethingsnetwork.org/docs/devices/uno/quick-start.html](https://www.thethingsnetwork.org/docs/devices/uno/quick-start.html) we recommend to replace with Badgerboard lib https//github.com/nasys/badgerboard (HW reasons). If you have TTN gateways nearby follow the TTN tutorial from Create an Account paragraph up till Message your Device since its about registering your device in their service. Badgerboard library will have helper functions for receiving data from gateway in few days, so that the TTN tutorial can be easily followed to the end.

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [February 8, 2017, 9:58pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/5 "2017-02-08T21:58:57Z")

</div>

> [@Geab](#):
>
> we recommend to replace with Badgerboard lib https//github.com/nasys/badgerboard (HW reasons)

Anything more specific than just _“hardware reasons”_?

Looking at the current state of their software and the lack of any documentation, I’d stick with the TTN software. Also, they responded [to one of the issues I raised](https://github.com/nasys/badgerboard/issues/5) saying:

> […] Badgerboard is meant mostly for making proof-of-concepts […]

It’s still a nice board, but I feel they should just document the wiring. Or open source the schematics [like they promised when it was still a Kickstarter project](https://www.thethingsnetwork.org/forum/t/open-source-hardware-lora-development-board-launched-on-kickstarter/4178/12), so we can figure out ourselves how to use the board. Just my 2 cents though.

---

<div class="post-metadata">

**Author:** ![Geab](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/geab/32/11631_2.png) [@Geab](https://www.thethingsnetwork.org/forum/u/Geab)\
**Post date:** [February 8, 2017, 10:01pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/6 "2017-02-08T22:01:46Z")

</div>

I asked them to comment here - I am pretty new to LORA and need to understand how to 🙂Your post is highly appreciated - will try to follow when I have time

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [February 9, 2017, 9:16am UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/7 "2017-02-09T09:16:57Z")

</div>

Just noticed that for “low” temperatures (say 10 ºC, not _really_ low) the FaBo library or the HTS221 sensors report values such as 1212.51 ºC.

These are then sent as negative values, due to the integer `121251` exceeding the maximum value for 2 byte signed integers, which have a range of −32,768 to 32,767. (The hexadecimal value `0x01D9A3` is sent as 2 bytes in `0xD9A3` which decodes back to -98.21 ºC.)

Will investigate later…

---

<div class="post-metadata">

**Author:** ![anni](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/anni/32/2842_2.png) [@anni](https://www.thethingsnetwork.org/forum/u/anni)\
**Post date:** [February 9, 2017, 2:13pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/8 "2017-02-09T14:13:55Z")

</div>

Our apologies for extremely delayed schemetic update, but it will be up for everyone in next week for sure!  
The hardware wiring is documented in here:  
[http://badgerboard.io/wp-content/uploads/2016/11/badgerboard\_pinout.pdf](http://badgerboard.io/wp-content/uploads/2016/11/badgerboard_pinout.pdf)

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [February 9, 2017, 2:27pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/9 "2017-02-09T14:27:00Z")

</div>

That’s good news, @anni. For the wiring I meant to refer to _internal_ wiring, such as wiring from MCU to RN2438, the sensor, the LiPo charger and all. That would allow people to figure out if something special is needed for the software. However, if the schematics are provided then that is surely covered, nice.

---

<div class="post-metadata">

**Author:** ![nox1989](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nox1989/32/25844_2.png) [@nox1989](https://www.thethingsnetwork.org/forum/u/nox1989)\
**Post date:** [February 16, 2017, 10:33am UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/10 "2017-02-16T10:33:59Z")

</div>

Hi!  
I have trying to connect my badgerboard with the bagerboard library with ABP and have no success.  
Im using the standard library for bagerboard and Lora\_temp\_hum\_ABP.ino. It’s compiling but I get some error when trying to send “Bootmsg”. I have used the debug and this is what I get.

Configured onboard temp/humidity sensor.  
badger temp/hum sensor  
devEUI 01:02:03:04:05:06:07:08  
Start initABP  
[initABP]  
[init]  
[wakeUp]  
[wakeUp]  
[resetDevice]  
[expectString] expecting RN.(RN2483 1.0.1 Dec 15 2015 09:38:09) found a match!  
[wakeUp]  
The device type is RN2483  
[setMacParam] devaddr = [array][expectString] expecting ok.(ok) found a match!  
[setMacParam] appskey = [array][expectString] expecting ok.(ok) found a match!  
[setMacParam] nwkskey = [array][expectString] expecting ok.(ok) found a match!  
[setMacParam] adr = off  
[expectString] expecting ok.(ok) found a match!  
[joinNetwork]  
[expectString] expecting ok.(ok) found a match!  
[expectString] expecting accepted.(accepted) found a match!  
[sleep]  
[wakeUp]  
[wakeUp]  
[sendReqAck]  
[setMacParam] retx = 2  
[expectString] expecting ok.[sendReqAck] Non-fatal error: setting number of retries failed.  
[wakeUp]  
extrawakeupeakeup  
[setMacParam] retx = 2  
[expectString] expecting ok.[macTransmit]  
[expectString] expecting ok.[lookupMacTransmitError]: accepted  
[lookupMacTransmitError]: found 14  
LoRa warning: accepted  
[sleep]

It’s looks like the string “accepted” is still in the line after the Joinnetwork gets accepted.

Anyone has experience the same or have an idea how to fix ?

Regards NoX

---

<div class="post-metadata">

**Author:** ![anni](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/anni/32/2842_2.png) [@anni](https://www.thethingsnetwork.org/forum/u/anni)\
**Post date:** [February 21, 2017, 8:01am UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/11 "2017-02-21T08:01:47Z")

</div>

Hi everyone, you can find the schematics from github: [https://github.com/nasys/badgerboard/tree/master/schematics](https://github.com/nasys/badgerboard/tree/master/schematics)

---

<div class="post-metadata">

**Author:** ![nox1989](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nox1989/32/25844_2.png) [@nox1989](https://www.thethingsnetwork.org/forum/u/nox1989)\
**Post date:** [February 21, 2017, 9:02am UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/12 "2017-02-21T09:02:04Z")

</div>

I just saw that you have uploaded the schematics. How do I open it? I’ve tried open the .sch with KiCad without success. Isn’t it easier to just upload a PDF or something also ?

Or can you recommend any freeware to open the schematics with ?

Regards NoX

---

<div class="post-metadata">

**Author:** ![anni](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/anni/32/2842_2.png) [@anni](https://www.thethingsnetwork.org/forum/u/anni)\
**Post date:** [February 21, 2017, 9:39am UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/13 "2017-02-21T09:39:51Z")

</div>

Hi @nox1989, the PDF file will be up soon as well, meanwhile you should be able to get PNG & SVG from [https://schematics.io](https://schematics.io)

---

<div class="post-metadata">

**Author:** ![anni](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/anni/32/2842_2.png) [@anni](https://www.thethingsnetwork.org/forum/u/anni)\
**Post date:** [February 21, 2017, 11:03am UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/15 "2017-02-21T11:03:15Z")

</div>

Here is the PDF file: [BB-M-1\_0.pdf](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/1/15db80010f731415739aabed2d0e4c54f6e35c0a.pdf) (163.7 KB)

---

<div class="post-metadata">

**Author:** ![BoRRoZ](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/borroz/32/44234_2.png) [@BoRRoZ](https://www.thethingsnetwork.org/forum/u/BoRRoZ)\
**Post date:** [February 21, 2017, 2:43pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/16 "2017-02-21T14:43:21Z")

</div>

![](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/5/5f6675fabf4669366943e85d9bb09a3f1ec2a95f.jpg)

---

<div class="post-metadata">

**Author:** ![Geab](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/geab/32/11631_2.png) [@Geab](https://www.thethingsnetwork.org/forum/u/Geab)\
**Post date:** [July 2, 2017, 10:38am UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/17 "2017-07-02T10:38:13Z")

</div>

Just want to hear how you Badger board is performing; we have had a TTN workshop here in Cph and now I can work on getting my Badger connected Greetings, Gernot

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [July 2, 2017, 3:13pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/18 "2017-07-02T15:13:17Z")

</div>

Sorry, I am not _really_ using them.

I still had one running that I also used for this topic, so: not using any of the Badgerboard libraries. Looking into that device now:

- It had somehow downgraded to SF12 (might be a TTN ADR issue?). Cycling its power made it go back to SF7.

- Like mentioned above, when running on a mains adapter, the reported voltage level is always the exact same value (3.283 for this very board, and 3.325 for another one I tested earlier).

- The temperature reading this one board gives is about 7 degrees Celcius too high at room temperature. (If not due to it being an onboard sensor, then maybe due to using different libraries; I did not compare to another Badgerboard.)

- It does not work on battery packs that have some smart power management, as it draws too little current, making my battery packs switch off automatically 🙂

Also, shame on me for not switching it off after I was done testing…

---

<div class="post-metadata">

**Author:** ![nox1989](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nox1989/32/25844_2.png) [@nox1989](https://www.thethingsnetwork.org/forum/u/nox1989)\
**Post date:** [July 5, 2017, 5:34am UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/19 "2017-07-05T05:34:07Z")

</div>

I have the same problem you have with the temperature sensor. It’s reading a couple degrees higher then any other temperature sensor I have.  
Also have the same problem with my powerbank. To low current so it switch off after 30 sec or so.

I have mailed badgerboard twice about the faulty temperature sensor and haven’t even got a replay on those mail.

I have also noticed that on their site its says “Stand by 200 uA”. While mine is in full sleep it draws around 400-500uA.

---

<div class="post-metadata">

**Author:** ![jezd](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jezd/32/46461_2.png) [@jezd](https://www.thethingsnetwork.org/forum/u/jezd)\
**Post date:** [December 18, 2017, 9:41am UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/20 "2017-12-18T09:41:06Z")

</div>

Updated my badger board RN2483 firmware to version 1.03 using the Lora java tools in the ink below, upload the TTN passthough example code first of course - works well.

[https://www.thethingsnetwork.org/forum/t/rn2903-au-firmware/7127/9?u=jezd](https://www.thethingsnetwork.org/forum/t/rn2903-au-firmware/7127/9?u=jezd)

Would be curious if those measuring sleep current find this update helps?

---

<div class="post-metadata">

**Author:** ![jezd](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jezd/32/46461_2.png) [@jezd](https://www.thethingsnetwork.org/forum/u/jezd)\
**Post date:** [December 27, 2017, 12:35pm UTC](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224/21 "2017-12-27T12:35:56Z")

</div>

Maybe I’ve missed something re the voltage measurement side of this thread, but as the atmega32u4 is sat behind the voltage regulator all we can expect is a steady 3.3v (approx, small variations withing the circuit can be expected) regardless of usb/lipo connection and regardless of the lipo charge level, looking at the circuit I am (entirely) guessing that the only way to get the lipo V state is a voltage divider setup?

[Next page](https://www.thethingsnetwork.org/forum/t/getting-badgerboard-to-work-with-ttn/5224.md?page=2)
