Page 1 sur 2

[RESOLU] Programmation d'un node pour un capteur BMP180

Publié : 25 août 2016, 12:50
par denis91
Bonjour à tous,

La mise en place de Mysensors me pose une nouvelle fois des soucis.

Je souhaiterai mettre en place un capteur atmosphérique BMP180 dans mon domoticz et j'ai donc ce matin cherché à programmer un Arduino nano V3.0 avec Arduino Arduino 1.6.11

Je n'ai pas trouvé dans les exemples pour la version 2.0 de Mysensors de script "tout fait" donc j'ai pris le script ci-dessous que j'ai trouvé sur internet :

Code : Tout sélectionner

#include <MyConfig.h>
#include <MySensors.h>

/**
 * The MySensors Arduino library handles the wireless radio link and protocol
 * between your home built sensors/actuators and HA controller of choice.
 * The sensors forms a self healing radio network with optional repeaters. Each
 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
 * network topology allowing messages to be routed to nodes.
 *
 * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
 * Copyright (C) 2013-2015 Sensnology AB
 * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 *******************************
 *
 * REVISION HISTORY
 * Version 1.0 - Henrik Ekblad
 * 
 * DESCRIPTION
 * Pressure sensor example using BMP085 module  
 * http://www.mysensors.org/build/pressure
 *
 */
 
#include <SPI.h>
#include <MySensor.h>  
#include <Wire.h>
#include <Adafruit_BMP085.h>

#define BARO_CHILD 0
#define TEMP_CHILD 1

const float ALTITUDE = 688; // <-- adapt this value to your own location's altitude.

// Sleep time between reads (in seconds). Do not change this value as the forecast algorithm needs a sample every minute.
const unsigned long SLEEP_TIME = 60000; 

const char *weather[] = { "stable", "sunny", "cloudy", "unstable", "thunderstorm", "unknown" };
enum FORECAST
{
	STABLE = 0,			// "Stable Weather Pattern"
	SUNNY = 1,			// "Slowly rising Good Weather", "Clear/Sunny "
	CLOUDY = 2,			// "Slowly falling L-Pressure ", "Cloudy/Rain "
	UNSTABLE = 3,		// "Quickly rising H-Press",     "Not Stable"
	THUNDERSTORM = 4,	// "Quickly falling L-Press",    "Thunderstorm"
	UNKNOWN = 5			// "Unknown (More Time needed)
};

Adafruit_BMP085 bmp = Adafruit_BMP085();      // Digital Pressure Sensor 
MySensor gw;

float lastPressure = -1;
float lastTemp = -1;
int lastForecast = -1;

const int LAST_SAMPLES_COUNT = 5;
float lastPressureSamples[LAST_SAMPLES_COUNT];

// this CONVERSION_FACTOR is used to convert from Pa to kPa in forecast algorithm
// get kPa/h be dividing hPa by 10 
#define CONVERSION_FACTOR (1.0/10.0)

int minuteCount = 0;
bool firstRound = true;
// average value is used in forecast algorithm.
float pressureAvg;
// average after 2 hours is used as reference value for the next iteration.
float pressureAvg2;

float dP_dt;
boolean metric;
MyMessage tempMsg(TEMP_CHILD, V_TEMP);
MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
MyMessage forecastMsg(BARO_CHILD, V_FORECAST);


void setup() 
{
	gw.begin();

	// Send the sketch version information to the gateway and Controller
	gw.sendSketchInfo("Pressure Sensor", "1.1");

	if (!bmp.begin()) 
	{
		Serial.println("Could not find a valid BMP085 sensor, check wiring!");
		while (1) {}
	}

	// Register sensors to gw (they will be created as child devices)
	gw.present(BARO_CHILD, S_BARO);
	gw.present(TEMP_CHILD, S_TEMP);
	metric = gw.getConfig().isMetric;
}

