صفحه 2 از 2 نخستنخست 12
نمایش نتایج: از 11 به 16 از 16
Like Tree3 لایک

موضوع: چگونگی اتصال ماژول sim 900 به اردوینو مگا و کار کردن با آن

  1. #11
    Junior Member
    تاریخ عضویت
    Apr 2014
    نوشته ها
    3

    Post چگونگی اتصال ماژول sim 900 به اردوینو مگا

    دوستان فقط ننویسید کارم راه افتاد. بگید دقیقا چطور کارتون راه افتاد
    ماژولی که من خریدم: ماژول GSM با قابلیت اتصال GPRS و ارسال و دریافت پیامک Sim900A

    تصویر سیم بندی
    برای دیدن سایز بزرگ روی عکس کلیک کنید

نام: SIM900A-Mini-03.jpg
مشاهده: 263
حجم: 94.0 کیلو بایت

    نکته1: اول که ولتاژ ماژول رو وصل کردید چراغ D6 (گوشه ماژول) سریع چشمک میزنه (1ثانیه یه بار) و بعد که آنتن گرفت آرومتر چشمک می زنه (3ثانیه یه بار)
    نکته2: اگر رایتل استفاده می کنید یا باید خیلی صبر کنبد تا آنتن بیاد یا تو گوشی اپراتور رو به صورت دستی رومیگ کتید رو ایرانسل یا همراه اول
    نکته3: توی کدنویسی شماره تلفن رو با 98+ شروع کنید
    نکته4: کمی به قسمت انگلیسی مغز فشار بیارید و توضیحات اول کد رو بخونید

    کد آردوینو مگا 2560
    کد:
    /*Note: this code is a demo for how to using gprs shield to send sms message,
    dial a voice call and
    send a http request to the website, upload data to pachube.com by TCP connection,
    The microcontrollers Digital Pin 7 and hence allow unhindered
    communication with GPRS Shield using SoftSerial Library.
    IDE: Arduino 1.0 or later
    Replace the following items in the code:
    1.Phone number, don't forget add the country code
    2.Replace the Access Point Name
    3. Replace the Pachube API Key with your personal ones assigned
    to your account at cosm.com
    */
    #include <SoftwareSerial.h>
    #include <String.h>
    SoftwareSerial mySerial(7, 8);
    void setup()
    {
    mySerial.begin(19200); // the GPRS baud rate
    Serial.begin(19200); // the GPRS baud rate
    delay(500);
    }
    void loop()
    {
    //after start up the program, you can using terminal to connect the serial of gprs shield,
    //if you input 't' in the terminal, the program will execute SendTextMessage(), it will show how to send a sms message,
    //if input 'd' in the terminal, it will execute DialVoiceCall(), etc.
    if (Serial.available())
    switch(Serial.read())
    {
    case 't':
    SendTextMessage();
    break;
    case 'r':
    RecieveTextMessage();//This program code by directive'r'to receive, by receiving the information after the return to call the function
    //to verify receiving function. But it can not display the received content in SIM.
    DialVoiceCall();
    break;
    case 'd':
    DialVoiceCall();
    break;
    case 'h':
    SubmitHttpRequest();
    break;
    case 's':
    Send2Pachube();
    break;
    }
    if (mySerial.available())
    Serial.write(mySerial.read());
    }
    ///SendTextMessage()
    ///this function is to send a sms message
    void SendTextMessage()
    {
    mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
    delay(100);
    Serial.write(mySerial.read());
    mySerial.println("AT + CMGS = \"0914xxxxxxx\"");//send sms message, be careful need to add a country code before the cellphone number
    delay(100);
    Serial.write(mySerial.read());
    mySerial.println("A test message!");//the content of the message
    delay(100);
    Serial.write(mySerial.read());
    mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
    delay(100);
    mySerial.println();
    }
    void RecieveTextMessage()
    {
    //mySerial.print("AT+CMGF=1\r"); //Because we want to recieve the SMS in text mode
    //delay(100);
    mySerial.print("AT+CMGR=1\r");//Because we want to recieve the SMS in text mode
    delay(100);
    mySerial.println("AT + CSCA = \"0914xxxxxxx\"");//recieve sms message, be careful need to add a country code before the cellphone number
    delay(100);
    mySerial.println("A test message!");//the content of the message
    delay(100);
    mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
    delay(100);
    mySerial.println();
    //return r;
    }
    ///DialVoiceCall
    ///this function is to dial a voice call
    void DialVoiceCall()
    {
    mySerial.println("ATD + 0914xxxxxxx;");//dial the number
    delay(100);
    mySerial.println();
    }
    ///SubmitHttpRequest()
    ///this function is submit a http request
    ///attention:the time of delay is very important, it must be set enough
    void SubmitHttpRequest()
    {
    mySerial.println("AT+CSQ");
    delay(100);
    ShowSerialData();// this code is to show the data from gprs shield, in order to easily see the process of how the gprs shield submit a http request, and the following is for this purpose too.
    mySerial.println("AT+CGATT?");
    delay(100);
    ShowSerialData();
    mySerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR, the connection type is using gprs
    delay(1000);
    ShowSerialData();
    mySerial.println("AT+SAPBR=3,1,\"APN\",\"CMNET\"");//setting the APN, the second need you fill in your local apn server
    delay(4000);
    ShowSerialData();
    mySerial.println("AT+SAPBR=1,1");//setting the SAPBR, for detail you can refer to the AT command mamual
    delay(2000);
    ShowSerialData();
    mySerial.println("AT+HTTPINIT"); //init the HTTP request
    delay(2000);
    ShowSerialData();
    mySerial.println("AT+HTTPPARA=\"URL\",\"www.google.com.hk\"");// setting the httppara, the second parameter is the website you want to access
    delay(1000);
    ShowSerialData();
    mySerial.println("AT+HTTPACTION=0");//submit the request
    delay(10000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.
    //while(!mySerial.available());
    ShowSerialData();
    mySerial.println("AT+HTTPREAD");// read the data from the website you access
    delay(300);
    ShowSerialData();
    mySerial.println("");
    delay(100);
    }
    ///send2Pachube()///
    ///this function is to send the sensor data to the pachube, you can see the new value in the pachube after execute this function///
    void Send2Pachube()
    {
    mySerial.println("AT+CGATT?");
    delay(100);
    ShowSerialData();
    mySerial.println("AT+CSTT=\"CMNET\"");//start task and setting the APN,
    delay(1000);
    ShowSerialData();
    mySerial.println("AT+CIICR");//bring up wireless connection
    delay(300);
    ShowSerialData();
    mySerial.println("AT+CIFSR");//get local IP adress
    delay(2000);
    ShowSerialData();
    mySerial.println("AT+CIPSPRT=0");
    delay(3000);
    ShowSerialData();
    mySerial.println("AT+CIPSTART=\"tcp\",\"api.cosm.com\",\"8081\"");//start up the connection
    delay(2000);
    ShowSerialData();
    mySerial.println("AT+CIPSEND");//begin send data to remote server
    delay(4000);
    ShowSerialData();
    String humidity = "1031";//these 4 line code are imitate the real sensor data, because the demo did't add other sensor, so using 4 string variable to replace.
    String moisture = "1242";//you can replace these four variable to the real sensor data in your project
    String temperature = "30";//
    String barometer = "60.56";//
    mySerial.print("{\"method\": \"put\",\"resource\":\"/feeds/42742/\",\"params\"");//here is the feed you apply from pachube
    delay(500);
    ShowSerialData();
    mySerial.print(": {},\"headers\": {\"X-PachubeApiKey\":");//in here, you should replace your pachubeapikey
    delay(500);
    ShowSerialData();
    mySerial.print("\"_cXwr5LE8qW4a296O-cDwOUvfddFer5pGmaRigPsiO0");//pachubeapikey
    delay(500);
    ShowSerialData();
    mySerial.print("jEB9OjK-W6vej56j9ItaSlIac-hgbQjxExuveD95yc8BttXc");//pachubeapikey
    delay(500);
    ShowSerialData();
    mySerial.print("Z7_seZqLVjeCOmNbEXUva45t6FL8AxOcuNSsQS\"},\"body\":");
    delay(500);
    ShowSerialData();
    mySerial.print(" {\"version\": \"1.0.0\",\"datastreams\": ");
    delay(500);
    ShowSerialData();
    mySerial.println("[{\"id\": \"01\",\"current_value\": \"" + barometer +"\"},");
    delay(500);
    ShowSerialData();
    mySerial.println("{\"id\": \"02\",\"current_value\": \"" + humidity + "\"},");
    delay(500);
    ShowSerialData();
    mySerial.println("{\"id\": \"03\",\"current_value\": \"" + moisture + "\"},");
    delay(500);
    ShowSerialData();
    mySerial.println("{\"id\": \"04\",\"current_value\": \"" + temperature +"\"}]},\"token\": \"lee\"}");
    delay(500);
    ShowSerialData();
    mySerial.println((char)26);//sending
    delay(5000);//waitting for reply, important! the time is base on the condition of internet
    mySerial.println();
    ShowSerialData();
    mySerial.println("AT+CIPCLOSE");//close the connection
    delay(100);
    ShowSerialData();
    }
    void ShowSerialData()
    {
    while(mySerial.available()!=0)
    Serial.write(mySerial.read());
    }
    ویرایش توسط masiha427 : 11-07-2015 در ساعت 07:31 PM
    لایک کردن

  2. #12
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,064
    دم شما حسابی گرم

  3. #13
    Junior Member
    تاریخ عضویت
    Mar 2014
    نوشته ها
    3
    سلام بر اساتید محترم. آیا میشه سیم 900 رو به اردوینو یونو متصل کرد یا باید حتما اردوینو مگا باشه؟

  4. #14
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,064
    نقل قول نوشته اصلی توسط sadegh_54 نمایش پست ها
    سلام بر اساتید محترم. آیا میشه سیم 900 رو به اردوینو یونو متصل کرد یا باید حتما اردوینو مگا باشه؟

    معلومه که میشه
    پروتکل ارتباطی اینها سریال هست
    چه مگا چه یونو

  5. #15
    Junior Member
    تاریخ عضویت
    Feb 2016
    نوشته ها
    16
    سلام بر دوستان
    یک کد ساده میخوام که با دریافت یک عدد خاص بصورت پیامک دستور بده به رله و در باز بشه
    اگر حوصلشو داشتید ممنون میشم کمک کنید
    کدی که گذاشتید خیلی پیچیده و طولانیه فقط قسمت دریافت رو میخوام
    ویرایش توسط Tragzes : 11-06-2016 در ساعت 08:27 AM

  6. #16
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,064
    نقل قول نوشته اصلی توسط Tragzes نمایش پست ها
    سلام بر دوستان
    یک کد ساده میخوام که با دریافت یک عدد خاص بصورت پیامک دستور بده به رله و در باز بشه
    اگر حوصلشو داشتید ممنون میشم کمک کنید
    کدی که گذاشتید خیلی پیچیده و طولانیه فقط قسمت دریافت رو میخوام
    توی گوگل سرچ کنی به احتمال زیاد در این مورد دیتا پیدا خواهید کد.

    ما هم تلاشمون رو می کنم براتون یه کد پیدا کنیم که بتونید باهاش کار کنید.
    فعلا میتونید با این کلید واژه خودتون آغاز کنید:
    arduino sim900 receive sms control

صفحه 2 از 2 نخستنخست 12

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  

SEO by vBSEO