This is a write up of my experience migrating a project from a Heltec Wifi LoRa V2 board to the new V3 board.
Platform definitions
First I changed in platformio.ini file:
board = heltec_wifi_lora_32_V3
This did not work, missing board definition. I tracked down what it would take to support the heltec V3 boards in platformio. It required changes to 3 repos:
- platformio/platform-espressif32: needs to contain board definitions. There was a pending PR which was blocked on an pin definition issue which I fixed here.
- espressif/arduino-esp32: contains pin definitions for each board. This repo did have entries for some of the heltec V3 boards, but the pin definitions were wrong or missing in some cases. I fixed them here but there is a pending followup PR which adds some missing pins here needed to make the heltec helper library work.
- HelTecAutomation/Heltec_ESP32: contains heltec helper library which can be used to configure and access things like the screen, wifi, and lora. Needs to be updated to support V3 boards. I have a pending a PR for that here.
Until these PRs to get merged, you can point platformio.ini to my forks of these repos:
[env:ap_device]
platform = espressif32
board = heltec_wifi_lora_32_V3
framework = arduino
platform_packages = framework-arduinoespressif32 @ https://github.com/platypii/arduino-esp32.git
lib_deps = https://github.com/platypii/Heltec_ESP32.git
Note: I will delete these repos when the upstream PRs are merged.
Moving away from heltec.h
The heltec helper library does not support the latest V3 boards. I made a PR to the heltec helper repo which fixes the basic functionality, but it has been pending for 2 weeks with no reviews. Hopefully this will get updated at some point. But I decided to move away from the heltec library and towards using 3rd party libraries directly, which will be easier to update in the future.
The heltec library contains an outdated copy-and-paste of two libraries: SSD1306Wire and arduino-LoRa. So my first goal was to use these upstream libraries.
In platformio.ini change lib_deps
from the heltec library to:
lib_deps =
sandeepmistry/LoRa
thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays
Some additional minor changes to my code were required:
- Remove
Heltec.init()
- Change
#include "heltec.h"
to#include "LoRa.h"
and#include "SSD1306Wire.h"
- Remove 2nd parameter from
LoRa.begin()
- Define display
SSD1306Wire display(0x3c, SDA_OLED, SCL_OLED);
- Replace
Heltec.display->
withdisplay.
- Add a reset before screen initialization. Copied from the heltec library, and was necessary to make the screen work:
pinMode(RST_OLED, OUTPUT);
digitalWrite(RST_OLED, LOW);
delay(20);
digitalWrite(RST_OLED, HIGH);
See commit here.
With these changes I was able to use the V2 boards but without using the heltec library.
V3 board
With my changes, the screen, bluetooth, and wifi all worked on the V3 heltec board. LoRa did not. I did some searching, and people recommended using RadioLib for its support of the new SX1262 lora chip. RadioLib has a very different API than arduino-LoRa used in the heltec library. It took some fighting to find the right config settings to match the arduino-LoRa settings but it was possible to do while still testing on the V2 boards.
When moving to the V3 board, the LoRa chip was changed from the SX1276 to the SX1262. I had to change the initialization from:
SX1276 radio = new Module(SS, 26, RST_LoRa, DIO0);
To:
SX1262 radio = new Module(SS, DIO0, RST_LoRa, BUSY_LoRa);
This got the radio to work on the V3. Hooray! However one last issue remained. I could not get the V2 to talk to the V3 boards over LoRa.
Some googling showed that there were changes made to the codeword parameter.
https://blog.classycode.com/lora-sync-word-compatibility-between-sx127x-and-sx126x-460324d1787a
I pulled out my SDR and tried to see if it was a tuning issue, or if there was some obvious difference in how the radios were transmitting. There was a noticable difference in transmission length, even for the same packet data. I don’t know why.
But my project does not depend on V2 talking to V3 so although I would like to solve this issue, it’s not critical for my project.
Hope that this write up helps someone. And if you work at Heltec, approve and merge my PR please.