Lesson 17. PLC module + relay



  • The purpose of this lesson

    Hi! Today we will add a relay to the PLC module and see how it works.

    Figure 1

    This tutorial will teach you to wield a soldering iron. Manage the load with M5.

    Short help

    List of components for the lesson:

    • PC;
    • M5STACK;
    • USB-C cable from standard set;
    • additional PLC module;
    • mains socket;
    • mains plug;
    • external power supply 12 V;
    • wires under load;
    • relay 250 V 10 a control voltage 5 V;
    • transistor 2N2222A;
    • resistor 1 kOhm;
    • soldering iron;
    • solder;
    • tooling.

    Let's start!

    Step 1. Installation

    Take a relay, transistor and resistor and solder it to the PCB of the PLC module according to the scheme shown in figure 2.

    Figure 2

    Approximately should look like after Assembly of components (Fig. 2.1).

    Figure 2.1

    Step 2. Assembly

    Now assemble the module in the case (Fig. 3 - 3.1).

    Figure 3

    Figure 3.1

    Step 3. Mains plug

    In order to connect our module to the power supply we need to prepare a plug with special plugs (Fig. 4).

    Figure 4

    Step 4. Socket

    Connect the wire to the socket and a special connector (Fig. 5).

    Figure 5

    Step 5. Connect

    Plug the plug and sockets into the device, then plug in the power supply (Fig. 6).

    Figure 6

    Step 6. Load the sketch

    Figure lightOn and lightOff files are available via the link in the **Downloads * * section.

    #include <M5Stack.h>
    
    extern unsigned char lightOn[];
    extern unsigned char lightOff[];
    
    void setup(){
      M5.begin();
      pinMode(5, OUTPUT);
      M5.Lcd.setBrightness(100);
    }
    
    void loop() {
      M5.Lcd.drawBitmap(126, 70, 100, 100, (uint16_t *) lightOff);
      digitalWrite(5, HIGH);
      delay (1500);
      M5.Lcd.drawBitmap(126, 70, 100, 100, (uint16_t *)lightOn);
      digitalWrite(5, LOW);
      delay (1500);
    }
    

    After the sketch is loaded, the device starts clicking the relay (Fig. 7 - 7.1).

    Figure 7

    Figure 7.1

    Final step

    That's all. :)

    Downloads


登录后回复
 

与 M5Stack Community 的连接断开,我们正在尝试重连,请耐心等待