The relay is not switching ON though the arduino digital pin is activated. If I use the arduino power source +5v to the relay module then it is working as expeted. Dont know where I am doing mistake.
This would go better if you posted your code. Per Wawa you did set your digital pin as Output correct? The default is Input so if you want a Digital Out you need to include it in your code. Here is a basic example.
void setup() {
pinMode(7, OUTPUT); // sets the digital pin 7 as output
}
void loop() {
digitalWrite(7, HIGH); // sets the digital pin 7 on
delay(1000); // waits for a second
digitalWrite(7, LOW); // sets the digital pin 7 off
delay(1000); // waits for a second
}
The example uses pin 7 but applies to any digital pin. You also fail to mention which pin you are using? Again, please post your code?
Your diagram looks good but? Post a link to your 12V to 5V converter and let us know if it is an isolated converter or if ground is the same on both sides. Also post a link to the relay module and is it rated for a digital input.
I am using the simple code and it is working if I use 5v and Gnd pins of arduino to power the relay module. But if I am trying to power the relay module as per my above diagram, the relay is not responding.
That does not match your picture. Per the diagram remove the jumper and JDVcc goes to the 12V supply. All grounds are connected. Using it as it I would expect it not to work.
Can you post a picture of this relay module and indicate in detail how you have it wired?
It's the 5V and JVCC jumper.
If you're bringing 12V to it, then the jumper-block (shunt) should be out/removed.