BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Relay Trouble using BLE and Arduino

The Arduino is only providing the signal that tells the relay to turn ON/OFF. The current would come from the power supply. We could confirm if you have this wired correctly if you could provide details on the module, and how it is wired.

1 Like

I will provide more information, stay tuned. My LED was just being swapped in and out as a replacement for the relay as a test to see if any current is being passed as i pressed my button.

This is my updated sketch, as i said before V12 is gone and was leftover.

//Project Definitions
#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
#include <Blynk.h>
#include <BlynkSimpleSerialBLE.h>

#define RelayPin 7
SoftwareSerial DebugSerial (2, 3); //RX, TX
char auth[] = "xxxxxxx"; //Connection Code for Blynk

BlynkTimer timer;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
Blynk.begin(Serial, auth);
}

BLYNK_WRITE(V2) { 
int buttonState = param.asInt();
  if (buttonState == 1)
   {
     digitalWrite(RelayPin , HIGH);
     digitalWrite(ledPin, HIGH);
     timer.setTimeout(1000L, OFF); 
    }
}

void OFF()
{
      digitalWrite(RelayPin , LOW);
     digitalWrite(ledPin, LOW);
}
void loop()
{
  Blynk.run();
  timer.run();

} 

Here is the link to my relay module, I have also tested with a single relay module and no luck.
https://www.amazon.ca/gp/product/B06XCN5JNH/ref=ppx_yo_dt_b_asin_title_o07_s00?ie=UTF8&psc=1

8 Channels because I intend on adding more outputs to be controlled.

I will begin drawing a schematic for you.

1 Like

if digitalWrite(ledPin, LOW) works , digitalWrite(RelayPin , LOW) works too
but sometime you have to revert output level

so digitalWrite(RelayPin , LOW) to put relay state on
digitalWrite(RelayPin , HIGH) to put relay state off

@Toro_Blanco

My relay has an optional Jumper between Vcc and JDVcc which I have removed in order to provide the relay with sperate 5V. I have tested this both ways.

The signal must be low at in1 to activate the relay.
try to put in1 to the ground, the relay will be on, I’m pretty sure

I would confirm it is like this (but with the green wire going to the correct pin for your application):

1 Like

2020-06-12_193843

This will change the relay state after 1s.

Yes, putting IN1 to ground powered the indication LED on the relay.

So you have to invert LOW HIGH as I told you before.

1 Like

Don’t need an Arduino to test the board.
Place the jumper back connecting Vcc to JDVcc
Connect Vcc to 5v
Connect Gnd to ground
Ground any relay pin on the board and its respective relay should turn on.

I’ve few of those boards. Some need a LOW and others need a HIGH to activate the relay :man_shrugging:t2:

1 Like

Yes after testing this, you and @Blynk_Coeur are correct. When I send my relay input to ground it switches. Thank you for this. My primary issue still stands, when I send a signal from the Blynk app nothing changes still.


//Project Definitions
#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
#include <Blynk.h>
#include <BlynkSimpleSerialBLE.h>

#define RelayPin 7
SoftwareSerial DebugSerial (2, 3); //RX, TX
char auth[] = "xxxxxxx"; //Connection Code for Blynk

BlynkTimer timer;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
Blynk.begin(Serial, auth);
}

BLYNK_WRITE(V2) { 
int buttonState = param.asInt();
  if (buttonState == 1)
   {
     digitalWrite(RelayPin , LOW);
     timer.setTimeout(1000L, OFF); 
    }
}

void OFF()
{
      digitalWrite(RelayPin , HIGH);
   
}
void loop()
{
  Blynk.run();
  timer.run();
 

This is my updated sketch after switching my HIGH and LOW for my relay input. I do not believe my issue is a hardware issue now that I know my relay switches on a LOW signal, what can I do code wise to fix my primary problem?

1 Like

Adding a pinMode statement in your void setup would be the first thing to do.

Pete.

2 Likes