GithubHelp home page GithubHelp logo

paulvha / sps30 Goto Github PK

View Code? Open in Web Editor NEW
65.0 12.0 27.0 10.56 MB

Sensirion SPS30 driver for ESP32, SODAQ, MEGA2560, UNO,UNO-R4 ESP8266, Particle-photon on UART OR I2C coummunication

License: GNU General Public License v3.0

C++ 100.00%
sps30 sensirion esp32 uno arduino-uno mega2560 sensor bme280 ds18x20 particle-photon

sps30's Issues

Replacement Connector Found!

This is not an issue - just a note to help others that may have damaged or lost the flimsy cable with the ZHR-5 connector. It is available inexpensively on eBay: https://www.ebay.com/itm/114551266422
Make sure you pick the correct type, which is 1.25mm 5 Pin.
(10 Sets JST SH 1.0 ZH 1.5 PH 2.0 XH 2.5 Housing Connector Female Male Wire)

CRC error when reading version info

This is a suggested change to your code.

I attached sensor to ESP8266 i2c using D1,D2 but also tested with D3/D4 and D5/D6.
Its power is 5V and pullup is to 3.3V.

The sensor works with exception of reporting faulty version information.

I modified your code in uint8_t SPS30::I2C_ReadToBuffer(uint8_t count, bool chk_zero)
so that data is copied to the receive buffer before the CRC is calculated.
I recommend this modification so one can see what the transmitted version number is.

My sensor reports the following with your demo program "Basic Readings with any i2c" when you implement the above change.

I2C Sending: 0xD1 0x00
I2C CRC error: Expected 0x69, calculated 0xF4
I2C Received: 0x02 0xFF length: 2

Error during reading from I2C: 0x51
Read version info with error.
Firmware level: 2.255
Library level : 1.4

Second byte of version information is likely faulty.

Support for ESP32C3

Overview

The library fails with ESP32C3 over Espressif 5.0.0 and also over Espressif 6.0.0. With other variants, like ESP32, 8266 and also Atmelsam works fine.

Compiling .pio/build/ESP32C3/lib658/S8_UART/utils.cpp.o
.pio/libdeps/ESP32C3/sps30/src/sps30.cpp: In member function 'bool SPS30::setSerialSpeed()':
.pio/libdeps/ESP32C3/sps30/src/sps30.cpp:1097:13: error: 'Serial2' was not declared in this scope
             Serial2.begin(_Serial_baud);
             ^~~~~~~
.pio/libdeps/ESP32C3/sps30/src/sps30.cpp:1097:13: note: suggested alternative: 'Serial1'
             Serial2.begin(_Serial_baud);
             ^~~~~~~
             Serial1

Dependencies:

Resolving ESP32C3 dependencies...
Platform espressif32 @ 6.0.0 (required: espressif32)
framework-arduinoespressif32 @ 3.20006.221224
sps30 @ 1.4.14

Thanks in advance.

'ERR_DATALENGTH' 'ERR_OK' not declared

Hello Paul, I've been trying to get the SPS30 to read PM values using an Heltec ESP32 LoRa WiFi board, ive tried i2c and UART, yet am experiencing this issue, which is weird since it was not giving me the error of having things undeclared but rather saying that the sps30 probe was not reading. Any assistance would be helpful thank you.

Arduino Zero (SAMD21) Issues

I've run into a couple issues while using this library on an Arduino Zero and Adafruit Metro M0 board:

printf.h:
#define _Stream_Obj_ Serial could be changed to #define _Stream_Obj_ SERIAL_PORT_MONITOR to work on most platforms

sps30.cpp:
On this platform the hardware Serial (D0 and D1) are called Serial1. This port is excluded by the ifdefined rules. My proposal is to change #if defined(__AVR_ATmega32U4__) to #if defined(__AVR_ATmega32U4__) || defined(ARDUINO_ARCH_SAMD)

sps30.h >> SER_STOP_MEASUREMENT

Hello Paul - great library!!

I may have stumbled upon a error in sps30.h, line 291:

bool probe();
bool reset() {return(Instruct(SER_RESET));}
bool start() {return(Instruct(SER_START_MEASUREMENT));}
bool stop() {return(Instruct(SER_START_MEASUREMENT));}
bool clean() {return(Instruct(SER_START_FAN_CLEANING));}

should

bool stop() {return(Instruct(SER_START_MEASUREMENT));}

not be

bool stop() {return(Instruct(SER_STOP_MEASUREMENT));}

? Seems like a copy-error :)

