Software Serial for Arduion MKRwifi 1010

Hi everyone, I'm working on Arduino MKRwifi 1010 with Arduino library for PM sensors with serial interface. I found a PM serial library on GitHub but it's for arduino UNO :
PMserial/src at master · avaldebe/PMserial · GitHub.
I tried a lot to make this library working on Arduino mkr but no success. Can anyone help me how I can modify it?

My Sketch arduino:

#include <PMserial.h>

Uart Serial1(&sercom5, 13, 14, SERCOM_RX_PAD_3, UART_TX_PAD_2);

void SERCOM5_Handler()
{
  Serial1.IrqHandler();
}
SerialPM pms(PM, 13, 14);  // PM Serial, RX, TX

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
  pms.init();                   // config serial port
}

void loop() {
  pms.read();                   // read the PM sensor
  Serial.print(F("PM1.0 "));Serial.print(pms.pm01);Serial.print(F(", "));
  Serial.print(F("PM2.5 "));Serial.print(pms.pm25);Serial.print(F(", "));
  Serial.print(F("PM10 ")) ;Serial.print(pms.pm10);Serial.println(F(" [ug/m3]"));
  delay(10000);                 // wait for 10 seconds
}

Thanks in advance

Can anyone help me how I can modify it?

Replace HardwareSerial by Uart in the .h and .cpp files and use the constructor that provides the serial interface object as a parameter and not the pins.

Thanks pylon , I tried a lot but no success if you can explain more I will appreciate that.

I replaced HardwareSerial.h by uart.h in the library(in .h and .cpp) (I found uart library on Github Arduino/cores/esp8266 at master · esp8266/Arduino · GitHub ) but I always get the same error:

Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: "Arduino MKR WiFi 1010"

In file included from D:\Anass_PM\PMserial\PMserial.ino:1:0:

C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:61:24: error: 'uart' has not been declared

SerialPM(PMS sensor, uart &serial) : pms(sensor) {

^~~~

C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h: In constructor 'SerialPM::SerialPM(PMS, int&)':

C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:62:13: error: cannot convert 'int*' to 'Stream*' in assignment

uart = &serial;

^~~~~~

D:\Anass_PM\PMserial\PMserial.ino: At global scope:

PMserial:17:24: error: no matching function for call to 'SerialPM::SerialPM(Pm*, int, int)'

SerialPM pms(PM, 13, 14); // PM Serial, RX, TX

^

In file included from D:\Anass_PM\PMserial\PMserial.ino:1:0:

C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:61:3: note: candidate: SerialPM::SerialPM(PMS, int&)

SerialPM(PMS sensor, uart &serial) : pms(sensor) {

^~~~~~~~

C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:61:3: note: candidate expects 2 arguments, 3 provided

C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:45:7: note: candidate: constexpr SerialPM::SerialPM(const SerialPM&)

class SerialPM{

^~~~~~~~

C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:45:7: note: candidate expects 1 argument, 3 provided

C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:45:7: note: candidate: constexpr SerialPM::SerialPM(SerialPM&&)

C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:45:7: note: candidate expects 1 argument, 3 provided

exit status 1
no matching function for call to 'SerialPM::SerialPM(Pm*, int, int)'

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

Did I write "uart"? C/C++ is case sensitive!

If you changed your code and get problems, post it again.

@pylon, the library is good without changes. only the hw Serial constructor must be called with the Serial1 from core, because Serial is USB

https://forum.arduino.cc/index.php?topic=676369.msg4563782#msg4563782