I am trying to control a waterpump with my build-in light sensor on my Arduino nano 33 BLE. Since I am a rookie in Arduino and coding, I am confused as to what to do. I realize that I need to use a relay to connect my water pump to my Arduino, but I don't know how te circuit exactly works and how to develop the coding.
A simple top level view of the circuit:
Control the relay 5V inputs with the Nano
Connect the power for the water pump to the NO (normally open) pin of the relay, and then out via the GND or common pin of the relay to the pump and then ground of the pump power.
Some details:
Must put a diode across the coil pins of the relay. I can't tell if this relay module has one built in already. Any cheap old diode will work, e.g. 1N4007 or any 1N400x. It must be connected such that current will not flow though it if you just looked at the static picture of the circuit diagram. That is, the anode to ground and cathode to positive. It is there to save the Nano from the voltage generated by the collapsing field in the coil when it is de-energised.
I can't see from the relay info what current it draws at 5V. Likely too high for the Nano. So, connect the Nano output pin to the base of any old NPN transistor and drive the relay from it.
I would suggest you find a different relay module, the one you chose the relay coil appears connected directly to the Arduino, that will eventually fry the Arduino pin even if you use a diode. I would also be surprised if the arduino could supply enough current to actuate the relay. Relay boards are available from many sources that will work with 3V3 or 5V that typically have a transistor on them to energize the relay. Use this as a search term: "arduino relay 3v3".