LoginSignup
1
2

More than 3 years have passed since last update.

SIMCOM社のSIM7080GをArduino UNOでコントロール

Last updated at Posted at 2021-01-02

少し前に 「SIMCOM社のSIM7080Gでさくらセキュアモバイルの通信テスト」という情報を公開しました。
その時はパソコンとノートPCをUSBケーブルで繋いで Tearaterm からコマンドをたたいてコントロールしましたが、今回は Arduino UNO で同じ制御を行いました。
(最後にNetwork を非アクティブにするコマンド[AT+CNACT=0,0]を追加しました。)

機器構成

名称 型名 メーカー
マイコンボード Arduino UNO Arduino
SIM7080G拡張ボード NS-SIM7080-0101 Next Step
SIMカード セキュアモバイルコネクト SIMカード さくらインターネット

image.png

Arduino UNO と SIM7080G間のUART通信のボーレートは4800bpsに設定しています。
また今回 AT-Command-Libraryを使っているので、ダウンロードしてインストールして下さい。

Arduino UNOのプログラム

SIM7080G_sendATcommands.ino
/* This code is an example of how to use the AT command library to
 *  send AT commands (or ASCII commands) to a module via UART (TX/RX)
 *  using software or hardware serial. The commands can be set up to
 *  check for a specified reply from the module as well as a timeout.
 *  
 *  Author: Timothy Woo (botletics.com)
 *  Last Modified: 10/20/2017
 */

#include "ATcommands.h"
#include <SoftwareSerial.h>

#define MCU_RX 8     // Remember MCU RX connects to module TX and vice versa
#define MCU_TX 7

#define RST 12       // MCU pin to SIM7080G module pwrket

#define RESET_PIN 11 // MCU pin to SIM7080G module reset
#define PWRKEY 12    // MCU pin to SIM7080G module pwrket
#define LED 13       // MCU pin to LED

SoftwareSerial moduleSS = SoftwareSerial(MCU_RX, MCU_TX); // MCU RX, TX
SoftwareSerial *moduleSerial = &moduleSS;

// Hardware serial is also possible!
// HardwareSerial *moduleSerial = &Serial1;

ATcommands module = ATcommands(RST, true); // Use "false" if you don't want AT commands with newline, "true" otherwise

void setup() {
  Serial.begin(115200);

  moduleSerial->begin(4800); // Verify your module's baud rate
  module.begin(*moduleSerial);

  pinMode(RESET_PIN, OUTPUT);
  digitalWrite(RESET_PIN, HIGH);
  delay(100);
  digitalWrite(RESET_PIN, LOW);
  delay(100);

  // Reset module if needed. This example pulses the reset pin low for 10ms.
  // If left out, the pulse duration is 100ms by default.
  module.reset(HIGH, 10); // module.reset(HIGH/LOW, pulseDuration)

  module.sendCommand("AT", "OK", 1000);
  module.sendCommand("AT+CGDCONT=1,\"IP\",\"sakura\"", "OK", 1000);
  module.sendCommand("AT+CNCFG=1,1,\"sakura\"", "OK", 1000);
  module.sendCommand("AT+COPS=1,2,\"44010\"", "OK", 1000);
  module.sendCommand("AT+COPS?", "OK", 1000);
  module.sendCommand("AT+CPIN?", "OK", 1000);
  module.sendCommand("AT+CNMP=38", "OK", 1000);
  module.sendCommand("AT+CMNB=1", "OK", 1000);
  module.sendCommand("AT+CSQ", "OK", 1000);
  module.sendCommand("AT+CGREG?", "OK", 1000);
  module.sendCommand("AT+CGNAPN", "OK", 1000);
  module.sendCommand("AT+CPSI?", "OK", 1000);
  module.sendCommand("AT+CNACT=0,1", "OK", 1000);
  module.sendCommand("AT+CNACT?", "OK", 1000);
  module.sendCommand("AT+SNPING4=\"google.com\",3,16,3000", "OK", 5000);
  module.sendCommand("AT+CNACT=0,0", "OK", 1000);
}

void loop() {
  // Nothing here
}

プログラムを実行するとシリアルモニタは以下のような表示になります。

    ---> AT
    <--- AT

OK

    ---> AT+CGDCONT=1,"IP","sakura"
    <--- AT+CGDCONT=1,"IP","sakura"

OK

    ---> AT+CNCFG=1,1,"sakura"
    <--- AT+CNCFG=1,1,"sakura"

OK

    ---> AT+COPS=1,2,"44010"
    <--- AT+COPS=1,2,"44010"

OK

    ---> AT+COPS?
    <--- AT+COPS?

+COPS: 1,2,"44010",7

OK

    ---> AT+CPIN?
    <--- AT+CPIN?

+CPIN: READY

OK

    ---> AT+CNMP=38
    <--- AT+CNMP=38

OK

    ---> AT+CMNB=1
    <--- AT+CMNB=1

OK

    ---> AT+CSQ
    <--- AT+CSQ

+CSQ: 15,99

OK

    ---> AT+CGREG?
    <--- AT+CGREG?

+CGREG: 0,5

OK

    ---> AT+CGNAPN
    <--- AT+CGNAPN

+CGNAPN: 1,"sakura"

OK

    ---> AT+CPSI?
    <--- AT+CPSI?

+CPSI: LTE CAT-M1,Online,440-10,0x90A8,155713537,310,EUTRAN-BAND1,276,4,4,-9,-103,-80,14

OK

    ---> AT+CNACT=0,1
    <--- AT+CNACT=0,1

OK

+APP PDP: 0,ACTIVE

    ---> AT+CNACT?
    <--- AT+CNACT?

+CNACT: 0,1,"192.168.0.101"
+CNACT: 1,0,"0.0.0.0"
+CNACT: 2,0,"0.0.0.0"
+CNACT: 3,0,"0.0.0.0"

OK

    ---> AT+SNPING4="google.com",3,16,3000
    <--- AT+SNPING4="google.com",3,16,3000

+SNPING4: 1,172.217.175.110,239
+SNPING4: 2,172.217.175.110,1148
+SNPING4: 3,172.217.175.110,290

OK

    ---> AT+CNACT=0,0
    <--- AT+CNACT=0,0

OK

+APP PDP: 0,DEACTIVE


今回はATコマンドを投げた後に成功/失敗の確認を行っていません(投げっぱなしの手抜きです)
次回はコマンドに対するレスポンスを確認するように変更してみます。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2