Good day everybody.
I have been struggling with this small issue. I hope from someone to give me an answer or at least a direction. Since this is Electronics related I think I placed it in the right forum topic, but if I’m wrong please correct me.
Problem:
I want to power a reed-relay via an ESP32. The reed-relay works fine if I power it directly via the 3v3 pin of the ESP32. However, it does not work if I try to power it up via another pin with OUTPUT pin mode set to HIGH.
Description:
I am creating a puzzle game that involves an mp3 player. I want to be able to relay the audio signal to a telephone horn if a phone message is playing. If not, I want to be able to play a moody background sound via a speaker. So, my ESP32 must be able to relay the audio either to the phone horn or the speaker.
To make this possible I first tried a regular relay switch. However, the clicking noise of the switch was bothering me and I looked for a more silent solution. After a little search I decided to choose a reed-relay. Technical specifications can be found here:
If I read the power specification correctly, it should work with 3v3 at 25mA. Slightly below the 40mA that the ESP32 can deliver.
My technical setup now looks like this:
But no matter which digital output pin I use, the reed-relay does not power up and work as intended. To make sure that my ESP32 is not damaged, I replaced the reed-relay with a simple resistor and LED. I see the diode shining once the output pin is powered up.
What am I overlooking or doing wrong? Is the power output of a digital pin lower than 3v3 at 40mA?
My thanks in advance for everybody that can point me in the right direction.
Additional Stuff:
Even though I don’t think it is program related, the code below can be used to test the reed-relay:
// Command module running on an ESP32.
#include <SoftwareSerial.h>
#include "DFRobotDFPlayerMini.h"
// MP3 initialization.
#define MP3_RX_PIN 5 // GPIO5/D1
#define MP3_TX_PIN 4 // GPIO4/D2
#define MP3_SERIAL_SPEED 9600 // DFPlayer Mini suport only 9600-baud
#define MP3_SERIAL_BUFFER_SIZE 32 // Software serial buffer size in bytes, to send 8-bytes you need 11-bytes buffer (start byte+8-data bytes+parity-byte+stop-byte=11-bytes)
// Pin initialization.
#define Audio_Pin 32 // GPIO18. Pin for controlling the Reed-Relay that handles the audio output.
// SoftwareSerial and MP3player declaration.
SoftwareSerial mp3Serial; // RX, TX
DFRobotDFPlayerMini mp3;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
mp3Serial.begin(MP3_SERIAL_SPEED, SWSERIAL_8N1, MP3_RX_PIN, MP3_TX_PIN, false, MP3_SERIAL_BUFFER_SIZE, 0);
delay(500);
if (!mp3.begin(mp3Serial)) { //Use softwareSerial to communicate with mp3.
Serial.println(F("DFPlayer unable to begin:"));
while (true);
}
Serial.println(F("DFPlayer Mini online."));
pinMode(Audio_Pin,OUTPUT);
// mp3 Config Settings
mp3.setTimeOut(400); //Set serial communictaion time out 400ms
mp3.volume(30); //Set volume value (0~30).
mp3.EQ(DFPLAYER_EQ_NORMAL);
mp3.outputDevice(DFPLAYER_DEVICE_SD);
mp3.loop(1);
}
void loop() {
digitalWrite(Audio_Pin,HIGH);
delay(500);
digitalWrite(Audio_Pin,LOW);
delay(500);
}