Bonjour à tous,
J'ai réalisé une sonde à base de pro-mini + bme/dallas/uv/lux pour transmettre sur domoticz. Tout fonctionne correctement pour la transmission de la valeur des sondes. Il me reste à intégrer la gestion de la batterie, j'ai "emprunté" un bout de code à Henri Bachetti (comme d'hab !) quand j'utilise ce code seul il fonctionne parfaitement, quand je tente d'intégrer ce code dans le mien j'ai une erreur de compilation quand je rajoute la ligne " batM(); // goto void batM(){ //gestion batterie " dans ma boucle loop. Le message d'erreur de compilation ne semble pas avoir de rapport avec la choucroute.
"In function 'global constructors keyed to 65535_0_bme_dallas_lux_uv.ino.cpp.o':
lto1.exe: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html for instructions.
lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status compilation terminated.
c:/program files/windowsapps/arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
Le code qui fonctionne bien tout seul et que je tente d'intégrer au mien:
// dernière version dimanche mercredi 10 avril 2019 ok
#define MY_DEBUG
#define MY_RADIO_NRF24
#define MY_RF24_PA_LEVEL RF24_PA_LOW
//#define MY_RF24_DATARATE RF24_250KBPS
#define MY_RF24_CE_PIN A0 // ATTENTION j'ai remplacé la 9 par la a0
#define MY_RF24_CS_PIN 10
#include <MySensors.h>
// #define CHILD_ID 1 // Id of the sensor child
unsigned long SLEEP_TIME = 18*60000; // Sleep time (in milliseconds).
// unsigned long SLEEP_TIME = 10000; // use this instead for debug
//=========================
#define VOLTAGE_CHILD_ID 5
#define CHILD_ID_BAT 2 //
MyMessage msgBat(CHILD_ID_BAT, V_VOLTAGE);
MyMessage voltageMsg(VOLTAGE_CHILD_ID, V_VOLTAGE);
// BATTERY VOLTAGE DIVIDER SETUP
// 1M, 470K divider across battery and using internal ADC ref of 1.1V
// Sense point is bypassed with 0.1 uF cap to reduce noise at that point
// ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
// 3.44/1023 = Volts per bit = 0.003363075
#define VBAT_PER_BITS 0.003363075
#define VMIN 3 // Vmin (radio Min Volt)=1.9V (564v)//1.9
#define VMAX 3.44 // Vmax = (2xAA bat)=3.0V (892v) //3.0
int batteryPcnt = 0; // Calc value for battery %
int batLoop = 0; // Loop to help calc average
int batArray[3]; // Array to store value for average calc.
int BATTERY_SENSE_PIN = A3; // select the input pin for the battery sense point
//=========================
void presentation() {
// =================================================batterie début dans présentation
sendSketchInfo("niveau batterie","");
present(CHILD_ID_BAT, S_MULTIMETER);
// =================================================batterie début dans présentation
}
void setup()
{
analogReference(INTERNAL); // For battery sensing 1.1 V internal reference
Serial.println("Startup completed");
delay(500); // Allow time for radio if power used as reset
}
void loop()
{
// =================================================batterie début dans loop
// unsigned long currentTime = millis();
batM(); // goto void batM(){ //Tgestion batterie
// =================================================batterie fin dans loop
}
//=======================================================================début batterie module indépendant
void batM(){ //The battery calculations
delay(500);
// Battery monitoring reading // a supprimer ??
int sensorValue = analogRead(BATTERY_SENSE_PIN);
delay(500);
// Calculate the battery in %
float Vbat = sensorValue * VBAT_PER_BITS;
int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);
// Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");
// Add it to array so we get an average of 3 (3x20min)
batArray[batLoop] = batteryPcnt;
if (batLoop > 1) {
batteryPcnt = (batArray[0] + batArray[1] + batArray[2]);
batteryPcnt = batteryPcnt / 3;
if (batteryPcnt > 100) {
batteryPcnt=100;
}
Serial.print("batterie niveau moyen % (Send): "); Serial.print(batteryPcnt); Serial.println(" %");
Serial.print("batterie niveau moyen volts(Send): "); Serial.print(Vbat, 2); Serial.println(" v");
sendBatteryLevel(batteryPcnt);
send(voltageMsg.set(Vbat, 2));
batLoop = 0;
}
else
{
batLoop++;
}
}
//=======================================================================fin batterie module indépendant
Mon code avec les sondes est en pièce jointe.
Merci
bme_dallas_lux_uv.ino (19.7 KB)