Introduction: Door Alarm System With Node32s Aiyarafun
What's amazing!! If you can create the security system with your own.Imagine if you're hang out somewhere and a thief know you not here and try to break in your room.What will happened? Maybe you need it to help you !!
You can create "Door Alarm System" so easy by yourself.We use Node32s to control DFPlayer mini mp3 module and send the data as a notification on cloud platform "Anto.io" which you can open this web on any device like your mobile phone ,pc and Ipad. It's use the principle of capacitive sensor which is already built in some pins on NODE32s.It will sense the voltage when it was touched by something conductivity like your fingers.We adapt it by stripping wire at the end of jumper wire.You will see the copper out and then stick it to the knob.
Step 1: Install ESP32 in Arduino Ide
You can follow and download the library from Espressif github in https://github.com/espressif/arduino-esp32
Prepare the software before installing
1. Install Git command line
2.Install Python 2.7.x
Install Python Serial
3.Install arduino ide
For ESP32 Core, Go to directory file's arduino ide with 'CD....' command (follow in picture)
and then clone arduino-esp32 project from Github with command git clone https://github.com/espressif/arduino-esp32.git esp32
Install compiler tool with command 'cd esp32/tools'
Step 2: Prepare Your Equipments
1. Aiyarafun/LamLoei Node32S 1 pc.
2. Speaker 1 pc.
3. DFPlayer mini mp3 module 1 pc.
4. SD card 1 pc.
5. jumper wire 10 pc.
6. Breadbroad 1 pc.
Step 3: Wiring Your Equipments
The green label in 'NODE32S pinout' picture show capacitive sensor pins.In this video we use 'touch0' which is on GPIO04.We also use GPIO16 and GPIO17 to control DFPlayer mini mp3 module. Because we need pin on DFPlayer module to play only one pin one file as the description DFPlayer pins in this picture.It's ADDKEY_1 which trigger play fist segment and ADDKEY_2 which trigger play fifth segment. So,We need to record voice in SD Card around 5 files but really use just only two files
About this "Door Alarm System",we would like to use ADDKEY_2 to play track "Please identify yourself" and ADDKEY_1 to play track "scream". You can see more information about DFPlayer mini mp3 module fromhttps://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299
VCC and TX pins on DFPlayer module is connect to the loud speaker in order to alarm when capacitivs sensor was touched.
Step 4: Test the Range of Threshold in Arduino Ide
1.You need to check your selected board at 'Tools' -> select 'Node32s'
2.Go to 'File' -> 'Example' -> 'ESP32' -. 'Toch' -> 'TouchRead'
3.Connect the micro USB between your Node32s to your computer and then upload this example code.
Open serial Monitor in arduino ide and notice the value changed when you touched the capactive sensor. Follow in picture,when we touch it. The value is change from '35' to '12'.So,if you want to set the value,maybe fill 20.It's mean whenever the value is lower than 20, sent the data to do next on your program.
Step 5: Create Channel Thing on Cloud Platform Anto.io
Anto.io is cloud platform that you can use it free.You can look the data in realtime and when the internet is lost,it will save the last value for you.
You can download the library and set in arduino ide fromhttps://github.com/AntoIOT/anto-esp32-arduino
1. After you log in to Anto.io. First, you click on 'thing' at the left side.It will display like this picture below.and then you will see the topic 'create new thing' on the top page.
When you click on "create new thing" it will display you to create name.In this video, we use name "AlertDoor".
Step 6: Create Name Device in Channel Things Anto.io
2. click on magnifying glass (number 2),it will show the empty page.You need to click on "create new channel" on the top page and then it will give you to fill 'channel name' and select the type for your variable.For example,we create name "LEDdoor". You want to control led to on/off when someone touch sensor.So,it need to use type "switch". For name "Message",you want to sent the message as "your room is safe".It need to use type "string".For name "password",you want to set number in order to identify yourself before enter room.So, you need to use type "integer".
Step 7: Create Key on Anto.io
3.Go to topic "Key" on the left side.You will see the empty page in first time.Click on "Create new key".One thing in channel name has only one key.
It will display the index of channel name which you have created and then click 'read' and 'update' in order to allow the variable can be change in real time using.
Step 8: Create Dynamic Text on Dashboard Anto.io
We use dynamic text to be the notification for user to know your room now is safe or someone try to break in your room.In general,it will show "Your room is safe" but in the reverse it will show "Someone hack your room".The message you can change in code on arduino.ide
Go to topic "Dashboard" on the left side.You will see "Add New Widget" click to open it.It will display diversity options about how to present the information on dashboard.Try to play "Dynamic text".When you create "Dynamic text" it will show small popup on Dashboard and then click on the cog symbol.It will show the detail about "Dynamic text".You need to choose which text source you want to show data.The option name in 'text source' come from device name you created in channel thing on Anto.io. For programming on arduino ide,if you want to sent the data from NODE32s to Anto.io.You need to write "anto.mqtt.pub("Message",text2); " When "Message" is device name in Anto.io and text2 is the variable which you want to sent the message as "String text2= "Your room is safe".
Step 9: Create Light Bulb on Dashboard Anto.io
Click on "Add New Widget" and choose "Light Bulb" and then you will see the small light bulb on your dashboard.Click on the cog symbol,it will show detail about light bulb. You need to choose which channel you want to show data.It's "LEDdoor" that we created in device name in channel thing.
In this video, Led will turn on when the capacitive sensor was touched.For programming on arduino ide,if you want to sent the data from NODE32s to Anto.io.You need to write "anto.mqtt.pub("LEDdoor","1"); " However if you want to turn off the led you need to write "anto.mqtt.pub("LEDdoor","0"); ".
By the way, if you want to sent the data from Anto.io to NODE32s,you need to write ""anto.mqtt.sub()".In this case, we use "password" on Anto.io to be like the authentication.So, we need to write "anto.mqtt.sub("password");"Whenever we fill "1" in password and sent it from Anto.io to Node32s. It means you fill correct password.So,it will not alarm.
Step 10: How to Code It
You can download code from https://drive.google.com/file/d/0B7B755VWb8z5OHl5ZjRuYTRrXzQ/view?pageId=117565435305139242166
The DFPlayer module will play when logic "Low" If you ever write the basic program in arduino ide on example"Blink".It use the same way to control that module.
digitalWrite(plaIt's easy and y2,LOW);
digitalWrite(play2,HIGH); //play2 is pin 17 on NODE32s
and the capacitive sensor in programming it works like interrupt with the main function.Try to understand how it works in Examples -> ESP32 -> Touch -> TouchInterrup ..on arduino ide.You should to understand it before you adapt code to use.It's easy and funny to learn.
We have a be nice policy.
Please be positive and constructive.