ESP32 Devkitv1 help

Right so ive search high and low and I cant figure out why my ESP32 Devkitv1 is running the setup and loop once and then rebooting

here is the serial port stuff that comes out every time

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1240
load:0x40078000,len:13012
load:0x40080400,len:3648
entry 0x400805f8
[��mum����2-hal-cpu.c:211] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
VMDPR_Setup start
Setup end
1
2
Buzz

if you can pls help

Can you provide code using the code tag </> and a schematic of what you have hooked up?

...especially whatever you turn on just after you print, "Buzz". :slight_smile:

If your board is DOIT ESP32_DEVKIT_V1, you have to select correspondingly. Selecting ESP32_DEV, etc. will cause the board to reboot like that.

You can also have to add delay(1) in the loop(), such as

void loop()
{
  ...

  delay(1);
}

I forgot to say I'm using visual studio and that's not an option on the topic select

#include <Tone32.h>
#include <pitches.h>

#define IR_Sensor 18
#define BUZZER_PIN 19
#define BUZZER_CHANNEL 0


int Counter;
int IR;
int frequency;

// the setup function runs once when you press reset or power the board
void setup() 
{
	Serial.begin(115200);
	Serial.println("Setup start");
	pinMode(IR_Sensor, INPUT);
	Serial.println("Setup end");
}

// the loop function runs over and over again until power down or reset
void loop()
{
	if (Counter == 0)
	{
		IR = digitalRead(IR_Sensor);
		if (IR = HIGH)
		{
			Counter++;
			Serial.println(Counter);
			delay(1000);
		}
	}

	if (Counter >= 1);
	{
		Counter++;
		delay(1000);
	}

	if (Counter >= 900)
	{
		Serial.println(Counter);
		Counter = 0;
		delay(500);
	}

	Serial.println(Counter);
	Buzzz();
	Serial.println(frequency);
}

void Buzzz()
{

	if (Counter == 300 && Counter <= 600)
	{
		frequency = 4000;
	}
	if (Counter == 600 && Counter <= 900)
	{
		frequency = 8000;
	}
	
	if (Counter <= 300)
	{
		Serial.println("Buzz");
		tone(BUZZER_PIN, frequency, 500, BUZZER_CHANNEL);
		noTone(BUZZER_PIN, BUZZER_CHANNEL);
		delay(500);
		tone(BUZZER_PIN, frequency, 500, BUZZER_CHANNEL);
		noTone(BUZZER_PIN, BUZZER_CHANNEL);
		delay(500);
	}
}


The thing above is the IR sensor

See the error with the above?

When you loaded the debug info into the ESP Exception Decoder what was the decoded message?

The op might want to learn more about the tone32.h library being used and how the numbers being sent to the tone32 library affect the ESP32's LEDC API, clicky clicky, and how those numbers are effecting the HardwareTimers and how the pitches.h numbers are interacting with the hardware timers.

1 Like

As @Idahowalker said, just change the frequency will solve your reboot issue, such as

...
tone(BUZZER_PIN, NOTE_C7, 500, BUZZER_CHANNEL);
noTone(BUZZER_PIN, BUZZER_CHANNEL);
delay(500);
tone(BUZZER_PIN, NOTE_DS8, 500, BUZZER_CHANNEL);
noTone(BUZZER_PIN, BUZZER_CHANNEL);
delay(500);
...
1 Like

The ESP32 MCU doesn't have as much driving power on its pins as Arduino UNO's 328P MCU. If you wish to use a buzzer, you need to drive it with some transistors. Even if you don't want transistors, you should use some resistors such as 500 ohm in series with the buzzer. Directly connecting the buzzer to an IO pin may cause damage to the pin. I have a similar looking buzzer. Whenever I turn it on, there is the order of hundreds of mA of current through my circuit. If you disconnect that buzzer and run your code without modification and it runs without reboot, you know it's the buzzer. Adding the resistor will make the sound very soft. Best is to use a transistor to drive it. Better than best is if you are already familiar with transistors and use two transistors and drive the buzzer with 5V.