auto-clean on esp8266 not working

10:53:26.255 -> Serial number : 79D40290B4DFxxxx
10:53:26.255 -> Product name : not available
10:53:26.255 -> Article code : not available
10:53:26.255 -> could not get clean interval.Protocol error
10:53:26.255 -> No Auto Clean interval change requested.
10:53:27.251 -> Measurement started
10:53:27.251 ->
10:53:27.251 -> Hit to continue reading
10:53:29.263 -> Hit to continue reading
10:53:31.248 -> Hit to continue reading
10:53:33.259 -> -------------Mass ----------- ------------- Number -------------- -Average-
10:53:33.259 -> Concentration [μg/m3] Concentration [#/cm3] [μm]
10:53:33.293 -> P1.0 P2.5 P4.0 P10 P0.5 P1.0 P2.5 P4.0 P10 PartSize
10:53:33.293 ->
10:53:33.293 -> 0.74 2.94 4.69 5.04 0.40 3.55 5.73 6.15 6.21 1.63
10:53:36.299 -> 0.79 1.49 2.01 2.12 3.92 5.58 6.26 6.39 6.41 0.89
10:53:39.297 -> 0.87 1.52 2.01 2.11 4.58 6.29 6.93 7.05 7.07 0.92

Using I2c on ESP8266.

SPS_DEBUGSERIAL_SODAQ Error

Dear Paul

I'm a newbie to Arduino and your package, so I'm not sure if the following error is due to a programming error on my side or a bug in the package.

I use a ATMega328P on a Chinese Arduino Uno (which worked well for other applications) wired according your sketch to the SPS30.
Now I wanted to upload/compile the example sketch number 1 from your package. I changed the lines to
#define SP30_COMMS I2C_COMMS
#define TX_PIN 0
#define RX_PIN 0
to communicate over I2C to the SPS. I receive the error message below. Since you added recently the feature DEBUGSERIAL I wondered if this is maybe a bug...

In file included from /Users/webseitz/Documents/Arduino/libraries/sps30-master/src/sps30.cpp:66:0:
/Users/webseitz/Documents/Arduino/libraries/sps30-master/src/sps30.cpp: In member function 'void SPS30::DebugPrintf(const char*, ...)':
/Users/webseitz/Documents/Arduino/libraries/sps30-master/src/sps30.h:72:33: error: 'SerialUSB' was not declared in this scope
 #define SPS30_DEBUGSERIAL_SODAQ SerialUSB
                                 ^
/Users/webseitz/Documents/Arduino/libraries/sps30-master/src/sps30.cpp:129:13: note: in expansion of macro 'SPS30_DEBUGSERIAL_SODAQ'
             SPS30_DEBUGSERIAL_SODAQ.print(prfbuf);
             ^~~~~~~~~~~~~~~~~~~~~~~
/Users/webseitz/Documents/Arduino/libraries/sps30-master/src/sps30.h:72:33: note: suggested alternative: 'Serial_RX'
 #define SPS30_DEBUGSERIAL_SODAQ SerialUSB
                                 ^
/Users/webseitz/Documents/Arduino/libraries/sps30-master/src/sps30.cpp:129:13: note: in expansion of macro 'SPS30_DEBUGSERIAL_SODAQ'
             SPS30_DEBUGSERIAL_SODAQ.print(prfbuf);
             ^~~~~~~~~~~~~~~~~~~~~~~

I uncommented line 128 and 129 of sps30.cpp and then the code worked!

SPS not running Uart

Have purchased a new SPS30. Label 2021 03-03. Operation I2C runs well with both the original library and Pauls. In no way it will run UART. Tried on an Esp32 and mega. With external 5volt power, ground through connected. Cable 4 not connected. No power to SPS30 when changing I2C to UART, cable 4. Right serial ports named. Trying for many days but no results. Someone same problem? Some help?
Product name : 00080000
Firmware level: 2.2
Library level : 1.4

PM1.0 measure over i2c sometimes give 0

Hi,

First, thanks for your library, for your work on it. I'm using this library on CanAirIO firmware and our wrapper library CanAirIO Sensorlib. With UART implementation we don't have this issue but with i2c sometimes the PM1.0 value give 0, the other variables, PM2.5 and PM10 works fine.

When the debug flag is enable, before the issue is reached, we have the next output:

20:37:03.820 > Error: Received NO bytes
20:37:03.820 > I2C Received: length: 0
20:37:03.820 > 
20:37:03.820 > Error during reading from I2C: 0x51
20:37:03.820 > -->[SPS30] read > done! 
20:37:03.820 > -->[SENSORS] PM1:000 PM25:008 PM10:008 CO2:0000 CO2humi:0.0% CO2temp:0.0°C H:39.21% T:25.5°C

It is weird because the error is detected by SPS30 library but something resetting to zero the PM1.0 value. The read method implementation in our library is this

The final output after this issue is something like this:

screenshot20210705_004315

Thanks

Setting up serialport2 TX and RX

Hi,
I'm having trouble to connect an sps30 to a TTGO wrover esp32.
For serial port 2 I have to use 16,17 pins but the TTGO esp32 doesn't have this pinouts.
I tried to change them in the sketch with 4,5 but without success.
Have u got any hint?

Thnks
Paul
anyway thanks for the lib, nice work

ByteToFloat

Hi Paul,

I tried compiling and example 7 this evening, but I run into those errors:

{
	"resource": "/Users/matthijsvandenberg/Documents/PlatformIO/Projects/AirQual Plafond/.pio/libdeps/d1_mini/sps30/src/sps30.h",
	"owner": "cpp",
	"severity": 8,
	"message": "conflicting declaration 'typedef union ByteToFloat ByteToFloat'",
	"startLineNumber": 329,
	"startColumn": 3,
	"endLineNumber": 329,
	"endColumn": 3
}

and

{
	"resource": "/Users/<naam>/Documents/PlatformIO/Projects/AirQual Plafond/lib/scd30/src/paulvha_SCD30.h",
	"owner": "cpp",
	"severity": 8,
	"message": "'ByteToFloat' has a previous declaration as 'typedef union ByteToFloat ByteToFloat'",
	"startLineNumber": 110,
	"startColumn": 3,
	"endLineNumber": 110,
	"endColumn": 3
}

I try this with PlatformIO in VSCode. Any idea's? Google comes up empty. Is this an old version of something? Bit of a noob as you know. :-(

Thnx.

I2C Wake-up does not work

sps30.h line 410
is #define I2C_WAKEUP 0X1002
should be #define I2C_WAKEUP 0X1103
otherwise I2C Wake-up does not work

SPS30 - Not A Teamplayer - Problems with other devices on I2C

First the important stuff: Paul: I love your library! SENSIRION should hire you for the job you did here.

SYSTEM:
ESP8266 / WeMOS D1 Board
Arduino IDE 1.8.9
esp8266 Library V2.5.2

I2C Devices
SENSIRION SPS30
BME680
D1 OLED-Display Shield

I'm developing a Sensor-Reader/Data-Logger device, set up the SPS30 pretty much the way you did in the examples.

I read the sensor every two seconds, together with the BME680 and update the Display (via the u2g8 Library). And I get garbage like that:

19-06-12_garbage.txt
(Tab separated text file)

Interestingly, if I disable the routines, that write the Display - the SPS30 works fine:

19-06-12_ok.txt

I tried to leave the SPS30 "time to breathe" by tick-tocking every second between reading the SPS30 on even seconds and writing the display on the odd ones - no success.

Tried the combination SPS30/BME680/Display unter the ESP8266-Lib 2.4.2 and it worked. Sadly, we can't go back, b'c some upcomming devices depend on the 2.5.2 Library - welcome to dependency hell.

One more thing: currently the devices are read/written to in that oder:

tick:

  • SPS30
  • BME680

tock:

  • Display

If I change the order, so the BME680 gets read before the SPS30, it screws up the measurement again.

I know: your library comes without warranty or help - if you got any idea what's going on there, it would be greatly appreciated.

Error reading sps30.

Hi.
Using the library with canairio proyect, I found that some times the sensor show me some errors:

->[SLIB] attempt enable sensor : SPS30
-->[SLIB] SPS30 Serial number : 3D59CD669A90A7EB
-->[SLIB] SPS30 product name : 00080000
-->[SLIB] SPS30 firmware level : 2.1
-->[SLIB] SPS30 Hardware level : 0
-->[SLIB] SPS30 SHDLC protocol : 0.0
-->[SLIB] SPS30 Library level : 1.4
-->[SLIB] SPS30 Detected SPS30 via I2C.
-->[SLIB] SPS30 Measurement OK
-->[SLIB] sensor registered : SPS30 :D

Here the error:

[E][SLIB] SPS30 error msg : Protocol error
-->[SLIB] AM2320 read : done!
-->[HEAP] LOOP bytes used : 5860b/052Kb
-->[SLIB] Sensors devices count : 2 (SPS30,AM232X,)
-->[SLIB] Sensors units count : 6 (PM1,PM2.5,PM4,PM10,T,H,)
-->[SLIB] Preview sensors values : PM1:18.0 PM2.5:20.0 PM4:20.0 PM10:20.0 T:20.0 H:38.3
-->[SLIB] SPS30 read : done!
-->[SLIB] AM2320 read : done!
-->[HEAP] LOOP bytes used : -1768b/054Kb
-->[SLIB] Sensors devices count : 2 (SPS30,AM232X,)
-->[SLIB] Sensors units count : 6 (PM1,PM2.5,PM4,PM10,T,H,)
-->[SLIB] Preview sensors values : PM1:19.0 PM2.5:20.0 PM4:20.0 PM10:20.0 T:20.0 H:37.1
-->[MQTT] Anaire cloud published : payload size: 197
-->[IFDB] CanAirIO cloud write : payload size: 48

other example with more info:
11:46:13.149 > -->[SLIB] trying to load I2C sensors..
11:46:13.155 > -->[SLIB] I2C SPS30 starting sensor..
11:46:13.155 > I2C Sending: 0xD1 0x00
11:46:13.160 > I2C Received: 0x02 0x01 length: 2
11:46:13.160 >
11:46:13.160 > I2C Sending: 0xD0 0x33
11:46:13.166 > I2C Received: 0x33 0x44 0x35 0x39 0x43 0x44 0x36 0x36 0x39 0x41 0x39 0x30 0x41 0x37 0x45 0x42 0x00 0x00 length: 18
11:46:13.171 >
11:46:13.171 > -->[SLIB] SPS30 Serial number : 3D59CD669A90A7EB
11:46:13.276 > I2C Sending: 0xD0 0x02
11:46:13.276 > I2C Received: 0x30 0x30 0x30 0x38 0x30 0x30 0x30 0x30 length: 8
11:46:13.276 >
11:46:13.276 > -->[SLIB] SPS30 product name : 00080000
11:46:13.276 > I2C Sending: 0xD1 0x00
11:46:13.276 > I2C Received: 0x02 0x01 length: 2
11:46:13.276 >
11:46:13.276 > -->[SLIB] SPS30 firmware level: 2.1
11:46:13.276 > -->[SLIB] SPS30 Hardware level: 0
11:46:13.276 > -->[SLIB] SPS30 SHDLC protocol: 0.0
11:46:13.276 > -->[SLIB] SPS30 Library level : 1.4
11:46:13.276 > I2C Sending: 0xD3 0x04
11:46:15.196 > -->[SLIB] SPS30 Detected SPS30 via I2C.
11:46:15.202 > I2C Sending: 0x00 0x10 0x03 0x00 0xAC
11:46:16.197 > -->[SLIB] SPS30 Measurement OK
11:46:16.203 > -->[SLIB] I2C detected SPS30 sensor :)

