Monday, September 1, 2025

0000 0001 0000 0100

ESP32-C6 Solar Powered WiFi Extender

I have been tinkering with Solar Power and WiFi for a while now - and the arrival of some new solar panels and the tiny Seeed Studio ESP32-C6  prompted me to put together a prototype for testing.

I also decided to (briefly) use an IP2312 charging module - but as you will see in the video below it didn't really work out for me - more exploration required at this point!

Another snag was that the little board needed a software coded switch to activate the external antenna, and so I had to insert that code into the project, and ended up creating my own github folder with the tweaks, including compiled binary files if you want to just lock and load the code.

// Added by OneCircuit (and Gemini AI) on Tue 12 Aug 2025 14:49:14 AEST
// https://www.youtube.com/@onecircuit-as

#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

// Define GPIO pin numbers
#define ESP32C6_WIFI_ENABLE_PIN  GPIO_NUM_3
#define ESP32C6_WIFI_ANT_CONFIG_PIN GPIO_NUM_14

void initialise_ext_antenna(void) {
    // Configure GPIO pins as outputs
    gpio_reset_pin(ESP32C6_WIFI_ENABLE_PIN);
    gpio_set_direction(ESP32C6_WIFI_ENABLE_PIN, GPIO_MODE_OUTPUT);

    gpio_reset_pin(ESP32C6_WIFI_ANT_CONFIG_PIN);
    gpio_set_direction(ESP32C6_WIFI_ANT_CONFIG_PIN, GPIO_MODE_OUTPUT);

    // Set pin levels
    gpio_set_level(ESP32C6_WIFI_ENABLE_PIN, 0); // Activate RF switch control (LOW)

    // Delay
    vTaskDelay(pdMS_TO_TICKS(100)); // Use a FreeRTOS delay function

    gpio_set_level(ESP32C6_WIFI_ANT_CONFIG_PIN, 1); // Use external antenna (HIGH)
}

This is a version of the ESP32 router code found at:

https://github.com/dchristl/esp32_nat_router_extended, which in turn is a version of the code found here:

https://github.com/martin-ger/esp32_nat_router

I also slightly modified the partitions csv file to work with the ESP32C6, and added a file of the commands I used to load the binaries using esptool.py

Also thanks to Gemini AI who came in after three days of me banging me head against a wall trying to merge two coding platforms and sorted out the last little hiccups in my code.

Finally, for LOLS, I moved from the Arduino IDE to Visual Code Studio with PlatformIO and ESP-IDF extensions running - it's own little adventure in the end.

The whole project taught me a great deal about all of these components - hardware, software, tweaking and even some antenna rabbit holes!

Enjoy and please leave a comment if you have a moment!




No comments:

Post a Comment