Rules for PMSx003 dust sensor

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
Malanow
Normal user
Posts: 12
Joined: 18 Mar 2018, 22:47
Location: Poland
Contact:

Rules for PMSx003 dust sensor

#1 Post by Malanow » 25 Dec 2018, 22:02

Hi!
How to change the rules so that the sensor makes a measurement every ten minutes?
Armageddon was yesterday, today we have a serious problem.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Rules for PMSx003 dust sensor

#2 Post by Shardan » 25 Dec 2018, 23:23

Hello,

Do you refer to the wiki https://letscontrolit.com/wiki/index.php?title=PMSx003 ?
If you use the rules from the wiki it is quite easy to change the time.

on System#Boot do
gpio,16,0
timerSet,1,20
endon
On Rules#Timer=1 do
LongPulse,16,1,5
timerSet,1,20
endon

The time is set with the "timerSet" command.
In this example it is set to 20 seconds. You may set this to bigger values.
Regards
Shardan

User avatar
Malanow
Normal user
Posts: 12
Joined: 18 Mar 2018, 22:47
Location: Poland
Contact:

Re: Rules for PMSx003 dust sensor

#3 Post by Malanow » 28 Dec 2018, 22:56

Thanks for quick answer.
I am not sure if I understand this rule correctly. The first part is responsible for the start after running Wemos, for exemple 20 seconds.
But what the second part does?
I will explain what I would like to achieve, the sensor is turned off for 10 minutes, then it takes measurements for 2 minutes and turns off again for 10 minutes and so in the loop. Maybe something is wrong with my sensor, because it looks like only the first part of the rule works. 600 seconds after switching on, the fan starts working, but it does not turn off after a set time, the readings are equal to zero. I checked all connections, I have the same as in the wiki.
Armageddon was yesterday, today we have a serious problem.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Rules for PMSx003 dust sensor

#4 Post by Shardan » 29 Dec 2018, 00:07

Malanow wrote: 28 Dec 2018, 22:56 Thanks for quick answer.
I am not sure if I understand this rule correctly. The first part is responsible for the start after running Wemos, for exemple 20 seconds.
But what the second part does?
I will explain what I would like to achieve, the sensor is turned off for 10 minutes, then it takes measurements for 2 minutes and turns off again for 10 minutes and so in the loop. Maybe something is wrong with my sensor, because it looks like only the first part of the rule works. 600 seconds after switching on, the fan starts working, but it does not turn off after a set time, the readings are equal to zero. I checked all connections, I have the same as in the wiki.
On GPIO16 I've connected the SET connector from the PMS.
The first part sets GPIO16=0 so the sensor is in deep sleep.
Then the timer1 is initialized for the first waiting period. (timerSet,1,20) This is necessary to trigger the Rules#Timer event in the second part the first time.

The second part fires up if the timer event Rules#Timer=1 is triggered.
It activates the sensor on GPIO16 for 5 Seconds (Longpulse, 16,1,5).
Then the timer is reinitialized to trigger this part again after 20 Seconds.
So the second part builds a time controlled loop that is executed every 20 seconds.
Regards
Shardan

User avatar
Malanow
Normal user
Posts: 12
Joined: 18 Mar 2018, 22:47
Location: Poland
Contact:

Re: Rules for PMSx003 dust sensor

#5 Post by Malanow » 29 Dec 2018, 20:22

I understand almost everything. If I wanted to extend the measurement time I should change it this part:

Code: Select all

LongPulse,16,1,5
for example

Code: Select all

LongPulse,16,1,60
for for one minute measurement?
Armageddon was yesterday, today we have a serious problem.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules for PMSx003 dust sensor

#6 Post by grovkillen » 29 Dec 2018, 21:47

Malanow wrote: 29 Dec 2018, 20:22 I understand almost everything. If I wanted to extend the measurement time I should change it this part:

Code: Select all

LongPulse,16,1,5
for example

Code: Select all

LongPulse,16,1,60
for for one minute measurement?
That is correct
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Rules for PMSx003 dust sensor

#7 Post by Shardan » 29 Dec 2018, 21:55

