My strcut does not print it value

Hello

I am a bit suprise about what return a 'Serial.print()' while I want to print a struct.

I am rewriting my code, and I want to have a file for each station, with different default values.

For exemple, I define if a sensor is active or not, or a analog pin where a sensor is connected to.

I created a struct as the following


struct ini_station
{
  const char* nom;
  const int station_id;
  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 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;        
  const bool datetime_active;    // da; h;
  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 = {
    "Station 23",   // Station name
    23,             // station ID
    true,           // station active (true or false)
    900,            // 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
    true,           // LOGGER: (SD must not be 0) If true, the station activity will be saved into the SD card
    false,          // OLED: Active or not
    true,           // RTC DS3231 I2C
    true,           // EEMPROM: Active or not
    true,           // Watchdog
    false,           // SLEEP: Active the sleep mode (Arduinolowpower)
    1,              // LoRaWAN: 0=unactivate; 1=OTAA; 2=ABP; 10=OTAA disable sending; 20=ABP disable sending
    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
    false,          // da; h;
    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
    false,          // 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
    true,           // ir; n;
    false,          // wr; o
    14,             // b1; p;     // 0=Unactive; *14=A0*; 15=A1; 16=A2; 17=A3; 18=A4; 19=A5
    15,             // b2; q;     // 0=Unactive; 14=A0; *15=A1*; 16=A2; 17=A3; 18=A4; 19=A5
    16,             // b3; r;     // 0=Unactive; 14=A0; 15=A1; *16=A2*; 17=A3; 18=A4; 19=A5
    17,             // 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
    
};

Then in my ino file, at some point, I print the configuration


Serial.print(F("Name:\t")); Serial.println(F(station.nom));
  Serial.print(F("Station ID:\t")); Si.sprintln(F(station.station_id),0);
  Serial.print(F("Interval (s):\t")); Serial.println(F(station.tx_interval));
  Serial.print(F("Print:\t")); Serial.println(F(station.mprint));
  Serial.print(F("SD:\t")); Serial.println(F(station.sd));
  if(station.sd == 0) station.logger = false;
  Serial.print(F("Logger:\t")); Serial.println(F(station.logger));
  Serial.print("\t"); Serial.println(F("! SD must be active !"));
  Serial.print(F("OLED:\t")); Serial.println(F(station.oled));
  Serial.print(F("RTC:\t")); Serial.println(F(station.rtc));
  Serial.print(F("EEPROM:\t")); Serial.println(F(station.eeprom));
  Serial.print(F("Watchdog:\t")); Serial.println(F(station.watchdog));
  Serial.print(F("Sleep mode:\t")); Serial.println(F(station.sleepMode));
  Serial.print(F("LoRaWAN:\t")); Serial.println(F(station.lora));
  Serial.println(F("SENSORS"));
  Serial.print(F("Temperature (I2C):\t")); Serial.println(F(station.temperature_active));
  Serial.print(F("Pression (I2C):\t")); Serial.println(F(station.pressure_active));
  Serial.print(F("Humidity (I2C):\t")); Serial.println(F(station.humidity_active));
  Serial.print(F("Luminosity (I2C):\t")); Serial.println(F(station.luminosity_active));
  Serial.print(F("Watermark 1:\t")); Serial.println(F(station.wm1_active));
  Serial.print(F("Watermark 2:\t")); Serial.println(F(station.wm2_active));
  Serial.print(F("Watermark 3:\t")); Serial.println(F(station.wm3_active));
  Serial.print(F("RTC Date/Time (I2C):\t")); Serial.println(F(station.datetime_active));
  Serial.print(F("Temperature Soil (1Wire):\t")); Serial.println(F(station.temperature_soil_active));
  Serial.print(F("Rain:\t")); Serial.println(F(station.gauge_active));
  Serial.print(F("Battery:\t")); Serial.println(F(station.battery_active));
  Serial.print(F("Wattering:\t")); Serial.println(F(station.wattering_active));
  Serial.print(F("Wind speed:\t")); Serial.println(F(station.aneno_active));
  Serial.print(F("Temp. IR (I2C):\t")); Serial.println(F(station.irtemp_active));
  Serial.print(F("WRM:\t")); Serial.println(F(station.wrm_active));
  Serial.print(F("Bud 1:\t")); Serial.println(F(station.bud1_active));
  Serial.print(F("Bud 2:\t")); Serial.println(F(station.bud2_active));
  Serial.print(F("Bud 3:\t")); Serial.println(F(station.bud3_active));
  Serial.print(F("Bud 4:\t")); Serial.println(F(station.bud4_active));
  Serial.print(F("Sun:\t")); Serial.println(F(station.sun_active));
  Serial.print(F("Wind direction:\t")); Serial.println(F(station.wdirection_active));
  Serial.print(F("SF110 Bud:\t")); Serial.println(F(station.sf110bud_active));
  Serial.print(F("SF110 Leaf:\t")); Serial.println(F(station.sf110leaf_active));

Only the first line print: Station 23 and the second line should print 23
The third should print 900 and the forth 0 for false.

Oever, all ine excepted the first, print nothing

How can it be possible, that Serial.print do not print a int, byte or bool varaiable?

What's that?

OK, I see

if I change all to

Serial.println(station.nom);`
Serial.println(station.rtc);
Serial.println(station.old);

it work

Is possible to set the same value as another one?

For exemple, I have


ini_station station = {
    "Station 23",   // Station name
    23,             // station ID
    true,           // station active (true or false)
    30,            // 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 from SD
    true,           // LOGGER: (SD must not be 0) If true, the station activity will be saved into the SD card
    false,          // OLED: Active or not
    true,           // RTC DS3231 I2C
       true,           // EEMPROM: Active or not
    true,           // Watchdog
    this.rtc,           // date_time_active
....

I would like that

const bool datetime_active;    // da; h;

always has the same vaue than

const bool rtc;    // da; h;

I stupidly wrote 'this.rtc' as it's an object, but it's not.
With a struct, can we do smething simialr`

Do you see?

Are you asking if you can assign one struct variable to another of the same type?
Yes you can.

Just get rid of one of those then…there is no point keeping two attributes that are always identical

Just get rid of one of those then…there is no point keeping two attributes that are always identical

that makes sense