I've been playing around with my Arduino Pro Mini 5V. I got it setup to control a relay. I'm having no trouble having it work when I power it from the USB adapter I got it connected to and it also works just fine powered to an external PSU.
Here's the Schematics*:
*I adjusted my voltage regulator to output 5V instead of the 6.9V that's on the image but it didn't help my case. The voltage regulator is the lm2596.
I have no formal education in Electronics my specialization is Software Engineering so I might have something wrong with my connections. All my knowledge on electronics is self taught and very weak. If there's a good book you can recommend to read I'd appreciate the recommendation.
Now what's happening is that, when I have the arduino connected to the PSU and I connect it by USB, the two at the same time. The USB connection keeps reseting, Windows even makes the sound it makes when you plug in a USB device. This is really bad because I wanted to later connect a RaspberryPi by USB to interact with the Arduino.
This is the sketch I'm running (I can't find where to add a code snippet):
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(7, OUTPUT);
}
int i = 0;
void loop() {
// put your main code here, to run repeatedly:
Serial.print("Attempt number ");
digitalWrite(7, i%2);
i++;
Serial.println(i);
delay(5000);
}
It is definitely related with switching the Relay given that if I remove the digitalWrite(7, i%2) line I get an uninterrupted feed. But as soon as it starts switching the Relay the USB connection starts dropping. I have no idea what I'm doing wrong and help would be greatly appreciated.
Is that a plain relay or a relay board with a driver? If it’s just a relay hopefully it doesn’t take too much current to power the relay than the pin can take. Second if it’s just a relay do you have a fly back diode?
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
blh64:
You don't have a common ground throughout your schematic. You need to connect the PSU negative to the arduino ground (COM-)
I can’t see anything wrong here.
In that respect.
Many Arduinos have a built in switching circuit that powers the board either from the USB or the external input. The Pro Mini does not have this circuit so you are in effect connecting the 5V from your external supply to the USB socket. This will try and power the PC’s USB port which could damage your PC. The Pro Mini is not suited to what you want to do.
wolframore:
Is that a plain relay or a relay board with a driver? If it’s just a relay hopefully it doesn’t take too much current to power the relay than the pin can take. Second if it’s just a relay do you have a fly back diode?
It's a relay board, one like this:
The jumper is off and I'm powering the JD_VCC pin from the power supply.
Where would I need to place the fly back diode?
TomGeorge:
Hi,
Welcome to the forum.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
What voltage do you have going into Vraw?
Thanks.. Tom...
Already fixed my original post. Thanks for the tip. The Voltage going into Vraw is 5v.
Grumpy_Mike:
I can’t see anything wrong here.
In that respect.
Many Arduinos have a built in switching circuit that powers the board either from the USB or the external input. The Pro Mini does not have this circuit so you are in effect connecting the 5V from your external supply to the USB socket. This will try and power the PC’s USB port which could damage your PC. The Pro Mini is not suited to what you want to do.
I didn't know that. But I can communicate nicely with it if I don't start switching the relay. I can get an uninterrupted feed and in my original code I'm using serialEvent() to interface with it and it goes nicely, the code in it looks like this:
void serialEvent() {
String requestResult = Serial.readString();
char input = requestResult[0];
switch(input) {
case 's': // Switch
Serial.print("SWITCH FROM ");
Serial.print(relay.getPeriodVerbose());
relay.switchState();
Serial.print(" TO ");
Serial.println(relay.getPeriodVerbose());
break;
case 't': // Timer Disable/Enable
timer.toggle(relay.getTimerId());
Serial.println("TIMER PAUSED!");
break;
case 'r': // Reset timer
timer.restartTimer(relay.getTimerId());
Serial.println("TIMER RESET!");
break;
case 'l': // Log
printLog();
break;
default:
printLog();
Serial.print("Command Received is not in API: ");
Serial.println(requestResult);
}
}
If this is bad practice what's the recommended way to have the Pro Mini interface with some external computer? I have some ESP8266 but it's giving me headaches to getting them to work... It seems counter intuitive that you wouldn't be able to use the Serial communication channel on the Pro Mini once it's being powered by an external power source.
But I can communicate nicely with it if I don't start switching the relay. I can get an uninterrupted feed and in my original code I'm using serialEvent() to interface with it and it goes nicely,
When the relay is turned on the current draw of the whole system increases. My guess is it is that which is upsetting the balance and causing back feeding into the USB. If you had an oscilloscope you could check it for your self.
Grumpy_Mike:
When the relay is turned on the current draw of the whole system increases. My guess is it is that which is upsetting the balance and causing back feeding into the USB. If you had an oscilloscope you could check it for your self.
Okay I've been researching about that whole back feeding phenomena. It does seem like that's the problem, well spotted! I'm still left with no solution, I don't know what are my options now. Should I just give up on using serial communications? Can I connect a USB without the power lines and will that work? Do I man up and setup my ESP8266 to have the arduino on my local network?
I'm still left with no solution, I don't know what are my options now.
Options:-
Add a switching circuit for the power like that found in the Uno. Look at the Uno schematics for this.
Use another type of Arduino, one that does have power switching circuits.
Modify the FT232 connections so you don't wire the 5V out of this to the Vcc input. This way you will always need you external power supply as well as a USB connection.