Hello,
I need to complete a configuration file for my stations.
My stations have serveral sensors and I use my cofniguration file to activate it or not, or to define the analog pin, where there are connected.
Here is an exemple of my struct for a station pay attention to bud1_active, bud2_active, bud3_active and bud4_active)
struct ini_station
{
const char* nom;
const int station_id;
const int analogRResolution;
bool actif; //Activate station: true/false
const int32_t tx_interval; // // (sec) 15, 30, 60 (1mn), 120 (2mn), 300 (5mn), 900 (15mn), 1800 (30mn), 3600sec (1h)
const bool mprint; // Display print in the terminal
const int sd; //Activate SD card: 0=inactive; 1=active; 2=active and read config from SD
//boolean conf_from_sd = false; // If sd is active and conf_from_sd, the sensor configuration from SD will considered instead of the conf from that ino file
bool logger; // (sd must be true) If true, the station activity will be saved into the SD card
const bool oled; // Activate the OLED display
const bool rtc; // Activate the RTC DS3231 clock
const bool rtc_calibrate; // Calibrating the RTC DS3231 clock. RTC. RTC must be true (Default false)
const bool eeprom; // Activate the EEPROM chip. It must be true to save the LoRaWAN keys
const bool watchdog;
const bool sleepMode;
const int lora; // 0=unactivate LoRaWAN; 1=OTAA; 2=ABP
const bool temperature_active; // te; a;
const bool pressure_active; // pr; b;
const bool humidity_active; // hu; c
const bool luminosity_active; // lu; d;
const byte wm1_active; // w1; e;
const byte wm2_active; // w2; f;
const byte wm3_active; // w3; g;
// bool datetime_active; // da; h; // date_time_active is always the same than rtc
const bool temperature_soil_active; // ts; i; // Must define the analog pin
const byte gauge_active; // ga; j;
const bool battery_active; // ba; k;
const byte wattering_active; // ar; l;
const byte aneno_active; // an; m;
const bool irtemp_active; // ir; n;
const bool wrm_active; // wr; o
const byte bud1_active; // b1; p;
const byte bud2_active; // b2; q;
const byte bud3_active; // b3; r;
const byte bud4_active; // b4; s;
const byte sun_active; // su; t;
const byte wdirection_active; // wd; u;
const byte wdirection_offset;
const byte sf110bud_active; // sb; v;
const byte sf110leaf_active; // sl; w;
/*
const char * nomDuCapteur;
const uint8_t codeDuCapteur;
*/
};
ini_station station = {
"A12", // Station name
25, // station ID
12, // analogReadResolution
true, // station active (true or false)
15, // TX INTERVAL (sec) 15, 30, 60 (1mn), 120 (2mn), 300 (5mn), 900 (15mn), 1800 (30mn), 3600sec (1h)
true, // mprint
0, // SD card: 0=inactive; 1=active; 2=active and read config from SD
false, // LOGGER: (SD must not be 0) If true, the station activity will be saved into the SD card
false, // OLED: Active or not
false, // RTC DS3231 I2C
false, // RTC CALIBRATE RTC Must be true. Do not forget to have it back to fase after calibrating
false, // EEMPROM: Active or not
false, // Watchdog
false, // SLEEP: Active the sleep mode (Arduinolowpower)
1, // LoRaWAN: 0=unactivate; 1=OTAA; 2=ABP;
false, // te; a;
false, // pr; b;
false, // hu; c
false, // lu; d;
0, // w1; e; // 0=Unactive; 14=A0; *15=A1*; 16=A2; 17=A3; 18=A4; 19=A5
0, // w2; f; // 0=Unactive; 14=A0; 15=A1; *16=A2*; 17=A3; 18=A4; 19=A5
0, // w3; g; // 0=Unactive; 14=A0; 15=A1; 16=A2; *17=A3*; 18=A4; 19=A5
//true, // da; h; // date_time_active is always the same than rtc
false, // ts; i; // Must define the analog pin
0, // ga; j; // 0=Unactive; 14=A0; 15=A1; 16=A2; *17=A3*; 18=A4; 19=A5
true, // ba; k;
0, // ar; l; // WATTERING // 0=Unactive; 14=A0; 15=A1; 16=A2; 17=A3; *18=A4*; 19=A5
0, // an; m; // WWIND SPEED // 0=Unactive; *14=A0*; 15=A1; 16=A2; 17=A3; 18=A4; 19=A5
false, // ir; n;
false, // wr; o
14, // b1; p; // 0=Unactive; *14=A0*; 15=A1; 16=A2; 17=A3; 18=A4; 19=A5
0, // b2; q; // 0=Unactive; 14=A0; *15=A1*; 16=A2; 17=A3; 18=A4; 19=A5
0, // b3; r; // 0=Unactive; 14=A0; 15=A1; *16=A2*; 17=A3; 18=A4; 19=A5
19, // b4; s; // 0=Unactive; 14=A0; 15=A1; 16=A2; *17=A3*; 18=A4; 19=A5
0, // su; t; // SUN: // 0=Unactive; 14=A0; 15=A1; *16=A2*; 17=A3; 18=A4; 19=A5
0, // wd; u; // WIND DIRECTION 0=Unactive; 14=A0; *15=A1*; 16=A2; 17=A3; 18=A4; 19=A5 and the WindDirectionOffset
0, // Offset of the wind direction bar from the Noth (Degree). 0 if the bar point to the North
0, // sb; v; // 0=Unactive; 14=A0; 15=A1; *16=A2*; 17=A3; 18=A4; 19=A5
0, // sl; w; // 0=Unactive; 14=A0; 15=A1; *16=A2*; 17=A3; 18=A4; 19=A5
};
I have 4 bs18b20 sensors (bud1_active, bud2_active, bud3_active, bud4_active), connected to A1,A2,A3 and A4.
Thoses sensors need to be calibrated but taking a measure in a ice and hot water and I want to perfect the bellow part to be included (or merged) in the above struct
struct t_calibrate{
const byte pin;
float tMin; // Mesure in the ice (°C)
float tMax;// Measure in the hot water (°C)
};
struct t_bs18b20 {
const char* nom;
float refMin; // Reference, temperature of the Ice (°C)
float refMax; // refrence, temerature of the hot water (°C)
t_clibrate calibrate[4]; // 4 is the number of ds18b20
};
// Exemple of serval station with 4 ds18b20 sensors
t_bs18b20 bs18b20[] = {
{"Error, No station", 0, 0, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}},
{"station 1", 0, 97, {{19, -0.8, 96.9}, {0, 0, 0}, {0, 0, 0}, {14, -1.1, 94.5}}},
[... other station ...]
}
As I may have written, I want to have one configuration file for one station. So this should be enough for one station (station 1)
t_bs18b20 bs18b20 = {
"station 1", 0, 97, {{19, -0.8, 96.9}, {0, 0, 0}, {0, 0, 0}, {14, -1.1, 94.5}},
}
My problem and how to make it better
As you can see I defined the analog pin (14,15,16,17,18,19) in struct ini_station
and in t_bs18b20
and it's not a good idea.
How would you modify t_bs18b20 bs18b20
with two goal
- delete the analog pin indication
const byte pin
- to make sure that
bud1_actvate
definition will macth the righ value.
Do you understand my goal?
The other idea, would be to not work with several struct, and to add bud1_setting in ```struct ini_station``
struct ini_station
{
const byte bud1_active; // b1; p;
const byte bud1_setting; // {0, 97,-0.8, 96.9} (refMin, refMax, min, max)
const byte bud2_active; // b2; q;
const byte bud2_setting; // {0, 97,-0.8, 96.9} (refMin, refMax, min, max)
const byte bud3_active; // b3; r;
const byte bud3_setting; // {0, 97,-0.8, 96.9} (refMin, refMax, min, max)
const byte bud4_active; // b4; s;
const byte bud4_seting; // {0, 97,-0.8, 96.9} (refMin, refMax, min, max)
}
ini_station station = {
14, // b1; p; // 0=Unactive; *14=A0*; 15=A1; 16=A2; 17=A3; 18=A4; 19=A5
{0, 97,-0.8, 96.9}, //bud1_setting
0, // b2; q; // 0=Unactive; 14=A0; *15=A1*; 16=A2; 17=A3; 18=A4; 19=A5
{0, 97,-0.8, 96.9}, // bud2_setting
0, // b3; r; // 0=Unactive; 14=A0; 15=A1; *16=A2*; 17=A3; 18=A4; 19=A5
{0, 97,-0.8, 96.9}, //bud3_setting
19, // b4; s; // 0=Unactive; 14=A0; 15=A1; 16=A2; *17=A3*; 18=A4; 19=A5
{0, 97,-0.8, 96.9}, //bud4_setting
}
May be, it's look more simple.
Which best way you'd recommand me, with may exemples...
Many thanks!!!