And the error:

11:46:24.173 > -->[SLIB] AM2320 read > done!
11:46:24.254 > I2C Sending: 0x02 0x02
11:46:24.259 > I2C Received: 0x00 0x01 length: 2
11:46:24.259 >
11:46:24.259 > I2C Sending: 0x03 0x00
11:46:24.261 > I2C CRC error: Expected 0xE8, calculated 0xD0
11:46:24.267 > I2C Received: 0x41 0x5B 0x50 0xFB 0x41 0x67 0xEB 0x2F length: 8
11:46:24.273 >
11:46:24.273 > Error during reading from I2C: 0x51
11:46:24.277 > [E][SLIB] SPS30 Protocol error
11:46:24.298 > -->[SLIB] PM1:000 PM25:000 PM10:000 CO2:0000 CO2humi:0.000000% CO2temp:0.000000°C H:37.099998% T:18.700001°C
11:46:24.309 > -->[SLIB] new sample time: 15
11:46:39.264 > I2C Sending: 0x02 0x02
11:46:39.265 > I2C Received: 0x00 0x01 length: 2
11:46:39.265 >
11:46:39.265 > I2C Sending: 0x03 0x00
11:46:39.267 > I2C CRC error: Expected 0xFF, calculated 0xF8
11:46:39.273 > I2C Received: 0x41 0x97 0xDB 0x34 0x41 0xA0 0x95 0x0E 0x41 0xA0 0x95 0x07 length: 12
11:46:39.284 >
11:46:39.284 > Error during reading from I2C: 0x51
11:46:39.284 > [E][SLIB] SPS30 Protocol error
11:46:39.290 > -->[SLIB] Any data from sensors? check your wirings!
11:46:39.314 > -->[SLIB] PM1:000 PM25:000 PM10:000 CO2:0000 CO2humi:0.000000% CO2temp:0.000000°C H:37.099998% T:18.700001°C
11:46:41.998 > -->[MQTT] Anaire sensor payload published. (size: 194)

I am not sure if this is an issue or not.
Thanks.

Example 6 SPS30

return on line 284 required the addition of a variable to compile for me. Added (true) and everything has been working peachy.

Hard reset?

Is it possible to conduct a hard reset on the SPS30?
When uploading new code while a previous program is running and accessing the sensor through I2C, the command ".probe()" usually fails. If the sensor is powered down and reenergized, the program works as expected.

This likely is a firmware issue or perhaps when using I2C one needs to send reset before executing probe()?

i2c speed recommendation

I recommend changing the speed for i2c to 50,000 for the sps30.
In my setup I have less than 20cm cable length and I have the pullups and esp8266.
When operating at standard clock and polling data every second, my system usually stalls within a 48hr time frame.
When it stalls, all communication with the device fails and it requires power cycle to restart.
This indicates that the controller inside the senor crashed.

When I use 50kHz i2c clock, the system is more stable.

One can achieve this in the "*any_I2c.ino" example program with

TwoWire.setClock(50000);
ret = sps30.GetValues(&val);
TwoWire.setClock(100000);

I would like to suggest to add the above two statements in the i2c example code and to comment them out so that users having same issue can enable it.

One can also change the driver code but there might be other i2c devices on the bus that will change the clock speed when they are initialized or they don't operate properly at 50kHz. One would need to change speed in the getValues section and change it back after data transfer is completed.