void loop() 
{
	float pressure = bmp.readSealevelPressure(ALTITUDE) / 100.0;
	float temperature = bmp.readTemperature();

	if (!metric) 
	{
		// Convert to fahrenheit
		temperature = temperature * 9.0 / 5.0 + 32.0;
	}

	int forecast = sample(pressure);

	Serial.print("Temperature = ");
	Serial.print(temperature);
	Serial.println(metric ? " *C" : " *F");
	Serial.print("Pressure = ");
	Serial.print(pressure);
	Serial.println(" hPa");
	Serial.print("Forecast = ");
	Serial.println(weather[forecast]);


	if (temperature != lastTemp) 
	{
		gw.send(tempMsg.set(temperature, 1));
		lastTemp = temperature;
	}

	if (pressure != lastPressure) 
	{
		gw.send(pressureMsg.set(pressure, 0));
		lastPressure = pressure;
	}

	if (forecast != lastForecast)
	{
		gw.send(forecastMsg.set(weather[forecast]));
		lastForecast = forecast;
	}

	gw.sleep(SLEEP_TIME);
}

float getLastPressureSamplesAverage()
{
	float lastPressureSamplesAverage = 0;
	for (int i = 0; i < LAST_SAMPLES_COUNT; i++)
	{
		lastPressureSamplesAverage += lastPressureSamples[i];
	}
	lastPressureSamplesAverage /= LAST_SAMPLES_COUNT;

	return lastPressureSamplesAverage;
}



// Algorithm found here
// http://www.freescale.com/files/sensors/doc/app_note/AN3914.pdf
// Pressure in hPa -->  forecast done by calculating kPa/h
int sample(float pressure)
{
	// Calculate the average of the last n minutes.
	int index = minuteCount % LAST_SAMPLES_COUNT;
	lastPressureSamples[index] = pressure;

	minuteCount++;
	if (minuteCount > 185)
	{
		minuteCount = 6;
	}

	if (minuteCount == 5)
	{
		pressureAvg = getLastPressureSamplesAverage();
	}
	else if (minuteCount == 35)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) // first time initial 3 hour
		{
			dP_dt = change * 2; // note this is for t = 0.5hour
		}
		else
		{
			dP_dt = change / 1.5; // divide by 1.5 as this is the difference in time from 0 value.
		}
	}
	else if (minuteCount == 65)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) //first time initial 3 hour
		{
			dP_dt = change; //note this is for t = 1 hour
		}
		else
		{
			dP_dt = change / 2; //divide by 2 as this is the difference in time from 0 value
		}
	}
	else if (minuteCount == 95)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) // first time initial 3 hour
		{
			dP_dt = change / 1.5; // note this is for t = 1.5 hour
		}
		else
		{
			dP_dt = change / 2.5; // divide by 2.5 as this is the difference in time from 0 value
		}
	}
	else if (minuteCount == 125)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		pressureAvg2 = lastPressureAvg; // store for later use.
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) // first time initial 3 hour
		{
			dP_dt = change / 2; // note this is for t = 2 hour
		}
		else
		{
			dP_dt = change / 3; // divide by 3 as this is the difference in time from 0 value
		}
	}
	else if (minuteCount == 155)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) // first time initial 3 hour
		{
			dP_dt = change / 2.5; // note this is for t = 2.5 hour
		}
		else
		{
			dP_dt = change / 3.5; // divide by 3.5 as this is the difference in time from 0 value
		}
	}
	else if (minuteCount == 185)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) // first time initial 3 hour
		{
			dP_dt = change / 3; // note this is for t = 3 hour
		}
		else
		{
			dP_dt = change / 4; // divide by 4 as this is the difference in time from 0 value
		}
		pressureAvg = pressureAvg2; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past.
		firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop.
	}

	int forecast = UNKNOWN;
	if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval.
	{
		forecast = UNKNOWN;
	}
	else if (dP_dt < (-0.25))
	{
		forecast = THUNDERSTORM;
	}
	else if (dP_dt > 0.25)
	{
		forecast = UNSTABLE;
	}
	else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05)))
	{
		forecast = CLOUDY;
	}
	else if ((dP_dt > 0.05) && (dP_dt < 0.25))
	{
		forecast = SUNNY;
	}
	else if ((dP_dt >(-0.05)) && (dP_dt < 0.05))
	{
		forecast = STABLE;
	}
	else
	{
		forecast = UNKNOWN;
	}

	// uncomment when debugging
	//Serial.print(F("Forecast at minute "));
	//Serial.print(minuteCount);
	//Serial.print(F(" dP/dt = "));
	//Serial.print(dP_dt);
	//Serial.print(F("kPa/h --> "));
	//Serial.println(weather[forecast]);

	return forecast;
}
Mon soucis c'est que j'ai une erreur de compilation :

Code : Tout sélectionner

Arduino : 1.6.11 (Windows 10), Carte : "Arduino Nano, ATmega328"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Frédérique\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10611 -build-path C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp -warnings=all -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Frédérique\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10611 -build-path C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp -warnings=all -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino
Using board 'nano' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
In file included from C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino:2:0:

C:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master/MySensors.h:287:4: error: #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.

   #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.

    ^

C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino:34:24: fatal error: MySensor.h: No such file or directory

compilation terminated.

Utilisation de la bibliothèque MySensors-master version 2.0.0 dans le dossier: C:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master 
Utilisation de la bibliothèque SPI version 1.0 dans le dossier: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
exit status 1
Erreur de compilation pour la carte Arduino Nano
et là je ne comprends pas trop car j'ai programmé la gateway et je n'ai pas eu d'erreur de compilation mais j'ai utilisé l'exemple.

Quelqu'un peu m'aider ? J'ai regarder le forum et d'autres site mais je n'ai rien trouvé.

La bibliotheque mysensors 2.0.0 est bien installée alors qu'il semble dire que ce n'est pas le cas. Elle n'est pas au bon endroit ?

Merci pour votre aide.
Bonne journée.
Denis

Re: Programmation d'un node pour un capteur BMP180

Publié : 25 août 2016, 14:55
par denis91
RE,

Je me réponds à moi-même.

Je n'ai pas encore trouvé la cause mais un lien où je pense que la solution à mon problème s'y trouve :

https://forum.mysensors.org/topic/4276/ ... x-to-2-0-x

Juste une petite question tout de même :

Faut-il dans myconfig.h indiquer le module radio que l'on va utiliser ?

J'y ai fait cette modification :

Code : Tout sélectionner

// Selecting uplink transport layer is optional (for a gateway node).

#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
//#define MY_RS485
J'ai vu aussi un modification possible de la puissance d'émission mais je ne suis pas sûr que ce soit dans ce fichier.

Je vous tiens informé.

Bon après-midi et soirée.
Denis

ps :

la situation où j'en suis avant de lire l'explication pour la conversion.

Code : Tout sélectionner

:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino: In function 'void setup()':

PressureSensor:88: error: 'gw' was not declared in this scope

C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino: In function 'void loop()':

PressureSensor:116: error: 'sample' was not declared in this scope

PressureSensor:130: error: 'gw' was not declared in this scope

PressureSensor:136: error: 'gw' was not declared in this scope

PressureSensor:142: error: 'gw' was not declared in this scope

PressureSensor:146: error: 'gw' was not declared in this scope

Utilisation de la bibliothèque SPI version 1.0 dans le dossier: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
Utilisation de la bibliothèque MySensors-master version 2.0.0 dans le dossier: C:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master 
Utilisation de la bibliothèque Wire version 1.0 dans le dossier: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire 
Utilisation de la bibliothèque Adafruit_BMP085_Library version 1.0.0 dans le dossier: C:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library 
exit status 1
'MySensors' does not name a type

Re: Programmation d'un node pour un capteur BMP180

Publié : 25 août 2016, 17:19
par denis91
RE,

Mon programme converti :

Code : Tout sélectionner

#include <MyConfig.h>
#include <MySensors.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>

/**
 * The MySensors Arduino library handles the wireless radio link and protocol
 * between your home built sensors/actuators and HA controller of choice.
 * The sensors forms a self healing radio network with optional repeaters. Each
 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
 * network topology allowing messages to be routed to nodes.
 *
 * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
 * Copyright (C) 2013-2015 Sensnology AB
 * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 *******************************
 *
 * REVISION HISTORY
 * Version 1.0 - Henrik Ekblad
 * 
 * DESCRIPTION
 * Pressure sensor example using BMP085 module  
 * http://www.mysensors.org/build/pressure
 *
 */
 
//#include <SPI.h>
//#include <MySensor.h>  
//#include <Wire.h>
//#include <Adafruit_BMP085.h>

#define MY_RADIO_NRF24
#define MY_GATEWAY_SERIAL
#define BARO_CHILD 0
#define TEMP_CHILD 1

const float ALTITUDE = 688; // <-- adapt this value to your own location's altitude.

// Sleep time between reads (in seconds). Do not change this value as the forecast algorithm needs a sample every minute.
const unsigned long SLEEP_TIME = 60000; 

