This is an old revision of the document!
We will be using the ESP32-C6 Sparrow board as the main development board for the lab assignments.
Also, for the most of the labs, we will be using the Visual Studio Code and Platformio environment, which you can download from here
After downloading and installing the PlatformIO extension, create a new project using any ESP32-C6 board. After project creation, you will need to edit the platformio.ini file and replace it with the following:
; PlatformIO Project Configuration File ; ; Build options: build flags, source filter ; Upload options: custom upload port, speed and extra flags ; Library options: dependencies, extra library storages ; Advanced options: extra scripting ; ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html [env:esp32-c6-sparrow] platform = https://github.com/FarhadGUL06/platform-espressif32.git board = esp32-c6-sparrow framework = arduino ; Serial monitor options monitor_speed = 115200 lib_deps = adafruit/Adafruit NeoPixel@^1.11.0 adafruit/Adafruit GFX Library@^1.11.9 adafruit/Adafruit SSD1306@^2.5.10 dantudose/LTR308 library@^1.0 https://github.com/sparkfun/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library stm32duino/STM32duino LSM6DSL@^2.0.0
Open the “Blink” example in the Arduino IDE
Define LED_BUILTIN to correspond to one of the on-board LEDs.
For the GREEN boards (rev. 1) the LED has the following pinout
And for the BLUE boards (rev. 2), the LED has the following pinout:
#define LED_BUILTIN ...
Load this WiFi scanner code:
#include <Arduino.h> #include <WiFi.h> // Arduino-ESP32 WiFi (works on ESP32-C6 with Arduino 3.x) static const char* authModeToStr(wifi_auth_mode_t m) { switch (m) { case WIFI_AUTH_OPEN: return "OPEN"; case WIFI_AUTH_WEP: return "WEP"; case WIFI_AUTH_WPA_PSK: return "WPA_PSK"; case WIFI_AUTH_WPA2_PSK: return "WPA2_PSK"; case WIFI_AUTH_WPA_WPA2_PSK: return "WPA/WPA2_PSK"; case WIFI_AUTH_WPA2_ENTERPRISE:return "WPA2_ENT"; case WIFI_AUTH_WPA3_PSK: return "WPA3_PSK"; case WIFI_AUTH_WPA2_WPA3_PSK: return "WPA2/WPA3"; case WIFI_AUTH_WAPI_PSK: return "WAPI_PSK"; case WIFI_AUTH_OWE: return "OWE"; default: return "UNKNOWN"; } } void setup() { Serial.begin(115200); delay(300); // Scan as a station, disconnected WiFi.mode(WIFI_STA); WiFi.persistent(false); WiFi.disconnect(true, true); WiFi.setSleep(false); Serial.println("\nWiFi scanner ready."); } void loop() { Serial.println("\n--- Scanning... ---"); // Synchronous scan; set 2nd arg to true to include hidden SSIDs int n = WiFi.scanNetworks(/*async=*/false, /*show_hidden=*/true); if (n <= 0) { Serial.println("No networks found."); } else { Serial.printf("Found %d network(s):\n", n); for (int i = 0; i < n; ++i) { String ssid = WiFi.SSID(i); String bssid = WiFi.BSSIDstr(i); int32_t rssi = WiFi.RSSI(i); int32_t ch = WiFi.channel(i); auto auth = (wifi_auth_mode_t)WiFi.encryptionType(i); bool hidden = (ssid.length() == 0); // no API needed if (hidden) ssid = "(hidden)"; Serial.printf("%2d) %-32s BSSID:%s CH:%2ld RSSI:%4ld dBm AUTH:%s\n", i + 1, ssid.c_str(), bssid.c_str(), (long)ch, (long)rssi, authModeToStr(auth) ); } } WiFi.scanDelete(); // free RAM delay(5000); }
Build, Upload and Monitor the results. You should be able to see a periodic scan of the available WiFi networks in your proximity.
Load the “SimpleBleDevice” example. Install on your phone an app that scans nearby Bluetooth devices, such as this BLE Scanner. Check if your device is in the list.