paulvha / sps30

Sensirion SPS30 driver for ESP32, SODAQ, MEGA2560, UNO,UNO-R4 ESP8266, Particle-photon on UART OR I2C coummunication
GNU General Public License v3.0
66 stars 27 forks source link

Hard reset? #17

Closed uutzinger closed 2 years ago

uutzinger commented 3 years ago

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()?

paulvha commented 3 years ago

hi Urs,

Strange.. I have not had that issue before.

What is the sketch you are running ?

Couple of options jumps to mind:

Are you using the sleep() option for the SPS30 ? If so, it might have been put to sleep and then needs a special sequence to wakup() (or reset). Calling wakeup() when new code is loading will not help as the current code will check whether you had put it to sleep first ?

Normally at begin() the wire is reset, but not the SPS30, You could try to do a reset(), but I have not seen or heard the need for this before..

regards, Paul


Van: Urs Utzinger notifications@github.com Verzonden: donderdag 10 december 2020 18:40 Aan: paulvha/sps30 sps30@noreply.github.com CC: Subscribed subscribed@noreply.github.com Onderwerp: [paulvha/sps30] Hard reset? (#17)

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()?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpaulvha%2Fsps30%2Fissues%2F17&data=04%7C01%7C%7Ced6a7b840bec46934ec908d89d329ec9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637432188017211364%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fYoUQDRBoLVZ2D5VNPK%2Fak%2BVcKDGi42kuVpmBVEmqYg%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD2GBPFUVGUJJYRC3NTZ6G3SUEBXBANCNFSM4UVLLDTQ&data=04%7C01%7C%7Ced6a7b840bec46934ec908d89d329ec9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637432188017221354%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=irWTZK0SGzeal1KUNcbvlKvU%2F8sxKjnU4KBnxC84rzw%3D&reserved=0.

uutzinger commented 3 years ago

That is interesting to hear. My firmware does not allow sleep.

But since I have many sensors on the same i2c bus, its possible that a software reboot leaves their state undetermined and sensors affect each other. I will try with SPS30 being only sensor accessed. If that does not work I will remove physically other sensors from my board.

What I understand from your response is that under normal operation where sensor is only device on i2c bus, your example programs can be programmed to ESP8266 and one does not need power to down the SPS30 to make them start properly. Thank you for your response.

Urs Utzinger


From: paulvha notifications@github.com Sent: Thursday, December 10, 2020 10:52 AM To: paulvha/sps30 sps30@noreply.github.com Cc: Utzinger, Urs - (utzinger) utzinger@arizona.edu; Author author@noreply.github.com Subject: [EXT]Re: [paulvha/sps30] Hard reset? (#17)

External Email

hi Urs,

Strange.. I have not had that issue before.

What is the sketch you are running ?

Couple of options jumps to mind:

Are you using the sleep() option for the SPS30 ? If so, it might have been put to sleep and then needs a special sequence to wakup() (or reset). Calling wakeup() when new code is loading will not help as the current code will check whether you had put it to sleep first ?

Normally at begin() the wire is reset, but not the SPS30, You could try to do a reset(), but I have not seen or heard the need for this before..

regards, Paul


Van: Urs Utzinger notifications@github.com Verzonden: donderdag 10 december 2020 18:40 Aan: paulvha/sps30 sps30@noreply.github.com CC: Subscribed subscribed@noreply.github.com Onderwerp: [paulvha/sps30] Hard reset? (#17)

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()?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpaulvha%2Fsps30%2Fissues%2F17&data=04%7C01%7C%7Ced6a7b840bec46934ec908d89d329ec9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637432188017211364%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fYoUQDRBoLVZ2D5VNPK%2Fak%2BVcKDGi42kuVpmBVEmqYg%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD2GBPFUVGUJJYRC3NTZ6G3SUEBXBANCNFSM4UVLLDTQ&data=04%7C01%7C%7Ced6a7b840bec46934ec908d89d329ec9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637432188017221354%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=irWTZK0SGzeal1KUNcbvlKvU%2F8sxKjnU4KBnxC84rzw%3D&reserved=0.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/paulvha/sps30/issues/17#issuecomment-742685884, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACEQDE366HEBM2GPMM56X3LSUEDE5ANCNFSM4UVLLDTQ.

paulvha commented 3 years ago

HI Urs

It could indeed be that some sensors are in different state. Say a slave device is half way sending a reply or data, it may pull SDA low waiting for the next clock on SCL. If that never comes, it keeps the I2C bus locked and keep the bus locked low. Some Wire libraries will test at init whether SDA and SCL lines are responding as expected before returning OK.

There are ways to unlock an I2C bus/reset:

With the SPS30 I never had any problems to restart/reconnect/probe after uploading a new sketch update.

regards, Paul


Van: Urs Utzinger notifications@github.com Verzonden: vrijdag 11 december 2020 22:56 Aan: paulvha/sps30 sps30@noreply.github.com CC: paulvha paulvha@outlook.com; Comment comment@noreply.github.com Onderwerp: Re: [paulvha/sps30] Hard reset? (#17)

That is interesting to hear. My firmware does not allow sleep.

But since I have many sensors on the same i2c bus, its possible that a software reboot leaves their state undetermined and sensors affect each other. I will try with SPS30 being only sensor accessed. If that does not work I will remove physically other sensors from my board.

What I understand from your response is that under normal operation where sensor is only device on i2c bus, your example programs can be programmed to ESP8266 and one does not need power to down the SPS30 to make them start properly. Thank you for your response.

Urs Utzinger


From: paulvha notifications@github.com Sent: Thursday, December 10, 2020 10:52 AM To: paulvha/sps30 sps30@noreply.github.com Cc: Utzinger, Urs - (utzinger) utzinger@arizona.edu; Author author@noreply.github.com Subject: [EXT]Re: [paulvha/sps30] Hard reset? (#17)

External Email

hi Urs,

Strange.. I have not had that issue before.

What is the sketch you are running ?

Couple of options jumps to mind:

Are you using the sleep() option for the SPS30 ? If so, it might have been put to sleep and then needs a special sequence to wakup() (or reset). Calling wakeup() when new code is loading will not help as the current code will check whether you had put it to sleep first ?

Normally at begin() the wire is reset, but not the SPS30, You could try to do a reset(), but I have not seen or heard the need for this before..

regards, Paul


Van: Urs Utzinger notifications@github.com Verzonden: donderdag 10 december 2020 18:40 Aan: paulvha/sps30 sps30@noreply.github.com CC: Subscribed subscribed@noreply.github.com Onderwerp: [paulvha/sps30] Hard reset? (#17)

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()?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpaulvha%2Fsps30%2Fissues%2F17&data=04%7C01%7C%7Ced6a7b840bec46934ec908d89d329ec9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637432188017211364%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fYoUQDRBoLVZ2D5VNPK%2Fak%2BVcKDGi42kuVpmBVEmqYg%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD2GBPFUVGUJJYRC3NTZ6G3SUEBXBANCNFSM4UVLLDTQ&data=04%7C01%7C%7Ced6a7b840bec46934ec908d89d329ec9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637432188017221354%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=irWTZK0SGzeal1KUNcbvlKvU%2F8sxKjnU4KBnxC84rzw%3D&reserved=0.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/paulvha/sps30/issues/17#issuecomment-742685884, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACEQDE366HEBM2GPMM56X3LSUEDE5ANCNFSM4UVLLDTQ.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpaulvha%2Fsps30%2Fissues%2F17%23issuecomment-743447703&data=04%7C01%7C%7C8cdec100f95644c0b15e08d89e1fa2ab%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637433205994766995%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=uLgXfb5UTu4pNEBsjtf%2FuXAHD0QXx56OWTCXSbxiC0Y%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD2GBPHNJSKHTWC2KY7UDQ3SUKIRNANCNFSM4UVLLDTQ&data=04%7C01%7C%7C8cdec100f95644c0b15e08d89e1fa2ab%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637433205994766995%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=HbjR90JTqqIQTkTqHLMqb3marO4tW7S1v5mG4Nbzf9A%3D&reserved=0.

uutzinger commented 3 years ago

Paul

thank you very much for your feedback. I went back to your example programs (read basics) and indeed the sps30 and system behaves as expected.

I found that the LCD backpack (20x4 characters) causes the behavior I described above. Once I disable its initialization my program no longer hangs at the probe() command. I replaced the LCD backpack with one from Adafruit and its corresponding LiquidCrystal library and it also causes same issue. I also noticed the MLX90614 sensor causing similar issue.

My interpretation is that the issue is within the i2c core of ESP8266 or the Lolin D1 Board I am using.

I will try to implement the bus reset when probe fails as you suggested. Please feel free to close this issue as I don't think this has anything to do with your library.

Urs

paulvha commented 3 years ago

Thanks for the update

I looked at the source, the ESP8266 Wire implementation does not perform a bus-check at the start and does not have a bus-reset call.

Just out of interest.. do you have pull-up resistors on SDA and SCL and what value are they ?

regards, Paul


Van: Urs Utzinger notifications@github.com Verzonden: maandag 14 december 2020 17:12 Aan: paulvha/sps30 sps30@noreply.github.com CC: paulvha paulvha@outlook.com; Comment comment@noreply.github.com Onderwerp: Re: [paulvha/sps30] Hard reset? (#17)

Paul

thank you very much for your feedback. I went back to your example programs (read basics) and indeed the sps30 and system behaves as expected.

I found that the LCD backpack (20x4 characters) causes the behavior I described above. Once I disable its initialization my program no longer hangs at the probe() command. I replaced the LCD backpack with one from Adafruit and its corresponding LiquidCrystal library and it also causes same issue. I also noticed the MLX90614 sensor causing similar issue.

My interpretation is that the issue is within the i2c core of ESP8266 or the Lolin D1 Board I am using.

I will try to implement the bus reset when probe fails as you suggested. Please feel free to close this issue as I don't think this has anything to do with your library.

Urs

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpaulvha%2Fsps30%2Fissues%2F17%23issuecomment-744544483&data=04%7C01%7C%7C5bebd31621334394eb3d08d8a04b1470%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637435591604801483%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=CQfyQv6HAbctOzCpGlCiIvvNCAn1bS20nWECEVSQdfc%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD2GBPH7U2T5H2WNYTBYQY3SUY2PPANCNFSM4UVLLDTQ&data=04%7C01%7C%7C5bebd31621334394eb3d08d8a04b1470%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637435591604801483%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=N30%2FxppuMJoB1A%2FRjokmiie7OjnVmTtd%2FLOS1FxjSyI%3D&reserved=0.

uutzinger commented 3 years ago

Thanks Paul, I used level shifter breakout board 3.3 to 5V. The LCD backpack and the SPS30 are attached to the level shifter. I don't recall the size of the pullups in the level shifter breakout board and whether its one from Sparkfun (Sparkfun uses 10k). I will measure later today. I will also check on the 3.3 V side perhaps some of the breakout boards together add pullups in parallel.

uutzinger commented 3 years ago

On 5V side, the level shifter has 5k pullup. The lcd backpack 10k. Total R 3.3k. On 3.3V side its a mix of 5k and 10k on the breakout boards. Total 1.3k. I think I will need to use separate i2c bus for LCD backpack.

paulvha commented 3 years ago

HI Urs

1.3K is on the low side indeed.. Normally I try to keep it 4K7 to 10K. It could cause the issue with draining too much power. If you have a scope you could detect it. On other aspect to consider is the total power consumption. A backlight on an LCD could easily take 200mA and then when reset it can cause a dip.

regards, Paul


Van: Urs Utzinger notifications@github.com Verzonden: dinsdag 15 december 2020 05:08 Aan: paulvha/sps30 sps30@noreply.github.com CC: paulvha paulvha@outlook.com; Comment comment@noreply.github.com Onderwerp: Re: [paulvha/sps30] Hard reset? (#17)

On 5V side, the level shifter has 5k pullup. The lcd backpack 10k. Total R 3.3k. On 3.3V side its a mix of 5k and 10k on the breakout boards. Total 1.3k. I think I will need to use separate i2c bus for LCD backpack.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpaulvha%2Fsps30%2Fissues%2F17%23issuecomment-745038906&data=04%7C01%7C%7Ccbce6bc0b6fd41fb180c08d8a0af0f57%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637436021021092579%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=2ypU00iMfdj%2FyB8OI6EJtOVoCSRb1sLc8WvfckiokIU%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD2GBPEP3CKAIBWRDUPSCRTSU3OLJANCNFSM4UVLLDTQ&data=04%7C01%7C%7Ccbce6bc0b6fd41fb180c08d8a0af0f57%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637436021021092579%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=p484QWrS9B%2FAkmjna5pMlRxvfyRKSChmo37NO0vKoEw%3D&reserved=0.

ra1nb0w commented 3 years ago

Hi, I am using the serial port with ESP32 with sleep()/wakeup() and each time I flash a new firmware either via USB or OTA the sensor is not probed. Just to confirm the library code I tried, in case of probe() fails, to reset()/stop()/wakeup()/ecc. and esp_restart() without any success. Do you have some suggestions on how to avoid this annoying problem and reinitialise the SPS30?

thank you very much for the hard work that you put in this library!

ra1nb0w commented 3 years ago

for the moment, I will use start() and stop()

paulvha commented 3 years ago

Hi,

I am on a short break and will look at this when I am back.

Regards, Paul

Verzonden vanuit Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 voor Windows

Van: @.> Verzonden: zaterdag 14 augustus 2021 09:36 Aan: @.> CC: @.>; @.> Onderwerp: Re: [paulvha/sps30] Hard reset? (#17)

for the moment, I will use start() and stop()

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpaulvha%2Fsps30%2Fissues%2F17%23issuecomment-898859737&data=04%7C01%7C%7Cee5b002c080a4526304008d95ef62a98%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637645233632390161%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=KDtgsM0U1CGYiqxW3%2BZb0qIHJcz%2FlZohZTUCOdFHBBs%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD2GBPAG45PXGAHGCSY3ELDT4YMGDANCNFSM4UVLLDTQ&data=04%7C01%7C%7Cee5b002c080a4526304008d95ef62a98%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637645233632390161%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=S1%2FthvmfO3kN0Zk62pN3aCa0WHhQvczxkcCxt%2FkWQIw%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7Cee5b002c080a4526304008d95ef62a98%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637645233632400155%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=2AvIbi%2FA%2FLYV8f9OayXEFtVA6eZ1JUKFGiu8yod3RZo%3D&reserved=0 or Androidhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26utm_campaign%3Dnotification-email&data=04%7C01%7C%7Cee5b002c080a4526304008d95ef62a98%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637645233632400155%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=XzFia9Nv%2FYGx9zukY0lFxsdz4Q2kdXqbW03ioq5HmJ8%3D&reserved=0.

paulvha commented 3 years ago

in SPS30.cpp, line 482 I do a check whether the SPS30 was set to sleep earlier before performing a wake-up call. If you load a new program this is reset. For now comment out line 482 if (! _sleep) return(ERR_OK); to // if (! _sleep) return(ERR_OK); this will bypass the check and sent the wakeup instruction. regards, Paul

ra1nb0w commented 3 years ago

thank you @paulvha