Skip to content

Commit a2da07e

Browse files
authored
Documentation for TTN and Helium (#12)
* option for 1.0.4 (Helium network) * documentation update * fix spell check * fix old link
1 parent bdb4394 commit a2da07e

File tree

8 files changed

+380
-50
lines changed

8 files changed

+380
-50
lines changed

.github/workflows/spell-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
- name: Spell check
1717
uses: codespell-project/actions-codespell@master
1818
with:
19-
ignore_words_list: ned
19+
ignore_words_list: ned, ser

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.vscode/launch.json
55
.vscode/ipch
66
.vscode/extensions.json
7+
screenshot/*.png

README.md

Lines changed: 65 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<!-- ## TTGO T-Beam Tracker for The Things Network and/or The Helium Network -->
2-
# LILYGO T-Beam Mapper for the Helium or TTN LoRaWAN Network.
3-
2+
# LILYGO T-Beam Mapper for the Helium or TTN LoRaWAN Network
43

54
This code loads onto LilyGo TTGO T-Beam v1.2 board with AXP2101 and SX1262 or SX1276 to make a LoraWan (Helium/TTN) Network Mapper. To build one: download this build, configure some files, and upload it to your device. Go travel the world to contribute to the TTN/Helium Network Coverage Maps!
65

@@ -16,21 +15,57 @@ Details for the Mapper project can be found [TTN Mapper](https://ttnmapper.org/)
1615

1716
The Mapper is intended to be highly active while the vehicle is in motion, and quieter when the vehicle is stationary. By default, it is not miserly with Data Credits. If you want to conserve Data Credits or battery power, tune the configuration to send packets less frequently.
1817

19-
### But do I get PAID for Mapping?
18+
## Supported Hardware
2019

21-
No, you do not. I put this here because it seems to be the #1 FAQ. You do not earn HNT or Data Credits by mapping. Mapping costs you very little -- One Penny (USD $0.01) for every thousand mapping packets. It helps the Helium network by providing a coverage map, and it helps you by providing clarity on your own local Helium environment. It's all volunteer.
20+
I tested this software on LilyGo [TTGO T-Beam v1.2](https://www.lilygo.cc/products/t-beam-softrf?variant=43170155692213) devices, all on **EU868**. Others have enjoyed success on other worldwide bands, with the matching device. These are commonly available as "Meshtastic" devices from AliExpress, Amazon, Banggood, eBay, etc, usually as a kit with an unsoldered OLED screen and SMA antenna for around USD $30.00.
2221

23-
### But do I get to flag and delist spoofing gamer Hotspots?!
22+
## Quick Setup
2423

25-
No, you do not. It's the #2 FAQ. The Mapper data and coverage maps are not involved in any POC challenges or used for gaming denylists.
24+
Settings for the console and in `credentials.h`
2625

27-
## Supported Hardware
26+
### The Things Network TTN
27+
28+
Console:
29+
30+
- Frequency plan: Europe 863-870 MHz (SF9 for RX2 - recommended)
31+
- LoRaWAN version: LoRaWAN Specification 1.1.0
32+
- Regional Parameters version: RP001 Regional Parameters 1.1 revision A
33+
- Payload formatters: Uplink: JavaScript functions and paste: /console-decoders/unified_decoder.js
34+
- End devices: General settings: Join settings: Resets join nonces: Enabled
35+
36+
credentials.h:
37+
38+
- uncomment #define USE_NWK_KEY
39+
- RADIOLIB_LORAWAN_JOIN_EUI: all 0
40+
- RADIOLIB_LORAWAN_DEV_EUI: copy msb from console
41+
- RADIOLIB_LORAWAN_JOIN_EUI: copy msb from console
42+
- RADIOLIB_LORAWAN_APP_KEY: copy msb from console
43+
- RADIOLIB_LORAWAN_NWK_KEY: copy msb from console
44+
45+
### Helium
46+
47+
Console:
48+
49+
- Region: EU868
50+
- MAC version: LoRaWAN 1.0.4
51+
- Regional Parameters revision: A
52+
- ADR algorithm: Default ADR algorithm (LoRa only)
53+
- Join OTAA/ABP: Device supports OTAA
54+
- Codec: JavaScript functions and paste: /console-decoders/unified_decoder.js
55+
- Device Configuration: Disable frame-counter validation
56+
57+
credentials.h:
2858

29-
I tested this software on (many) LilyGo [TTGO T-Beam v1.2](https://www.lilygo.cc/products/t-beam-softrf?variant=43170155692213) devices, all on **EU868**. Others have enjoyed success on **EU688** and other worldwide bands, with the matching device. These are commonly available as "Meshtastic" devices from AliExpress, Amazon, Banggood, eBay, etc, usually as a kit with an unsoldered OLED screen and SMA antenna for around USD $30.00.
59+
- comment #define USE_NWK_KEY
60+
- RADIOLIB_LORAWAN_JOIN_EUI: copy msb from console
61+
- RADIOLIB_LORAWAN_DEV_EUI: copy msb from console
62+
- RADIOLIB_LORAWAN_JOIN_EUI: copy msb from console
63+
- RADIOLIB_LORAWAN_APP_KEY: copy msb from console
64+
- RADIOLIB_LORAWAN_NWK_KEY: will not be used
3065

3166
### Semtech LoRa Radio
3267

33-
This build uses the [RadioLib Library](https://github.com/jgromes/RadioLib/) for LoRaWAN on the Semtech SX1262 or SX1276 radio modules.
68+
This Fork uses the [RadioLib Library](https://github.com/jgromes/RadioLib/) for LoRaWAN on the Semtech SX1262 or SX1276 radio modules.
3469

3570
### OLED Display
3671

@@ -47,12 +82,15 @@ If you incorrectly power the OLED, short connections, or damage the Pin 21/22 co
4782
## Mandatory Configuration
4883

4984
Before Building and Uploading, you will probably want to inspect or change some items in these three files:
50-
- `platformio.ini`
51-
- `main/configuration.h`
52-
- `main/credentials.h`
85+
86+
- `main/configuration.h`
87+
- `main/credentials.h`
88+
- `platformio.ini`
89+
5390
The comments and text below will guide you on what values to look out for.
5491

5592
### Geographic Region, and Frequency
93+
5694
By default, this build is for the **EU868** region. Change the declaration in `credentials.h` for a different locale, to select the correct operating rules and frequency for your country.
5795

5896
### PlatformIO Communication port
@@ -63,11 +101,11 @@ On MacOS, it can be significantly more complicated to connect PlatformIO to your
63101

64102
### Device IDs
65103

66-
Each LoRaWAN device is identified by the three OTAA values used in Joining the network: `DevEUI`, `AppEUI`, and `AppKey`.
104+
Each LoRaWAN device is identified by the three OTAA values used in Joining the network: `DevEUI`, `NwkKey`, and `AppKey`.
67105

68-
You should choose your own private `AppKey` value in `credentials.cpp`. Either take the random value generated by the new Console Device entry, or make up one of your own. Read the notes in `credentials.cpp` for details. The value in the build must match the value in Console, regardless of how you achieve that.
106+
You should choose your own private `AppKey` value in `credentials.h`. Either take the random value generated by the new Console Device entry, or make up one of your own. Read the notes in `credentials.h` for details. The value in the build must match the value in Console, regardless of how you achieve that.
69107

70-
By default, the `DevEUI` is generated automatically to be unique to each unit, but you may want to hardcode it in `credentials.cpp` instead. There is an explanation there of why you might want to go either way.
108+
By default, the `DevEUI` is generated automatically to be unique to each unit, but you may want to hardcode it in `credentials.h` instead. There is an explanation there of why you might want to go either way.
71109

72110
### Mapper uplink period and behavior
73111

@@ -164,6 +202,7 @@ Regardless of battery or sleep state, the Mapper will power on and resume when U
164202
### Buttons
165203

166204
The TTGO T-Beam has three buttons on the underside:
205+
167206
1. Power: Nearest the USB connector is the Power button.
168207
- Menu: **short press** while on will enter the Menu display. Use the Power button to step through options, and the **Middle** button to select a menu entry.
169208
- Off: **long press** on this button will turn the unit completely off (5 seconds).
@@ -181,6 +220,7 @@ The device outputs debugging information on the USB Serial connection at 115200b
181220
#### ESP32 Bootloader
182221

183222
On powerup or reset, the very first messages will be from the Bootloader built into the ESP system. This is before any Mapper software runs and should look something like this:
223+
184224
```
185225
ets Jul 29 2019 12:21:46
186226
@@ -218,7 +258,9 @@ On startup, the USB Serial port will print the DevEUI, AppID, and AppKey values,
218258
For some, this is the easiest way to configure a new device. Upload the software, monitor the first boot, then cut & paste the values from the messages into the Console "New Device" setup.
219259

220260
##### Saved Preferences
261+
221262
The Mapper will retain certain settings across power cycles.
263+
222264
* Minimum distance
223265
* Stationary Tx Interval (min time)
224266
* Rest Wait (time until slower reporting)
@@ -299,9 +341,11 @@ The T-Beam usually comes as a kit with a 0.96" SSD1306 OLED screen that you must
299341
The OLED screen is always on when operating, as it uses only 10mA.
300342

301343
#### Status Bar
344+
302345
Operating Status is shown in the top two rows, with a running 4-line message log in the region below the line.
303346

304347
The top status line alternates between two displays every few seconds:
348+
305349
- `#ABC` is the last three hex digits of your DevEUI, so you can match it to the correct device in Console. Handy if you have several Mappers that look the same.
306350
- `4.10v` is the battery voltage
307351
- `80%` is the charge level of the the battery.
@@ -337,16 +381,17 @@ The Payload Port and byte content have been selected to match the format used by
337381
A custom Decoder Function translates the payload bytes into a set of JSON values required by the Integrations for both Mapper and Cargo.
338382
This turns the Base64 Payload into values for Lat, Long, Altitude, Speed, Battery, and Sats.
339383

340-
This [Decoder Function](https://github.com/designer2k2/tbeam-lorawan-mapper/blob/RadioLib_SX1262/console-decoders/unified_decoder.js)) can be pasted directly into the Console custom function. Do not use Decoder functions from other builds or instructions! The Uplink decoding is specific to the software that made the packet, so it has to match. (Note that HDOP is not sent in this data.)
384+
This [Decoder Function](https://github.com/designer2k2/tbeam-lorawan-mapper/blob/main/console-decoders/unified_decoder.js) can be pasted directly into the Console custom function. Do not use Decoder functions from other builds or instructions! The Uplink decoding is specific to the software that made the packet, so it has to match. (Note that HDOP is not sent in this data.)
341385

342386
### Grafana integration for custom maps
343387

344388
If you want to maintain your own device map, there is an excellent [Grafana guide](https://github.com/takeabyte/helium_mapper_grafana) by @takeabyte (`@friends just call me bob`) available.
345389

346390
## Downlink
391+
347392
This builds adds the option to reconfigure the Mapper remotely via Helium Downlink (network to device). You can change the maximum Time Interval, Distance, and Battery Cut-off voltage remotely.
348393

349-
### Format your Downlink Payload.
394+
### Format your Downlink Payload
350395

351396
You can use the `console-decoders/downlink_encoder.py` Python script to convert your intent into a Base64 Payload.
352397
```
@@ -395,12 +440,11 @@ This build is a modification of work by many experts, with input from the [Heliu
395440

396441
The Fork history here in Github shows the lineage and prior work, including https://github.com/helium/longfi-arduino/tree/master/TTGO-TBeam-Tracker
397442

398-
This code was originally developed for use on The Things Network (TTN) it has been edited/repurposed for use with the Helium Network.
443+
This code was originally developed for use on The Things Network (TTN) it has been edited/repurposed for use with the Helium Network. And then back to be universal for both.
399444

400-
This version is based on a forked repo from github user [kizniche] https://github.com/kizniche/ttgo-tbeam-ttn-tracker. Which in turn is based on the code from [xoseperez/ttgo-beam-tracker](https://github.com/xoseperez/ttgo-beam-tracker), with excerpts from [dermatthias/Lora-TTNMapper-T-Beam](https://github.com/dermatthias/Lora-TTNMapper-T-Beam) to fix an issue with incorrect GPS data being transmitted to the network. Support was also added for the 915 MHz frequency (North and South America).
445+
This version is based on a forked repo from github user [Max-Plastix](https://github.com/Max-Plastix/tbeam-helium-mapper). Which is based on [kizniche](https://github.com/kizniche/ttgo-tbeam-ttn-tracker). Which in turn is based on the code from [xoseperez/ttgo-beam-tracker](https://github.com/xoseperez/ttgo-beam-tracker), with excerpts from [dermatthias/Lora-TTNMapper-T-Beam](https://github.com/dermatthias/Lora-TTNMapper-T-Beam) to fix an issue with incorrect GPS data being transmitted to the network. Support was also added for the 915 MHz frequency (North and South America).
401446

402-
This is a LoRaWAN node based on the [TTGO T-Beam](https://github.com/LilyGO/TTGO-T-Beam) development platform using the SSD1306 I2C OLED display.
403-
It uses a RFM95 by HopeRF and the MCCI LoRaWAN LMIC stack. This sample code is configured to connect to The LoRaWan network using the US 915 MHz frequency by default, but can be changed to EU 868 MHz.
447+
This is a LoRaWAN node based on the [TTGO T-Beam](https://github.com/LilyGO/TTGO-T-Beam) development platform using the SSD1306 I2C OLED display. This sample code is configured to connect to The LoRaWan network using the US 915 MHz frequency by default, but can be changed to EU 868 MHz.
404448

405449
NOTE: There are now 2 versions of the TTGO T-BEAM, the first version (Rev0) and a newer version (Rev1). The GPS module on Rev1 is connected to different pins than Rev0. This code has been successfully tested on REV0, and is in the process of being tested on REV1. See the end of this README for photos of each board.
406450

main/credentials.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,34 @@
66
#include <RadioLib.h>
77

88
/*
9-
This is where you define the three key values that map your Device to the Helium Console.
9+
This is where you define the three key values that map your Device to the LoRaWAN Console.
1010
All three values must match between the code and the Console.
1111
12-
There are two general ways to go about this:
13-
1) Let the Console pick random values for one or all of them, and copy them here in the code.
14-
-or-
15-
2) Define them here in the code, and then copy them to the Console to match these values.
16-
17-
When the Mapper boots, it will show all three values in the Monitor console, like this:
18-
19-
DevEUI (msb): AABBCCDDEEFEFF
20-
APPEUI (msb): 6081F9BF908E2EA0
21-
APPKEY (msb): CF4B3E8F8FCB779C8E1CAEE311712AE5
22-
23-
This format is suitable for copying from Terminal/Monitor and pasting directly into the console as-is.
24-
2512
If you want to take the random Console values for a new device, and use them here, be sure to select:
2613
Device EUI: msb
2714
App Key: msb
2815
NwK Key: msb
2916
in the Console, then click the arrows to expand the values with comma separators, then paste them below.
3017
*/
18+
19+
/*
20+
NwkKey option for LoRaWAN 1.1.x
21+
- For LoRaWAN 1.0.x, comment out the #define line.
22+
- For LoRaWAN 1.1.x, uncomment it and provide your NwkKey.
23+
*/
24+
//#define USE_NWK_KEY
25+
3126
// joinEUI - previous versions of LoRaWAN called this AppEUI
3227
// for development purposes you can use all zeros - see wiki for details
33-
#define RADIOLIB_LORAWAN_JOIN_EUI 0x0000000000000000
28+
#define RADIOLIB_LORAWAN_JOIN_EUI 0xa09284515663b1a5
3429

3530
// the Device EUI & two keys can be generated on the TTN console
3631
#ifndef RADIOLIB_LORAWAN_DEV_EUI // Replace with your Device EUI
37-
#define RADIOLIB_LORAWAN_DEV_EUI 0x70B3D57ED0066B6E
32+
#define RADIOLIB_LORAWAN_DEV_EUI 0x044e31696f7f04de
3833
#endif
3934
#ifndef RADIOLIB_LORAWAN_APP_KEY // Replace with your App Key
4035
#define RADIOLIB_LORAWAN_APP_KEY \
41-
0x74, 0x5D, 0x28, 0x7B, 0xEF, 0xFB, 0x51, 0xFF, 0x4A, 0x89, 0xDC, 0xF7, 0x95, 0x3B, 0x16, 0x4D
36+
0x4B, 0x8F, 0xA9, 0x31, 0xAB, 0x2C, 0x68, 0x5B, 0x14, 0x3C, 0x49, 0xB0, 0x7B, 0xFD, 0x35, 0xE3
4237
#endif
4338
#ifndef RADIOLIB_LORAWAN_NWK_KEY // Put your Nwk Key here
4439
#define RADIOLIB_LORAWAN_NWK_KEY \
@@ -56,8 +51,13 @@ const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
5651
uint64_t joinEUI = RADIOLIB_LORAWAN_JOIN_EUI;
5752
uint64_t devEUI = RADIOLIB_LORAWAN_DEV_EUI;
5853
uint8_t appKey[] = {RADIOLIB_LORAWAN_APP_KEY};
59-
uint8_t nwkKey[] = {RADIOLIB_LORAWAN_NWK_KEY};
6054

55+
// Conditionally define nwkKey. If the macro doesn't exist, it becomes a null pointer.
56+
#ifdef USE_NWK_KEY
57+
uint8_t nwkKey[] = {RADIOLIB_LORAWAN_NWK_KEY};
58+
#else
59+
uint8_t* nwkKey = NULL;
60+
#endif
6161

6262
// do not modify below easily, switch between radios in the platformio.ini file build_flags section.
6363

main/main.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
/**
22
* LoRaWan Mapper build for LilyGo TTGO T-Beam v1.2 boards.
3+
*
4+
* Copyright (C) 2025 designer2k2 Stephan M.
35
* Copyright (C) 2021-2022 by Max-Plastix
46
*
5-
* This is a development fork by Max-Plastix hosted here:
6-
* https://github.com/Max-Plastix/tbeam-helium-mapper/
7+
* This is a fork by designer2k2 hosted here:
8+
* https://github.com/designer2k2/tbeam-lorawan-mapper
79
*
810
* This code comes from a number of developers and earlier efforts, visible in
911
* the full lineage on Github, including:
1012
*
11-
* Fizzy, longfi-arduino, Kyle T. Gabriel, and Xose Pérez
13+
* Max-Plastix, Fizzy, longfi-arduino, Kyle T. Gabriel, and Xose Pérez
1214
*
1315
* GPL makes this all possible -- continue to modify, extend, and share!
1416
*/
@@ -139,8 +141,6 @@ esp_sleep_source_t wakeCause; // the reason we booted this time
139141

140142
char buffer[40]; // Screen buffer
141143

142-
143-
String lorawanServer;
144144
uint8_t lorawanAck = false;
145145
uint8_t lorawan_sf; // prefs LORAWAN_SF
146146
uint8_t lorawan_tx_power;
@@ -573,7 +573,6 @@ void lorawan_restore_prefs(void) {
573573
if (p.begin("lora", true)) { // Read-only
574574
lorawanAck = p.getUChar("ack", LORAWAN_CONFIRMED_EVERY);
575575
lorawan_sf = p.getUChar("sf", LORAWAN_SF);
576-
lorawanServer = p.getString("server", "helium");
577576
lorawan_tx_power = p.getUChar("tx_power", 16);
578577
// a buffer that holds all LW base parameters that should persist at all times!
579578
uint8_t BbufferNonces[RADIOLIB_LORAWAN_NONCES_BUF_SIZE];
@@ -612,7 +611,6 @@ void lorawan_save_prefs(void) {
612611
Preferences p;
613612
Serial.println("Saving lorawan prefs.");
614613
if (p.begin("lora", false)) {
615-
p.putString("server", lorawanServer);
616614
p.putUChar("sf", lorawan_sf);
617615
p.putUChar("ack", lorawanAck);
618616
p.putUChar("tx_power", lorawan_tx_power);

0 commit comments

Comments
 (0)