<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Lesson 17. PLC module + relay]]></title><description><![CDATA[<h2>The purpose of this lesson</h2>
<p dir="auto">Hi! Today we will add a relay to the PLC module and see how it works.</p>
<p dir="auto"><img src="https://pp.userapi.com/c850216/v850216196/5245e/qI6TfRuWstA.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Figure 1</p>
<p dir="auto">This tutorial will teach you to wield a soldering iron. Manage the load with M5.</p>
<h2>Short help</h2>
<p dir="auto"><strong>List of components for the lesson:</strong></p>
<ul>
<li>PC;</li>
<li>M5STACK;</li>
<li>USB-C cable from standard set;</li>
<li>additional PLC module;</li>
<li>mains socket;</li>
<li>mains plug;</li>
<li>external power supply 12 V;</li>
<li>wires under load;</li>
<li>relay 250 V 10 a control voltage 5 V;</li>
<li>transistor 2N2222A;</li>
<li>resistor 1 kOhm;</li>
<li>soldering iron;</li>
<li>solder;</li>
<li>tooling.</li>
</ul>
<h2>Let's start!</h2>
<h3>Step 1. Installation</h3>
<p dir="auto">Take a relay, transistor and resistor and solder it to the PCB of the PLC module according to the scheme shown in figure 2.</p>
<p dir="auto"><img src="https://pp.userapi.com/c850216/v850216287/4df4b/a2gOsnmovbs.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Figure 2</p>
<p dir="auto">Approximately should look like after Assembly of components (Fig. 2.1).</p>
<p dir="auto"><img src="https://pp.userapi.com/c850216/v850216196/524b0/0m3oSKbTju8.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Figure 2.1</p>
<h3>Step 2. Assembly</h3>
<p dir="auto">Now assemble the module in the case (Fig. 3 - 3.1).</p>
<p dir="auto"><img src="https://pp.userapi.com/c850216/v850216287/4df7e/9EsAJ7McWaA.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Figure 3</p>
<p dir="auto"><img src="https://pp.userapi.com/c850216/v850216287/4df74/cVVoCsPNVKs.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Figure 3.1</p>
<h3>Step 3. Mains plug</h3>
<p dir="auto">In order to connect our module to the power supply we need to prepare a plug with special plugs (Fig. 4).</p>
<p dir="auto"><img src="https://pp.userapi.com/c850216/v850216287/4df92/TKmh73rlY9Y.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Figure 4</p>
<h3>Step 4. Socket</h3>
<p dir="auto">Connect the wire to the socket and a special connector (Fig. 5).</p>
<p dir="auto"><img src="https://pp.userapi.com/c850216/v850216287/4df9c/v49uaVLyuVE.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Figure 5</p>
<h3>Step 5. Connect</h3>
<p dir="auto">Plug the plug and sockets into the device, then plug in the power supply (Fig. 6).</p>
<p dir="auto"><img src="https://pp.userapi.com/c846016/v846016125/11727d/mAmzIKfkOD4.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Figure 6</p>
<h3>Step 6. Load the sketch</h3>
<p dir="auto">Figure lightOn and lightOff files are available via the link in the **Downloads * * section.</p>
<pre><code>#include &lt;M5Stack.h&gt;

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);
}
</code></pre>
<p dir="auto">After the sketch is loaded, the device starts clicking the relay (Fig. 7 - 7.1).</p>
<p dir="auto"><img src="https://pp.userapi.com/c846016/v846016125/1172b5/aJ15DYDek-Y.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Figure 7</p>
<p dir="auto"><img src="https://pp.userapi.com/c846016/v846016125/1172ab/1IdlaiD_7Jc.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">Figure 7.1</p>
<h3>Final step</h3>
<p dir="auto">That's all. :)</p>
<h2>Downloads</h2>
<ul>
<li>Video (YouTube): <a href="https://youtu.be/_07uW7Cve8Q" target="_blank" rel="noopener noreferrer nofollow ugc">https://youtu.be/_07uW7Cve8Q</a></li>
<li>LightOn and lightOff (Yandex.Disk): <a href="https://yadi.sk/d/65SleNXxa0X_dw" title="https://yadi.sk/d/65SleNXxa0X_dw" target="_blank" rel="noopener noreferrer nofollow ugc">https://yadi.sk/d/65SleNXxa0X_dw</a></li>
</ul>
]]></description><link>https://community.m5stack.com/topic/372/lesson-17-plc-module-relay</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Mar 2026 07:16:31 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/372.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 18 Oct 2018 16:18:16 GMT</pubDate><ttl>60</ttl></channel></rss>