can I use one of those to power arduino nano?
I would like to build a clap on off bulb similar to this .
I want to use it in order to save the extra 5v psu so I could just use 1 plug to the main that will also power the arduino
can I use one of those to power arduino nano?
I would like to build a clap on off bulb similar to this .
I want to use it in order to save the extra 5v psu so I could just use 1 plug to the main that will also power the arduino
This is the schematic I have - is that make sense?
code:
const int SOUND_PIN = 2; // KY-037 digital output (interrupt-capable pin)
const int RELAY_PIN = 4; // Relay control pin
volatile bool clapDetected = false;
unsigned long lastClapTime = 0;
int clapCount = 0;
const unsigned long IGNORE_MS = 150; // Ignore re-triggers from the same clap's noise/echo
const unsigned long WINDOW_MS = 500; // Time window to wait for a possible second clap
bool waitingToDecide = false;
void handleClap() {
clapDetected = true;
}
void setup() {
pinMode(SOUND_PIN, INPUT);
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW);
attachInterrupt(digitalPinToInterrupt(SOUND_PIN), handleClap, RISING);
Serial.begin(9600);
}
void loop() {
unsigned long now = millis();
if (clapDetected) {
clapDetected = false;
// Ignore rapid re-triggers from the same clap's own noise
if (now - lastClapTime < IGNORE_MS) {
return;
}
clapCount++;
lastClapTime = now;
waitingToDecide = true;
Serial.print("Clap detected, count = ");
Serial.println(clapCount);
}
// After the window closes with no new clap, decide what to do
if (waitingToDecide && (now - lastClapTime > WINDOW_MS)) {
waitingToDecide = false;
if (clapCount == 1) {
digitalWrite(RELAY_PIN, HIGH);
Serial.println("Lamp ON");
} else if (clapCount >= 2) {
digitalWrite(RELAY_PIN, LOW);
Serial.println("Lamp OFF");
}
clapCount = 0;
}
}
Relay 5v:
sound module KY-037:
Please clarify exactly which "Nano" board you are using as there are multiple boards with Nano in their name
In general term, yes you can use that module to power a Nano but what experience of dealing with high voltages do you have ?
3.0 CH340 USB Type-C ATmega328P
I do have some experience with main. I build something similar using 555 timer and 4017 which worked for some degree (not all claps were capture)
Regarding the wiring - is my schematic is right in term of connecting the Live line of the bulb to the live line input while the Natural is passing through the Relay? or it needed to be the other way around? or it is not really matter?
It should be adequate, but you need to add up the power requirements of all the items in your project, and that means everything.
Power your Arduino board from it, but don't exceed the maximum power output of the board as a whole or the individual pins on the board.
A good rule of thumb is that the board controls the loads etc., it doesn't power them.
Of course, there are exceptions. Low power LEDs with limiting resistors work fine.
PS Take care with 220-V AC. It can kill, or at best, you won't touch it twice.
For safety reasons, I would not think in terms of “which one should I switch?”. Use a properly rated double-pole relay/contactor and switch both Live and Neutral.
Also, never switch protective earth / PE / ground. PE must remain permanently connected. Only Live and Neutral may be switched.
like this one?
Please note that AC wires correct names are "Line" and "Neutral"
Please show in more detail how are you going to connect load to relay module.
I could not found 220vAC 5vDC DPDT relay. can I use two single relays?
what is not clear from the schematic?
Your link shows: DPDT Double Pole Double Throw Relay!
but it rated to 120vAC and not 220v
what could happen using only 1 relay to switch the Line wire? it seems all the example online using this way (this not saying it is the right way..)
This is usually not necessary. In most cases, a relay is used to switch only one pole. Switching two poles is only necessary if there are increased safety requirements—for example, if the device will be used in hazardous areas or may be used by children.
not in my case. so I could go with the last schematic I posted?
The diagram does not show how the L, N and G wires are connected to the load.
the load (lump) have only two wires . the lump plug is connected to the output socket (the most right hand socket symbol)
that output socket N pin is connected directly to the input socket N pin (the most left hand side in the schematic)
the L pin of the output socket is connected to the Normalyl Open pin of the relay while the L wire of the input socket is connected to the Relay Common pin.
the G wire is not connected nowhere because it is not used
Is this more clear?
Mains voltage can be lethal. Based on your questions, I don't think you currently have the background needed to work on mains-powered equipment safely.
My recommendation is simple: don't continue with this project.
I'm out.
That depends.
Can you please post the datasheets for the two modules.