je commence à évoluer et je réussie à partir de mon arduino à lire une sonde mg811 et une sonde DTH 11 mais séparément.
j’ai essayé de rassembler les codes et résolus pas mal d’erreur mais je bloque sur 2 lignes. de sont les lignes 68 ET 69.Voici les erreurs relevées
solar_ino1.ino: In function ‘void loop()’:
solar_ino1:68: error: expected primary-expression before ‘.’ token
solar_ino1:69: error: expected primary-expression before ‘.’ tokenJ’ai lu plusieurs sujets mais aucun ne réponds à mon erreur. A coté de mon stetch j’ai 2 fichiers pour la librairie dth11, dth11.CPP et dth11.h
si quelqu’un peut m’aider … =(/*****************************SENSOR DTH11 HUMIDITY AND TEMPERATURE***********************************************/
/-----( Import needed libraries )-----/
#include <dht11.h>
/-----( Declare objects )-----/
dht11 DHT11;
/-----( Declare Constants, Pin Numbers )-----/
#define DHT11PIN 2
/Hardware Related Macros************/
#define MG_PIN (0) //define which analog input channel you are going to use
#define BOOL_PIN (2)
#define DC_GAIN (8.5) //define the DC gain of amplifier
/Software Related Macros*************/
#define READ_SAMPLE_INTERVAL (50) //define how many samples you are going to take in normal operation
#define READ_SAMPLE_TIMES (5) //define the time interval(in milisecond) between each samples in
//normal operation
/Application Related Macros************/
//These two values differ from sensor to sensor. user should derermine this value.
#define ZERO_POINT_VOLTAGE (0.220) //define the output of the sensor in volts when the concentration of CO2 is 400PPM
#define REACTION_VOLTGAE (0.020) //define the voltage drop of the sensor when move the sensor from air into 1000ppm CO2
/Globals******************/
float CO2Curve[3] = {2.602,ZERO_POINT_VOLTAGE,(REACTION_VOLTGAE/(2.602-3))};
//two points are taken from the curve.
//with these two points, a line is formed which is
//“approximately equivalent” to the original curve.
//data format:{ x, y, slope}; point1: (lg400, 0.324), point2: (lg4000, 0.280)
//slope = ( reaction voltage ) / (log400 ¨Clog1000)
void setup()
{
Serial.begin(9600); //UART setup, baudrate = 9600bps
pinMode(BOOL_PIN, INPUT); //set pin to input
digitalWrite(BOOL_PIN, HIGH); //turn on pullup resistors
}
void loop()
{
// SONDE DTH_solar Reading temperature or humidity takes about 250 milliseconds! Sensor readings may also be up to 2 seconds ‘old’ (its a very slow sensor)
float h = dht11.readHumidity();
float t = dht11.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
delay (2000);
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println(“Failed to read from DHT_solar”);
} else {
Serial.print(“Humidity: “);
Serial.print(h);
Serial.print(” %\t”);
Serial.print(“Temperature: “);
Serial.print(t);
Serial.println(” *C”);
}
//SONDE CO2
int percentage;
float volts;
volts = MGRead(MG_PIN);
Serial.print( “MG_solar:” );
percentage = MGGetPercentage(volts,CO2Curve);
Serial.print(“CO2:”);
if (percentage == -1) {
Serial.print( “<400” );
} else {
Serial.print(percentage);
}
Serial.print( “ppm” );
Serial.print("\n");
Serial.print("\n");
delay(200);
}
/***************************** MGRead *********************************************
Input: mg_pin - analog channel
Output: output of MG_solar
Remarks: This function reads the output of MG_solar
************************************************************************************/
float MGRead(int mg_pin)
{
int i;
float v=0;
for (i=0;i<READ_SAMPLE_TIMES;i++) {
v += analogRead(mg_pin);
delay(READ_SAMPLE_INTERVAL);
}
v = (v/READ_SAMPLE_TIMES) *5/1024 ;
return v;
}
/***************************** MQGetPercentage **********************************
Input: volts - MG_solar output measured in volts
pcurve - pointer to the curve of the target gas
Output: ppm of the target gas
Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm)
of the line could be derived if y(MG-811 output) is provided. As it is a
logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic
value.
************************************************************************************/
int MGGetPercentage(float volts, float *pcurve)
{
if ((volts/DC_GAIN )>=ZERO_POINT_VOLTAGE) {
return -1;
} else {
return pow(10, ((volts/DC_GAIN)-pcurve[1])/pcurve[2]+pcurve[0]);
}
}