I tested the 50kHz clock because there are other Sensirion devices such as CO2 SCD30 where datasheet recommends 50kHz clock.

Example5_sps30_bme280_BasicReadings

Hello - thanks for the library. I found a superfluous curly bracket on line 248 in Example5_sps30_bme280_BasicReadings. If I remove it, it compiles without complaining in Arduino IDE.

PM2.5 - PM10 identical after stabilization time

Hello and thank you for this great library!
I am using it with an ESP32 over UART and have a weird problem. After starting the measurement mode, it only takes some measurements (between 1 and 10) and the values for PM2.5, PM4 and PM10 concentrations are identical. I think it's pretty unlikely that there aren't any larger particles for several days. After a reset the first measurements show different values but they are getting the same pretty fast again.
Have you ever seen a similar behaviour? I am not sure if my sensor is faulty or if I am doing anything wrong.

-------------Mass -----------    ------------- Number --------------   -Average-
     Concentration [μg/m3]             Concentration [#/cm3]             [μm]
P1.0	P2.5	P4.0	P10	P0.5	P1.0	P2.5	P4.0	P10	PartSize

4.41	7.04	8.87	9.25	24.16	32.17	34.83	35.15	35.21	0.75
4.22	5.75	6.77	6.98	26.03	32.34	33.86	34.04	34.07	0.65
4.02	4.16	4.16	4.16	28.70	32.90	33.00	33.00	33.00	0.53
3.89	4.03	4.03	4.03	27.75	31.82	31.91	31.91	31.91	0.51
3.75	3.88	3.88	3.88	26.74	30.66	30.75	30.75	30.75	0.53
3.98	4.12	4.12	4.12	28.39	32.56	32.65	32.65	32.65	0.50
3.98	4.12	4.12	4.12	28.41	32.57	32.66	32.66	32.66	0.50
3.94	4.08	4.08	4.08	28.10	32.22	32.31	32.31	32.32	0.48
3.85	3.99	3.99	3.99	27.47	31.49	31.58	31.58	31.59	0.47
3.74	3.88	3.88	3.88	26.71	30.63	30.72	30.72	30.72	0.48
3.64	3.77	3.77	3.77	26.00	29.82	29.90	29.90	29.90	0.48
3.69	3.82	3.82	3.82	26.33	30.19	30.28	30.28	30.28	0.47
3.66	3.79	3.79	3.79	26.15	29.98	30.07	30.07	30.07	0.47
3.62	3.75	3.75	3.75	25.81	29.60	29.68	29.69	29.69	0.48
3.71	3.84	3.84	3.84	26.45	30.32	30.41	30.41	30.41	0.47
3.92	4.06	4.06	4.06	27.95	32.05	32.14	32.14	32.14	0.47
4.16	4.31	4.31	4.31	29.69	34.04	34.14	34.14	34.14	0.47
4.35	4.50	4.50	4.50	31.02	35.57	35.67	35.67	35.67	0.47
4.27	4.42	4.42	4.42	30.45	34.91	35.01	35.01	35.01	0.47
4.13	4.28	4.28	4.28	29.47	33.79	33.88	33.88	33.88	0.46
4.10	4.25	4.25	4.25	29.28	33.57	33.67	33.67	33.67	0.47
4.08	4.22	4.22	4.22	29.10	33.37	33.46	33.46	33.46	0.47
4.02	4.16	4.16	4.16	28.69	32.89	32.99	32.99	32.99	0.47
3.95	4.09	4.09	4.09	28.18	32.31	32.40	32.40	32.40	0.48
3.87	4.01	4.01	4.01	27.65	31.70	31.79	31.80	31.80	0.48
3.94	4.08	4.08	4.08	28.15	32.28	32.37	32.37	32.37	0.48
4.01	4.15	4.15	4.15	28.62	32.82	32.91	32.91	32.91	0.48
4.16	4.31	4.31	4.31	29.70	34.05	34.15	34.15	34.15	0.48
4.21	4.36	4.36	4.36	30.05	34.45	34.55	34.56	34.56	0.48
4.22	4.37	4.37	4.37	30.10	34.52	34.62	34.62	34.62	0.48
4.07	4.21	4.21	4.21	29.04	33.30	33.39	33.39	33.40	0.48
3.81	3.94	3.94	3.94	27.17	31.15	31.24	31.24	31.24	0.49
3.66	3.79	3.79	3.79	26.10	29.92	30.01	30.01	30.01	0.49
3.74	3.87	3.87	3.87	26.70	30.61	30.70	30.70	30.70	0.49
3.95	4.09	4.09	4.09	28.18	32.31	32.41	32.41	32.41	0.49
4.14	4.28	4.28	4.28	29.53	33.86	33.96	33.96	33.96	0.49
4.21	4.36	4.36	4.36	30.03	34.43	34.53	34.53	34.53	0.49
4.02	4.16	4.16	4.16	28.70	32.90	33.00	33.00	33.00	0.49
3.94	4.09	4.09	4.09	28.16	32.28	32.38	32.38	32.38	0.49
...

Please support NANO 33 IOT board.

Hi

I'm using NANO 33 IOT board with SPS30 UART Connection.
NANO 33 IOT board have a SERIALPORT1 except debug port.
If you add code below at "SPS30::setSerialSpeed()" class then very helpful another people.
(for beginner like me)

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

Thanks your good code.
Good luck.

https://store.arduino.cc/usa/nano-33-iot

could not probe / connect with SPS30.

Hi,

Does the fan turn on no matter what? It was working, and tried to upload new code and now it doesnt work. I hadn't touched code in a while so something may have changed.. I need to debug this. I get:

Trying to connect
could not probe / connect with SPS30.
Program on hold

Should the fan turn on once plugged in, or is it after the mcu communicates with the sps?
I'm tripple checking the rx tx pins. I'm setting Serial1 and defining RX TX as I'm using an ESP32.
On pin 17 16.

Further check possible when reading values; avoids bad data

I have an SPS30 readout by an ESP8266-NodeMCU, powered by the 5 V pin and using SoftSerial UART with 3.3 V communications.
It has frequent read errors (one per 100 or so), usually caught by the CRC check. But I guess with an 8bit CRC check, once in 256 errors you happen to get the same code by chance, allowing bad data through. Most such events have a few data words missing, and crazy values like billions or negative. So the payload is 0x28, but the actual length value is less than 46 (typically 43). This is easy to detect, just after the redundancy check. When I put this in, it cleared up all the bad data (well, for 24 hours running, reading continuously).

Compile error when excluding UART

Hi Paul

When I comment out #define INCLUDE_UART 1 I get a compile error:
[...] /sps30.cpp:772:1: error: control reaches end of non-void function [-Werror=return-type]
772 | }

I'm compiling for a Particle Boron using Particle Workbench (MS Visual Code).

Thanks

Dave

Setting up UART

Hi, I'm having some trouble getting the code running on an ESP32 via UART. I've commented out all the I2C parts and have it compiling. when I turn the debug mode on, I see that the data being sent but no reply. I've got the wires hooked up as in the document, and have turned Serial2 on for the pin 17 and 16 serial2. Could you advise on how I can debug the issue? Thanks!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.