lewapek / sds-dust-sensors-arduino-library

Library for Nova Fitness SDS dust sensors family (SDS011, SDS021)
MIT License
64 stars 19 forks source link

invalid initialization of non-const reference of type 'HardwareSerial&' , sds(rxPin, txPin); #35

Open dr2okevin opened 1 year ago

dr2okevin commented 1 year ago

When I try to compile the example for a ES32 board, I get this error in the Arduino IDE.

Feinstaub:33:31: error: invalid initialization of non-const reference of type 'HardwareSerial&' from an rvalue of type 'HardwareSerial'
 SdsDustSensor sds(rxPin, txPin);
                               ^
In file included from /home/kevin/.arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/Arduino.h:154:0,
                 from sketch/Feinstaub.ino.cpp:1:
/home/kevin/.arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/HardwareSerial.h:56:5: note:   after user-defined conversion: HardwareSerial::HardwareSerial(int)
     HardwareSerial(int uart_nr);
     ^
In file included from /home/kevin/Arduino/Feinstaub/Feinstaub.ino:2:0:
/home/kevin/Arduino/libraries/Nova_Fitness_Sds_dust_sensors_library/src/SdsDustSensor.h:60:3: note:   initializing argument 1 of 'SdsDustSensor::SdsDustSensor(HardwareSerial&, int, int)'
   SdsDustSensor(HardwareSerial &hardwareSerial,
   ^

Line 31-33 are the following:

int rxPin = 21;
int txPin = 22;
SdsDustSensor sds(rxPin, txPin);
lewapek commented 1 year ago

Hi, Thanks for pointing this out.

I haven't tested (compiled) the library myself on ESP32 boards. If in the future I will use this with ESP32 - I will make required adjustments in the source code. In the meantime, if you overcome the issue yourself, feel free to create a PR

icepick3000 commented 4 months ago

Any news on this issue? I am running into the same issues.