ESP32S3 doesn't run without serial usb?

Hi

i’ve just started working on a project with an esp32s3

i’ve made a program to send some data to Prometheus, except that the program doesn’t seem to be willing to run if i don’t use serial

Code

#include <Wire.h>

#include <esp_sleep.h>

#include <PromLokiTransport.h>

#include <PrometheusArduino.h>

#define WAKEUP_TIME_SEC 300 // 5 minutes

#define NO_TOUCH 0xFE

#define THRESHOLD 100

#define ATTINY1_HIGH_ADDR 0x78

#define ATTINY2_LOW_ADDR 0x77

unsigned char low_data[8] = {0};

unsigned char high_data[12] = {0};

PromLokiTransport transport;

PromClient client(transport);

// Create a write request for 2 series.

WriteRequest req(2);

TimeSeries ts1(5, “battery_level”, “{job=“esp32-test”,host=“esp32”}”);

TimeSeries ts2(5, “water_level”, “{job=“esp32-test”,host=“esp32”,foo=“bar”}”);

int loopCounter = 0;

void setup() {

Wire.begin();

Serial.begin(115200);

esp_sleep_enable_timer_wakeup(WAKEUP_TIME_SEC * 1000000); // Time in microseconds

transport.setWifiSsid("REDACTED");

transport.setWifiPass("REDACTED");

if (!transport.begin()) {

    Serial.println(transport.errmsg);

    while (true) {};

}

// Configure the client

client.setUrl("REDACTED");

client.setPath("REDACTED");

client.setPort(REDACTED);

if (!client.begin()) {

    Serial.println(client.errmsg);

    while (true) {};

}

// Add our TimeSeries to the WriteRequest

req.addTimeSeries(ts1);

req.addTimeSeries(ts2);

Serial.print("Setup Complete");

};

void loop() {

Serial.println("loop");

collect_send();

delay(5000);

};

void collect_send(void)

{

int64_t time;

time = transport.getTimeMillis();

if (!ts1.addSample(time, check_battery())) {

  Serial.println(ts1.errmsg);

}

if (!ts2.addSample(time, check())) {

  Serial.println(ts2.errmsg);

}

loopCounter++;

if (loopCounter >= 4) {

  Serial.println("4loop");

  // Send data

  loopCounter = 0;

  PromClient::SendResult res = client.send(req);

  if (!res == PromClient::SendResult::SUCCESS) {

      Serial.println(client.errmsg);

  }

  ts1.resetSamples();

  ts2.resetSamples();

  esp_deep_sleep_start();

}

}

void getHigh12SectionValue(void)

{

memset(high_data, 0, sizeof(high_data));

Wire.requestFrom(ATTINY1_HIGH_ADDR, 12);

while (12 != Wire.available());

for (int i = 0; i < 12; i++) {

high_data[i] = Wire.read();

}

delay(10);

}

void getLow8SectionValue(void)

{

memset(low_data, 0, sizeof(low_data));

Wire.requestFrom(ATTINY2_LOW_ADDR, 8);

while (8 != Wire.available());

for (int i = 0; i < 8 ; i++) {

low_data[i] = Wire.read(); // receive a byte as character

}

delay(10);

}

double check_battery(void)

{

uint32_t Vbatt = 0;

for(int i = 0; i < 16; i++) {

Vbatt = Vbatt + analogReadMilliVolts(A0); // ADC with correction  

}

float Vbattf = 2 * Vbatt / 16 / 1000.0;

return (double)Vbattf;

}

int check()

{

int sensorvalue_min = 250;

int sensorvalue_max = 255;

int low_count = 0;

int high_count = 0;

while (1)

{

uint32_t touch_val = 0;

uint8_t trig_section = 0;

low_count = 0;

high_count = 0;

getLow8SectionValue();

getHigh12SectionValue();

for (int i = 0; i < 8; i++)

{

  if (low_data[i] >= sensorvalue_min && low_data[i] <= sensorvalue_max)

  {

    low_count++;

  }

}

for (int i = 0; i < 12; i++)

{

  if (high_data[i] >= sensorvalue_min && high_data[i] <= sensorvalue_max)

  {

    high_count++;

  }

}

for (int i = 0 ; i < 8; i++) {

  if (low_data[i] > THRESHOLD) {

    touch_val |= 1 << i;

  }

}

for (int i = 0 ; i < 12; i++) {

  if (high_data[i] > THRESHOLD) {

    touch_val |= (uint32_t)1 << (8 + i);

  }

}

while (touch_val & 0x01)

{

  trig_section++;

  touch_val >>= 1;

}



return(trig_section*5);

}

}

I know i’m missing something, but i can’t put my finger on it

    // Initializes the debug output
    Serial.begin(115200);
    while (!Serial) delay(100);     // Wait for ready

Code of this type is designed to wait for serial connection before proceeding

<!> means while the serial port IS NOT CONNECTED…

yeah, i know that

but i’m not using it

the ones i’m using are if there is no wifi, and no server connection, nothing is about the Serial connection

How are you powering it?

I tried two ways

1- battery through the allocated pins
2- through the 5v pin with a regulated power supply

None of those works

try regulated 3v3 to the 3v3 pin

also i do not know why the battery would not work… did you use 3.7v LiPo?

even though the data sheet may say different… the 5v is supply from the usb only… the 5v pin will not recieve power if you want to power with 5v use a power bank

Hi there,
So if this is just an S3 no camera same applies.
from the WiKi
Circuit operating Voltage (ready to operate):

  • Type-C: 5V@19mA
  • BAT: 3.8V@22mA

  • 5V - This is 5v out from the USB port. You can also use this as a voltage input but you must have some sort of diode (schottky, signal, power) between your external power source and this pin with anode to battery, cathode to 5V pin.
  • 3V3 - This is the regulated output from the onboard regulator. You can draw 700mA
  • GND - Power/data/signal ground

Choice is Battery or USB-C
HTH
Gl :slight_smile: PJ :v:

BTW , Deep Sleep Model: 3.8V/14 μA:+1:

are you saying you CANT power 3v3 to the board?.. i am not an expert… i just read comments and extrapolate results… all i know is no one seems to be able to power thru 5v pin… maybe the forge to ground or something… what da?

I’ve just tried plugging a USB C, straight from the Power Adaptor

I get a blinking red light , as if it was charging the battery (which i disconnected)

But the ESP still doesn’t run

i still need to connect it to a computer for it to work

Opening a serial connection is not required, just plugging it in a computer seems to do the trick

I don’t know if it’s a design issue, or a manufactoring error, but that doesn’t seem right

Hi there,
The LED will blink initially and then go out.
normal operation.
Some battery packs will shut off as the Xiao doesn’t look like enough of a load on certain units.
Post the code and use the code tags above “</>” paste it in there/
Your close.
HTH
GL :slight_smile: PJ :v:

2 Likes