Weather station with was: ESP32 C3 Mini now: XIAO ESP32 C3

I ordered my last lot of 24 directly from Seeed (US$4.20).
I wonder why Ali is even cheaper than that (old stock?, seconds?).
This is what the original Seeed packaging looks like.
Leo..

That is an impressive quantity! Are these all for your own use ?

No, small commercial project involving automated empty domestic gas bottle detecting and re-ordering.
Leo..

$4.20 each, I assume, not for the lot of 24?

Makes my purchase at £1.63 (==$2.19) look very suspect! Time will tell.

My XIAO ESP32C3 board arrived. That was pretty quick for AliEx, from my experience. 6 days to UK. The label mentions Germany.

The packaging is similar but not identical to @Wawa

The board looks well made. It is indeed slightly smaller than the supermini C3, having 2 fewer pins:

I tested with WiFi scanner with the supplied stick-on WiFi antenna:

10:05:45.074 -> Scan start
10:05:47.857 -> Scan done
10:05:47.857 -> 9 networks found
10:05:47.857 -> Nr | SSID                             | RSSI | CH | Encryption
10:05:47.857 ->  1 | DIRECT-59-HP M283 LaserJet       |  -38 |  6 | WPA2
10:05:47.890 ->  2 | granary                          |  -42 | 13 | WPA2
10:05:47.890 ->  3 | (redacted)                       |  -76 |  1 | WPA2
10:05:47.890 ->  4 | granary2                         |  -89 |  1 | WPA+WPA2
10:05:47.924 ->  5 | (redacted)                       |  -92 |  1 | WPA2
10:05:47.924 ->  6 | (redacted)                       |  -92 |  6 | WPA2
10:05:47.924 ->  7 | (redacted)                       |  -92 |  6 | WPA2
10:05:47.957 ->  8 | granary4                         |  -92 |  9 | WPA+WPA2
10:05:47.957 ->  9 | (redacted)                       |  -93 |  1 | WPA2

Signals are stronger than the other boards I tested above, and more APs are detected.

Next I tested with that same 3dBi (?) antenna I used with the Wemos earlier:

10:21:24.903 -> Scan start
10:21:27.718 -> Scan done
10:21:27.718 -> 7 networks found
10:21:27.718 -> Nr | SSID                             | RSSI | CH | Encryption
10:21:27.718 ->  1 | granary                          |  -35 | 13 | WPA2
10:21:27.718 ->  2 | DIRECT-59-HP M283 LaserJet       |  -37 |  6 | WPA2
10:21:27.718 ->  3 | (redacted)                       |  -81 |  1 | WPA2
10:21:27.751 ->  4 | granary2                         |  -83 |  1 | WPA+WPA2
10:21:27.751 ->  5 | (redacted)                       |  -89 |  6 | WPA2
10:21:27.751 ->  6 | granary4                         |  -93 |  9 | WPA+WPA2
10:21:27.784 ->  7 | (redacted)                       |  -94 |  1 | WPA2

Strongest signals yet, but fewer APs detected.

I noticed that it's tiny red led is blinking rapidly when I first plugged it in. This didn't stop when I uploaded the WiFi scanner sketch.

Package seems the same, from Seeed, just a different colour.
Looking forward to seeing your weather station project using this board.

Never had the need for deepsleep. I only turn the radio off after NTP updates with
WiFi.mode(WIFI_OFF);
Draws about 20mA after that.
Leo..

Here's the link where I purchased it:
https://www.aliexpress.com/item/1005006353156304.html?spm=a2g0o.order_list.order_list_main.5.78f31802zrMgW6
The price has increased to £4.79!

I must have been lucky and stumbled onto a special offer price:

When I click the Add To Cart button on my Orders page, I don't get the special offer price again... full price + non-free postage...

My weather station will run on Li-ion battery. I'm hoping for deep sleep consumption of a few hundred uA. I'll test deep sleep current with the XIAO later.

Any idea about the flashing red LED? Does/did your boards do that?

EDIT: The page you linked to above implies the led I see flashing is battery charge led. It is labelled "CH" on the board. Perhaps it blinks when no battery is connected.

Onboard LEDs Charge LED

Do you know if this circuit includes over-discharge protection? That would save me having to use an external protection circuit with unprotected Li-ion batteries.

EDIT: that page you linked to implies that it does:

Battery charging chip: Supports lithium battery charge and discharge management