The Longpulse says how long the sensor is activated.
Setting Longpulse to 60 seconds with a waittime of 20 seconds will set the sensor to permanent running!
Not a good idea.
The sensor, exactly the laser inside has a limited lifetime of around 8000h, less then one year
when permanently running, so it should run as short as possible.
Setting "Longpulse" to 60 seconds would keep the sensor alive for 60 seconds... much longer then necessary
and much longer then the waittime.. due to that sensor would never switch off.

on System#Boot do
gpio,16,0
timerSet,1,20 <-- Waittime until first measurement starts
endon
On Rules#Timer=1 do
LongPulse,16,1,5 <---- "On" Time of the sensor, 5 secs here
timerSet,1,20 <-- Waittime between measurements. Change this for longer waittime between measurements
endon

These setting says that every 20 seconds the sensor starts for 5 seconds. This extends lifetime up to around three years.
The values are stored by ESPEasy so it is no problem if you try to read values more often then the sensor starts.
It will just show the last values from the sensor.

If you need a measurement every minute, change the second "timerSet,1,20" to "timerSet,1,60.
For two minutes change to "timerSet,1,120" and so on.
Regards
Shardan

User avatar
Malanow
Normal user
Posts: 12
Joined: 18 Mar 2018, 22:47
Location: Poland
Contact:

Re: Rules for PMSx003 dust sensor

#8 Post by Malanow » 29 Dec 2018, 23:02

All clear, this is my rules:

Code: Select all

on System#Boot do
  gpio,16,0
  timerSet,1,600
endon

On Rules#Timer=1 do
  LongPulse,16,1,5
  timerSet,1,600
endon
10 minutes delay after start, and 10 minutes between the next measurements. But only the first part works, after 10 minutes from the start, the fan in the sensor starts. Do I understand correctly that after five seconds he should turn off and turn on again after another 10 minutes? In my case it does not turn off . I suspect the sensor is broken because it does not give any readings.
Armageddon was yesterday, today we have a serious problem.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Rules for PMSx003 dust sensor

#9 Post by Shardan » 29 Dec 2018, 23:23

Sure you don't have any quirk with cabling?
Rx/Tx swapped? SET and RESET correct?
Be sure both are connected to the ESP and have a pullup resistor (10 KOhm from the SET / RESET to 3.3V)
I've added the schematics from the printed circuit board I've created for the PMS7003.
Beware: The PMS5003 has another connector layout!
.
Schematics.jpg
Schematics.jpg (1.08 MiB) Viewed 13560 times
.
Sadly the forum does not take PDF uploads.
Maybe send me your email address via PM, I can send you the datasheets
and some documentation about the build I did.
Regards
Shardan

User avatar
Malanow
Normal user
Posts: 12
Joined: 18 Mar 2018, 22:47
Location: Poland
Contact:

Re: Rules for PMSx003 dust sensor

#10 Post by Malanow » 29 Dec 2018, 23:39

I use this datasheet.
I checked several times, and it seems to me that everything is fine, but I will check again tomorrow.
Armageddon was yesterday, today we have a serious problem.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Rules for PMSx003 dust sensor

#11 Post by Shardan » 30 Dec 2018, 00:04

Check for Rx & Tx. They might be swapped.

Second, test for GPIO16 <-< SET. 10KOhm resistor attached?
If the resistor is in place, just leave the resistor connected to 3.3V and SET, open the connection to GPIO16.
This sets the sensor to permanent running.
Regards
Shardan

BertB
Normal user
Posts: 1049
Joined: 25 Apr 2015, 14:39

Re: Rules for PMSx003 dust sensor

#12 Post by BertB » 31 Dec 2018, 16:43

I have a working connection between ESP and PMS 5003, but indeed, the fan keeps on forever.
In the documentation, I read :

GPIO 0-15 all have a built-in pull-up resistor, just like in an Arduino. GPIO16 has a built-in pull-down resistor.

If this is true, it is possible that GPIO16 is not capable to pull down the set port.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Rules for PMSx003 dust sensor

#13 Post by Shardan » 31 Dec 2018, 19:27

