This shows you the differences between two versions of the page.
|
iothings:laboratoare:2025:lab1 [2025/09/25 22:37] dan.tudose |
iothings:laboratoare:2025:lab1 [2026/03/05 16:32] (current) mihnea.dinica Ordering |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Lab 1: Getting Started ====== | + | ===== Lab 1. Getting Started. WiFi Basics ====== |
| ===== Necessary gear ===== | ===== Necessary gear ===== | ||
| - | We will be using the [[https://github.com/FarhadGUL06/esp32-c6-sparrow/tree/main| ESP32-C6 Sparrow]] board as the main development board for the lab assignments. | + | We will be using the [[https://github.com/dantudose/ESP32-Sparrow-rev3/| ESP32-C6 Sparrow]] board as the main development board for the lab assignments. |
| - | {{:iothings:laboratoare:2025:20250925_131952.png?750| }} | ||
| + | {{ :iothings:laboratoare:2025:sparrow_rev3.png?750|}} | ||
| Also, for the most of the labs, we will be using the Visual Studio Code and Platformio environment, which you can download from [[https://platformio.org/|here]] | Also, for the most of the labs, we will be using the Visual Studio Code and Platformio environment, which you can download from [[https://platformio.org/|here]] | ||
| Line 15: | Line 15: | ||
| This is the pinout diagram of the development board: | This is the pinout diagram of the development board: | ||
| - | {{:iothings:laboratoare:2025:esp32-c6-sparrow-pinout.png?800|}} | + | {{ :iothings:laboratoare:2025:esp32-c6-sparrow-pinout_v3-1.png?800|}} |
| ===== First Steps ===== | ===== First Steps ===== | ||
| Line 23: | Line 22: | ||
| - | 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: | + | After downloading and installing the PlatformIO extension, create a new project using any ESP32-C6 board (be sure to have the Framework set to Arduino and not Espidf). After project creation, you will need to edit the platformio.ini file and replace it with the following: |
| <code bash platformio.ini> | <code bash platformio.ini> | ||
| Line 270: | Line 269: | ||
| - | === 6. Web Server === | + | === 5. Web Server === |
| Now let's bring everything together and configure the board to connect to our local WiFi, act as a web server and display a dynamic html page in which it can plot the sensor readings. | Now let's bring everything together and configure the board to connect to our local WiFi, act as a web server and display a dynamic html page in which it can plot the sensor readings. | ||
| Line 727: | Line 726: | ||
| </note> | </note> | ||
| - | === 6. Advertise on BLE === | ||
| - | |||
| - | Build the example below, which advertises the board on BLE. Install on your phone an app that scans nearby Bluetooth devices, such as [[https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en&pli=1| nRF Connect]]. Check if your device is in the list. | ||
| - | |||
| - | <code C main.cpp> | ||
| - | #include <Arduino.h> | ||
| - | #include <NimBLEDevice.h> | ||
| - | |||
| - | static const char* DEVICE_NAME = "ESP32-C6 Demo"; | ||
| - | static NimBLEUUID SERVICE_UUID("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"); | ||
| - | static NimBLEUUID CHAR_UUID ("6E400002-B5A3-F393-E0A9-E50E24DCCA9E"); | ||
| - | |||
| - | NimBLEServer* gServer = nullptr; | ||
| - | NimBLEService* gService = nullptr; | ||
| - | NimBLECharacteristic* gChar = nullptr; | ||
| - | |||
| - | void startBLE() { | ||
| - | NimBLEDevice::init(DEVICE_NAME); | ||
| - | |||
| - | gServer = NimBLEDevice::createServer(); | ||
| - | gService = gServer->createService(SERVICE_UUID); | ||
| - | |||
| - | gChar = gService->createCharacteristic( | ||
| - | CHAR_UUID, | ||
| - | NIMBLE_PROPERTY::READ | ||
| - | ); | ||
| - | gChar->setValue("Hello from ESP32-C6!"); | ||
| - | gService->start(); | ||
| - | |||
| - | NimBLEAdvertising* adv = NimBLEDevice::getAdvertising(); | ||
| - | |||
| - | // Advertise our service UUID | ||
| - | adv->addServiceUUID(SERVICE_UUID); | ||
| - | |||
| - | // (v2.x) Build advertising + scan-response payloads explicitly | ||
| - | NimBLEAdvertisementData advData; | ||
| - | advData.setFlags(0x06); // LE General Discoverable + BR/EDR Not Supported | ||
| - | |||
| - | NimBLEAdvertisementData scanData; | ||
| - | scanData.setName(DEVICE_NAME); // put the name in scan response | ||
| - | // you can also add manufacturer data here if you want: | ||
| - | // std::string mfg = "\x34\x12C6"; scanData.setManufacturerData(mfg); | ||
| - | |||
| - | adv->setAdvertisementData(advData); | ||
| - | adv->setScanResponseData(scanData); | ||
| - | |||
| - | // Appearance is still supported | ||
| - | adv->setAppearance(0x0200); // Generic Tag | ||
| - | |||
| - | NimBLEDevice::startAdvertising(); | ||
| - | } | ||
| - | |||
| - | void setup() { | ||
| - | Serial.begin(115200); | ||
| - | while (!Serial) { delay(10); } | ||
| - | startBLE(); | ||
| - | Serial.println("Advertising as ESP32-C6 Demo. Open nRF Connect -> Scan."); | ||
| - | } | ||
| - | |||
| - | void loop() { | ||
| - | delay(1000); | ||
| - | } | ||
| - | |||
| - | </code> | ||
| - | {{:iothings:laboratoare:lab1-ble-scanner.jpg?300|}} | ||
| ===== Resources ===== | ===== Resources ===== | ||