const char *weather[] = { "stable", "sunny", "cloudy", "unstable", "thunderstorm", "unknown" };
enum FORECAST
{
	STABLE = 0,			// "Stable Weather Pattern"
	SUNNY = 1,			// "Slowly rising Good Weather", "Clear/Sunny "
	CLOUDY = 2,			// "Slowly falling L-Pressure ", "Cloudy/Rain "
	UNSTABLE = 3,		// "Quickly rising H-Press",     "Not Stable"
	THUNDERSTORM = 4,	// "Quickly falling L-Press",    "Thunderstorm"
	UNKNOWN = 5			// "Unknown (More Time needed)
};

Adafruit_BMP085 bmp = Adafruit_BMP085();      // Digital Pressure Sensor 


float lastPressure = -1;
float lastTemp = -1;
int lastForecast = -1;

const int LAST_SAMPLES_COUNT = 5;
float lastPressureSamples[LAST_SAMPLES_COUNT];

// this CONVERSION_FACTOR is used to convert from Pa to kPa in forecast algorithm
// get kPa/h be dividing hPa by 10 
#define CONVERSION_FACTOR (1.0/10.0)

int minuteCount = 0;
bool firstRound = true;
// average value is used in forecast algorithm.
float pressureAvg;
// average after 2 hours is used as reference value for the next iteration.
float pressureAvg2;

float dP_dt;
boolean metric;
MyMessage tempMsg(TEMP_CHILD, V_TEMP);
MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
MyMessage forecastMsg(BARO_CHILD, V_FORECAST);


void presentation()  
{

	// Send the sketch version information to the gateway and Controller
	sendSketchInfo("Pressure Sensor", "1.1");

	if (!bmp.begin()) 
	{
		Serial.println("Could not find a valid BMP085 sensor, check wiring!");
		while (1) {}
	}

	// Register sensors to gw (they will be created as child devices)
	present(BARO_CHILD, S_BARO);
	present(TEMP_CHILD, S_TEMP);
	metric = getConfig().isMetric;
}

void loop() 
{
	float pressure = bmp.readSealevelPressure(ALTITUDE) / 100.0;
	float temperature = bmp.readTemperature();

	if (!metric) 
	{
		// Convert to fahrenheit
		temperature = temperature * 9.0 / 5.0 + 32.0;
	}

	int forecast = sample(pressure);

	Serial.print("Temperature = ");
	Serial.print(temperature);
	Serial.println(metric ? " *C" : " *F");
	Serial.print("Pressure = ");
	Serial.print(pressure);
	Serial.println(" hPa");
	Serial.print("Forecast = ");
	Serial.println(weather[forecast]);


	if (temperature != lastTemp) 
	{
		send(tempMsg.set(temperature, 1));
		lastTemp = temperature;
	}

	if (pressure != lastPressure) 
	{
		send(pressureMsg.set(pressure, 0));
		lastPressure = pressure;
	}

	if (forecast != lastForecast)
	{
		send(forecastMsg.set(weather[forecast]));
		lastForecast = forecast;
	}

	sleep(SLEEP_TIME);
}

float getLastPressureSamplesAverage()
{
	float lastPressureSamplesAverage = 0;
	for (int i = 0; i < LAST_SAMPLES_COUNT; i++)
	{
		lastPressureSamplesAverage += lastPressureSamples[i];
	}
	lastPressureSamplesAverage /= LAST_SAMPLES_COUNT;

	return lastPressureSamplesAverage;
}



