Error compiling for board Generic STM32F4 series

Hi, I'm trying to verify some code for a STM405F board but when I try to verify it I get this error message. Haven't been able to figure out the problem as the error message is very long and confusing to me. I have verified the test code that came with the sensor and code for writing to the built in sd card. But haven't been able to verify this file which is just snippets of code from both of the examples. If anyone could help me decipher this error message and what can be done to fix it that would be amazing! Thanks!

  • Connor

Error message:
Arduino: 1.8.19 (Mac OS X), Board: "Generic STM32F4 series, Adafruit Feather STM32F405, STM32CubeProgrammer (DFU), Enabled (generic 'Serial'), CDC (generic 'Serial' supersede U(S)ART), Low/Full Speed, Smallest (-Os default), Newlib Nano (default)"

In file included from /Users/[Name]/Library/Arduino15/packages/STM32/hardware/stm32/1.9.0/cores/arduino/Print.h:27,
from /Users/[Name]/Library/Arduino15/packages/STM32/hardware/stm32/1.9.0/cores/arduino/Stream.h:26,
from /Users/[Name]/Library/Arduino15/packages/STM32/hardware/stm32/1.9.0/cores/arduino/HardwareSerial.h:29,
from /Users/[Name]/Library/Arduino15/packages/STM32/hardware/stm32/1.9.0/cores/arduino/WSerial.h:5,
from /Users/[Name]/Library/Arduino15/packages/STM32/hardware/stm32/1.9.0/cores/arduino/wiring.h:47,
from /Users/[Name]/Library/Arduino15/packages/STM32/hardware/stm32/1.9.0/cores/arduino/Arduino.h:36,
from sketch/OSR_Air_Quality.ino.cpp:1:
/Users/[Name]/Documents/Arduino/OSR_Air_Quality/OSR_Air_Quality.ino: In function 'void loop()':
/Users/[Name]/Library/Arduino15/packages/STM32/hardware/stm32/1.9.0/cores/arduino/WString.h:38:28: error: cannot bind non-const lvalue reference of type 'String&' to an rvalue of type 'String'
38 | #define F(string_literal) (reinterpret_cast<const __FlashStringHelper >(PSTR(string_literal)))
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/[Name]/Documents/Arduino/OSR_Air_Quality/OSR_Air_Quality.ino:44:19: note: in expansion of macro 'F'
44 | myFile.println(F("PM 1.0: ")); (data.pm10_env);
| ^
/Users/[Name]/Library/Arduino15/packages/STM32/hardware/stm32/1.9.0/cores/arduino/WString.h:60:5: note: after user-defined conversion: 'String::String(const __FlashStringHelper
)'
60 | String(const __FlashStringHelper *str);
| ^~~~~~
In file included from /Users/[Name]/Documents/Arduino/OSR_Air_Quality/OSR_Air_Quality.ino:2:
/Users/[Name]/Documents/Arduino/libraries/STM32SD-main/src/STM32SD.h:63:36: note: initializing argument 1 of 'virtual size_t File::println(String&)'
63 | virtual size_t println(String &data);
| ~~~~~~^~
Multiple libraries were found for "Adafruit_PM25AQI.h"
Used: /Users/[Name]/Documents/Arduino/libraries/Adafruit_PM25AQI-master
Not used: /Users/[Name]/Documents/Arduino/libraries/Adafruit_PM25_AQI_Sensor
Multiple libraries were found for "STM32SD.h"
Used: /Users/[Name]/Documents/Arduino/libraries/STM32SD-main
Not used: /Users/[Name]/Documents/Arduino/libraries/STM32duino_STM32SD
exit status 1
Error compiling for board Generic STM32F4 series.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

My code:

#include "Adafruit_PM25AQI.h"
#include <STM32SD.h>
#ifndef SD_DETECT_PIN
#define SD_DETECT_PIN SD_DETECT_NONE
#endif
File myFile;
Adafruit_PM25AQI aqi = Adafruit_PM25AQI();

void setup() {
  
Serial.begin(115200);
  while (!Serial) delay(10);
  delay(1000);
  Serial.print("Initializing SD card...");
  while (!SD.begin(SD_DETECT_PIN))
  {
    delay(10);
  }
  Serial.println("initialization done.");
  
 if (! aqi.begin_I2C()) {
  Serial.println("Could not find PM 2.5 sensor!");
    while (1) delay(10);
 }
 Serial.println("PM25 found!");
 myFile = SD.open("test.csv", FILE_WRITE);
}

void loop() {
 PM25_AQI_Data data;
  
 if (! aqi.read(&data)) {
   Serial.println("Could not read from AQI");
   delay(500);  // try again in a bit!
   return;
  }
  Serial.println("AQI reading success"); 
  Serial.println(F("---------------------------------------"));
  Serial.print(F("PM 1.0: ")); Serial.print(data.pm10_env);
  Serial.print(F("\t\tPM 2.5: ")); Serial.print(data.pm25_env);
  Serial.print(F("\t\tPM 10: ")); Serial.println(data.pm100_env);
   Serial.print("Writing");
   myFile.println("PM 1.0, PM 2.5, PM 10");
   myFile.println(F("PM 1.0: ")); (data.pm10_env);
   myFile.close();
}

It looks like your IDE does not know where your libraries are, which caused the other errors of not recognizing your code. This article describes common library problems:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.