
Chinese: 
各位好，之前有幾集一直談物聯網的應用
包括學生、老師、同工及校長，不止一人問及
究竟Blynk是否只能控兩顆LED
大家可以看看
不要說光是開啟220V的燈及風扇
看完這集，飛機大炮都可用Blynk啟動啊！
不信嗎？我們立即開始！
提醒一下，假如大家都喜歡風琴奇俠卡洛斯的頻道
請於右下角按訂閱

English: 
Hello everyone, I have been talking about the application of the Internet of Things in a few episodes before
Including students, teachers, co-workers and principals, not only one person asked
Does Blynk only control two LEDs?
Everyone can take a look
Don’t just turn on 220V lights and fans
After watching this episode, the aircraft cannon can be activated with Blynk!
Don't believe it? Let's start now!
Just a reminder, if everyone likes the channel of Carlos the OrganMan
Please click subscribe in the lower right corner

Chinese: 
假如希望第一時間接到新影片的通知
請按叮噹
亦歡迎大家按讚及留言發問
談了這麼多集IoT之後
又令卡洛斯想起周星馳的"整蛊專家"中的一幕
假使我能用Blynk控制遠方NodeMCU
再操控其他電器，那理論上不用再入元朗了！
一起看看什麼是Blynk，Blynk是一個物聯網平台
平常容易，五分鐘可完成編程
手機和NodeMCU現在同一網絡下

English: 
If you want to be notified of new videos as soon as possible
Please press the bell
Everyone is also welcome to like and leave a message to ask questions
After talking about so many episodes of IoT
It reminds Carlos of a scene from Stephen Chow’s "Tricky Expert"
If I can control a remote NodeMCU with Blynk
If you control other electrical appliances, you don't need to enter Yuen Long in theory!
Let’s take a look at what Blynk is, Blynk is an IoT platform
Normally easy, programming can be completed in five minutes
The mobile phone and NodeMCU are now under the same network

Chinese: 
理論上啟動手機編程便可控NodeMCU
按D0，On時LED不亮，Off時LED亮
On時LED不亮，Off時LED亮
那如何用NodeMCU控大型的電器
那我要介紹新零件，名稱為繼電器
繼電器(Relay)是一種用低電壓供高電壓電路的元件
款式有多種，我們用動畫解說一下
這部份是電磁鐵，接上如DC5V就會有磁力

English: 
In theory, NodeMCU can be controlled by starting mobile phone programming
Press D0, the LED is off when On, and the LED is on when Off
LED is not bright when On, LED is bright when Off
How to use NodeMCU to control large electrical appliances
Then I’m going to introduce a new part named Relay
Relay is a component that uses low voltage for high voltage circuit
There are many styles, let’s explain with animation
This part is an electromagnet, if it is connected to DC5V, it will have magnetic force

English: 
The upper part is a metal sheet, the electromagnet will be attracted by the magnetic force, thereby pushing the side contact
The contact can allow large voltage and high current to pass through
Such as AC220V used at home
Low voltage and high voltage lines are completely isolated
That is, the user can control the high voltage by just touching the low voltage
Will not get electric shock easily, so safety control is achieved
Then use everycircuit platform to explain the relay circuit
This is the DC 5V power supply symbol, this is the single pole single throw (SPST) switch symbol
This is a relay with two wires in the middle
Indicates that the primary DC line is completely separated from the secondary AC line

Chinese: 
上方是金屬片，電磁鐵有磁力會被吸下，從而推動旁邊接點
接點是可容大電壓大電流通過的
如家裡用的AC220V
低電壓與高電壓線路完全隔離
即用家只需接觸低電壓便能控高電壓那邊
不會輕易觸電，因此達成安全控制
再用everycircuit平台講解一下繼電器線路
這是直流5V電源符號，這是單刀單擲(SPST)開關符號
這是繼電器，中間有兩條線
表示初級的直流線路與次級交流線路完全分隔