// Algorithm found here
// http://www.freescale.com/files/sensors/doc/app_note/AN3914.pdf
// Pressure in hPa -->  forecast done by calculating kPa/h
int sample(float pressure)
{
	// Calculate the average of the last n minutes.
	int index = minuteCount % LAST_SAMPLES_COUNT;
	lastPressureSamples[index] = pressure;

	minuteCount++;
	if (minuteCount > 185)
	{
		minuteCount = 6;
	}

	if (minuteCount == 5)
	{
		pressureAvg = getLastPressureSamplesAverage();
	}
	else if (minuteCount == 35)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) // first time initial 3 hour
		{
			dP_dt = change * 2; // note this is for t = 0.5hour
		}
		else
		{
			dP_dt = change / 1.5; // divide by 1.5 as this is the difference in time from 0 value.
		}
	}
	else if (minuteCount == 65)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) //first time initial 3 hour
		{
			dP_dt = change; //note this is for t = 1 hour
		}
		else
		{
			dP_dt = change / 2; //divide by 2 as this is the difference in time from 0 value
		}
	}
	else if (minuteCount == 95)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) // first time initial 3 hour
		{
			dP_dt = change / 1.5; // note this is for t = 1.5 hour
		}
		else
		{
			dP_dt = change / 2.5; // divide by 2.5 as this is the difference in time from 0 value
		}
	}
	else if (minuteCount == 125)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		pressureAvg2 = lastPressureAvg; // store for later use.
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) // first time initial 3 hour
		{
			dP_dt = change / 2; // note this is for t = 2 hour
		}
		else
		{
			dP_dt = change / 3; // divide by 3 as this is the difference in time from 0 value
		}
	}
	else if (minuteCount == 155)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) // first time initial 3 hour
		{
			dP_dt = change / 2.5; // note this is for t = 2.5 hour
		}
		else
		{
			dP_dt = change / 3.5; // divide by 3.5 as this is the difference in time from 0 value
		}
	}
	else if (minuteCount == 185)
	{
		float lastPressureAvg = getLastPressureSamplesAverage();
		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
		if (firstRound) // first time initial 3 hour
		{
			dP_dt = change / 3; // note this is for t = 3 hour
		}
		else
		{
			dP_dt = change / 4; // divide by 4 as this is the difference in time from 0 value
		}
		pressureAvg = pressureAvg2; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past.
		firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop.
	}

	int forecast = UNKNOWN;
	if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval.
	{
		forecast = UNKNOWN;
	}
	else if (dP_dt < (-0.25))
	{
		forecast = THUNDERSTORM;
	}
	else if (dP_dt > 0.25)
	{
		forecast = UNSTABLE;
	}
	else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05)))
	{
		forecast = CLOUDY;
	}
	else if ((dP_dt > 0.05) && (dP_dt < 0.25))
	{
		forecast = SUNNY;
	}
	else if ((dP_dt >(-0.05)) && (dP_dt < 0.05))
	{
		forecast = STABLE;
	}
	else
	{
		forecast = UNKNOWN;
	}

	// uncomment when debugging
	//Serial.print(F("Forecast at minute "));
	//Serial.print(minuteCount);
	//Serial.print(F(" dP/dt = "));
	//Serial.print(dP_dt);
	//Serial.print(F("kPa/h --> "));
	//Serial.println(weather[forecast]);

	return forecast;
}
et j'ai une erreur à la ligne suivante :

int forecast = sample(pressure);

et là ca dépasse mes capacités. Qu'est sample ? une fonction dans la librairie du BMP085/BMP180 ?

sinon voici ce que dit le compilateur :

Code : Tout sélectionner

Arduino : 1.6.11 (Windows 10), Carte : "Arduino Nano, ATmega328"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Frédérique\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10611 -build-path C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp -warnings=all -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Frédérique\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10611 -build-path C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp -warnings=all -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino
Using board 'nano' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src\SPI.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\Wire.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library\Adafruit_BMP085.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
Compilation du croquis...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp.o"
C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino: In function 'void loop()':

PressureSensor:119: error: 'sample' was not declared in this scope

Utilisation de la bibliothèque MySensors-master version 2.0.0 dans le dossier: C:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master 
Utilisation de la bibliothèque SPI version 1.0 dans le dossier: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
Utilisation de la bibliothèque Wire version 1.0 dans le dossier: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire 
Utilisation de la bibliothèque Adafruit_BMP085_Library version 1.0.0 dans le dossier: C:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library 
exit status 1
'sample' was not declared in this scope

Je ne dois pas être loin mais j'ai enlevé gw.begin(); et remplacé void setup() par void presentation() . Un problème de ce coté ?

Avant

Code : Tout sélectionner