The datasheet states 43uA in deep sleep.
Flat LiPo cells usually contain a protection circuit.


Periodic charging can also be done with a cellphone power bank, connected to the USB-C socket of the ESP. With the lead hanging out, there is no need to open the weather station box.
Leo..

Hey Leo could you do me a favor? Or anyone else around with a XIAO ESP32 C3 that's willing.

Using the ESP32-->DeepSleep-->Timer Wakeup example sketch, measure the current your XIAO draws during deep sleep?

I'm seeing 290~300uA.

I'm powering the XIAO through the VUSB pin with 3.7V Li-ion battery (currently reading around 3.4V).

Perhaps the difference is the current needed by the RTC circuits. Maybe the 43uA can only be achieved when they are disabled.

EDIT: I've seen a post on ESP32 forum suggesting to try connecting the battery via the underside battery pads. I'll try that soon. I suppose that might avoid the 3.3V regulator quiescent current.

The battery charger chip is also in circuit when the ESP is powered via USB/Vin.
And the power LED.
Leo..

Ta-Da!


Powering via the battery +/- pads on underside of board drawing only 35uA in deep sleep :grinning:

:+1:
How are you planning to wake.
By timer or GPIO.
Leo..

Both.

By GPIO when triggered by the anemometer or rain gauge.

By timer every 6s to capture wind gust speed. Then back to deep sleep, unless 15 mins is up, in which case wake up fully, connect to WiFi, read i2c sensors etc.

Not sure about when/how often to read the wind vane. Maybe every few pulses from the anemometer, maybe each 6s.

I have yet to figure out what is possible to do with code running in RTC memory. Think I should be able to figure out which GPIO caused the wake and increment the appropriate counter. But can I take ADC reading from the wind vane? More research to do.

Update (I finally got the time and enthusiasm).

Have been trying out light sleep mode on the XIAO ESP32C3.

I get current draw around 170~180uA. Its not as low as the 35uA I got in deep sleep, but on the plus side:

  • I can get it to wake on either a timer or a GPIO signal.
  • I read that waking up from light sleep takes only around 1ms, much faster than deep sleep.
  • On waking, the code continues executing from where it left off. It doesn't cause a reset like deep sleep.
  • All variables are retained, so no need to use RTC memory.
  • millis() seems to update normally during light sleep.

I also tried dropping the clock speed to 10MHz. This reduced current consumption from about 15mA (80MHz) to around 5mA (10MHz) when not in sleep mode (WiFi not in use). Not quite as low as I had expected, and not fast enough for using WiFi anyway. But I wanted to know if this would further reduce current in light sleep. It doesn't. Exactly the same (170~180uA).

So this could be a way forward with my Weather Station project. 170uA is around 1/4 of the current drawn by my current solution (ESP8266 in deep sleep + ATTINY85 awake, 1MHz).

Test code:


int counter = 0;
gpio_num_t btnPin = GPIO_NUM_2;
const int ledPin = 3;           // GPIO pin for onboard LED
uint64_t sleepTime = 5000000;  // Sleep duration in microseconds (10 seconds)

void setup() {
    Serial.begin(115200);
//    while (!Serial);
    pinMode(ledPin, OUTPUT);
    pinMode(btnPin, INPUT_PULLDOWN);

    // Enable wake-up by timer
    esp_err_t result = esp_sleep_enable_timer_wakeup(sleepTime);

    if (result == ESP_OK) {
        Serial.println("Timer Wake-Up set successfully as wake-up source.");
    } else {
        Serial.println("Failed to set Timer Wake-Up as wake-up source.");
    }

    gpio_wakeup_enable(btnPin, GPIO_INTR_HIGH_LEVEL);
    result = esp_sleep_enable_gpio_wakeup();

    if (result == ESP_OK) {
        Serial.println("GPIO Wake-Up set successfully as wake-up source.");
    } else {
        Serial.println("Failed to set GPIO Wake-Up as wake-up source.");
    }
}

void loop() {
    Serial.printf("Counter: %d millis %ld btn %d\n", counter, millis(), digitalRead(btnPin));
    counter++;
    delay(5000);

    if (digitalRead(btnPin) == LOW)
      gpio_wakeup_enable(btnPin, GPIO_INTR_HIGH_LEVEL);
    else
      gpio_wakeup_enable(btnPin, GPIO_INTR_LOW_LEVEL);
    
    Serial.println("Going into light sleep mode");
    Serial.flush();
    digitalWrite(ledPin, LOW);   // Turn off LED before going to sleep
    esp_light_sleep_start();     // Enter light sleep
    digitalWrite(ledPin, HIGH);  // LED on to indicate wake-up
    Serial.println("Returning from light sleep");
}

