I have a Honeywell board mount pressure sensor that I want to read using an Arduino.
I have two codes for them to read the temperature and the Pressure, With one of the coding, I have got the values of the Pressure. The second code works but I can't calculate the value of Temperature from there.
Without having much experience with I2C in the past it's hard for my to get my head around it.
Code 1 used for the Pressure
#include<Wire.h>
#define sensor 0x28 //Unique bus address
void setup()
{
Wire.begin();//Wakes up I2C bus
Serial.begin(9600);
}
void getdata(byte *a, byte *b)
{
//Move register pointer back to the first register
//Wire.beginTransmission(sensor);
//Wire.write(1);
//Wire.endTransmission();
Wire.requestFrom(sensor,2);//Sends content of first two registers
*a = Wire.read(); //first byte recieved stored here
*b = Wire.read(); //second byte recieved stored here
}
void showdata()
{
byte aa,bb;
float pressure =0;
getdata(&aa,&bb);
Serial.print("byte 1: ");Serial.println(aa,DEC);
Serial.print("byte 2 ");Serial.println(bb,DEC);
delay(1000);
}
void loop()
{
showdata();
}`
Code 2
#include<Wire.h>
#define sensor 0x28 //Unique bus address
void setup()
{
Wire.begin();//Wakes up I2C bus
Serial.begin(9600);
}
void getdata(byte *a, byte *b)
{
Wire.requestFrom(sensor,2);//Sends content of first two registers
*a = Wire.read(); //first byte recieved stored here
*b = Wire.read(); //second byte recieved stored here
}
void showdata()
{
byte aa,bb;
float pressure =0;
getdata(&aa,&bb);
Serial.print("byte 1: ");Serial.println(aa,DEC);
Serial.print("byte 2 ");Serial.println(bb,DEC);
delay(1000);
}
void loop()
{
showdata();
}
Data is For Pressure From Code 2
byte 1: 6
byte 2 88
byte 1: 6
byte 2 82
byte 1: 6
byte 2 92
byte 1: 6
byte 2 102
byte 1: 6
byte 2 108
byte 1: 6
byte 2 106
byte 1: 6
byte 2 106
byte 1: 6
byte 2 108
byte 1: 6
byte 2 112
byte 1: 6
byte 2 119
byte 1: 6
byte 2 123
byte 1: 6
byte 2 135
Data collected from Code 1 for Temperature and Pressure
byte 1: 6
byte 2: 5A
byte 3: 60
byte 1: 6
byte 2: 58
byte 3: 60
byte 1: 6
byte 2: 5A
byte 3: 60
byte 1: 6
byte 2: 58
byte 3: 60
byte 1: 6
byte 2: 5C
byte 3: 60
byte 1: 6
byte 2: 54
byte 3: 60