【炫Q香蕉派】香蕉派 BPI LM75温度传感器模块应用资料


#1

gitbook资料:
https://bananapi.gitbooks.io/bpi-accessories/content/en/lm75_temperature_sensor_module.html

英文论坛资料:
http://forum.banana-pi.org/t/bpi-m3-bpi-temperature-lm75-module-and-how-to-use/1075

首先安装模块,如图有对齐,安装到内侧


#2

可以先按照gitbook的方法确认模块是否正常工作然后用如下代码测试
https://github.com/bpiq/MikuPi/blob/master/examples/lm75.cpp

/*
 * lm75.cpp:
 *
 *      Welcome to MikuQ.com! MikuDuino for BananaPi
 *
 *     by MikuQ(i@mikuq.com) 2017-1-8
 *
 * https://github.com/bpiq/MikuPi
 *
 */

#include <MikuDuino.h>
#include <Wire.h>

void setup()
{
  Wire.begin();
}

void loop()
{
  Wire.requestFrom(72, 2);    
  while(Wire.available()) 
  { 
   int part1 = Wire.read();
   int part2 = Wire.read();
   printf("result is : %.1f\r\n",part1+part2/256.0);
   printf("-----------------\r\n");
  }
  delay(500);
}

运行效果如下图