Sample output:

17:12:44.354 -> Timer Wake-Up set successfully as wake-up source.
17:12:44.354 -> GPIO Wake-Up set successfully as wake-up source.
17:12:44.354 -> Counter: 0 millis 9 btn 0
17:12:44.354 -> Going into light sleep mode
17:12:49.356 -> Returning from light sleep
17:12:49.356 -> Counter: 1 millis 10014 btn 0
17:12:54.356 -> Going into light sleep mode
17:12:58.499 -> Returning from light sleep
17:12:58.499 -> Counter: 2 millis 19173 btn 1 <-- here, I woke the chip by pressing the button
17:13:03.503 -> Going into light sleep mode
17:13:04.233 -> Returning from light sleep
17:13:04.233 -> Counter: 3 millis 24916 btn 0 <-- here I woke the chip by releasing the button
17:13:09.235 -> Going into light sleep mode
17:13:14.234 -> Returning from light sleep
17:13:14.267 -> Counter: 4 millis 34922 btn 0
17:13:19.267 -> Going into light sleep mode
17:13:24.238 -> Returning from light sleep
17:13:24.271 -> Counter: 5 millis 44926 btn 0
17:13:29.270 -> Going into light sleep mode
17:13:34.239 -> Returning from light sleep
17:13:34.239 -> Counter: 6 millis 54931 btn 0
17:13:39.244 -> Going into light sleep mode
17:13:44.245 -> Returning from light sleep
17:13:44.245 -> Counter: 7 millis 64936 btn 0
17:13:49.255 -> Going into light sleep mode
17:13:54.260 -> Returning from light sleep
17:13:54.260 -> Counter: 8 millis 74942 btn 0
17:13:59.260 -> Going into light sleep mode

Good yo hear you're making progress and thank you for sharing.

I'm still happy with my no_sleep approach, but I will keep this post bookmarked...
The 20x20cm 5volt white solar panel connected directly to the XIAO ESP-C3's USB socket keeps the 3Ah Lipo (directly connected to the board) well topped up. There hasn't been a morning that the battery dropped below 4volt. But, it's now summer here...
Curious what it will do in winter.

With your sleep mode a small 5volt panel with USB lead could keep that battery topped up too.

Below the HomeAssistant log that shows the battery being topped op between 8:30 and 9:30am (4V18), and not dropping below 4V06 before first daylight stops a further drop at 5am.
The internal charger of the XIAO C3 works very well.
Leo..

Quick update. Will write more later after more field testing (less than 24 hours so far).

The weather station is deployed and working well so far with the XIAO ESP32C3.

I went ahead with using light sleep mode, which consumes around 0.2mA with occasional peaks which I can't explain and can't measure with multimeter because they are too short. I guess I could get some kind of shunt so I can measure the current peaks with my scope.

I tested wake-up time from light sleep using my scope. I used a GPIO to wake the ESP32 and get it to set a second GPIO to HIGH so I could measure the wake up time. It seems to be around 550~600us.

Here are a few pics:



I tried the link I posted in post #27. I was offered the XIAO ESP32C3 for £1.73 with free postage. But when I logged in, the price changed to £6.40 with free postage over £8!

So the offer price must be for new customers only. I suppose I could create another account with another email. I wonder if that would work after I give the same delivery address as I used previously...

What else have I learned about using XIAO ESP32C3 so far?

When using either sleep mode, you have to force the board into bootloader mode before you can upload more code. This is done by holding down the "B" button while clicking the "R" button. After upload completes, you have to click "R" again to set the code running.

Debugging code that uses sleep modes (deep or light) is tricky. In either sleep mode, the native USB connection to the PC immediately stops working as soon as sleep mode is entered, and after waking again, a new port seems to get created (eg. /dev/ttyACM1 instead of /dev/ttyACM0). By the time you have switched to that new port and Serial Monitor has re-opened, it's too late and you missed the messages.

I fixed this by attaching a separate USB-serial adapter to the RX & TX pins and using Serial1 instead of Serial for all my debugging messages. This adapter stays awake and doesn't loose any of the messages. It's still a different port to the one you need to use to upload new code, but at least it always has the same port device name and doesn't keep disappearing and re-appearing.