BertB wrote: 31 Dec 2018, 16:43 I have a working connection between ESP and PMS 5003, but indeed, the fan keeps on forever.
In the documentation, I read :

GPIO 0-15 all have a built-in pull-up resistor, just like in an Arduino. GPIO16 has a built-in pull-down resistor.

If this is true, it is possible that GPIO16 is not capable to pull down the set port.
Definitely no. A Pull Down resistor will pull the output down so the fan would be off all time.
The schematic shown is running for 18 months now without a problem, GPIO16 works.
Regards
Shardan

BertB
Normal user
Posts: 1049
Joined: 25 Apr 2015, 14:39

Re: Rules for PMSx003 dust sensor

#14 Post by BertB » 01 Jan 2019, 16:46

There must be somthing wrong with LongPulse then.
Just for the purpose of faultfinding, I hooked up an oscilloscope to GPIO12 and put this conde in Rules.

Code: Select all

on System#Boot do
  gpio,12,0
  timerSet,1,60
endon

On Rules#Timer=1 do
  LongPulse,12,1,5
  timerSet,1,60
endon
At Boot I see the pin going to logic 0 for a little over 60 seconds.
But then it stays up forever.

Also tried this with this command:
Same result.

Using Pulse makes it work again. Remember Pulse works with ms.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules for PMSx003 dust sensor

#15 Post by grovkillen » 01 Jan 2019, 17:10

Male a test, set it to 1 and right after you set it to 0. After that you set the long pulse.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

BertB
Normal user
Posts: 1049
Joined: 25 Apr 2015, 14:39

Re: Rules for PMSx003 dust sensor

#16 Post by BertB » 01 Jan 2019, 22:12

grovkillen wrote: 01 Jan 2019, 17:10 Male a test, set it to 1 and right after you set it to 0. After that you set the long pulse.
I did as you suggested.
In this case I saw, GPIO16 going up, down and up forever.
LongPulse starts correctly but fails to return to the original state.

I also noticed that the GPIO Boot state is not there.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules for PMSx003 dust sensor

#17 Post by grovkillen » 02 Jan 2019, 06:04

What version are you using?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

BertB
Normal user
Posts: 1049
Joined: 25 Apr 2015, 14:39

Re: Rules for PMSx003 dust sensor

#18 Post by BertB » 02 Jan 2019, 12:11

grovkillen wrote: 02 Jan 2019, 06:04 What version are you using?
mega-20181231, but I think the problem is much older. I could try an older version.

BertB
Normal user
Posts: 1049
Joined: 25 Apr 2015, 14:39

Re: Rules for PMSx003 dust sensor

#19 Post by BertB » 02 Jan 2019, 13:57

grovkillen wrote: 02 Jan 2019, 06:04 What version are you using?
Starting with ESP_Easy_mega-20180415_test_ESP8266_4096.bin, I had working releases up until ESP_Easy_mega-20180522_test_ESP8266_4096.bin
ESP_Easy_mega-20180524_test_ESP8266_4096.bin gave an unknown command.

The Current release, ESP_Easy_mega-20181231_test_ESP8266_4096.bin gives a good response:
log "GPIO 16 Pulse set for 1 s"
plugin 1
pin 16
mode "output"
state 1
But simply does not carry out LongPulse.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules for PMSx003 dust sensor

#20 Post by grovkillen » 02 Jan 2019, 14:49

Please bug report on GitHub.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

BertB
Normal user
Posts: 1049
Joined: 25 Apr 2015, 14:39

Re: Rules for PMSx003 dust sensor

#21 Post by BertB » 02 Jan 2019, 16:25

grovkillen wrote: 02 Jan 2019, 14:49 Please bug report on GitHub.
seems it already exists:
Command LongPuls does not work correctly #1622

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules for PMSx003 dust sensor

#22 Post by grovkillen » 02 Jan 2019, 16:32

Sorry, you're right.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules for PMSx003 dust sensor

#23 Post by grovkillen » 02 Jan 2019, 17:19

You could use timer until we have a fix. GPIO+TimerSet
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests