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 1 year has passed since last update.

Arduino UNOで有機エレクトロルミネッセンス温度計。(STTS751)(Adafruit SSD1306,Adafruit GFX)

Posted at

x ライブラリのインストール方法は、めんどいので省略
x サイズは、約13KB

x OLED096UNO-Aです。
x Arduino UNOは、そのArduino UNO互換機

x 非営利、研究調査目的で引用する。

x 昔、秋月で売っていた温度センサーSTTS751
代用品は、S-5851A。(おもにアドレスの違い)

x 非営利、研究調査目的で引用する。

目的
OLEDで遊ぶ
適当にあつたI2C温度センサーを使用

o_con832.jpg

参考

STM32G071のプログラムの完全にそのまま




#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>



#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);



// コンパイル時にヘッダーファイルが適切に編集されていない場合に
// "Height incorrect, please fix Adafruit_SSD1306.h!"
// というエラーを表示するための記述
//#if (SSD1306_LCDHEIGHT != 64)
//#error("Height incorrect, please fix Adafruit_SSD1306.h!");
//#endif

// RSTピンがない互換品を使用するので-1を指定
//Adafruit_SSD1306 display(-1);

void setup() {
  // I2Cアドレスは使用するディスプレイに合わせて変更する
  display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
}

#define STTS751 0x39

int tempval;

void loop() {
  // 画面表示をクリア
  display.clearDisplay();

  // テキストサイズを設定
  display.setTextSize(3);
  // テキスト色を設定
  display.setTextColor(WHITE);
  // テキストの開始位置を設定
  display.setCursor(0, 10);


  //0番目のレジスター
  Wire.beginTransmission(STTS751);
  Wire.write(0);
  Wire.endTransmission();
  delay(1);

  //温度の読み込み
  tempval = 99;
  Wire.requestFrom(STTS751, 1);
  while(Wire.available())  {    // 要求より短いデータが来る可能性あり
    tempval = (int)Wire.read(); // 1バイトを受信
  }//while
  delay(1);

  //表示変換する
  char str1[3];
  str1[0] = '0' + (tempval/10);
  str1[1] = '0' + (tempval%10);
  str1[2] = 0;

  // 1行目に"Hello"を表示
  display.println(str1);
  // 2行目に"World!"を表示
  //display.println("World!");

  // 描画バッファの内容を画面に表示
  display.display();

  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?