Setup a Challenger 2040 LoRa in VS Code

I have recently been wanting to play with LoRa radios because reasons. This gives me a way of sending short messages between devices using a lightweight protocol with a range of a couple of kilometres on a bad day. I ended up picking up a Challenger 2040 LoRa manufactured by iLabs from The PiHut, mostly because all the others were out of stock. I then spent three days just getting the radio to initialize in my code.

Challenger RP2040 LoRa

As the Challenger 2040 LoRa has a lot of unhelpful documentation, this is a practical getting started guide using Platform IO, an alternative to the Arduino IDE, in Visual Studio Code on Windows for this board. Some familiarity with VS Code and Platform IO is assumed.

Installing RP2040 Support for Platform IO

If you have used the Pico 2040 before then you have probably done this already, but if not here is a summary for Windows users – this is for a new installation. The full instructions are on readthedocs.io, if you have it installed already and see the depreciation warning, check the full instructions:

Prerequisites:

  • Exit from VS Code
  • Enable long path support:
    1. Windows 10/11 Home users may need to activate gpedit, see this Major Geeks how-to
    2. Click Window key and type gpedit.msc, then press the Enter key. This launches the Local Group Policy Editor.
    3. Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem.
    4. Double click Enable NTFS/Win32 long paths and close the dialog.
  • Install git from: https://git-scm.com/download/win using the defaults.
  • Restart the computer – this adds git to the path.
  • Open an Administrator Console/Terminal (Terminal > Right Mouse Click and choose Run As Administrator), then:
  • Enable long paths in git: git config ——system core.longpaths true

Adding to Platform IO
Now load up VS Code, and in Platform IO create new project, Give it a name (rp2040test) and select Raspberry Pi Pico as the board and Arduino as the framework.

Pi Pico - Platform IO Selection
Pi Pico – Platform IO Selection

Click Finish and let it do its thing. This will give us a platformio.ini file to edit.

Update this file to be like:

When you save the file it takes a few minutes to automatically add the RP2040 SDK and long list of development boards including the Challenger 2040 LoRa to those available in Platform IO. You can now create a new project and choose the Challenger 2040 LoRa from the list of boards, which will give you this default platformio.ini:

but I prefer to use the one below.

Initializing the LoRa Radio

This is the part that took me the most time to get working, here is the cheat-sheet. Set platformio.ini as:

this also includes the LoRa library.

This is a modified version of the LoRaDumpRegisters.ino example just to show it working. The changes are to have it selecting SPI1 and setting the correct pins for the radio. Remember to set the correct frequency for your region:

The expected output on the serial port is a list of numbers in hexadecimal format ending with “LoRa init succeeded.”

I hope this is useful and saves much faffing about.

One thought on “Setup a Challenger 2040 LoRa in VS Code”

  1. Many thanks Karl. An excellent guide to getting the Challenger LoRa board configured in PlatformIO and VSC…as well as the super-useful notes on de-faffing the LoRa init 🙂 Thanks again!

Comments are closed.