Initial commit: Olimex ESP32-C6-EVB HA integration + Arduino sketch

This commit is contained in:
ske087
2026-02-23 21:10:38 +02:00
commit b1ee2610ca
18 changed files with 2178 additions and 0 deletions

View File

@@ -0,0 +1,270 @@
# ESP32-C6 Arduino Deployment Guide
Complete guide to compile and deploy the firmware to your Olimex ESP32-C6-EVB board.
---
## ✓ Pre-Deployment Checklist
- [ ] Arduino IDE installed (version 2.0+)
- [ ] ESP32 board package installed (version 3.0.0+)
- [ ] Olimex ESP32-C6-EVB board connected via USB
- [ ] USB drivers installed for your OS
- [ ] WiFi credentials available
---
## Step 1: Install Arduino IDE
1. Download from: https://www.arduino.cc/en/software
2. Install and launch Arduino IDE 2.0 or later
---
## Step 2: Add ESP32 Board Support
### Windows/Mac/Linux (same process):
1. **Open Preferences**
- File → Preferences (or Arduino IDE → Settings on Mac)
2. **Add Board URL**
- Find "Additional Boards Manager URLs" field
- Add this URL:
```
https://espressif.github.io/arduino-esp32/package_esp32_index.json
```
- Click OK
3. **Install ESP32 Board Package**
- Tools → Board → Boards Manager
- Search: "esp32"
- Install "esp32 by Espressif Systems" (version 3.0.0+)
- Wait for installation to complete
---
## Step 3: Configure Board Settings
After installation, configure these exact settings in Arduino IDE:
**Tools Menu Settings:**
| Setting | Value |
|---------|-------|
| Board | ESP32C6 Dev Module |
| Upload Speed | 921600 |
| USB CDC On Boot | **Enabled** ⚠️ CRITICAL |
| Flash Size | 4MB |
| Flash Mode | DIO |
| Flash Frequency | 80MHz |
| Partition Scheme | Default 4MB |
---
## Step 4: Update WiFi Credentials
**Before uploading**, edit the WiFi credentials in `esp32_arduino.ino`:
```cpp
// Line 16-17 - CHANGE THESE:
const char* ssid = "Your_WiFi_SSID_Here";
const char* password = "Your_WiFi_Password_Here";
```
Replace with your actual WiFi network name and password.
---
## Step 5: Connect Board & Find USB Port
### Linux/Mac:
```bash
# Check available ports
ls -la /dev/ttyACM* /dev/ttyUSB*
# Should see something like: /dev/ttyACM0
```
### Windows:
- Device Manager → Ports (COM & LPT)
- Look for "USB-UART Bridge" or similar
### Select Port in Arduino IDE:
- Tools → Port → [Select your port]
- Usually `/dev/ttyACM0` on Linux (not `/dev/ttyUSB0`)
---
## Step 6: Compile & Upload
1. **Verify Sketch** (check for errors before upload)
- Sketch → Verify/Compile
- OR press: Ctrl+R (Windows/Linux) or Cmd+R (Mac)
2. **Upload to Board**
- Sketch → Upload
- OR press: Ctrl+U (Windows/Linux) or Cmd+U (Mac)
3. **Watch Serial Monitor**
- Tools → Serial Monitor (or Ctrl+Shift+M)
- **Set baud rate to: 115200**
- You should see the startup messages
4. **If No Output:**
- Press the **RESET button** on the ESP32-C6 board
- Check that "USB CDC On Boot" is set to **Enabled**
- Verify Serial Monitor baud rate is 115200
---
## Step 7: Verify Deployment Success
### Expected Serial Output:
```
=================================
ESP32-C6 Home Assistant Device
Arduino Framework
=================================
GPIO initialized
Connecting to WiFi: Your_WiFi_SSID
.........................
✓ WiFi connected!
IP address: 192.168.1.xxx
RSSI: -45 dBm
MAC: AA:BB:CC:DD:EE:FF
✓ HTTP server started on port 80
=================================
Ready! Try these endpoints:
http://192.168.1.xxx/api/status
=================================
```
### Test the Board
**From Linux terminal or browser:**
```bash
# Get board status
curl http://192.168.1.xxx/api/status
# Expected response:
# {"temperature":25.0,"wifi_rssi":-45,"chip":"ESP32-C6","free_heap":123456,"uptime":12,"ip":"192.168.1.xxx","relay1":false,"led":false}
# Turn relay ON
curl -X POST http://192.168.1.xxx/api/relay/relay_1/on
# Turn relay OFF
curl -X POST http://192.168.1.xxx/api/relay/relay_1/off
# Get relay status
curl http://192.168.1.xxx/api/relay/relay_1/status
# Turn LED ON
curl -X POST http://192.168.1.xxx/api/led/led/on
# Turn LED OFF
curl -X POST http://192.168.1.xxx/api/led/led/off
```
**Or open in browser:**
- `http://192.168.1.xxx/` - Web control panel
- `http://192.168.1.xxx/api/status` - JSON status
---
## Step 8: Add to Home Assistant
1. **Get the board's IP address** (from Serial Monitor output)
2. **In Home Assistant:**
- Settings → Devices & Services → Integrations
- Click "+ Create Integration"
- Search for "Olimex ESP32-C6-EVB"
- Enter IP address and port (80)
- Select which relays/LEDs to include
3. **You should now see:**
- Temperature sensor
- WiFi signal strength
- Relay switch
- LED switch
---
## Troubleshooting
### No Serial Output
- ✓ Verify "USB CDC On Boot" is **Enabled** in board settings
- ✓ Press RESET button on the board
- ✓ Check Serial Monitor baud rate (115200)
- ✓ Try different USB cable
- ✓ Try different USB port
### WiFi Connection Failed
- ✓ Verify SSID and password are correct (check for typos)
- ✓ Ensure board is within WiFi range
- ✓ Check if WiFi network requires WPA3 (ESP32-C6 may have issues with some WPA3 networks)
- ✓ Try 2.4GHz network (not 5GHz)
### Can't Find Board in Arduino IDE
- ✓ Check USB cable is connected
- ✓ Verify USB drivers installed
- ✓ Try different USB port
- ✓ Restart Arduino IDE
- ✓ On Linux: `sudo usermod -a -G dialout $USER` then relogin
### API Endpoints Not Responding
- ✓ Verify board has WiFi connection (check Serial Monitor)
- ✓ Verify correct IP address
- ✓ Check firewall isn't blocking port 80
- ✓ Restart the board (press RESET button)
### Relay/LED Not Working
- ✓ Check GPIO pin connections (LED=GPIO8, Relay=GPIO2)
- ✓ Verify relay/LED hardware is connected correctly
- ✓ Test endpoints in Serial Monitor output
---
## GPIO Pin Reference
| Function | GPIO Pin | Usage |
|----------|----------|-------|
| LED (Onboard) | GPIO 8 | Blue LED control |
| Relay 1 | GPIO 2 | Relay control |
For additional GPIO pins, modify the code and add more handlers.
---
## What the Code Does
**WiFi Connection** - Connects to your WiFi network
**REST API** - Provides HTTP endpoints for control
**Web UI** - Control panel at root URL
**Relay Control** - On/Off control via GPIO2
**LED Control** - On/Off control via GPIO8
**Temperature Simulation** - Reads and reports simulated temperature
**System Status** - Reports uptime, free memory, WiFi signal strength
**Serial Debugging** - All actions logged to Serial Monitor
---
## Next Steps
1. Deploy firmware to board ✓
2. Verify board works in Serial Monitor ✓
3. Test API endpoints from terminal
4. Add to Home Assistant integration
5. Create automations using the relay/LED as switches
---
## More Resources
- [Arduino IDE Documentation](https://docs.arduino.cc/software/ide-v2)
- [Espressif ESP32-C6 Datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
- [Olimex ESP32-C6-EVB Board](https://www.olimex.com/Products/IoT/ESP32-C6-EVB/)