Initial commit: ESP32-C5-EVB and ESP32-C6-EVB Arduino firmware + HA custom components
This commit is contained in:
@@ -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/)
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
# ESP32-C6 Arduino Project
|
||||
|
||||
Arduino IDE project for ESP32-C6 Home Assistant integration.
|
||||
|
||||
## Arduino IDE Setup
|
||||
|
||||
### 1. Install ESP32 Board Support
|
||||
|
||||
1. Open Arduino IDE
|
||||
2. Go to **File → Preferences**
|
||||
3. Add this URL to "Additional Boards Manager URLs":
|
||||
```
|
||||
https://espressif.github.io/arduino-esp32/package_esp32_index.json
|
||||
```
|
||||
4. Go to **Tools → Board → Boards Manager**
|
||||
5. Search for "esp32" by Espressif Systems
|
||||
6. Install **esp32** (version 3.0.0 or later for ESP32-C6 support)
|
||||
|
||||
### 2. Board Configuration
|
||||
|
||||
In Arduino IDE, select:
|
||||
- **Board**: "ESP32C6 Dev Module"
|
||||
- **Upload Speed**: 921600
|
||||
- **USB CDC On Boot**: **Enabled** ⚠️ **CRITICAL for serial output!**
|
||||
- **Flash Size**: 4MB
|
||||
- **Flash Mode**: DIO
|
||||
- **Flash Frequency**: 80MHz
|
||||
- **Partition Scheme**: Default 4MB
|
||||
- **Port**: `/dev/ttyACM0` (ESP32-C6 typically uses ACM, not USB)
|
||||
|
||||
### 3. Open Project
|
||||
|
||||
1. Open **esp32_arduino.ino** in Arduino IDE
|
||||
2. The IDE will create a folder with the same name automatically
|
||||
|
||||
### 4. Upload
|
||||
|
||||
1. Connect your ESP32-C6 board via USB
|
||||
2. Check available ports: `ls -la /dev/ttyACM* /dev/ttyUSB*`
|
||||
3. Select the correct **Port** in Tools menu (usually `/dev/ttyACM0`)
|
||||
4. Click **Upload** button (→)
|
||||
5. Wait for compilation and upload
|
||||
6. Open **Serial Monitor** (Ctrl+Shift+M) and set to **115200 baud**
|
||||
7. **Press the RESET button** on your board to see output
|
||||
|
||||
**Important**: If you see no serial output:
|
||||
- Verify **USB CDC On Boot** is set to **Enabled**
|
||||
- Press the physical RESET button on the board
|
||||
- Make sure Serial Monitor is set to 115200 baud
|
||||
|
||||
## WiFi Configuration
|
||||
|
||||
WiFi credentials are already set in the code:
|
||||
```cpp
|
||||
const char* ssid = "Buon-Gusto_Nou";
|
||||
const char* password = "arleta13";
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
### Web Interface
|
||||
After upload, open your browser to the IP shown in Serial Monitor:
|
||||
- Control panel with buttons
|
||||
- Real-time status
|
||||
- API documentation
|
||||
|
||||
### REST API Endpoints
|
||||
|
||||
#### Get Device Status
|
||||
```bash
|
||||
curl http://<ESP32_IP>/api/status
|
||||
```
|
||||
|
||||
Response:
|
||||
```json
|
||||
{
|
||||
"temperature": 25.3,
|
||||
"wifi_rssi": -45,
|
||||
"chip": "ESP32-C6",
|
||||
"free_heap": 280000,
|
||||
"uptime": 123,
|
||||
"ip": "192.168.1.100",
|
||||
"relay1": false,
|
||||
"led": false
|
||||
}
|
||||
```
|
||||
|
||||
#### Control Relay
|
||||
```bash
|
||||
# Turn ON
|
||||
curl -X POST http://<ESP32_IP>/api/relay/relay_1/on
|
||||
|
||||
# Turn OFF
|
||||
curl -X POST http://<ESP32_IP>/api/relay/relay_1/off
|
||||
|
||||
# Get Status
|
||||
curl http://<ESP32_IP>/api/relay/relay_1/status
|
||||
```
|
||||
|
||||
#### Control LED
|
||||
```bash
|
||||
# Turn ON
|
||||
curl -X POST http://<ESP32_IP>/api/led/led/on
|
||||
|
||||
# Turn OFF
|
||||
curl -X POST http://<ESP32_IP>/api/led/led/off
|
||||
```
|
||||
|
||||
## GPIO Pins
|
||||
|
||||
- **LED_PIN**: GPIO 8 (onboard LED)
|
||||
- **RELAY_1_PIN**: GPIO 2 (relay control)
|
||||
|
||||
Modify these in the code if your board uses different pins.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Board Not Found in Arduino IDE
|
||||
- Make sure you installed ESP32 board support (minimum version 3.0.0)
|
||||
- Restart Arduino IDE after installation
|
||||
|
||||
### Upload Fails
|
||||
- Check USB cable connection
|
||||
- Select correct port in Tools → Port
|
||||
- Try pressing BOOT button during upload
|
||||
- Reduce upload speed to 115200
|
||||
|
||||
### WiFi Connection Fails
|
||||
- Verify SSID and password
|
||||
- Check if WiFi is 2.4GHz (ESP32-C6 doesn't support 5GHz)
|
||||
- Check Serial Monitor for connection messages
|
||||
|
||||
### Can't See Serial Output
|
||||
- Set Serial Monitor baud rate to **115200**
|
||||
- Enable "USB CDC On Boot" in board settings
|
||||
- Some boards need GPIO 0 held LOW during boot to enter programming mode
|
||||
|
||||
## Serial Monitor Output
|
||||
|
||||
Expected output after successful upload:
|
||||
```
|
||||
=================================
|
||||
ESP32-C6 Home Assistant Device
|
||||
=================================
|
||||
GPIO initialized
|
||||
Connecting to WiFi: Buon-Gusto_Nou
|
||||
..........
|
||||
✓ WiFi connected!
|
||||
IP address: 192.168.1.100
|
||||
RSSI: -45 dBm
|
||||
MAC: AA:BB:CC:DD:EE:FF
|
||||
|
||||
✓ HTTP server started on port 80
|
||||
|
||||
=================================
|
||||
Ready! Try these endpoints:
|
||||
http://192.168.1.100/api/status
|
||||
=================================
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. Upload the code to your ESP32-C6
|
||||
2. Note the IP address from Serial Monitor
|
||||
3. Test the web interface in your browser
|
||||
4. Integrate with Home Assistant using the custom component at `../custom_components/olimex_esp32_c6/`
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "../../../location_managemet"
|
||||
},
|
||||
{
|
||||
"path": "../.."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// ── Board secrets (EXAMPLE — copy to secrets.h and fill in your values) ───────
|
||||
// DO NOT commit secrets.h to version control.
|
||||
//
|
||||
// API_SECRET — shared secret for HMAC-SHA256 API request authentication.
|
||||
// Generate a strong random value with:
|
||||
// python3 -c "import secrets; print(secrets.token_hex(32))"
|
||||
// Then paste the same value into the board's Edit page in the Location
|
||||
// Management server.
|
||||
//
|
||||
// WEB_USER / WEB_PASSWORD — credentials for the browser control panel.
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
#define API_SECRET "REPLACE_WITH_OUTPUT_OF_python3_-c_import_secrets_token_hex_32"
|
||||
#define WEB_USER "your_username"
|
||||
#define WEB_PASSWORD "your_password"
|
||||
Reference in New Issue
Block a user