0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Arduinoに温度センサを(LM35)つなぐ

Last updated at Posted at 2016-12-28

さくらのIoT Platform βを試してみる の続きなので、Arduinoシールドが乗っていますが、直接つなぐ場合も同様です。シリアルにも出力していますが、さくらのIoTにも温度データを送信しています。

IMG_2480.jpg

# include <SakuraIO.h>

SakuraIO_I2C sakuraio;

float a_in = 0;
float temp_c = 0;

void setup(){
  while((sakuraio.getConnectionStatus() & 0x80) != 0x80){
    delay(1000);
    Serial.print(".");
  }
  Serial.println("");
}

void loop() {
  a_in = analogRead(0);
  temp_c = ((5 * a_in) / 1024) * 100;
  sakuraio.enqueueTx(0,temp_c);
  sakuraio.send();
  Serial.print(temp_c);
  Serial.print("  ");
  Serial.println(sakuraio.getConnectionStatus());
  delay(1000);
}

温度を取得する部分のコードは下記のサイトを参照させて頂きました。

次回は…

サーバに溜まったデータをグラフに!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?