Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with PMS3003.lua module #3

Closed
gkbtaru opened this issue May 7, 2016 · 44 comments
Closed

Help with PMS3003.lua module #3

gkbtaru opened this issue May 7, 2016 · 44 comments
Assignees

Comments

@gkbtaru
Copy link

gkbtaru commented May 7, 2016

I tried to use PMS3003. I get Attmpt to index Global "M" a null value. Is there any values to be added in the lua code?

@avaldebe
Copy link
Owner

avaldebe commented May 8, 2016

Hi @gkbtaru,
I'll continue our discussion here, as it might help other people with similar issues.
The following snippets are from our email exchange.

Can you tell me how are you uploading the using the module?
Are you uploading the most and then loading it with require, or are you trying to run it line by line?

I uploaded only the PMS3003. It does not have any "require" except as a comment [...]
I loaded it using Esplorer as as the whole file and it raises the issue of indexing.

From your description of the issue, it seems that you are running the module trough the lua interpreter instead of uploading the module. The following image (from the ESPlorer website) shows a series of buttons under the text area, on the bottom left. You need to use the one that says Upload.
ESPlorer IDE

I also did not find which pins are be used within the pms3003.lua. [...]
My unit is PMS5005. I am yet to connect to the unit, since the Esplorer raises the index issue and does not load

As far as I can tell there is no PMS5005 sensors. They are PMS5003 sensors which the seller have mislabeled. There is no reference to a PMS5005 sensor on the manufacturer website (plantower).
Also, the PMS5003 unit I have was advertised as a PMS5005 in AliExpress, but the manufacutrer lable in the unit said PMS5003...

You did not mentioned the esp8266 module are you using, but for completeness I'll assume that it is a NodeMCU devkit 1.0. As a minimum you need to connect the following pins:

PMS5003 esp8266 (devkit)
PIN1 (VCC) 5V (Vin)
PIN2 (GND) GND
PIN3 (SET) any unused digital pin
PIN5 (TXD) GPIO03 (RXD0)

PMS5003 pinout
NodeMCU pinout

As the note on the PMS5003 pinout says, PIN3 (SET) controls the state of the PMS5003 sensor. When PIN3 is low the PMS5003 is in stand by mode, i.e. it will not sample nor transmit its results.
This is important, as you do not want the raw data from the PMS5003 to go into the lua interpreter.

The following usage example is almost the same as the one in SENSORS.md. It has been modified for a PMS5003 sensor.

do
-- module setup
  PMset=7              -- D7 (GPIO13)
  require('pms3003')
  pms3003.model=5      -- set for a PMS5003
  pms3003.init(PMset)
  pms3003.verbose=true -- verbose mode
-- start sensor (set PMset high) and redirect UART input away from the lua interpreter
  pms3003.read(function() -- this code will be executed after reading the PMS5003 data 
    pm01 = pms3003.pm01 or 'null'
    pm25 = pms3003.pm25 or 'null'
    pm10 = pms3003.pm10 or 'null'

  -- release memory
    pms3003,package.loaded.pms3003 = nil,nil

  -- print the results
    print(('pm1:%s, pm2.5:%s, pm10:%s [ug/m3], heap:%d'):format(pm01,pm25,pm10,node.heap()))
  end)
-- the lua interpreter will be disabled until the PMS5003 data is read
end

@avaldebe avaldebe self-assigned this May 8, 2016
@avaldebe
Copy link
Owner

avaldebe commented May 8, 2016

I tried Arduino IDE on my ESP8266 devkit. It works perfectly, but I need a Lua based option so that I can combine with my DHT22 humidity and Temperature system [...]

If you are more comfortable working on the Arduino IDE, perhaps you should consider to use an Arduino library by dfrobot. It was written for an PMS1003, but the data format is the same than the PMS5003.

@gkbtaru
Copy link
Author

gkbtaru commented May 9, 2016

I am using nodemcu devkit.
The direct upload is working with the init.lua above to run, but shows null values.
My question is

The connection table( PMS5003-ESP8266) sent by you (above) shows GPIO01 (RXD0) (which is D10 or TXD0. (as per the NodeMCU drawing sent above.)

The code above sent by you shows
PMset=7 -- D7 (GPIO13)** (line 3 of your code above)

I treid different configurations of connecting to D7 as well as D10
I am getting null as outputs.
Where am I going wrong?

@avaldebe
Copy link
Owner

My mistake, RXD0 is on D9 (GPIO03).

@gkbtaru
Copy link
Author

gkbtaru commented May 10, 2016

The system works once, then I get BMBM continuously.
I have not changed the pin number but suing the RX port but it works
PMset=7 -- D7 (GPIO13)
The printout is as follows>>
NodeMCU custom build by frightanic.com
branch: master
commit: c8037568571edb5c568c2f8231e4f8ce0683b883
SSL: true
modules: adc,bmp085,cjson,dht,file,gpio,i2c,net,node,ow,spi,tmr,uart,wifi
build built on: 2016-04-22 15:56
powered by Lua 5.1.4 on SDK 1.4.0
pms3003: data acquisition started.
Console disabled.

pms3003: 12, 16, 17 [ug/m3]
pms3003: data acquisition finished.
Console enhabled.
pm1:12, pm2.5:16, pm10:17 [ug/m3]
BMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBMBM
WARNING! Comm port is disconnected

This is the result. Can the BM message avoided?

@avaldebe
Copy link
Owner

avaldebe commented May 10, 2016

Hi again,
The BM message comes from the PMS5003. In order to avoid them you need to connect the PMS5003 PIN3 to a digital output on your nodemcu devkit (D7 on the example code). The pms3003.lua module will set the pin low when the measurement is complete. This puts the PMS5003 in stand by mode, so no more BM messages.

@gkbtaru
Copy link
Author

gkbtaru commented May 10, 2016

Thanks again,. I get the readings without BM now. Can it be looped to provide data every X seconds? Secondly can this data be sent to thingspeak by reading th RX port?
Can we use custom ROM with built in UART?
Any help in this will be greatly appreciated.

@avaldebe
Copy link
Owner

Thanks again,. I get the readings without BM now. Can it be looped to
provide data every X seconds? Secondly can this data be sent to thingspeak
by reading th RX port?

That is precisely what AQmon does.
If you load all the required modules, it will read temperature, pressure
and relative humidity from different sensors, and PM concentrations from a
PMSx003 sensor and finally upload the results to thingspeak. All you need
to do us to edit the keys.lua module to configure the AQmon to your needs.

Have a look at the rest if the repository and ask away. I'll use the
answers to build a how-to/user guide.

Can we use custom ROM with built in UART?
Do not understand. Please elaborate.

Cheers, A.

@gkbtaru
Copy link
Author

gkbtaru commented May 10, 2016

I had tow times problems of BM even after using D7. WSo I was wondering if it deosnot take Customs Roms by Frightanic with UART module.
Now I am getting data once from each run.
I will definitely check up all modules and build up the AQmon station.
Thanks a ton for educating me. I am an old man who is trying to do this, since I am worried about the air quality and temperature extremes impacting Indian cities. Your contribution will be quoted in this work. I want to put at least 50 stations to educate the people and send advisories. The game is low quality high density data across the city that can enable granular data to give map of these parameters across the city. I am a novice, who started this project two weeks back, with no understanding about MCU, forget even ESP8266. I stated with Smart citizen kit idea and could not get hold of one andf thought about doing something cheap.

By the way, do you have module for DHT22 Temp and humidity module, which can use the custom rom's DHT functions?. We are using it since is the best possible here

Thanks, if you need help to write a manual , I can share my few words to tell how
I thought about this project, what pitfalls I faced etc.
Thanks again
Regards
Bhat

@avaldebe
Copy link
Owner

Hi again,

I had tow times problems of BM even after using D7. So I was wondering if it does not take Customs Roms by Frightanic with UART module.
[...]
By the way, do you have module for DHT22 Temp and humidity module, which can use the custom rom's DHT functions?. We are using it since is the best possible here

I think I got it now. You are talking about the custom nodemcu-build by frightanic.
A few days back I realized that the nodemcu dev branch had native support for all my sensors, except the PMSx003. Then, got a build from nodemcu-build to test the modules (including DHT). Alas, I have had no time yet to play with it.

One of the things I'm interested is to use the uart.alt function from the UART module, to read the PMSx003 data on RDX2 (D7; GPIO13) instead of RDX0 (D9; GPIO03). This should solve the intermittent BM problems you experience.

I'm not a big fan of the DHT22, I much prefer I2C sensors. If it is price and availability is an issue, please consider the AM2320. Which is also has a native module and can be purchased for less than 2 USD in aliexpress.

Thanks, if you need help to write a manual , I can share my few words to tell how I thought about this project, what pitfalls I faced etc.

Yes, please. It is hard to me to know how much retail is needed for a beginner.

For now we can use this conversation to get you going. Once you are up and ruing, we can collect the info on this issue and write the manual.

@gkbtaru
Copy link
Author

gkbtaru commented May 11, 2016

It will be very useful which pins are to be connected to diffident sensors. Anyone can then just connect the sensors and will be ready in minutes. Just for your consideration.

@avaldebe
Copy link
Owner

avaldebe commented May 11, 2016

Yes, I see that now.
I could provide wiring examples and configuration files for the NodeMCU devkit and for the WeMos D1 mini.

@gkbtaru
Copy link
Author

gkbtaru commented May 11, 2016

  1. It is a good option. Wemos is really cheap. For me every cent saved means that more numbers.
  2. Native module of PMS5033 can go a long way to make these easily accessible with less codes.
  3. I saw that AM2320 is much cheaper and ordered few right away. I2C makes it more attractive.
    At the end of the day, more people using them is what should be aimed at.

Thanks for your advice.

@gkbtaru
Copy link
Author

gkbtaru commented May 11, 2016

Hi,
We already have incorporated the DHT and BMP180 directly calling from the Frightanic ROM. It is so simple to just call DHT or BMP085.
I am attaching the init file. All we need now is to include your PMS3003 module. init.zip
I have one problem, the pms3003 with init.lua sent by you reads once and command prompt (>) in Lua loader or Esplorer does not come back. It gets stuck. We cannot run any other files after it gives out one set of PMS3003 data.

@gkbtaru
Copy link
Author

gkbtaru commented May 11, 2016

This is what happens after running init lua.
The port was closed after tow minutes, since the command promot did not come back.It seems it get stuck.
NodeMCU custom build by frightanic.com
branch: master
commit: c8037568571edb5c568c2f8231e4f8ce0683b883
SSL: true
modules: adc,bmp085,cjson,dht,file,gpio,i2c,net,node,ow,spi,tmr,uart,wifi
build built on: 2016-04-22 15:56
powered by Lua 5.1.4 on SDK 1.4.0
pms3003: data acquisition started.
Console dishabled.

pms3003: 28, 30, 44 [ug/m3]
pms3003: data acquisition finished.
Console enhabled.
pm1:28, pm2.5:30, pm10:44 [ug/m3]

PORT CLOSED

@avaldebe
Copy link
Owner

Not sure what is the problem. Can you share your init.lua?

@gkbtaru
Copy link
Author

gkbtaru commented May 11, 2016

init.lua has statement require app, from line 47:

   if console then
      pin,console=nil,nil
      print('Console/Upload mode')
      uart.on('data')
   else
      pin,console=nil,nil
      print('Run/App mode')
      require('app')
   end

@gkbtaru
Copy link
Author

gkbtaru commented May 11, 2016

Now I understood that you are using I2C and that is why you need AM2320 instead of DHT22.
Given lots of unused GPIOs, we can do with DHT. Now knowing that AN2320 is cheaper I will get them.
Can you make a version of PMS3003, which will directly use one of the GPIOs, and also go to sleep after collection and wake up. I think we are not able to get the data after it collects one set of data and then getting hung.
It has been a steep learning curve, but I could not understand the PMS3003 yet fully.
Hope you can get time to do this so that DHT, BMP180 and PMS 2003 can be used directly without I2C.
We will have another couple of GPIOs to add rain amount and wind direction and Wind speed later. Hope I am clear.
Once I get this sorted out, I will think about it and rain is one more month away.

Thanks again, for your efforts.

@gkbtaru
Copy link
Author

gkbtaru commented May 12, 2016

Can the PMS5003 work in lua with continuous monitoring ( instead of one time data output) without having to go through sensor hub. Can you help in sorting out this issue? Thanks in advance.
Regards
Bhat

@avaldebe
Copy link
Owner

Can the PMS5003 work in lua with continuous monitoring ( instead of one
time data output) without having to go through sensor hub. Can you help in
sorting out this issue? Thanks in advance.

Why do you want/need to skip sensor_hub?

It is possible to run the PMS5003 in continuous mode, but it will produce
measurements faster than the esp8266 can process and send them to thigspeak.

On the AQmon early versions the esp8266 was very unstable with the PMS3003
in continuous mode. It is possible that newer nodemcu firmware would handle
better continuous mode, but have had no reason to test it.

AQmon is set to read the sensors and send data to thigspeak eery 5 minutes,
so it makes no sense to keep the PMS in continuous mode. Besides, as the
PMS communicates via UART the lua interpreter (command line interface) has
to be disabled when the PMS us active.

@gkbtaru
Copy link
Author

gkbtaru commented May 12, 2016

I am unable to get AQmon working. It gives require "app" error. So if it works stand alone. I can use only PM5003 sensors running in some places. For example, whose who have asthma or other respiratory diseases require mostly the pm2.5 data.

@avaldebe
Copy link
Owner

You need to rename 2 files after uploading, before compiling them. This is briefly mentioned on lua_modules/README.md:

# upload, rename, compile and restart
luatool.py -p $PORT -rc -f sensor_hub.lua -t sensors.lua
luatool.py -p $PORT -rc -f AQmon.lua      -t app.lua

This mean that you need to rename AQmon.lua to app.lua and sensor_hub.lua to sensors.lua

@gkbtaru
Copy link
Author

gkbtaru commented May 14, 2016

Trying again. Where do I have to put following information

  1. SSID ( I am confused with the Keys lua Which gives
M.sta.SSID0='PASS0' -- pass=require('keys').sta
M.sta.SSID1='PASS1' -- ssid='PRE-SET SSID'
M.sta.SSID2='PASS2' -- wifi.sta.config(ssid,pass[ssid])
  1. Wifi password
  2. Thingspeak keys and channel
    Pleas help.

@gkbtaru
Copy link
Author

gkbtaru commented May 14, 2016

The wifi_connect lua says
"Initialize wifi in STATION mode from SSID/PASS keys stored is a separate file"
I am confused. Do I have to make a separate file?

@avaldebe
Copy link
Owner

The comment in wifi_connect.lua says that all settings are stored in keys.lua.
You should edit keys.lua to our specific set-up. In this way, the only difference between
different AQmon stations is their keys.lua.

  • AQmon can be preset with several ssid/password pairs. You need to set up at least one ssid/password pair. In the example (lines 3 to 6) there are 3 ssid/password sets:
M.sta["name of your 1st SSID"]="password to 1st SSID"
M.sta["name of your 2nd SSID"]="password to 2nd SSID"
M.sta["name of your 3rd SSID"]="password to 3rd SSID"
  • ThingSpeak settings are on lines 13 to 17:
M.api.url='api.thingspeak.com' -- ThingSpeak URL
M.api.id='CHANNEL_ID'   -- channel number, not used on this version
M.api.get='Read  Key'   -- channel read key, not used on this version
M.api.put='Write Key'   -- channel write key, used to publish data
M.api.freq=1            -- update frequency in minutes
  • Pin assignments are on lines 18 to 23:
M.pin={led=0,tact=3,          -- NodeNCU devkit: led (active low), tact switch (KEY_FLASH)
       ledR=1,ledG=2,ledB=4,  -- RGB led for status
       sda=5,scl=6,           -- I2C bus
       PMset=7}               -- PMSx003 set (enable) pin

@gkbtaru
Copy link
Author

gkbtaru commented May 14, 2016

Now I got it. Going to try again. Last time the program just stopped. no errors, no progress. Will inform.
Thanks for your patience. It is a steep learning curve.
I was just looking for a solution for PMS5003, but this looks quite interesting and challenging. Thanks for teaching me possible use of I2C and hope someone produces a I2C dust monitor also.
Will get back to you, if I face problems.

@gkbtaru
Copy link
Author

gkbtaru commented May 15, 2016

Now it freezes after start. I am also getting BMBMBM message on serial port as soon as I plug in 5V power to PMS5003 and the TX of the unit to Rx of nodemcu. It goes on and on. Even before the start of the machine it goes on and on.
Checked up on Aruino and PMS gives proper readings

@avaldebe
Copy link
Owner

Now it freezes after start. I am also getting BMBMBM message on serial
port as soon as I plug in 5V power to PMS5003 and the TX of the unit to Rx
of nodemcu. It goes on and on. Even before the start of the machine it goes
on and on.

You need to connect PM5003 pin3 (set) to a digital io on the esp8266. Make
sure the physical pun connection matches the value of PMset in keys.lua.

@gkbtaru
Copy link
Author

gkbtaru commented May 15, 2016

PMset is 7 and I am using D7 for pin3
The Pin 5 is connected to RX port..
Even if I rename init lua as inittest.lua so that it doesnot automatically start, I get the same problem even before launching the inittest.lua

@gkbtaru
Copy link
Author

gkbtaru commented May 15, 2016

As you said ealrier,
"One of the things I'm interested is to use the uart.alt function from the UART module, to read the PMSx003 data on RDX2 (D7; GPIO13) instead of RDX0 (D9; GPIO03). This should solve the intermittent BM problems you experience."
I think it is the problem. When you get time, if you can change it it would be great help.
I tried to pin 5 of PMS5003 to D7 and the BM message stops. It is random test.
The DFrobot's arduino code also has RX as the pin for receiving from pin 5 of PMS5003. It works on the same nodemcu unit. without any problems.
image
I am perplexed by this new problem. It means that the port and PMS unit is fine.

@gkbtaru
Copy link
Author

gkbtaru commented May 15, 2016

I am interested to work on nodemcu and lua, and want to use your AQMON system which looks good and has great potential to be used for people's monitoring system. Any help from you will be greatly appreciated.

@gkbtaru
Copy link
Author

gkbtaru commented May 15, 2016

arduino DFrobot output in lua loader
image

@gkbtaru
Copy link
Author

gkbtaru commented May 15, 2016

It means that the system is fine, the RX pin is fine, but lua is creating the mistake somewhere.

@gkbtaru
Copy link
Author

gkbtaru commented May 15, 2016

Can the UARt pin be changed from D9 to another pin?
Please see this so that we can change
http://www.esp8266.com/viewtopic.php?f=13&t=1810
By Viteo
"Hi, uart index 0 is linked to esp8266 tx and rx pins?
If some peripheral send data to esp8266 rx pin it goes to nodemcu interpreter ...How can avoid this?
It should link uart to other pins to avoid data going to interpreter..

_Found answer_**

run_input: 0 or 1, 0: input from uart will not go into lua interpreter, can accept binary data.
1: input from uart will go into lua interpreter, and run.

uart.on("data", 4,
function(data)
print("receive from uart:", data)
end
end, 0) - See more at: http://www.esp8266.com/viewtopic.php?f=13&t=1810#sthash.ARZivOuA.dpuf
"
I do not know where to put it

@avaldebe
Copy link
Owner

I have tried to explain this issue a few times before, so I'll try again in
a different way. You almost got this, please read carefully.

In short, you need to tell the PMS5003 to shut up so the esp8266 can hear
your commands.

The nodemcu firmware allow us to send lua commands and run lua scripts. It
id does this trough a lua interpreter. The interpreter listens to commands
from the UART bus. When you send commands or upload files from esplorer,
you are interacting with the lua interpreter in the esp8266 trough the
UART bus, on pins D9 and D10 (RXD0 and RTD0).

The PMS5003 also communicates trough the UART bus. By default it is on
continuous sampling mode, sending a new set of measurements every ~650 ms.
Each one of the BM you see, marks the beginning of a new set of
measurements.

The UART bus is meant for communications between two parts. There we have
3: you (sending commands from esplorer), the PMS5003 sending measurements,
and the lua interpreter (on the esp8266). You can not communicate with the
lua interpreter, because the PMS5003 is constantly interrupting you.

To set the PMS5003 on standby mode, you need to set pin3 low. Then the
PMS5003 will stop sending new measurements, and the UART buss will be free
for you to talk to the lua interpreter.

If you are not using all of the AQmon modules, you need to need to set
PMset as an output and drive it low on your init.lua

gpio.mode(7,gpio.OUTPUT) -- assume PMset on D7
gpio.write(7,gpio.LOW) -- put PMS5003 on standby mode

@avaldebe
Copy link
Owner

avaldebe commented May 15, 2016

Found answer**

run_input: 0 or 1, 0: input from uart will not go into lua interpreter, can accept binary data.
1: input from uart will go into lua interpreter, and run.

uart.on("data", 4,
function(data)
print("receive from uart:", data)
end
end, 0) - See more at: http://www.esp8266.com/viewtopic.php?f=13&t=1810#sthash.ARZivOuA.dpuf

I do not know where to put it

You do not need to put this into your code. The PMS3003.lua module takes
care of it (lines 172 to 184). In fact, if you put this lines somewhere in
your code, the esp8266 will not respond to the commands you send from
esplorer, because you told UART module not send its input to the lua
interpreter.

@gkbtaru
Copy link
Author

gkbtaru commented May 15, 2016

It was a great learning for me. Thanks.
I want to see through the whole AQmon working over time starting with PMS5003. I am getting rest of the sensors( AM2320) to make it work.
I found following.

  1. The 5V input pin has to be taken out to flash, probably the board does not have enough power and it doesn't recognise ESP8266 if the 5V and GND are connected.
  2. Adding init lua and PMS3003.lua first by directly uploading without 5V supply works.
  3. The three process working and conflicts, but not clear about where in init lua your

My new questions are:

  1. Where do I have to put the lines suggested by you in init lua?
gpio.mode(7,gpio.OUTPUT) -- assume PMset on D7
gpio.write(7,gpio.LOW) -- put PMS5003 on standby mode

Can you send a new init lua with these incorporated? and also modified
2. Can we make your "init and PMS3003 lua" give out continuous data instead of one. This is necessary so that I can add one sensor at a time and make AQMON work at last. It is what I want at the end. May be a month from now.
3.Can you suggest minimum set of modules/combinations to get "temp, humidity, pressure and Air quality. I also want a "rain gauge and wind (direction and speed)" added later, which completes the picture.These are interrelated parameter that determine the air quality. Cheap rain gauge and wind sensors are available from Ali express type of sellers. These basically send data as counts based on moving magnets.
That would complete my lessons.

@gkbtaru
Copy link
Author

gkbtaru commented May 15, 2016

Hi,
Is it possible make a PMS module in https://nodemcu.readthedocs.io/en/dev/en/ and add in Frightanic's custom ROM's list? That would help people like to directly pick and write few lines of codes and get going in hours.
Thanks
Bhat

@gkbtaru
Copy link
Author

gkbtaru commented May 15, 2016

As far as I know, Your's PMS is the only publically available code for PMS in nodemcu. That makes it all the more important

@avaldebe
Copy link
Owner

It was a great learning for me. Thanks.
I want to see through the whole AQmon working over time starting with
PMS5003. I am getting rest of the sensors( AM2320) to make it work.
I found following.

  1. The 5V input pin has to be taken out to flash, probably the board does
    not have enough power and it doesn't recognise ESP8266 if the 5V and GND
    are connected.
  2. Adding init lua and PMS3003.lua first by directly uploading without 5V
    supply works.

I do not understand your description if the problem not the solution.

Are you trying to flash code into the nodemcu devkit with the PMS5003 wired
to it? If so, the reason of the problem is the PMS5003 taking over the UART
bus, as I described before. As before, you need to drive pin3 low to put it
standby, this time you need to do it in hardware, or just disconnect the
power lines...

  1. The three process working and conflicts, but not clear about where in
    init lua your
    My new questions are:
  2. Where do I have to put the lines suggested by you in init lua?
gpio.mode(7,gpio.OUTPUT) -- assume PMset on D7
gpio.write(7,gpio.LOW) -- put PMS5003 on standby mode

You can put those lines anywhere in your init.lua.

Can you send a new init lua with these incorporated? and also modified
2. Can we make your "init and PMS3003 lua" give out continuous data
instead of one. This is necessary so that I can add one sensor at a time
and make AQMON work at last. It is what I want at the end. May be a month
from now.

You are not using a full AQmon setup, so it is hard to keep track on what
are you using as a base to your project. Therefore, I'll add an examples
section on the AQmon repository which will contain an init.lua based on our
exchange. I can not do this today, you'll have to be patient.

3.Can you suggest minimum set of modules/combinations to get "temp,
humidity, pressure and Air quality. I also want a rain gauge and wind
(Direction and speed)added later, which completes the picture. These are
interrelated parameter that determine the air quality. Cheap rain gauge and
wind sensors are available from Ali express type of sellers. These
basically send data as counts based on moving magnets.
That would complete my lessons.

The selection depends on how tight is your budget.

For simplicity I would use a BME280 for temperature, pressure and relative
humidity. The I2C breakout board costs less than 6 USD, and today I saw
some advertised for less than 3 UDD. It is natively supported on the dev
branch of the nodemcu firmware. I have not tested it yet, but the code
looks good, and I hope it will solve the problems my bme280.lua module has
(see #1).

If you need to save every penny, I would get a BMP180 for pressure and a
AM2320 for temperature and relative humidity. This will save you about 2
USD per unit, at the cost of .complexity of the assembly.

For the PM measurements I would stay with the PMS5003. The technical
description says it can operate on I2C mode, but have not found any
information about the details about the specific registers. I'll try to
brut force them if I have to.

I do not known about cheap rain gauges, nor wind speed/direction sensors.
As far as I can tell any of this will cost you as much as all other sensors
together.

@avaldebe avaldebe changed the title PMS 3003 gives error Help with PMS3003.lua module May 15, 2016
@avaldebe avaldebe mentioned this issue May 15, 2016
9 tasks
@avaldebe
Copy link
Owner

I plan to make a native PMSx003 module, so it will be available on the dev branch of the nodemcu firmware. It will take some time, for me to write and test the module and then for the nodmcu team to deal with my pull request. For the time been I'll concentrate on reading the PMSx003 sensors on UART2 (D7 and D8).

@avaldebe
Copy link
Owner

@gkbtaru,

The original help request on this issue has been long answered. I opened #4, #5, #6 and #7 to follow up on the issues/requests you pointed out later.

I'm closing this issue now. Lets continue this discussion on the new issues. One at the time, please.

@AndriyHz
Copy link

Hi folk, I use of Plantower pms 3003 with Teensy 3.2. It's my code: https://github.com/AndriyHz/Teensy-3.2-and-Thingspeak/blob/master/PM2_with_S8_BME280_WiFi-For-Teensy3.ino
But I see that I receive sometimes incorrect data. For example,
PM2.5 --- 50
PM10 --- 65
PM2.5 --- 50
PM10 --- 65
....
PM2.5 --- 170 (once)
PM10 --- 500
.... again
PM2.5 --- 50
PM10 --- 65
....
PM2.5 --- 170 (once)
PM10 --- 500

Please help me.

@avaldebe
Copy link
Owner

Hi @AndriyHz

This project is quite old now, it started before we had Arduino for ESP8266, so it is nodemcu/lua based.
Since then I wrote a Arduino/C++ library to read the Plantower PMSx003 sensors (PMserial), please give it a try. If you have more Arduino/C++ questions please open an issue on PMserial.

Now to answer your question, as far as I can tell from reading your Arduino sketch, you are not reading the checksum bytes at the end of the message. Without them you can not be really sure that your message was read correctly.

Also, it seems that your message index off by one. In C/C++ array indexes start with 0. On the PMS3003 datasheet the message indexes start with 1. Therefore the first 2 bytes of the message in your code should be receiveDat[0] and receiveDat[1], not receiveDat[1] and receiveDat[2] you wrote. The same applies to the definitions of the PM values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants