LoraWan gateway part 2:1CH gateway V6 with helteclora32 platformIO

https://github.com/things4u/ESP-1ch-Gateway is a very updated library, this is one of those TTN 1ch forwarders, the most updated as today(2020/09/22). The writer is making the V6 on PlatformIO. 

One good thing is that in platformIO the project files will include all the libraries in the project. So that you don't need to take care of the dependency of libs. I used to use arduino, when making larger projects, you will use a lot of libs,  it's not a big problem when you start the project and make it work. But as time gose by, libs would be updated or renewed and get yourself into  troubles of compatibility between libraries. and it's not done yet, some times when arduino board profiles make large change, some libs can fail...especially on newer boards, such esp32/8266...

With PlatformIO, we get ride of the compatibility problem, since you include the need libs with correct version into the project, I'm not sure if the board definitions of platfromIO have impact on libs, but at least you can already get ride of the libs problem.

with  sthing4u V6 on platform IO, the first board I try is 

heltec lora32 433Mhz version I purchase few years ago.

as this article description mine is a v2, but it's not....

I tried following board setting and pin out(used and defined in loraModem.h) in the ini file:

heltec_wifi_lora_32_V2 with pin_out=5, board keep on reseting

heltec_wifi_lora_32_V2 with pin_out=4, board keep on reseting

heltec_wifi_lora_32 with pin_out=4, works...

[env:Gateway_38]
platform = espressif32
board = heltec_wifi_lora_32
framework = arduino
build_flags =
  -D _PIN_OUT=4
  -D _WIFIMANAGER=0
  -D _SPIFFS_FORMAT=0
  -D _OLED=1
  -D _DUSB=1
  -D _PROFILER=1
;  -D _JSONENCODE=1
  -D _MAXSEEN=10
  -D _STAT_LOG=0
upload_protocol = esptool
board_build.flash_mode = qio
upload_speed = 115200
monitor_speed = 115200

terminal output

--- Miniterm on COM3  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57
rst:0x10 (RTCWDT_RTC_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6364
entry 0x400806b8
E (1381) SPIFFS: mount failed, -10025
[E][SPIFFS.cpp:72] begin(): Mounting SPIFFS failed! Error: -1
SPIFFS.begin: not found, formatting
ets Jun  8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57
rst:0x10 (RTCWDT_RTC_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6364
entry 0x400806b8
SPIFFS begin
Do Asserts
readConfig ERR:: file=/gwayConfig.txt does not exist ..
readConfig:: Error reading config file
setup:: readGwayCfg: ERROR readGwayCfg Failed
MAC: 24:0a:c4:83:2f:58, len=17
0:0:2. WlanConnect SSID=H&M
WlanStatus:: CONNECTED ssid=H&M
Host=esp32-832f58 WiFi Connected to H&M on IP=192.168.0.25
Local UDP port=1700
UDP Connection successful
Gateway ID: 240ac4ffffffff456, Listening at SF7 on 433.18 MHz.
resolveHost:: OK=nl.pool.ntp.org IP=5.79.75.37
Time set=Wed 23-09-2020 10:24:05
resolveHost:: OK=router.eu.thethings.network IP=52.169.76.203
setupOta:: Started
Ready IP address: 192.168.0.25
WARNING:: readSeen, history file not exists /gwaySeen.txt
WWW Server started on port 80
WARNING:: writeSeen, file not exists=/gwaySeen.txt
OLED_ADDR=0x3C
 --- Setup() ended, Starting loop() ---
v readUdp:: NTP msg rcvd
[E][WebServer.cpp:617] _handleRequest(): request handler not found

register to TTN with the gateway ID shown form the debug message...


it's connected...
and you can get into the config web of gateway


TTGO board

according to the article, my board is a V2, but it's not in the platformIO definition.
in the ini file. I tried 
ttgo-lora32-v2 with pinout 4 and pinout5, code can't be compiled...

ttgo-lora32-v1 and pin4 then it does work but with no IIC, with pinout5, it works..
board = ttgo-lora32-v1
framework = arduino
build_flags =
  -D _PIN_OUT=5

from the terminal this time it shows the ACK..
resolveHost:: OK=nl.pool.ntp.org IP=162.159.200.123
Time set=Thu 24-09-2020 08:11:02
resolveHost:: OK=router.eu.thethings.network IP=52.169.76.203
setupOta:: Started
Ready IP address: 192.168.0.26
WWW Server started on port 80
OLED_ADDR=0x3C
 --- Setup() ended, Starting loop() ---
v PUSH_ACK:: token=53037, size=4, IP=52.169.76.203, port=1700, protocol=2
v PULL_ACK:: token=26791, size=4, IP=52.169.76.203, port=1700, protocol=2
v PULL_ACK:: token=65343, size=4, IP=52.169.76.203, port=1700, protocol=2


I got it worked on us frequency plan, since most lorawan projects comes with the frequency plan in LoRaWAN 1.0.2 rvB Regional Parameters , where you there is only AS frequency plan for asia area.

Build for other frquency plan

in configGaway.h add the name of your region to define with. I added AS923_925 which is AS2 plan.

Then goes to the end of file, modify the TTNserver, mine is: "router.as2.thethings.network"
make it fit with gateway config: https://github.com/TheThingsNetwork/gateway-conf



Then go to loraModem.h and add your frequency plan. The frequency table has to match to gateway config frequency plan. https://github.com/TheThingsNetwork/gateway-conf

below is my setup for AS2 and AS1.

the colons are seperated into 2 part, the fist part is the uplink ones, 2nd part is the down link ones. each set has description on frequency, bandwidth, spread factor(start of SF, and end of SF range).

for example, for AS1, the first roll reads:

923200000125712, 923200000125712},   

means 923.2Mhz is used for uplink with BW=125, spread factor 7 to 12

same config as down link.

//AS920_923 AS1
#elif defined(AS920_923)
// AS1 plan or TTN/Lora frequencies For Japan, Malaysia, Singapore 
vector freqs [] = { 
    { 923200000125712923200000125712},            // Channel 0, 923.2 MHz primary
    { 923400000125712923400000125712},            // Channel 1, 923.4 MHz primary
    { 922200000125712922200000125712},            // Channel 2, 922.2 MHz primary
    { 922400000125712922400000125712},            // Channel 3, 922.4 MHz primary
    { 922600000125712922600000125712},            // Channel 4, 922.6 MHz primary
    { 922800000125712922800000125712},            // Channel 5, 922.8 MHz primary
    { 923000000125712923000000125712},            // Channel 6, 923.0 MHz primary 
    { 922000000125712922000000125712} ,           // Channel 7, 922.0 MHz primary
    { 9221000002507,  7,         0,   00,  0}             // Channel 8, 922.1 SF7BW250 MHz 
};

//AS923_925
#elif defined(AS923_925)
// AS2 plan or TTN/Lora frequencies For Brunei, Cambodia, Hong Kong, Indonesia, Laos, Taiwan, Thailand, Vietnam
vector freqs [] = { 
    { 923200000125712923200000125712},            // Channel 0, 923.2 MHz primary
    { 923400000125712923400000125712},            // Channel 1, 923.4 MHz primary
    { 923600000125712923600000125712},            // Channel 2, 923.6 MHz primary
    { 923800000125712923800000125712},            // Channel 3, 923.8 MHz primary
    { 924000000125712924000000125712},            // Channel 4, 924.0 MHz primary
    { 924200000125712924200000125712},            // Channel 5, 924.2 MHz primary
    { 924400000125712924400000125712},            // Channel 6, 924.4 MHz primary 
    { 924600000125712924600000125712} ,           // Channel 7, 924.6 MHz primary
    { 9245000002507,  7,         0,   00,  0}             // Channel 8, 917.5 SF7BW250 MHz 
};

Note that in TTN frequency plan there is  a FSK channel, I did not list it.


With my TTGO , it works fine.

but the OLED display is inverted on my TTGO, so I went to oLED.ino comment out few  flips and it works fine.

//display.flipScreenVertically();


I have a Pi gateway runs on AS1 plan, and this TTGO 1CH gateway runs on AS2.

I currently has a AS1 plan device running on OTAA, from time to time, the AS2 TTGO gets data as well, since there are few frequencies in common. 






留言

這個網誌中的熱門文章

Heltec ESP32+OLED+Lora, hardware testing

micro SD card for ESP32, on lolin32 with OLED and heltec 32 lora oled

Install Network Time Protocol(NTP) on BeagleBone with Angstrom linux and set local time zone