Previously, I wrote a few examples of how to use C# to write STM32 programs. Similarly, we can also use C# under ESP32, relying on the ever-growing .Net nanoFramework. Currently, it supports more and more development boards and chip types, and the related libraries are also increasing. The supported devices can fully support conventional application development. 90% of the devices can be purchased on Taobao.
Recently, while browsing GitHub, I discovered that the LILYGO® T-WATCH-2020 V3 from Shenzhen Xinyuan Electronics has been supported by nanoFramework and is listed among the supported devices. This encouraged me greatly about nanoFramework, and I wrote this article hoping to help everyone enter the development of ESP32 with a low threshold.
First, you need to buy a device on Taobao. I chose the LILYGO® T-WATCH-2020 V3 + CH9102F, which can be found on Taobao. You can buy it from LILYGO’s official Taobao store for just over 200 yuan, which is incredibly cheap compared to STM32 development boards. After receiving the device, charge it and power it on. I don’t have much intention to operate the built-in interface because I want to use LVGL to create a usable interface that feels like Apple or Android. This requires a lot of time from designers and C programmers, so as a smart watch development board, it has already demonstrated all its functions. Therefore, without further ado, we directly flash the firmware.
-
Install nanoff, which is a tool for flashing the bootloader and nanoCLR for nanoFramework. With it, you can discover the device through Visual Studio development tools. The command is:
dotnet tool install -g nanoff
After the installation is complete, it prompts:
You can use the following command to invoke the tool: nanoff
Successfully installed tool “nanoff” (version “2.1.7”).
2. Use the command nanoff –listports to check if your device’s serial port is connected.
3. Flash the firmware. platform is used to specify the platform, such as STM32 or ESP32, serialport specifies the serial port, update means updating the firmware, and target specifies the name of the supported development board. If not specified, nanoff will automatically specify one based on the platform.
nanoff --platform esp32 --serialport COM3 --update --target ESP32_LILYGO
Note that there is an imperfection here. If you specify ESP32_LILYGO, it may not be discovered in VS, possibly due to firmware compatibility issues. If you use the default ESP32, there is no such problem. I have raised this issue in related threads, and you can follow up if you encounter this problem: GitHub Issue.
If successful, the interface should display as follows.
4. Open Visual Studio, and you need to install the .NET nanoFramework Extension so that you can select the nanoFramework project when creating a new project, as shown in the image below:
After creating a new project, the basic structure is as follows:
At this point, we need to open the nanoFramework device viewer and connect your watch.
Now click:
After starting, it should look like this:
At this point, your first line of code is implemented, covering Wi-Fi, interface, and data collection. You will need to do a lot of work. But it’s a start, and I hope you find joy in it. Good luck!