スケッチの作成
(Serial.begin(9600);→Serial.begin(115200);に変更するのみです。
//LPS25H
#include
#define disk1 0x5D //Address of LPS25H eeprom chip
void setup(void)
{
Serial.begin(115200);
Wire.begin();
Serial.println(readLPS25H(disk1, 0x0F),HEX );//通信確認正常ならば0xBDを受信
writeLPS25H(disk1, 0x20, 0x90);//パワーオン、1Hzを設定
}
void loop()
{
int i;
long data[5];
float P,T;
for(i=0;i<5;i++)
{
data[i]=readLPS25H(disk1, 0x28+i);
}
P=( float)(data[2]*256*256+data[1]*256+data[0])/4096.0;
if(data[4]>=128)
{
T=42.5-( float)(65536-(data[4]*256+data[3]))/480.0;
}
else
{
T=42.5+( float)(data[4]*256+data[3])/480.0;
}
Serial.print("Pressure(hPa)=");
Serial.print(P,2);
Serial.print("\t");
Serial.print("Temperature(C)=");
Serial.println(T,2);
delay(1000);
}
void writeLPS25H(int deviceaddress, byte eeaddress, byte data )
{
Wire.beginTransmission(deviceaddress);
Wire.write(eeaddress);
Wire.write(data);
Wire.endTransmission();
delay(5);
}
byte readLPS25H(int deviceaddress, byte eeaddress )
{
byte rdata = 0x00;
Wire.beginTransmission(deviceaddress);
Wire.write(eeaddress);
Wire.endTransmission();
Wire.requestFrom(deviceaddress,1);
if (Wire.available()) rdata = Wire.read();
return rdata;
}