void setup()
{
gw.begin();

// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Pressure Sensor", "1.1");
Maintenant

Code : Tout sélectionner

void presentation()  
{

	// Send the sketch version information to the gateway and Controller
	sendSketchInfo("Pressure Sensor", "1.1");

mais si je laisse le begin,il me fait une erreur ...

Merci pour votre aide.

A+ Denis

Re: Programmation d'un node pour un capteur BMP180

Publié : 25 août 2016, 17:27
par vil1driver
svp.. édite ton message et utilises les balises code pour la mise en forme

Re: Programmation d'un node pour un capteur BMP180

Publié : 25 août 2016, 17:39
par denis91
RE,

Désolé, je ne connaissais pas la fonction "code". Ca doit être plus lisible maintenant.

Mon programme converti :

Code : Tout sélectionner

#include <MyConfig.h>
#include <MySensors.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>

/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/gr ... ntributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - Henrik Ekblad
*
* DESCRIPTION
* Pressure sensor example using BMP085 module
* http://www.mysensors.org/build/pressure
*
*/

//#include <SPI.h>
//#include <MySensor.h>
//#include <Wire.h>
//#include <Adafruit_BMP085.h>

#define MY_RADIO_NRF24
#define MY_GATEWAY_SERIAL
#define BARO_CHILD 0
#define TEMP_CHILD 1

const float ALTITUDE = 688; // <-- adapt this value to your own location's altitude.

// Sleep time between reads (in seconds). Do not change this value as the forecast algorithm needs a sample every minute.
const unsigned long SLEEP_TIME = 60000;

const char *weather[] = { "stable", "sunny", "cloudy", "unstable", "thunderstorm", "unknown" };
enum FORECAST
{
STABLE = 0, // "Stable Weather Pattern"
SUNNY = 1, // "Slowly rising Good Weather", "Clear/Sunny "
CLOUDY = 2, // "Slowly falling L-Pressure ", "Cloudy/Rain "
UNSTABLE = 3, // "Quickly rising H-Press", "Not Stable"
THUNDERSTORM = 4, // "Quickly falling L-Press", "Thunderstorm"
UNKNOWN = 5 // "Unknown (More Time needed)
};

Adafruit_BMP085 bmp = Adafruit_BMP085(); // Digital Pressure Sensor


float lastPressure = -1;
float lastTemp = -1;
int lastForecast = -1;

const int LAST_SAMPLES_COUNT = 5;
float lastPressureSamples[LAST_SAMPLES_COUNT];

// this CONVERSION_FACTOR is used to convert from Pa to kPa in forecast algorithm
// get kPa/h be dividing hPa by 10
#define CONVERSION_FACTOR (1.0/10.0)

int minuteCount = 0;
bool firstRound = true;
// average value is used in forecast algorithm.
float pressureAvg;
// average after 2 hours is used as reference value for the next iteration.
float pressureAvg2;

float dP_dt;
boolean metric;
MyMessage tempMsg(TEMP_CHILD, V_TEMP);
MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
MyMessage forecastMsg(BARO_CHILD, V_FORECAST);


void presentation()
{

// Send the sketch version information to the gateway and Controller
sendSketchInfo("Pressure Sensor", "1.1");

if (!bmp.begin())
{
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
while (1) {}
}

// Register sensors to gw (they will be created as child devices)
present(BARO_CHILD, S_BARO);
present(TEMP_CHILD, S_TEMP);
metric = getConfig().isMetric;
}

void loop()
{
float pressure = bmp.readSealevelPressure(ALTITUDE) / 100.0;
float temperature = bmp.readTemperature();

if (!metric)
{
// Convert to fahrenheit
temperature = temperature * 9.0 / 5.0 + 32.0;
}

int forecast = sample(pressure);

Serial.print("Temperature = ");
Serial.print(temperature);
Serial.println(metric ? " *C" : " *F");
Serial.print("Pressure = ");
Serial.print(pressure);
Serial.println(" hPa");
Serial.print("Forecast = ");
Serial.println(weather[forecast]);


if (temperature != lastTemp)
{
send(tempMsg.set(temperature, 1));
lastTemp = temperature;
}

if (pressure != lastPressure)
{
send(pressureMsg.set(pressure, 0));
lastPressure = pressure;
}

if (forecast != lastForecast)
{
send(forecastMsg.set(weather[forecast]));
lastForecast = forecast;
}

sleep(SLEEP_TIME);
}

float getLastPressureSamplesAverage()
{
float lastPressureSamplesAverage = 0;
for (int i = 0; i < LAST_SAMPLES_COUNT; i++)
{
lastPressureSamplesAverage += lastPressureSamples[i];
}
lastPressureSamplesAverage /= LAST_SAMPLES_COUNT;

return lastPressureSamplesAverage;
}



// Algorithm found here
// http://www.freescale.com/files/sensors/ ... AN3914.pdf
// Pressure in hPa --> forecast done by calculating kPa/h
int sample(float pressure)
{
// Calculate the average of the last n minutes.
int index = minuteCount % LAST_SAMPLES_COUNT;
lastPressureSamples[index] = pressure;

minuteCount++;
if (minuteCount > 185)
{
minuteCount = 6;
}

if (minuteCount == 5)
{
pressureAvg = getLastPressureSamplesAverage();
}
else if (minuteCount == 35)
{
float lastPressureAvg = getLastPressureSamplesAverage();
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
if (firstRound) // first time initial 3 hour
{
dP_dt = change * 2; // note this is for t = 0.5hour
}
else
{
dP_dt = change / 1.5; // divide by 1.5 as this is the difference in time from 0 value.
}
}
else if (minuteCount == 65)
{
float lastPressureAvg = getLastPressureSamplesAverage();
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
if (firstRound) //first time initial 3 hour
{
dP_dt = change; //note this is for t = 1 hour
}
else
{
dP_dt = change / 2; //divide by 2 as this is the difference in time from 0 value
}
}
else if (minuteCount == 95)
{
float lastPressureAvg = getLastPressureSamplesAverage();
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
if (firstRound) // first time initial 3 hour
{
dP_dt = change / 1.5; // note this is for t = 1.5 hour
}
else
{
dP_dt = change / 2.5; // divide by 2.5 as this is the difference in time from 0 value
}
}
else if (minuteCount == 125)
{
float lastPressureAvg = getLastPressureSamplesAverage();
pressureAvg2 = lastPressureAvg; // store for later use.
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
if (firstRound) // first time initial 3 hour
{
dP_dt = change / 2; // note this is for t = 2 hour
}
else
{
dP_dt = change / 3; // divide by 3 as this is the difference in time from 0 value
}
}
else if (minuteCount == 155)
{
float lastPressureAvg = getLastPressureSamplesAverage();
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
if (firstRound) // first time initial 3 hour
{
dP_dt = change / 2.5; // note this is for t = 2.5 hour
}
else
{
dP_dt = change / 3.5; // divide by 3.5 as this is the difference in time from 0 value
}
}
else if (minuteCount == 185)
{
float lastPressureAvg = getLastPressureSamplesAverage();
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
if (firstRound) // first time initial 3 hour
{
dP_dt = change / 3; // note this is for t = 3 hour
}
else
{
dP_dt = change / 4; // divide by 4 as this is the difference in time from 0 value
}
pressureAvg = pressureAvg2; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past.
firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop.
}

int forecast = UNKNOWN;
if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval.
{
forecast = UNKNOWN;
}
else if (dP_dt < (-0.25))
{
forecast = THUNDERSTORM;
}
else if (dP_dt > 0.25)
{
forecast = UNSTABLE;
}
else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05)))
{
forecast = CLOUDY;
}
else if ((dP_dt > 0.05) && (dP_dt < 0.25))
{
forecast = SUNNY;
}
else if ((dP_dt >(-0.05)) && (dP_dt < 0.05))
{
forecast = STABLE;
}
else
{
forecast = UNKNOWN;
}

// uncomment when debugging
//Serial.print(F("Forecast at minute "));
//Serial.print(minuteCount);
//Serial.print(F(" dP/dt = "));
//Serial.print(dP_dt);
//Serial.print(F("kPa/h --> "));
//Serial.println(weather[forecast]);

return forecast;
}
et j'ai une erreur à la ligne suivante :

int forecast = sample(pressure);

et là ca dépasse mes capacités. Qu'est sample ? une fonction dans la librairie du BMP085/BMP180 ?

sinon voici ce que dit le compilateur :

Code : Tout sélectionner

Arduino : 1.6.11 (Windows 10), Carte : "Arduino Nano, ATmega328"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Frédérique\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10611 -build-path C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp -warnings=all -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Frédérique\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10611 -build-path C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp -warnings=all -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino
Using board 'nano' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src\SPI.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\Wire.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library\Adafruit_BMP085.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
Compilation du croquis...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "-IC:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library" "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp" -o "C:\Users\FRDRIQ~1\AppData\Local\Temp\build19e69adf26c6752b726e74fd6ee41ad1.tmp\sketch\PressureSensor.ino.cpp.o"
C:\Users\Frédérique\Downloads\PressureSensor\PressureSensor.ino: In function 'void loop()':

PressureSensor:119: error: 'sample' was not declared in this scope

