SPS30 over UART

Hello,

I just purchased the Sensirion SPS30 environmental sensor and I am trying to get it to work over UART. I have the board connected to a SparkFun FT232 board and the sensor is powered via 5V on the USB connection. Some data does seem to be coming from the sensor. When I open the port in a terminal and power on the sensor I see a single ‘0xFF’ come by and nothing else. Should I be seeing some data coming by?

As with many intelligent sensors, you have to provide instructions before it provides results. If you have an Arduino-variant you can use the SPS30 driver like https://github.com/paulvha/sps30

You are absolutely correct. I was not sending it the proper start characters. It is working now. Thank you.

There is a bug in version 1.4 of @paulva’s otherwise-exemplary SPS30 package. The Instruct function is supposed to return a boolean value, but under certain conditions it tries to return ERR_PARAMETER, a uint8_t. Information is lost.

Thanks for pointing out Robert.

I have corrected it now in version 1.4.6

There were 2 cases of ```
return ERR_PARAMETER


Also, since you are updating it, you might want to recognize some of the Teensy processors. Some of the ```
#if defined(...) || defined(...)|| ...
``` lines were getting unwieldy, so I rewrote the beginning of <B>**SPS30::setSerialSpeed()**</B> to

{ long _Serial_baud = 115200; // no other speed is allowed for SPS30

#if defined (__MK20DX256__)
  #define Teensy_312 1      // Teensy 3.1 & 3.2
#elif defined (__MK64FX512__)
  #define Teensy_35 1      // Teensy 3.5
#endif

#if defined(SAMD21G18A)
  #define HasSerial_1  1
#elif defined(Teensy_312)|| defined(__AVR_ATmega1280__)
  #define HasSerial_1  1
  #define HasSerial_23 1
#elif defined(__AVR_ATmega2560__) || defined(ARDUINO_SAM_DUE)
  #define HasSerial_1  1
  #define HasSerial_23 1
#elif defined(Teensy_35)
  #define HasSerial_1  1
  #define HasSerial_23 1
  #define HasSerial_45 1

#endif

switch (_Sensor_Comms)
  {   case  SERIALPORT: Serial.begin(_Serial_baud);
                        _serial = &Serial;
                        break;

    #if defined(HasSerial_1)
      case SERIALPORT1: Serial1.begin(_Serial_baud);
                        _serial = &Serial1;
                        break;
    #endif

    #if defined(HasSerial_23)
      case SERIALPORT2: Serial2.begin(_Serial_baud);
                        _serial = &Serial2;
                        break;

      case SERIALPORT3: Serial3.begin(_Serial_baud);
                        _serial = &Serial3;
                        break;
    #endif

(and so on)


See if you like it.

thanks Robert

I have changed the other return code as well and updated on github.

As it relates to have the embedded communication channel selection to recognize the Teensy, It looks good what you have done. However there are many new boards every week, with many different connection possibilities and pins. It would become a bottleneck for the driver to keep adding each and every possible combination. I have decided back in May to stop adding more to embedded communication channel selection and add the possibility to select the communication channel to use in the Sketch and pass that to the driver. I had added example12 and example13 to show that.