Skip to content

Commit 0b402f4

Browse files
author
BasicAirData
committed
Added Pressure Sensor
Included Pressure Sensor HCLA12
1 parent 6615650 commit 0b402f4

5 files changed

Lines changed: 131 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <AirDC.h>
2+
#include <AirSensor.h>
3+
4+
#define PSENSOR 1
5+
#if PSENSOR==1
6+
#include <Wire.h>
7+
#endif
8+
9+
int psensor;
10+
double p; //Static Pressure
11+
AirSensor AirDataSensor(1);
12+
AirDC AirDataComputer(1);
13+
14+
void setup() {
15+
Serial.begin(9600);
16+
#if PSENSOR==1
17+
psensor = 1;
18+
Wire.begin();
19+
#endif
20+
#if PSENSOR==2
21+
psensor = 2;
22+
#endif
23+
24+
}
25+
26+
void loop() {
27+
28+
AirDataSensor.Pressure(psensor);
29+
AirDataComputer._p=AirDataSensor._p;
30+
delay(1000);
31+
Serial.println(psensor); //Selected sensor
32+
Serial.println(AirDataComputer._p); //Pressure reading
33+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <AirDC.h>
2+
#include <stdio.h>
3+
4+
/*
5+
Minimal -Basic Air Data calculations with AirDC library
6+
Created by J. Larragueta, December 3, 2015.
7+
Refer to http:\\www.basicairdata.eu
8+
*/
9+
AirDC BasicAirData(1);
10+
11+
void setup() {
12+
// put your setup code here, to run once:
13+
Serial.begin(9600);
14+
}
15+
16+
void loop() {
17+
BasicAirData.RhoAir(101325,288.15,0,1);
18+
BasicAirData.IAS(100,1);
19+
delay(500);
20+
// put your main code here, to run repeatedly:
21+
Serial.println(BasicAirData._Rho,10);
22+
Serial.println(BasicAirData._uRho,10);
23+
Serial.println(BasicAirData._IAS,10);
24+
Serial.println(BasicAirData._uIAS,10);
25+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
AirSensor.cpp - Library for Basic Air Data calculations
3+
Created by J. Larragueta, December 3, 2015.
4+
Refer to http:\\www.basicairdata.eu
5+
*/
6+
#include "AirSensor.h"
7+
#include <math.h>
8+
#include <Wire.h>
9+
10+
AirSensor::AirSensor(int pid)
11+
{
12+
//Default parameters values
13+
_pid = pid;
14+
}
15+
void AirSensor::Pressure(int sensor)
16+
{
17+
switch (sensor)
18+
{
19+
case 1: //Sensor one is I2C HLCA12X5
20+
//http://www.first-sensor.com/cms/upload/datasheets/DS_Standard-HCLA_E_11629.pdf
21+
//Basic software for HLCA12X5 from Sensortechnics/First
22+
// Pressure - Sensor output hex/dec
23+
//12.5 mBar 1250 Pa - 6CCCx /27852d
24+
//-12.5 mBar 1250 Pa - 0666x /1638d
25+
// 0 mBar 0 Pa - 3999x/14745
26+
//(27852-1638)/2500=10.4856 per Pascal
27+
int reading ;//The reading from pressure sensor[Pa]
28+
float rawdata; //Reading with offset
29+
Wire.beginTransmission(120); //Initialize correct I2C device number
30+
Wire.requestFrom(120, 2);
31+
if(2 <= Wire.available()) //When the two requested bytes are available proceed to data handling
32+
{
33+
reading = Wire.read(); //16 Bit reading, 1 byte per time
34+
reading = reading << 8;
35+
reading |= Wire.read();
36+
rawdata=(reading-1638)/10.4856-1250;
37+
}
38+
_p=rawdata; //pa
39+
_up=10;//pa
40+
break;
41+
case 2:
42+
break; //Sensor two is SPI
43+
}
44+
}
45+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
AirDC.cpp - Library for Basic Air Data calculations
3+
Created by J. Larragueta, December 3, 2015.
4+
Refer to http:\\www.basicairdata.eu
5+
*/
6+
7+
#ifndef AirSensor_h
8+
#define AirSensor_h
9+
#include "Arduino.h"
10+
class AirSensor
11+
{
12+
public:
13+
AirSensor(int pid);
14+
void Pressure(int mode);
15+
//private:
16+
int _pid;
17+
double _p;
18+
double _T;
19+
double _RH;
20+
double _qc;
21+
double _up;
22+
double _uT;
23+
double _uRH;
24+
double _uqc;
25+
};
26+
#endif
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
AirSensor KEYWORD1
2+
Pressure KEYWORD2

0 commit comments

Comments
 (0)