arduino uno boards Boards + 5v + esp8266 mobile remote control relay for lamp 220v

The foregoing has achieved control of LED lamp, but the lamp control how to do household 220v, plus relay

Amoy relay module on the treasure basically support 5v trigger, 3.3v trigger much (3.3v yet arrived, not tested)

Before because they do not know esp8266 not trigger pin 3.3v 5v relay module has not led to success (said to be connected to a trigger signal amplifying triode, out of stock so I did not test)

First recorded several concepts:

1. relay module to use (usually, I am now in contact with):

(1) Control (trigger) ends, feeding to the module:

  VCC: Power modules (e.g., 5V) anode input

  GND: the access module negative supply terminal

  IN: input of the trigger module (real control trigger terminal)

(2) a control terminal, the external power supply terminal to be controlled (eg: 220v)

  NO: normally closed terminal, the relay is not energized when the trigger is connected to the negative power supply control

  COM: positive power supply input terminal is controlled

  NC: normally closed terminal, when the power relay is triggered, the power supply is connected to the negative control

  NO / NC to a termination

2.arduino uno boards default voltage 5v, 5v this experiment, the trigger voltage relay module 5v

3. The experiment is built on the basis of the previous article on this blog

4. The hardware used are:

  1.arduino uno development board 

  2.esp8266 development board

  3.5v relay module

  4. The bread board, wires, etc.

The first on the arduino programming codes (non Esp8266 Code), Esp8266 Please refer to the previous article

int Button2 = 2 ;
 int Button5 = . 5 ;
 void Setup () { 
  Serial.begin ( 9600 ); 
  the pinMode (Button2, the INPUT);   // set input terminal pin number arduino2, 3.3v input voltage received Esp8266 
  pinMode (button5, the oUTPUT); // set pin number arduino5 output terminal, the output voltage control relay 5v 
} 

void Loop () {
   int ButtonState = digitalRead (Button2);   // Arduino pin status read No. 2, there is a voltage, 0 is no 
  IF (ButtonState == 0 ) { 
    digitalWrite ( 5 , the lOW);                   // if there is no voltage on pin 5 is set low (0V) the voltage output 
  }the else { 
    digitalWrite ( 5 , HIGH);                  // if voltage on pin 5 is set high (5V) output voltage 
  } 
}

6. After programming successfully connected, the camera a bit chaotic, or text it

  1. First connect arduino and Esp8266

    (1) to supply esp8266: 3v3 pin connects arduino3.3v

    (2) esp8266 input voltage signal to arduino: D5 pin is connected to pin number arduino2

    (3) esp8266 GND pin is connected to the GND pin Arduino

  2. Relay connection arduino

    (1) IN pin is connected to the relay pins arduino ~ 5

    (2) relay GND pin is connected to GND pin Arduino

    (3) relay arduino 5v VCC pin connects the power pin

  3. The relay is controlled to ensure that access to the power access of the positive electrode terminal COM, NC and NO optionally a terminal, in series to the LED lamp (220V? 5v first with the test with it)

  4.arduino power (bit rubbish), connection completion

7. Open the applet server connection MQTT try it, success? ! ! !

8. I purely white, chiefs do not spray, recording learning process.

Recommended learning arduino development board learning b station video link (pure white type): https://www.bilibili.com/video/av52628485?p=1

Guess you like

Origin www.cnblogs.com/Strangers/p/12466519.html