Chinese: 
次級方面我們有另一個電源，是交流200V
別有一200V燈泡
開始接線
完成接線按左下角Run開始模擬
everycicuit會把每個接點的電流電壓都顯示
啟動開關後，看到電流運動以動畫顯示
看到初級電磁啟動次級接點
於是次級的200V燈泡被點亮
在everycicuit更可指定電線通道
觀察電壓電流圖表

English: 
On the secondary side, we have another power supply which is AC 200V
Don't have a 200V bulb
Start wiring
Complete the wiring and press Run in the lower left corner to start simulation
everycicuit will display the current and voltage of each contact
After starting the switch, see the current movement displayed in animation
See the primary electromagnetic start secondary contact
So the secondary 200V bulb is lit
In everycicuit can also specify the wire channel
Observe the voltage and current graph

English: 
Is a very easy to use electronic circuit simulator
If you are interested, please try it on everycircuit.com
Carlos uses the previous video: Realizing the smart home
The Blynk and NodeMCU programs inside drive the relay
You can refer to this video if you haven’t watched it
The difference is that this time D0 and D4 are connected to the input of the dual relay module (the two circuit boards must share the ground)
So Blynk can control the relay through the network
And the secondary of the relay should be carefully connected to the mains to control the external electrical appliances
Safety must be the top priority when making assignments on utility power
Don’t make it like a small production
All parts and circuit board wiring cannot be exposed

Chinese: 
是非常好用的電子線路模擬器
有興趣請上everycircuit.com試用
卡洛斯使用之前影片：實現智能家居
裡面的Blynk及NodeMCU程式驅動繼電器
未看過的可先參考這影片
不同的是這次D0及D4連接了雙繼電器模組的輸入(兩線路板要共地)
於是用Blynk可通過網絡控制繼電器
而繼電器的次級要小心連接至市電以控制 外面的電器
每逢製作有關市電的習作必須安全至上
不能好像小製作般隨意做
所有零件及線路板接線不能外露

English: 
Must be installed in an insulated plastic case to ensure user safety
Carlos was born in electronic and electrical engineering
So I can take the responsibility for making textbooks about electrical
But if the teachers and students watching the video have not received training
Please let an experienced technician accompany the production
This case needs to be connected to the mains
There is a 5V transformer inside to power NodeMCU and relays
The Normal Open contact of the relay forms a loop with the mains and socket
After completion, you must cover the case before you can test the machine
First plug in the power
A fan and a revolving light are plugged into the output socket
The switch of the appliance itself must be turned on first
The power input of the chassis is equipped with a switch and indicator light, you can test it first

Chinese: 
必須安裝於絕緣的塑料機箱內，以保障使用者安全
卡洛斯唸電子電機工程出身
因此可以為自己製作有關電氣的教材承擔責任
但觀看影片的老師同學若沒有接受訓練
請讓有經驗的技術員陪同製作
這機箱要連接市電
內裡有一5V變壓器為NodeMCU及繼電器供電
而繼電器的Normal Open接點則與市電及插座構成迴路
完成後必須蓋上機箱才可以試機
首先插上電源
在輸出插座插上了風扇及走馬燈
電器本身的開關先要開啟
機箱的電源輸入附有開關及指示燈，可以先測試一下

English: 
After DIY for so long, I finally feel the joy of using a mobile phone to control electrical appliances!
After seeing the demonstration, in theory, you no longer have to go to the Yuen Long Customs System?
But thinking about it further, is there any mobile phone that has no signal?
In case the mobile phone fails or the other party’s WiFi has problems
Then we must go to the Yuen Long Customs General Administration!
In order to take care of unexpected network accidents, we still have to think more
For example, if the mobile phone is disconnected, the home appliances cannot be controlled
And my wife came home and saw the light at home turned on
At least one physical button must be prepared for her to turn off the lights!
So I improved the design and first found two illuminated buttons
Drill and cut square holes in the chassis to install buttons
Screw nut on the back of the button to fix
Finally install the LED and switch components
As for the NodeMCU expansion board and relay module

Chinese: 
DIY了這麼久，終於感受到用手機控制電器的喜悅！
看到了示範，理論上不再要到元朗關總制吧？
但想深一層，有否手機沒有訊號？
萬一手機失靈，或對方的WiFi出現問題
那還是要到元朗關總制吧！
為了照顧網絡突發的意外，還是要多想一步
例如手機失聯，控不了家中電器
而我太太回到家，看見家中的燈開啟了
最少要預備一個實體按鈕讓她關燈吧！
於是我改良設計，首先找到兩個帶燈按鈕
在機箱鑽孔、切割出四方孔來安裝按鈕
按鈕背面擰上絲母固定
最後安裝LED及開關組件
至於NodeMCU擴展板及繼電器模組

English: 
Need to be fixed on the bottom of the chassis with copper pillars dedicated for circuit boards
Plug in NodeMCU after fixing the circuit board
Because of the budget, the programming needs to be modified frequently
So I drilled a hole where the USB plug of NodeMCU was close to the chassis
Easy to plug in USB cable for programming at any time
As for the wiring of the illuminated button, we must first study
The two pins in the middle are LED pins, and the two pins on the side are switch pins.
I first tear out two pairs of wires with rainbow wires
First solder the LED pins of the illuminated button
Because I want the LED to display the D0 and D4 status of NodeMCU

Chinese: 
需要用線路板專用的銅柱固定在機箱底部
固定線路板後才插上NodeMCU
由於預算了要經常修改編程
因此我在NodeMCU的USB插貼近機箱處鑽孔
方便隨時插上USB cable編程
至於帶燈按鈕的接線要先研究一下
原來中間的兩腳是LED接腳，而側面的兩腳是開關接腳
我先用彩虹線撕出兩對接線
先銲接帶燈按鈕的LED接腳
由於我想LED顯示NodeMCU的D0及D4狀態

English: 
So connect the LED and D0 and D4 in parallel
In the study of computer programming, Divide and Conquer (divide and conquer) are often used
Simply put, it is to destroy one by one
Let's first test whether the indicator light works
If the LED is not bright, the polarity may be reversed
There is no problem with the indicator light, so we can deal with the button
Randomly pick two out of the many interfaces of NodeMCU, I picked D2, D3
Each pair of wiring should be connected to the D pin (Data) and G pin (Ground) of D2, D3
The switch contact of the button is directly welded on the other side of the wiring
The hardware should be fine, unless there is a problem
NodeMCU programming will be more complicated this time, let me explain slowly

Chinese: 
因此把LED和D0及D4並聯便可
在電腦編程的學習上，經常要使用Divide and Conquer(分治法)
簡單來說就是逐個擊破法
我們先來測試了指示燈是否工作
如LED不亮，有可能是極性對調
指示燈方面沒問題，才來處理按鈕
在NodeMCU的眾多接口中隨意挑兩個，我挑了D2, D3
每對接線應接上D2, D3的D腳(Data)及G腳(Ground)
接線另一邊直接銲上按鈕的開關接點
硬件應該沒問題了，除非有問題
NodeMCU編程今次會較為複雜，讓我來慢慢解釋

English: 
As always, these three sentences open the Blynk and NodeMCU libraries
Since Blynk will check the button regularly this time, set Timer
These four variables carry relay and button status
These three sentences are very familiar, namely the authorization code, WiFi name and password
Button 1 and 2 are set to D2 and D3 pins
After starting Blynk, set the pinMode, D2 is the input, usually the button is not pressed, it should be PULLUP
D0 is the output
The state of relay 1 and D0 should be the same, so use digitalWrite to write D0
D3 is input, D4 is output, D4 should be the same as relay 2
This sentence is to use Timer, every twenty one second to checkPhysicalButton check button

Chinese: 
一如以往，這三句開啟Blynk及NodeMCU程式庫
由於今次要Blynk定時檢查按鈕，所以設Timer
這四個變數載著繼電器及按鈕狀態
這三句很熟，就是授權碼、WiFi名及密碼
按鈕1及2設定為D2及D3針腳
啟動Blynk後便設pinMode，D2是輸入，平時按鈕沒按下應PULLUP(高電位)
D0是輸出
繼電器1的狀態和D0應一致，因此用digitalWrite寫入D0
D3是輸入，D4是輸出，D4應和繼電器2一致
此句是運用Timer，每二十份一秒到checkPhysicalButton檢查按鈕

Chinese: 
主程式超簡單，就是Blynk.run( )及timer.run( )
子程式比較多，第一個BLYNK_CONNECTED( )檢查手機Virtual Pin V1, V2
若然有會啟動BLYNK_WRITE(V1)及BLYNK_WRITE(V2)
內容就是把V1及V2狀態寫入D0, D4
最後一個子程式checkPhysicalButton( )才是主角
剛才設了每二十份一秒會跳過來
先檢有沒有按紅色鈕
若有要改變繼電器狀態
連手機V1狀態也改變
即有人去了元朗按總掣，我手機也會顯示
另一按鈕也是一般處理
我發覺我把紅色和黃色對調了！

English: 
The main program is super simple, namely Blynk.run() and timer.run()
There are many subprograms, the first BLYNK_CONNECTED() checks the phone Virtual Pin V1, V2
If so, BLYNK_WRITE (V1) and BLYNK_WRITE (V2) will be activated
The content is to write the status of V1 and V2 into D0, D4
The last subroutine checkPhysicalButton() is the protagonist
I just set it to skip every 20 seconds
Check if the red button is pressed first
If you want to change the relay state
Even the phone V1 status has changed
Even if someone goes to Yuen Long and presses the switch, my phone will display
The other button is also general processing
I noticed that I reversed red and yellow!

Chinese: 
BUTTON_1是黃色，BUTTON_2才是紅色
聽完解說還不明白？可以在info bar下載慢慢研究
除了下載了NodeMCU的編程，手機的編程也修改了
兩個BUTTON現在不是D0, D4，而是V1, V2
指示燈之前已經試了，現在試真實按鈕
按黃色鈕，指示燈亮，同時回饋到手機啟動V1
再按，兩者同時關上
紅色按鈕的反應也一致
接近完全，先接市電
把電器接上智能控制盒
開了總開關試用
一如之前，手機可控電器

English: 
BUTTON_1 is yellow, BUTTON_2 is red
Still don’t understand after listening to the commentary? You can download it in the info bar and study it slowly
In addition to downloading the programming of NodeMCU, the programming of the mobile phone is also modified
The two BUTTONs are now not D0, D4, but V1, V2
The indicator light has been tried before, now try the real button
Press the yellow button, the indicator light is on, and the phone will start V1
Press again to close both at the same time
The response of the red button is also consistent
Nearly complete, first connect to the mains
Connect electrical appliances to the smart control box
Open the main switch for trial
As before, mobile phones can control electrical appliances

English: 
If the network fails, use the Physical Button
If there is a network when using Physical Button, the phone will see
The Internet of Things system must be controlled in two ways like this before we can use it with confidence
After this episode, everyone will understand that the smart home controlled by Blynk is not a fantasy
Because with external circuits and relays, it is possible to control electrical appliances with different voltages
Even if the network is unstable, Plan B can be arranged with parts and programming
I hope the video can deepen everyone’s understanding of the Internet of Things and smart homes
Like my video, please add likes and comments!

Chinese: 
若然網絡失靈，便用Physical Button
若然用Physical Button時有網絡，手機會看到
物聯網系統要像這樣雙向控制，我們才放心用
經過今集，大家會明白Blynk控制的智能家居不是空想
因為配合外在電路及繼電器，是可控制不同電壓的電器
即使網絡不穩定， 也可用零件及編程安排Plan B
希望影片可加深大家對物聯網和智能家居的認識
喜歡我的影片，句吝惜加讚及留言！
