#WioTerminal – @code and PlatformIO, working with libraries in a zero-to-hero project ☁️🌧️☁️

Hi !

Yesterday, I shared a very simple project created with PlatformIO Labs in Visual Studio Code for a Wio Terminal. If you are used to work with the Arduino IDE, there are a couple of notes here that may help.

Let’s start with a very simple program:

Check RTL8720 Firmware Version

This program is based on the “Check RTL8720 Firmware Version from Arduino IDE” section on the official SeeedStudio Wiki on how to “Update the Wio Terminal Wireless Core Firmware“.

Once you updated the firmware, you need to install these dependencies in the Arduino IDE

  • Seeed_Arduino_rpcWiFi – search for “seeed rpcwifi”
  • Seeed_Arduino_rpcUnified – search for “seeed rpcunified”
  • Seeed_Arduino_mbedtls – search for “seeed mbedtls”
  • Seeed_Arduino_FS – search for “seeed fs”
  • Seeed_Arduino_SFUD – search for “seeed sfud”

And then build and upload this program.

#include "rpcWiFi.h"
void setup() {
    Serial.begin(115200);
    while(!Serial); // Wait to open Serial Monitor
    Serial.printf("RTL8720 Firmware Version: %s", rpc_system_version());
}
void loop() {}

Super simple. Let’s see how we can do this with PlatformIO.

Check RTL8720 Firmware Version with Platform IO

Let’s create a new project using the Project Wizard.

new project to check firmware version

Empty project created, let’s check the code.

First difference is in the main.cpp file, we can see that this file includes the <Arduino.h> file. This is tricky, we may need to add all the necessary Arduino code files to build. More on this later 😁.

Let’s add the dependencies. We have 2 ways to do this:

On the PlatformIO portal, we can add a new section to our project where we will define the libraries to be downloaded and used when the project is built.

add libraries section

Once this secion is added we can start to search and add our libraries.

add specific libraries

Once we add our 5 libraries, this section will look like something like this.

complete set of dependency libraries added to the project

The 2nd way to do this is to edit the [platformio.ini] file and add / edit this changes in text mode. Once you are familiar with the file structure, this is a super gast way to do this.

edit platformio ini file

Ok, now it’s time to update the code. I leave the include for the <Arduino.h> header, and added the sample code.

code ready to test

1st Build failed. 😢😢😢

build failed.png

I may probably explain a lot here about how the Arduino / microprocessor compiler works, however, it’s kind of late so I’ll just share the solution.

Include the SPI.h in our main code.

SPI is part of the core processor, we don’t need any extra dependency, we just need the compiler to have this file already there (line 3).

#include <Arduino.h>
#include <rpcWiFi.h>
#include <SPI.h>
 
void setup() {
    Serial.begin(115200);
    while(!Serial); // Wait to open Serial Monitor
    Serial.printf("RTL8720 Firmware Version: %s", rpc_system_version());
}
 
void loop() {
}

Once the project is build and uploaded, we can see the output in the terminal monitor.

build and firmware check working

You can check the complete code here.

https://github.com/elbruno/Blog/tree/main/20211209%20Check%20RTL%208720%20Firmware%20Version

Happy coding!

Greetings

El Bruno

More posts in my blog ElBruno.com.

More info in https://beacons.ai/elbruno


References

Advertisement

2 comments

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: