Introduction: Radio LoRa Ra-01 With STM32 and ESP32

About: Do you like technology? Follow my channel on Youtube and my Blog. In them I put videos every week of microcontrollers, arduinos, networks, among other subjects.

As this is a popular subject among those following my posts, I decided to talk about LoRa today. However, I’m going to discuss the subject with some new elements: this time without using the ESP32, but the STM32 instead. I always wanted to post about the STM32, as it composes a whole family of 32-bit microcontrollers produced by STMicroelectronics. I have several friends who are using this chip outside of Brazil. They can attest to the successes of this European manufacturing device. First, I’m going to introduce the STM32, and also discuss the LoRa Ra-01 Module. In addition, I’ll discuss programming the STM32 in the Arduino IDE.

This video will show you an STM32 development kit not meant for programming in Arduino, but instead with C language or those that are native to STMicroelectronics. If I'm not mistaken, there are eight companies that produce compilers for STM32, which shows us that there is a sizable global culture concerning this chip.

I want to explain to you here that STMicroelectronics is at least four times larger than Microchip, and it produces the STM32 family. It consists of architectures ranging from very small chips to STM32 F7, which I consider to be "super powerful".

In our assembly, we use an STM32 Maple Mini, which looks like an Arduino Nano. However, it is much more powerful. We’ll also use the Ai-Thinker Ra-01. It is separate from the LoRa radio, which will communicate with the STM32 via SPI (the communication of the Semtech LoRa chip).

Step 1: Demonstration

In our video, you can see in the assembly that we have the STM32 Maple Mini connected via SPI to the Ra-01 module. This assembly transmits the data to our "beloved" ESP32, which has an embedded i2c display that displays the packages. You can see that it only takes 81 milliseconds for preparation, sending, and receiving of the package by the ESP32, as well as for the on-screen display. If the distance is increased, and there is a change in the software, this time tends to increase.

Our aim with this assembly is to show the STM32, which is a different chip, sending data in the standard Lora radio. It is important to remember that there are two different hardware pieces that are talking via LoRa radio protocol.

Step 2: LoRa Module Ra-01

Basically, we have here the Semtech LoRa chip, with some discrete components on the board, including an antenna output. The interface is SPI. At this moment, we must bring up the question of chip speed, which is at above 300Kbps. We know that LoRa doesn’t function at this speed, as it rotates only at 37K or less. Why? To go far, you must lower the bit rate. It is important to remember that speed is not a concern of LoRa, but rather its scope. The frequency of this device is 433MHz, and the transmission power is at about 18 dBm, with 3v3 power.

Step 3: Maple Mini

I consider this special concerning the STM32. What's the difference between this and the STMicroelectronics development kit (the STM32 L4 Series ultra low power)? The kit is more powerful, but the Maple Mini works in the Arduino IDE, which makes it a lot easier for those who are not as knowledgeable with regards to the programming. We can say that Maple Mini functions like a kind of Arduino, with a Flash of 128 KB. The Maple Mini also has 20 KB of RAM, USB input, LEDs, buttons, a highlight for its 34 IOs, plus 12 16-bit PWMs and 9 12-bit analog inputs.

Step 4: Pinning

Shown here is the Maple Mini Pinout.

Step 5: Install Support for ARM 32bit Cards

In the Arduino IDE, go to Tools-> Board-> Board Manager ...

In the window that opens, search for Arduino SAM Boards and install Arduino SAM Boards (32-bit ARM Cortex-M3)

Step 6: Lora Library

Now go to Sketch-> Include Library-> Manage Libraries ...

Look for LoRa and install LoRa by Sandeep Mistry

Step 7: SMT32 Arduino

Download the zip at https://github.com/rogerclarkmelbourne/Arduino_STM32

Unzip and copy the folder to Documents / Arduino / hardware

Step 8: Assembly

Here you can see how simple our scheme is. I connect via SPI the Ai-Thinker module (LoRa) to STM32.

Step 9: Settings

After downloading the source

code, available at the end of this article, you then go to the build. Then, follow the steps in this picture.

Step 10: Code Based on ESP32 LoRa Send and Receive Video

The source code we use in this project is the same that we have already used in an assembly with an ESP32, in the video: ESP32 LoRa with Arduino IDE: Send and Receive TX RX, with one exception: it does not have the display. This part of i2C has already been removed from the code that I downloaded below. To find out how this code works, simply watch the video.

Step 11: Files

Download the files:

PDF

INO