Hello, I have the following problem with the ESP32 board, I try to activate a relay from Bluetooth, but the relay does not activate, I made a measurement to verify that voltage arrived through PIN 12, and the signal it generates is 3.3v, the relay is of 3v, and even so, with this signal, the relay does not work.
What could be happening?
Code:
//This example code is in the Public Domain (or CC0 licensed, at your option.)
//By Evandro Copercini - 2018
//
//This example creates a bridge between Serial and Classical Bluetooth (SPP)
//and also demonstrate that SerialBT have the same functionalities of a normal Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
#if !defined(CONFIG_BT_SPP_ENABLED)
#error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip.
#endif
BluetoothSerial SerialBT;
int pinOut = 12;
int maleta = 23;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
pinMode(pinOut, OUTPUT);
digitalWrite (pinOut, LOW);
delay (20);
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available())
{
char data = ((byte) SerialBT.read());
switch (data)
{
case 'P':
digitalWrite (pinOut, HIGH);
//Hacemos un delay de 1 segundo
delay (1000);
digitalWrite (pinOut, LOW);
break;
case 'b':
digitalWrite(maleta, HIGH);
delay(800);
digitalWrite(maleta, LOW);
break;
default : break;
}
Serial.println(data);
}
delay(20);
}
Diagram