3.3 relay going crazy

i have 2 relays that have the VI(3.3v), IN(signal to toggle the relay) and GND, its plugged to an ESP32 and when i press a button, both open at the same time, everything works amaizing when its pluged to my pc, but as soon i connect the sistem to an buck converter, the relays start to flick like it would not be a tomorrow, i dont know what is causing this bc i dont change either the code or the cables, the only thing that change is the power suply, i think it could be linked to the fact that the way it detects the button is bc it sense a voltage in the pin and that the noise of the buck converter is messing with it, but i have no experience in this so pls help

You may need a more powerful PSU.

Welcome!!!
Send circuit diagrams along with the code.(pls post the code in code tags)

How is your pullup (or pulldown) of that button?

Please provide a wiring diagram and datasheets for the relay and buck.
There are many ESP32 variations and boards, which are you using?

There is more to electricity / electronics than volts. Things like current (Amps), resistance (Ohms), power (Watts), etc, etc.
How much current does your project (including relay coil current) require? How much current can your power supply provide without the voltage sagging below a critical level?

Hi, @finters
Welcome to the forum.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Do you have a DMM? (Digital MultiMeter)

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

hello and thanks for the welcome, yes i have a DMM

the hardware is the "DOIT ESP32 DEV KIT V1", 2 3.3v relays the button, cap, and resistor as it is shown in the image, and the power supply is a 12V batery going to a buck converter

DOIT ESP32 DEV KIT V1

the way is coded ( by AI ) is that whenever it detects an analog value => 4000 from the 4095 it can read

const int analogButtonPin = 15; // Pin donde está el botón analógico
const int controlPin1 = 22;     // Pin de control 1 del actuador
const int controlPin2 = 23;     // Pin de control 2 del actuador

const int threshold = 4000;     // Umbral analĂłgico para activar el botĂłn

void setup() {
  Serial.begin(9600);           // Inicia la comunicaciĂłn serial
  pinMode(controlPin1, OUTPUT);
  pinMode(controlPin2, OUTPUT);
  digitalWrite(controlPin1, LOW);
  digitalWrite(controlPin2, LOW);
}

void loop() {
  int analogValue = analogRead(analogButtonPin);

  if (analogValue >= threshold) {
    digitalWrite(controlPin1, HIGH);
    digitalWrite(controlPin2, HIGH);
    Serial.println("Estado: Pin 22 y Pin 23 en HIGH");
  } else {
    digitalWrite(controlPin1, LOW);
    digitalWrite(controlPin2, LOW);
    Serial.println("Estado: Pin 22 y Pin 23 en LOW");
  }
}

it used to have an pullup but i thougt that that part of the code was the responsible of messing with the relays, but as soon i changed it (besides having a more simple code) when i tested it again with the esp32 pluged to my pc it runed smother than before so i leave it like that

Hi, @finters

Measure the 3V3 supply to your relays when connected to PC and working okay.
Measure the 3V3 supply to your realys when connected to the DC-DC converter and faulty.

Can you post some images of your project?
So we can see your component layout.

Why is there a 490uF across the button?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Why are you using an analog input, you should be using a digital mode input.

AI , now start from scratch and write your own code.

What did you ask AI to put in your code?

The resistor/switch configuration will not work properly.

Tom.. :smiley: :+1: :coffee: :australia:

I would start by knowing how much current your relays need verse what your power supply is capable of.

Ron

I'm not able to perfectly follow you and AI, but noisy power combined with floating input is not best way to go. Try with 1K hardware pullup to test if it resolves it.

in this moment i dont have access to it but tomorrow i ll do, yet, i remember me measuring it in both occasions and in both were 3.3v, in any case im cheking it again tomorrow an i will tell you

in order you can understand the image (bc ik its a mess) im telling you this, the esp32 is mounted on a board that have screw ports and pin inputs for each pin of the board, the button is to the left of the board ( the black and blue thing) and the capacitor and the resistor is conected to the button going directly to the board

and the capacitor is between 200pF and 100pF tbh i dont remeber, but its in the button to remove the button kickback

the relay´s coil uses about 200mA for it to operate and i use 2 relays, and the ESP32 uses nearly 50mA , and the buck converter can provide up to 2A

everything, i barely know anything about c++, i asked to make a pin to change state (LOW or HIGH) depending if a button is pressed or not, and is writted in analog bc before if the pin sensed just a bit of voltage it would change state and mess with the sistem, even if i touched it could change the state of the relays, thats why i prefered going for an analog value of, and i used 4000 and not the full 4095 it can read to leave a margin of error

what do you mean?

Hi, @finters
What is printed on the top of the relays?

Your image is good, but closer would let us read the component annotations.

:smiley: :+1: :coffee: :australia:

Looks like you are feeding 3.3V into the MCU board's 3.3V OUTPUT pin.