Arduino Nano與SIM800C 通信


首先感謝

  原文作者:https://blog.csdn.net/weixin_44481398/article/details/86596933#commentBox

  找了好久沒有找到,使用他的代碼一次就可以。

  我的教程可能不夠明了,建議不明白的地方查看原文鏈接。

追加:

  1. 3.3V好像信號不好,接上5v
  2. 如果命令的時候有時候沒有及時返回,等待一會。如果還是沒有反應,建議重新插拔一下。
  3. 我的信號很低,不清楚什么原因 0-12之間
  4. 如果AT命令不帶=號,如測試信號強度如:AT+CSQ ,如果提示錯誤則可在命令后加 ? ,如 AT+CSQ? 就可以顯示想要查看的配置信息。(很重要ERROR看這里)
  5. HTTPS請求獲取不到

正文開始

先上圖片(不一樣的SIM800C):

 

 

 接線:

 整體:

 

 

 Arduino:

 說明:

  1. SIM800c Sim卡那面為反面,芯片那一面為正面. 針腳為下
  2. 下方的6個針孔(只需用到4個)依次為 3.3V,GND,RX,TX
  3. Arduino 使用到 3.3V,GND,10(RX),11(TX)

 

 接線:

  1. Sim800c 3.3V -> Arduino 3.3V
  2. Sim800c GND -> Arduino GND
  3. Sim800c RX -> Arduino TX
  4. Sim800c TX -> Arduino RX

代碼

#include <SoftwareSerial.h>        // 采用軟件的串口

SoftwareSerial SIM800C(10, 11);     // Serial RX, TX
boolean bState, bOldState;
int incomingByte = 0;               // for incoming serial data

void setup() {
  // put your setup code here, to run once:
  // Open serial communications and wait for port to open
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  while (!Serial) {
    ;   // wait for serial port to connect. Needed for native USB port only
  } 

  Serial.println("Good Morning, my old friend!");
  
  SIM800C.begin(9600);
  SIM800C.println("AT+CMGF=1");
  
}

void loop() {
  // put your main code here, to run repeatedly:
  if (SIM800C.available()) {
    Serial.write(SIM800C.read());
    digitalWrite(13, HIGH);// 如果通信成功,則把Arduino上面的L13 LED 燈打開
  }
  if (Serial.available()) {
    SIM800C.write(Serial.read());
//    incomingByte = Serial.read();
//    Serial.print("I received: ");
//    Serial.println(incomingByte, DEC);
//    digitalWrite(13, !digitalRead(13));
  }
  
}

 測試:

  

  

  在這里我們發送了一個AT命令,SIM800C返回一個Ok。再發送一個AT+GSV,返回:
  13:33:20.943 -> SIMCOM_Ltd
  13:33:20.943 -> SIMCOM_SIM800C
  13:33:20.979 -> Revision:1418B06SIM800C24
  通訊成功。任務初步完成。

備注:

  AT命令可以百度查找,如:https://blog.csdn.net/bihaiqiyuan/article/details/17595327,https://blog.csdn.net/wzt_007/article/details/78557268。

  只要根據教程如輸入AT 返回OK即表示連線正確和程序正常運行。命令格式: AT, AT+GSV等

 推薦:

  1. SIM800使用AT進行GPRS建立TCP遠程連接 https://blog.csdn.net/wzt_007/article/details/78557268

  2. SIM800C實現GPRS上網的AT指令 https://blog.csdn.net/zyxhangiian123456789/article/details/79490793

  3. SIM800A模塊進行HTTP的GET和POST操作 https://blog.csdn.net/qq_26602023/article/details/72898753 (親測可行)(推薦)(如果不可以請按照推薦6進行排查)(備用地址:SIM800A模塊進行HTTP的GET和POST操作)

  4. AT+CSQ (查看信號強度詳解) http://www.360doc.com/content/16/1228/17/18578054_618460530.shtml
  5. SIM800C通訊模塊調試(一) https://blog.csdn.net/cqdawnxsg/article/details/80680270(對於命令解析比較全面)

  6. AT+CREG?出現問題+CREG: 0,0/+CREG: 0,2等問題解決 https://blog.csdn.net/heroybc/article/details/90108113 (檢查信號,手機卡是否正確安裝使用)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM