Relay not working with Particle photon

Hi Guys,
This is my first time here and I am really not sure about the rules and things.
So I am planning to control a light switch using the photon,so I am using a single channel relay and I have connected it to ground and connected the vin of the relay to 3V pin,And the terminal pin of the relay is connected to pin D7.

As a start i put it as on for 5 seconds and off for 5 seconds.But my relay doesn’t respond,its power green LED is on and the red relay light is also on all the time.

I dont know why the relay doesnt respond.The relay works well I tested it manually.

please help

maybe shoot a photo of your rig.

Your relay may need 5V to actuate, and you should not power it from a GPIO.

1 Like

now the relay lights work but i cant hear the sound of the relay and it doesnt work as a switch

try moving the red power line from 3V3 to VIN (5Volts coming from USB)

I tried doing it Then always the red one is on,No matter i change D& low or high

on the relay, black is GND I can see that… what does the middle (orange) and the other side (red) say on the relay?

is your relay ACTIVE HIGH (actuates when signal pin is brought to ground) or ACTIVE LOW (actuates when signal pin is brought high)?

VIN- Red
In1-Orange
GND-Black

my relay switch gets on when i supply a low voltage to the orange wire

Can you post stripped down example code?

int led1 = D7;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop() {
digitalWrite(led1, HIGH);
delay(5000);
digitalWrite(led1, LOW);
delay(5000);
}

perhaps the pin D7 is not providing enough delta in voltage? Did you try another pin that has no LED and corresponding resistor attached?

Can you manually connect the orange lead to GND and make it actuate when you are powering from VIN?

yes I have tried all pins individually to see wether there is a voltage problem,Yes when the orange is connected to the ground the relay works perfectly.

I have attached no resistor,should i attach one

I found what I believe to be the relay board you are using, the HL-51. How can they possibly sell a relay board like that with free international shipping for US$0.89? Yes, 89 cents! Unfortunately, the eBay seller didn’t link to the schematics or specs, so that wasn’t that helpful in this case.

Do you say its a bad relay or what.
I tried this with an Arduino Uno it works perfectly

Arduino Uno => 5Volt GPIO’s

Particle Photon => 3.3V GPIO’s

your voltage delta may not be getting over the hump

You can try a PULLUP resistor on your signal pin, pulling it up to VIN, but make sure it is a 5V tolerant pin.

I would not use D7

Hi this sounds it will work can you explain a bit more clearly please.

Can you just draw a rough sketch and tell me what reisitor to use.Please

  1. Modify your code to work on pin D6.

  2. Place a pull-up resistor of reasonable size (e.g.10 kOhm) between VIN and D6. This will force the pin to a 5V state when ‘idle’ (high).

  3. When you digitalWrite(D6, LOW); you are bringing the signal pin to ground. Hopefully that will create enough of a voltage drop for your finicky relay module to trip.

  4. when youdigitalWrite(D6, HIGH); it will bring the pin up to 5V, not the expected 3.3V, but that pin is tolerant of 5V.

OK?

So i place the a 10Kohm resistor between D6 and VIN(5V).and I power the relay using 3V
AM I correct

And where should I connect the output pin for the relay?To D6?

First try:

GND (black) to GND on Particle
In1 (orange) to D6
VIN (red) to VIN Particle

Then if that doesn’t work:

GND (black) to GND on Particle
In1 (orange) to D6
VIN (red) to VIN Particle
Connect Pull-Up resistor from D6 to VIN on Particle

what does the arduino have to with this I dont understand

Particle (edited)