I'm working on a project where 5 piezo ceramic sensors are connected to an Arduino and turning on a 5V relay when any of the 5 sensors are registering pressure.
The problem I'm having is that the 5V relay only turns on accordingly when powered via USB to laptop and not via a 30W universal AC/DC power adaptor.
Any suggestions to what the issue may be?
Here is the code I'm using:
int relayPin = 3;
void setup()
{
Serial.begin(9600);
pinMode(relayPin, OUTPUT);
}
void loop()
{
int val1;
val1=analogRead(0); //Connect the analog piezoelectric ceramic vibration sensor to analog interface 0
int val2;
val2=analogRead(1);
int val3;
val3=analogRead(2);
int val4;
val4=analogRead(3);
int val5;
val5=analogRead(4);
if (val1>0 || val2>0 || val3>0 || val4>0 || val5>0) {
digitalWrite(relayPin, HIGH);
Serial.println(val1, DEC);//Print the analog value read via serial port
Serial.println(val2, DEC);
Serial.println(val3, DEC);
Serial.println(val4, DEC);
Serial.println(val5, DEC);
delay(1000) ; //delay in milli seconds
}
else {
digitalWrite(relayPin, LOW);
Serial.println("off");
}
delay(100);
}
fishmarcel:
I've put it on 5V and tried the other voltages as well but without any luck
You can not put 5V on the barrel jack. That supplies the on-board voltage regulator so you need to supply at least 6 V for the regulator to work. If you already have 5V and it is regulated, you can connect it directly to the 5V pin on the Arduino (as well as to your sensors)
blh64:
You can not put 5V on the barrel jack. That supplies the on-board voltage regulator so you need to supply at least 6 V for the regulator to work. If you already have 5V and it is regulated, you can connect it directly to the 5V pin on the Arduino (as well as to your sensors)
I've had similar issues to fishmarcel. How do you do that if the power supply you are using has a barrel jack plug?
The clear blunder is not comprehending what the "Vin" or "RAW" terminal is. The regulator on the Arduino UNO/ Nano/ Pro Mini/ Mega2560/ Leonardo/ Pro Micro has very little heatsink, so will not pass very much current (depending on the input voltage and thus, how much voltage it has to drop) before it overheats and (hopefully reversibly) shuts down. It is essentially a novelty provided in the very beginning of the Arduino project when "9V" power packs were common and this was a practical way to power a lone Arduino board for initial demonstration purposes. And even then it was limited because an unloaded 9 V transformer-rectifier-capacitor supply would generally provide over 12 V which the regulator could barely handle.
Nowadays, 5 V regulated switchmode packs are arguably the most readily available in the form of "Phone chargers" and switchmode "buck" regulators are cheap on eBay so these can be fed into the USB connector or 5 V pin to provide adequate power for most applications. Unfortunately, many tutorials or "instructables" are seriously outdated or misleading and have not been updated to reflect the contemporary situation.