LoginSignup
1
0

More than 5 years have passed since last update.

3GIM > Arduino UNO R3 から3G通信 > 2. 時刻取得

Last updated at Posted at 2018-01-04

以下の続きになります。
3GIM > Arduino UNO R3 から3G通信 - Qiita

3G経由で時刻を取得します。

a3gsライブラリのgetTime()関数で時刻を取得します。

get_time.ino

// 3GIM(V2) sample sketch -- getTime

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

#define baudrate    9600UL
#define baudrate_3gim   115200
const int powerPin = 7;     // 3gim power pin(If not using power control, 0 is set.)

void setup()
{
  Serial.begin(baudrate);
  delay(3000);  // Wait for Start Serial Monitor
  Serial.println("Get Time Ready.");

  Serial.print("Initializing.. ");
  if (a3gs.start(powerPin) == 0 && a3gs.begin(0, baudrate_3gim) == 0) {
    Serial.println("Succeeded.");
    char date[a3gsDATE_SIZE], time[a3gsTIME_SIZE];
    if (a3gs.getTime(date, time) == 0) {
      Serial.print(date);
      Serial.print(" ");
      Serial.println(time);
    }
  }
  else
    Serial.println("Failed.");

  Serial.println("Shutdown..");
  a3gs.end();
  a3gs.shutdown();
}

void loop()
{
}

// END

Soracomのコンソールで通信履歴を見ると使用履歴が残っており、3G通信していることがわかりました。

スクリーンショット 2018-01-02 11.16.15.png

1
0
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
0