Skip to content

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

@dr2okevin

Description

@dr2okevin

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions