-
Notifications
You must be signed in to change notification settings - Fork 13
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
Comments
Hi @gkbtaru,
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
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). 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:
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. 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 |
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. |
I am using nodemcu devkit. 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 I treid different configurations of connecting to D7 as well as D10 |
My mistake, RXD0 is on D9 (GPIO03). |
The system works once, then I get BMBM continuously.
This is the result. Can the BM message avoided? |
Hi again, |
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. Have a look at the rest if the repository and ask away. I'll use the
Cheers, A. |
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. 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 |
Hi again,
I think I got it now. You are talking about the custom nodemcu-build by frightanic. One of the things I'm interested is to use the 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.
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. |
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. |
Yes, I see that now. |
Thanks for your advice. |
Hi, |
This is what happens after running init lua.
PORT CLOSED |
Not sure what is the problem. Can you share your init.lua? |
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 |
Now I understood that you are using I2C and that is why you need AM2320 instead of DHT22. Thanks again, for your efforts. |
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 On the AQmon early versions the esp8266 was very unstable with the PMS3003 AQmon is set to read the sensors and send data to thigspeak eery 5 minutes, |
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. |
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 |
Trying again. Where do I have to put following information
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])
|
The wifi_connect lua says |
The comment in wifi_connect.lua says that all settings are stored in keys.lua.
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"
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
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 |
Now I got it. Going to try again. Last time the program just stopped. no errors, no progress. Will inform. |
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 |
PMset is 7 and I am using D7 for pin3 |
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. |
It means that the system is fine, the RX pin is fine, but lua is creating the mistake somewhere. |
Can the UARt pin be changed from D9 to another pin? _Found answer_** run_input: 0 or 1, 0: input from uart will not go into lua interpreter, can accept binary data. uart.on("data", 4, |
I have tried to explain this issue a few times before, so I'll try again in In short, you need to tell the PMS5003 to shut up so the esp8266 can hear The nodemcu firmware allow us to send lua commands and run lua scripts. It The PMS5003 also communicates trough the UART bus. By default it is on The UART bus is meant for communications between two parts. There we have To set the PMS5003 on standby mode, you need to set pin3 low. Then the If you are not using all of the AQmon modules, you need to need to set gpio.mode(7,gpio.OUTPUT) -- assume PMset on D7
gpio.write(7,gpio.LOW) -- put PMS5003 on standby mode |
You do not need to put this into your code. The PMS3003.lua module takes |
It was a great learning for me. Thanks.
My new questions are:
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 |
Hi, |
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 |
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
You can put those lines anywhere in your init.lua.
You are not using a full AQmon setup, so it is hard to keep track on what
The selection depends on how tight is your budget. For simplicity I would use a BME280 for temperature, pressure and relative If you need to save every penny, I would get a BMP180 for pressure and a For the PM measurements I would stay with the PMS5003. The technical I do not known about cheap rain gauges, nor wind speed/direction sensors. |
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). |
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 Please help me. |
Hi @AndriyHz This project is quite old now, it started before we had Arduino for ESP8266, so it is nodemcu/lua based. 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 |
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?
The text was updated successfully, but these errors were encountered: