Introduction: Arduino With GSM and PIR Sensor (English/Arabic)

درس التحكم بالاردوينو عن طريق شبكة الجوال

المقدمة:

يتيح لك هذا الدرس استخدام شبكة الجوال للتحكم بضوء الليد بالمنزل عن طريق ارسال رسالة نصية وايضا استخدام الاردوينو للاتصال الاتوماتيكي من المنزل لجوالك عند استشعار اي حركة في الغرفة لسماع نوع الاصوات في غرفتك واتخاذ الاجراء الازم

Introduction:

This lesson will allow you to use SMS to control an LED along with using Arduino to make automatic calls to your phone in case it sensed movements in your room. You will be able to listen to the voices there and act upon emergency.

Step 1: Required Parts

القطع المطلوبة:

· اردوينو

· سلك ارتباط الاردوينو بالكمبيوتر

· قطعة شبكة الجوال

· شريحة جوال

· حساس حركة

· ٢ من الالوان المختلفة من أضواء الليد

· مقاومة بقيمة 220 Ω ٢ من

· اسلاك

· لوح كهربائي للتجارب

· 12VDC محول كهربائي

· مايكروفون

· سماعات خارجية ( كإضافة وليست مطلوبة

Parts:

· Arduino Uno R3

· Type A to B USB

· SainSmart GSM SIM300 Module

· Sim Card

· Motion Sensor

· 2 different Color LED

· 2x 220 Ohm Resistor

· Jumper wires

· Breadboard

· 12VDC adaptor

· Microphone

· Speakers (Optional)

Step 2: Connections

توصيل القطع:

الشكل التالي يوضح لك كيفية توصيل القطع مع الاردوينو. فقط تتبع الاسلاك المرسومة بحذر و تأكد منها في الجداول المرفقة

Connections:

Follow the attached picture connections carefully. Please verify your connections with the table below.

توصيل قطعة شبكة الجوال

Connections between Arduino and GSM Module:

GSM === Arduino

TX === PIN 3

RX === PIN 2

GND === GND

توصيل حساس الحركة:

Connections between Arduino and Motion Sensor:

Motion Sensor === Arduino

VCC === 5 V

Data === PIN 7

GND === GND

توصيل الاردوينو لضوء الليد

منفذ رقم تسعة و عشرة في الاردوينو => الطرف الاول من المقاومة

الطرف الثاني من المقاومة => الطرف الموجب في الليد : هو الطرف الاطول في القطعة

الطرف السالب في الليد => منفذ الارض في الاردوينو

Connections between Arduino and LED

Pin 9/10 in Arduino => one side of the Resistor

Other side of the Resistor => Positive Side of LED (long leg)

Negative side of LED => GND in Arduino

Step 3: GSM Configuration

بعض الترتيبات على قطعة شبكة الجوال:

· الرجاء التأكد من اماكن قطعة التوصيل ووضعها كما موضح بالصورة

o هذا المكان يمكن القطعة من معرفة هل التعامل مع الكمبيوتر او متحكم دقيق

· تأكد من توصيل سماعات ومايكرفون للجهاز كما بالصورة

· تأكد من وضع شريحة جوال تعمل و يفضل بدون رقم سري

· تأكد من توصيل المحول الكهربائي

GSM Configuration:

· Please make sure the jumpers are correctly placed as attached picture

o This will allow the chip to know if it is dealing with a micro controller or PC

· Connect speakers and microphone as in picture

· Place a valid SIM card preferably no pin code.

· Connect Power adapter to GSM

Step 4: Programming

رفع البرنامج إلى الاردوينو:

فقط حمل البرنامج المرفق او انسخ الكود الى برنامج الاردوينو

الرجاء التأكد من بعض المعطيات في الكود قبل تشغيله:

· NUM_MSGS_DELETE تأكد من هذا الرقم اذا كانت الشريحة غير مخصصه للمشروع

· CPIN[] ادخل رقم الشريحة السري ان وجد في

· AT() اذا وجد رقم سري تاكد من تفعيل الكود في دالة

· CALL_NUM رقم الاتصال عند حدوث حركة

توجد هناك دالة مضافة للكود لتوفر لك خاصية ارسال الاردوينو للرسائل النصية

1. لأستخدامها يجب عليك ملئ هذه الحقول في الكود:

o SEND_MSG_NUM ادخل رقم مستقبل الرسالة

o SEND_MSG_TXT محتوى الرسالة النصية

2. وايضا تغير امر الاتصال الى امر ارسال رسالة في الدالة الرئيسية

o send_call() ----to----> send_txt()

أضف مكتبة جديدة للأردوينو:

حمل المكتبة المرفقة واستخرجها من الضغط الى

C:\Users\user\Documents\Arduino\libraries

هذه المكتبة عبارة عن مكتبة السوفتوير سيرال الاساسية ولكن اضفت مساحة اضافية في الحاوية الداخلية من 64 بايت الى 100 لأستقبال الرسائل كاملة

Uploading program to Arduino:

Just download the program or copy the code into an Arduino sketch

Please go over this code check list prior to executing the code:

· NUM_MSGS_DELETE (check it’s value if the SIM is not dedicated for the project)

· CPIN[] (insert SIM PIN Code, if required )

· if PIN is required, uncomment the code in AT()

· CALL_NUM (Emergency Call Number For Motion)

There is an additional function (send_txt()) in the code for Sending SMS instead of calling you.

1. For it to work you must fill :

o SEND_MSG_NUM (Insert phone number to receive SMS MSG)

o SEND_MSG_TXT (Insert SMS text)

2. And replace send_call() with send_txt() in main loop

ADDED LIBRARY:

Download adjusted Software Serial library and place it in:

C:\Users\user\Documents\Arduino\libraries

Only internal buffer increased to 100 instead of 64 nothing more.

Step 5: Explaining the Code

شرح البرنامج:

يوجد شرح بسيط بداخل الكود عن ما يفعله كل سطر في الكود المرفق بالعربية والانجليزية

ارجوا قراءة جميع التعليقات لفهم عمل المشروع

Explaining the code:

Almost every line inside the code has comments along with it

Please try reading all comments attached to understand the code.


أوامر الاي تي:

اوامر الاي تي هي تعليمات تتيح للمستخدم التحكم بالمودم. والاي تي هي اختصار من كلمة انجليزية تعني الانتباه او انتبه .

عند ارسال امر في بدايته

"AT" or "at"

ينتبه المودم للأجابة على الامر في الحال.

لمعرفة المزيد من الاوامر وكيفية عملهم، مرفق ملف به الاوامر التي يمكنك استخدامها.

AT Commands:

“AT commands are instructions used to control a modem. AT is the abbreviation of ATtention. Every command line starts with "AT" or "at". That's why modem commands are called AT commands. Note that the starting "AT" is the prefix that informs the modem about the start of a command line.” From CodeProject.com

To know and understand each command, you can download attached PDF file.

Step 6: Controlling the Project

التحكم بالمشروع:

1. عند الحركة المستمره امام مستشعر الحركة سيتم الاتصال بهاتفك الجوال

2. عند الاجابة على الجوال ستتمكن من سماع ما يدور من حركة في المكان

a. في هذه الاثناء، بإمكانك الحكم على الاصوات بالخطورة او عدمها

3. يمكنك ارسال رسالة جوال للشريحة المتواجدة مع الاردوينو تحتوي على كلمة

a. ON لتشغيل الليد

b. OFF لإغلاق الليد

Controlling the project:

1. When a continuous movement is detected by the motion sensor, you will receive a call

2. When answering your phone, you will be able to listen to the surroundings of the device.

a. This will allow you to take necessary action

3. You can also send a Text to the Arduino with:

a. ON – To turn the LED ON

b. OFF – To turn the LED OFF

Step 7: Future Projects Using This Lesson

مشاريع مستقبلية باستخدام هذه التقنية:

· عن طريق أضافة الريلاي بأمكانك التحكم بإنارة المنزل،بجرس أنذار، او بتشغيل اي جهاز متصل بكهرباء البيت

· عن طريق اضافة قطعة الاشعة تحت الحمراء بإمكانك التحكم بالمكيفات و اجهزة التلفاز بشبكة الجوال

· وايضا الكثير من المشاريع المميزة

Future projects using this lesson:

· By adding a Relay, you can control any AC device like your room lights, Alarm Sound, or any 110 V or 220V Household equipment

· By adding IR transmitter, you can control your TV and A/C using your phone World Wide.

· And many more…