реклама:

The relay unit with 1 or 4 outputs. Part 11.

The relay unit with 1 output

The relay unit we need to control the pumps. In a simple scheme we only have one pump, so we may use relay with one output. In this case, the power for the relay can be taken from the board Arduino.

Here is a table of conformity between relay pins and Arduino:

Relay pinsArduino pins
VCC5V
GNDGND
IN30

Wiring diagram:

The relay unit with 1 output

To connect the relay with 1 output is used only 3 wires
The relay unit with 4 outputs

If you have a more complicated system with two or three pumps or there is a need to heat water using electrical heating element, then it is necessary to switch four outputs. And there is a small problem. If you do not supply arduino via the USB input, but through the power connector - then, most likely, when all four relays will be switched on simultaneously arduino board will go into reset because of overheating of power chip. There are two solutions. The first is to use an external 5V power supply for the relay. In this case, the power to the relay module is not taken from the board arduino, but directly from the power supply. It is advisable to take the relay module with galvanic isolation - it is necessary to clarify the seller when buying such a unit.

Below is a wiring diagram with two power suppliers:

The relay unit with 4 outputs

Power Arduino board with 2 power supply unit

The second - to use 5V power supply, which is able to keep the current 1.5 - 2A and USB cord. You may use any USB cable of B type. This connector has a square shape with bevelled corners. You have to cut it and find + 5V and GND pins. And connect them with the correct polarity to the power supply. I think you will need to have a multimeter, to do it.

In any case, give here pinout:

Power Arduino via USB cord

Way to cross the power supply and USB cable

You can buy a universal power supply with different attachments, including a USB:

DC to USB connector

Or use the power supply with USB connector

Power supply with USB

Connecting the relay via a USB cable:

Power Arduino via USB cord

This way you may supply Arduino board via USB connector

After connecting the relay download the test sketch below, and make sure that the power switch is connected properly. If you have connected everything correctly, the relay should click one by one... 1, 2, 3, 4. If you are using 1 output relay, you will hear only one click. The correct order of connection you may check with help of LEDs, which are located on the relay.

Sketch example:

// include the library code:
#include <LiquidCrystal.h>

#define PWM_LED_PIN 3 
#define PIN_LCD_RS 39
#define PIN_LCD_EN 41
#define PIN_LCD_D4 43
#define PIN_LCD_D5 45
#define PIN_LCD_D6 47
#define PIN_LCD_D7 49

#define P1_PIN 30
#define P2_PIN 31
#define P3_PIN 32
#define P4_PIN 33

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd( PIN_LCD_RS, PIN_LCD_EN, PIN_LCD_D4, PIN_LCD_D5, PIN_LCD_D6, PIN_LCD_D7 );

void setup() {   
  analogWrite( PWM_LED_PIN, 255 );
  
  lcd.begin(16, 2); 
  lcd.print("House4u sol.proj");
  lcd.setCursor(0, 1); 
}
int Delay = 1000;
void loop() 
{             
   for ( int i = 0; i < 4; i++ )
   {    
     lcd.setCursor(0, 1);            
     lcd.print("P");
     lcd.print( i + 1 );
     lcd.print(": On ");
     
     pinMode( P1_PIN + i, 1 );       
     delay( Delay );
   
     lcd.setCursor(0, 1);
     lcd.print("P");
     lcd.print( i + 1 );
     lcd.print(": Off");  
     
     pinMode( P1_PIN + i, 0 );   
     delay( Delay );
   }    
   
   Delay += 1000;
   if ( Delay > 2000 )
     Delay = 1000;   
}

This picture you should see on your Arduino's display :

Result of the program on the LCD display

The result of the program on the LCD display

On the relay box you should see the flashing of the LEDs:

Flashing LEDs on the relay

The result of the program - flashing LEDs on the relay


<< BackNext >>


Share with friends:

Donate