Skip to content

4. First Steps with CatWAN USB Stick

Yoshio Garcia edited this page Dec 29, 2023 · 5 revisions

Downloading and installing Arduino IDE

Click here to read the “Download and install Arduino IDE” article.

After installing the Arduino IDE you should see the next window.

After installing the Arduino IDE, it will be required to install the libraries needed to start with the CatWAN Arduino LoRa Shield.

Installing CatWAN USB Stick Cores

To update a previous version, click on Electronic Cats SAMD Core for Arduino in Boards Manager, then click Update.

Note: The Electronic Cats Core requires Arduino IDE 1.6.7 or above (including 1.8.x).

To use the Electronic Cats boards it is necessary to add the Electronic Cats boards reference to your Arduino IDE

  1. Go to Arduino IDE>File>Preferences.
  2. Click on the button next to the Additional Boards Manager URLs field.
  3. Add https://electroniccats.github.io/Arduino_Boards_Index/package_electroniccats_index.json.
  4. Save preferences, then go to Arduino IDE>Tools>Board>Boards Manager.

For SAMD21 version

  1. Install the Arduino SAMD Boards (32-bits ARM Cortex-M0+) package. Use version the latest version.

  1. Install the latest version of the Electronic Cats SAMD Boards package.

  1. Close Boards Manager, then go to Tools>Board>Electronic Cats SAMD (L)(C) Core for Arduino>Electronic Cats CatWAN USB Stick.

  1. Plug in the board. The blink sketch should be running.

  2. Select the correct port by clicking on Tools>Port.

  3. You can now upload your own sketch.

For RP2040 version

  1. Install the Arduino Mbed OS RP2040 Boards package. Use the latest version.

  1. Install the latest version of the Electronic Cats Mbed OS RP2040 Boards package.

  1. Close Boards Manager, then go to Tools>Board>Electronic Cats Mbed OS RP2040 Boards>Electronic Cats CatWAN USB Stick 2040.

  1. Plug in the board. The blink sketch should be running.

  2. Select the correct port by clicking on Tools>Port.

  3. You can now upload your own sketch.

Installing LoRa library

To do this, it is necessary to move your mouse to the menu and select “Sketch”, select “Include Library” from the list, and click on “Manage Libraries”.

A new window will open; write “LoRa”.

The library you must look for is the one from “by Sandeep Mistry”, as in the following image.

After finding the library, it is necessary to press the button “Install”.

Installing LoRaWAN library

Download the latest version of the library from the repository: Arduino LoRaWAN Library

Once you download the library go to Arduino IDE-> Sketch-> Include Library-> Add .ZIP Library...

Select the downloaded file and finish the process, once this process is finished the library will be installed.

Installing Arduino-SerialCommand

Download the latest version of the library from the repository: Arduino-SerialCommand

Once you download the library go to Arduino IDE-> Sketch-> Include Library-> Add .ZIP Library...

Select the downloaded file and finish the process, once this process is finished the library will be installed.

Installing Circuit python

What is CircuitPython?

CircuitPython is a Python implementation designed for programming microcontrollers and development boards. Developed by Adafruit Industries, it simplifies hardware programming by providing a Python interface directly on the microcontroller. This approach makes microcontroller programming accessible for beginners and eliminates the need to work with low-level languages. CircuitPython includes preinstalled libraries and modules to facilitate interaction with sensors and actuators. Its simplicity and user-friendly nature make it an excellent choice for those looking to start with hardware programming.

Easy version download firmware

Download a version according to your needs from the official repository.

Download lasted version

Build CircuitPython for CatWAN USB Stick

Fetch the Code to Build

Once your build tools are installed, fetch the CircuitPython source code from its GitHub repository ("repo") and also fetch the git "submodules" it needs. The submodules are extra code that you need that's stored in another repository.

In the commands below, you're cloning from Adafruit's CircuitPython repo. But if you want to make changes, you might want to "fork" that repo on GitHub to make a copy for yourself, and clone from there.

git clone https://github.com/adafruit/circuitpython.git
cd circuitpython
git submodule sync
git submodule update --init --recursive

Build mpy-cross

Build the mpy-cross compiler first, which compiles Circuitpython .py files into .mpy files. It's needed to include library code in certain boards.

Download file Copy Code

make -C mpy-cross

Build CircuitPython

Now you're all set to build CircuitPython. If you're in the master branch of the repo, you'll be building the latest version (3.0 as of this writing). Choose which board you want to build for. The boards available are all the subdirectories in ports/atmel-samd/boards/.

cd ports/atmel-samd
make BOARD=catwan_usbstick

In 4.x we've introduced translated versions of CircuitPython. By default the en_US version will be built. To build for a different language supply a TRANSLATION argument.

cd ports/atmel-samd
make BOARD=catwan_usbstick TRANSLATION=es

Run your build!

When you've successfully built, you'll see output like:

Create build-catwan_usbstick/firmware.bin
Create build-catwan_usbstick/firmware.uf2
python2 ../../tools/uf2/utils/uf2conv.py -b 0x2000 -c -o build-catwan_usbstick/firmware.uf2 build-catwan_usbstick/firmware.bin
Converting to uf2, output size: 485888, start address: 0x2000
Wrote 485888 bytes to catwan_usbstick/firmware.uf2.

Copy firmware.uf2 to your board the same way you'd update CircuitPython: Double-click to get the BOOT drive, and then just copy the .uf2 file:

Double-click the reset button, then:

cp build-circuitplayground_express/firmware.uf2 /media/yourname/CATWAN

The board will restart, and your build will start running.

If you're using a board without a UF2 bootloader, you'll need to use bossac and the firmware.bin file, not the .uf2 file. Detailed instructions are here.

When to make clean

After you make changes to code, normally just doing make BOARD=... will be sufficient. The changed files will be recompiled and CircuitPython will be rebuilt.

However, there are some circumstances where you must do:

make clean BOARD=...

If you have changed the #include file structure in certain ways, or if you have defined QSTR's (a way of defining constants strings in the CircuitPython source), then you must make clean before rebuilding. If you're not sure, it's always safe to make clean and then make. It might take a little longer to build, but you'll be sure it was rebuilt properly.

Updating Your Repo

When there are changes in the GitHub repo, you might want to fetch those and then rebuild. Just "pull" the new code (assuming you haven't made changes yourself), update the submodules if necessary, and rebuild:

git pull
git submodule update --init --recursive
Clone this wiki locally