Featured image of post [IoT] Getting Started - Blinking the LED

[IoT] Getting Started - Blinking the LED

Recently discovered the TinyGo project, so I acquired two development boards: a Raspberry Pi Pico and an ESP32

Introduction

As a complete novice in IoT development, after several days of online research, I learned that:


  • To balance both cost-performance and ease of use, I bought both boards
  • Both have official Taobao stores linked from their official websites: Raspberry Pi Espressif Systems
  • Both boards cost around 20-30 RMB

Windows Environment Variables

  • Right-click Computer (or open any folder and right-click “This PC”) -> Properties -> Advanced System Settings -> Environment Variables -> Double-click PATH (System variables) -> Add new paths as needed

Go Installation

go version
go version go1.17.8 windows/amd64

TinyGo Setup

tinygo version
tinygo version 0.22.0 windows/amd64 (using go version go1.17.5 and LLVM version 13.0.0)

Raspberry Pi Pico

  • Recommended to get an expansion board for easier pin access
  • Pre-soldered headers save time - simply plug the dev board into the expansion board


  • First project: LED blinking. Pico is remarkably simple compared to ESP32 - no extra toolchain needed

  • Directly connect to PC via USB and flash code

  • To enter bootloader mode:

    • Hold BOOTSEL button
    • Connect USB cable
    • Release BOOTSEL
    • Flash new code

ESP32 Setup

Prerequisites

Installation Steps

  • Install MINGW32 (recommend C:\msys32)
  • Get ESP-IDF
    • mkdir -p ~/esp && cd ~/esp
      git clone -b release/v3.0 --recursive https://github.com/espressif/esp-idf.git
      
  • Set IDF_PATH
    • echo "export IDF_PATH=\"C:/msys32/home/your-username/esp/esp-idf\"" > /etc/profile.d/export_idf_path.sh
      
    • Restart MINGW32 and verify:
      printenv IDF_PATH
      
  • Create Project
    • cd ~/esp
      cp -r $IDF_PATH/examples/get-started/hello_world .
      cd hello_world
      make menuconfig
      
    • Configure serial port under Serial flasher config -> Default serial port

  • Find COM port in Windows Device Manager

  • Set correct COM port (e.g., COM3) and save

  • Flash Firmware
    • make flash
      

Install esptool

  • pip install esptool
    
  • Will update Raspberry Pi Pico section next time. Stay tuned!

Common Errors

Error 1

Makefile:8: C:/msys32/home/user-name/esp/esp-idf/make/project.mk: No such file or directory 
make: *** No rule to make target 'C:/msys32/home/user-name/esp/esp-idf/make/project.m'. Stop.
  • Fix: Verify IDF_PATH in /etc/profile.d/export_idf_path.sh uses correct username

Error 2

make flash: could not open port '/dev/ttyUSB0
  • Fix: Ensure correct COM port is set in make menuconfig configuration