Updating your sensor using PlatformIO
At Maketronics, we believe in giving access to all the information needed to augment or hack the software your device comes with. The RadSense sensor is based on a popular microcontroller from Espressif that is called ESP32 C3. In addition to measuring signals and turning things on/off, the device also has Wifi and Bluetooth connectivity. The device is fully working out of the box, but if you do want to update the firmware on the device or maybe even reprogram it to do new things, this tutorial will get you started.
Let’s start by blinking the builtin LED. The LED is inside the box, so you’ll need to use the screwdriver that came with the kit to remove the lid to see it. Unscrew the four corner screws and you can see the electronics. At the top left, you can see the LED marked as D1 on the circut board. We’ll now make that blink. We recommend to use one of the screws to hold the circuit board firmly to the bottom of the box as you work with the device.
Downloading the software you need
If you are unfamiliar with PlatformIO, this is the place to start. If you already know the software, skip to the next section.
Software that is controlling hardware is usually referred to as “firmware”, since it’s in the hardware itself. To update the firmware on your RadSense 1, you’ll need a computer with an internet connection and the accompanying USB C cable.
Download the latest PlatfomIO IDE (Integrated Development Environment). The software is available for Windows, Mac and Linux. It’s based on the popular VSCode IDE, so the software you are installing is called Visual Studio Code, with PlatformIO included. Follow the installation instructions to complte the installation. If you already know VSCode and have it installed, you can just install the PlatformIO extension instead.
Once the program is installed, start the Visual Studio Code software.
Using the blink example
Once VSCode starts up, click the menu File > Open folder and select the folder you just downloaded and unzipped. Your screen should now look something like this. Most likely, there will be some updating going on in the lower right corner in the form of small windows with progress bars. Let that finish before you continue. It should only take a few minutes, depending on your connection. These popups happen when software installs as you are running VSCode, so don’t worry too much if you see something happening that does not end up with an error.
Click the PlatformIO icon (1) to show the list of commands. Next, connect the RadSense1 to your computer (No worries if you already plugged it in).
In the sidebar menu that shows up, Click the Upload button (1). The first time you do this, a window will open to show the Espressif IDF extension (2). If this extension is not already installed, it will automatically install. Once that is finished, the upload of the firmware will commence and you’ll see the progress in this terminal window (3).
If all goes well, you’ll see the device start blinking the onboard LED marked as D1 on the circuit board. (you did unscrew the lid, right?)
If you run into an error
1. Be sure you plugged the device in and that you're using the accompanying USB Type C cable (or any other cable that you know to be working)
2. Be sure that you did not delete or add any extra characters to the code. Computers are really finicky about this.
3. If you are new to PlatformIO, we recommend browsing some of the many tutorials online to get to know it.
4. We have listed some of the most common errors and how to solve them in this post.
Creating new projects
To create a new PlatformIO project without using a premade example, you start by creating a new window with File > New Window
Click the PlatformIO icon to open the Sidebar (1) and click the Create New Project button. This opens the PlatformIO home screen where you must (yet again) click the New project button (2). In the Project Wizard, set a name and location for your files and select the Espressif ESP32-C3-DevKitM-1 from the menu. You may type into the field to find it faster. Then click the Finish button.
Out ouf the box, you’ll now get an empty project that will not upload smoothly. To get everything working as intended, you need to open the created file named platformio.ini and add the following lines of text to it:
monitor_speed = 115200
build_flags =
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
-D CORE_DEBUG_LEVEL=1
-D ARDUINO_ESP32C3_DEV=1
With that in place, your project is ready to go. Use the RadSense 1 Pinout to access the builtin hardware.
Restoring the original software
Every time you upload a new software to the device, it will replace what’s on the device. If you want the device to be just like when you purchased it, you’ll need to uload the same code that we ship the device with. This code for PlatformIO is publicly available at this url https://github.com/jenschr/Radsense1
Unless you know what Github is, just click the green Code-button to reveal the link to download all the required files as a ZIP archive.
- Unzip the files
- Open a new window in VSCode (File > New window)
- Open the files you just unzipped (File > Open folder)