Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dr2okevin opened this issue Dec 30, 2022 · 2 comments

Comments

@dr2okevin
Copy link

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
Copy link
Owner

lewapek commented Jan 16, 2023

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants