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.

STM32L010のMbedでの温度,STTS751で温度表示(AQM0802A)(STM32L010F4P6)

Last updated at Posted at 2021-02-20

x 愛用していたSTTS751の入手が難しくなったので代用品は、S-5851A。(おもにアドレスの違い)

1.SCLとSDAを接続、プルアップも忘れずに
2.電源の接続
3.下記のソースコードを書き込む
4.コンパイル実行で表示されたら終了
5.おわり

注意
mbedのリビジョンは、125

参照
STM32L010のMbedでの液晶,AQM0802Aで表示(i2c)(STM32L010F4P6)
https://qiita.com/caa45040/items/4c7a55bfe837e4ff7bdf

忙しい人の為
https://os.mbed.com/users/caa45040/code/STTS751_i2c_lcd_010_1/

#include "mbed.h"

#define ADDR        (0x39<<1)   //  address
#define ADDR_LCD    (0x7C)      //  address

//I2C i2c(I2C_SDA, I2C_SCL); //767
//I2C i2c(dp5, dp27); //1114
I2C i2c(PA_10, PA_9); //010

int     tempval;        //温度
char    data_read[2];   //i2cバッファー
int     ii;             //ループカウンター
int     p_val;          //戻り値

char INIT_com[]={0x0,0x38,
0x0,0x39,
0x0,0x4,
0x0,0x14,
0x0,0x70,
0x0,0x56,
0x0,0x6C,
0x0,0x38,
0x0,0xC,
0x0,0x1,
0x40,0x41,0x99,0x99};

char INIT_cls[]={0x0,0x1};

int main()
{
 
    //液晶の初期化
    for(ii=0;ii<11;ii++){
        p_val = i2c.write(ADDR_LCD, &INIT_com[ii*2], 2);
        wait_ms(2);
    } //for
 
    while (1) {
        //液晶のクリア
        p_val = i2c.write(ADDR_LCD,INIT_cls,2);
        wait_ms(2);
        
        //温度の読み込み
        // Read temperature register
        i2c.read(ADDR, data_read,1,false);
 
        //温度の保存
        // Calculate temperature value in Celcius
        tempval =  data_read[0];
 
        //液晶に出力
        // Display result
        data_read[0] = '@';
        data_read[1] = (tempval/10)+'0';
        p_val = i2c.write(ADDR_LCD, data_read ,2);
        wait_ms(1);
        data_read[1] = (tempval%10)+'0';
        p_val = i2c.write(ADDR_LCD, data_read ,2);
        
        wait_ms(1000);
    }//while
 
}//main
 


STTS751_i2c_lcd_010_1.jpg

STTS751_i2c_lcd_010_2.jpg

i2c_lcd_stts751_l010_1.jpg

i2c_lcd_stts751_l010_2.jpg

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?