Utilisation de la bibliothèque MySensors-master version 2.0.0 dans le dossier: C:\Users\Frédérique\Documents\Arduino\libraries\MySensors-master
Utilisation de la bibliothèque SPI version 1.0 dans le dossier: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
Utilisation de la bibliothèque Wire version 1.0 dans le dossier: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Utilisation de la bibliothèque Adafruit_BMP085_Library version 1.0.0 dans le dossier: C:\Users\Frédérique\Documents\Arduino\libraries\Adafruit_BMP085_Library
exit status 1
'sample' was not declared in this scope

Je ne dois pas être loin mais j'ai enlevé gw.begin(); et remplacé void setup() par void presentation() . Un problème de ce coté ?

Avant

Code : Tout sélectionner

void setup()
{
gw.begin();

// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Pressure Sensor", "1.1");
Maintenant

Code : Tout sélectionner

void presentation()
{

// Send the sketch version information to the gateway and Controller
sendSketchInfo("Pressure Sensor", "1.1");
mais si je laisse le begin,il me fait une erreur ...

Merci pour votre aide.

A+ Denis

Re: Programmation d'un node pour un capteur BMP180

Publié : 25 août 2016, 18:33
par vil1driver
tu pouvais juste éditer/modifier ton message précédent ;) sinon oui c'est nettement plus sympa à lire :) merci

si tu cherches sample dans le code (ctrl+f) il est présent de la ligne 169 jusqu'à la fin..

peut-être faudrait il que sample soit remonté, pour qu'il soit déclaré avant son utilisation...

le sketch qui te sert de base était fonctionnel avec une précédente version de mysensors ?

Re: Programmation d'un node pour un capteur BMP180

Publié : 25 août 2016, 19:17
par denis91
Bonsoir,

Suis vraiment pas capable pour l'instant de comprendre le programme.

J'ai bien essayé de "remonter" sample mais j'ai toujours des erreurs.

Ce soir je vais laisser "tomber" car sinon madame va penser que la chaleur me rend inapte aux taches ménagères :-)

Sinon oui c'est un script qui fonctionnait normalement dans l'ancienne version de mysensors (une version 1.5 me semble-t-il) mais que j'ai essayé de convertir en version 2.0 mais je ne l'ai jamais testé en 1.5

Passez une bonne soirée et merci une nouvelle fois pour votre réponse.

A bientôt.
Denis

ps: j'ai repris l'ensemble de mes messages précédents pour mettre les balises "code"

Re: Programmation d'un node pour un capteur BMP180

Publié : 27 août 2016, 07:33
par denis91
Bonjour,

Pour info, j'ai demandé de l'aide sur le forum de mysensors et ai reçu une réponse avec une proposition de lien vers une version qui a été traduite en version 2.0 MAIS j'ai toujours la même erreur.

voici le lien vers le forum de mysensors où j'ai posé ma question : https://forum.mysensors.org/topic/4648/ ... r-bmp180/3

Bon W.E.
Denis

Re: Programmation d'un node pour un capteur BMP180

Publié : 27 août 2016, 11:45
par vil1driver
je viens de faire l'essai de compilation (IDE 1.6.8),

que ce soit avec ton sketch ou celui proposé sur le forum mysensors, précédemment cité, je n'ai pas d'erreur de compilation.

[RESOLU] Programmation d'un node pour un capteur BMP180

Publié : 02 sept. 2016, 19:55
par denis91
Bonsoir à tous,

Bon et bien effectivement en prenant un PC "vierge" d'Arduino 1.6.11 sous Windows 7, j'ai pu compiler sans problème.
J'attends mes modules RF pour mettre en ouvre maintenant.

Par contre, sous WINDOWS 10 j'ai eu beau essayer une réinstallation du logiciel audino 1.6.11, je n'ai jamais pu compiler le script pour le BMP180 :(

Par contre bizarrement, les autres scripts : Gateway et capteur UV ne m'ont posé aucun soucis ...

Merci à vil1driver pour son aide.

Bon W.E. à tous.
Denis