Giter VIP home page Giter VIP logo

pmserial's People

Contributors

avaldebe avatar fmatray avatar hex16 avatar pintert3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pmserial's Issues

Help me with Hardware Serial

Hi I have an esp32 and I connected a PMS A003 to the serial hardware (IO10, IO9) but it doesn't work, I always get "Sensor read timeout".
I used the HardwareSerial.ino sample code

Once add "TridentTD_LineNotify" library to the project PMserial would give Exception(3)

I have tried using the example main.cpp in ProjectIO and the program and sensor works just fine.

BUT... after I have added TridentTD_LineNotify library into the project (just added the #include "TridentTD_LineNotify.h" line will already cause problem), it seems that when running, Exception(3) is thrown

the Exception is as follow

Exception (3):
epc1=0x40100e2d epc2=0x00000000 epc3=0x00000000 excvaddr=0x40069bd8 depc=0x00000000

stack>>>

ctx: cont
sp: 3ffffd40 end: 3fffffc0 offset: 0190
3ffffed0: 00000019 40262010 00000000 4020ec2d
3ffffee0: 78534d50 20333030 53206e6f 00000040
3ffffef0: 3fff1c5c 3fffea28 00000020 401010cf
3fffff00: 00000a00 3fff1b3c 00000020 00000040
3fffff10: 3fff1c5c 40205948 3fffea50 4021f709
3fffff20: 00000003 40205a3c 00000020 4021f6f4
3fffff30: 3ffe8cc2 00002580 00000041 40205802
3fffff40: 00000003 3fffea28 3fffea00 40205980
3fffff50: 4020e850 00000001 3fffea00 40205a56
3fffff60: 4020e850 3ffefbe0 3ffe8cc0 3ffefd1c
3fffff70: 3fffdad0 00000000 3ffefb1c 4020e17b
3fffff80: 00000040 00000000 3ffefbe0 4020ecb0
3fffff90: 3fffdad0 00000000 3ffefbe0 402054f1
3fffffa0: feefeffe feefeffe 3ffefcdc 4020ffa8
3fffffb0: feefeffe feefeffe 3ffe85e0 401013c5
<<<stack<<<

Once i remove TridentTD_LineNotify library from the project, it just work once again.

I am using NodeMCU ESP8266 so I have made sure that

lib_deps = EspSoftwareSerial@>=6.7.1

is included into the platformio.ini as well

I have been trying everything out of my small knowledge but nothing seems to work... Could you please help to identify where it crash? I would really need to use this library along with TridentTD_LineNotify to notify PM2.5 to LINE Notify service.

Thank you very much!

PicoW support request

Hi,
I like this library and use it with ESP32. I recently migrated to raspberry picow and tried this library but it didn’t work(as it’s not supported for picow). Are there any plans for supporting raspberry picow? Thanks

Doesn`t work on esp32 wroom 32u

Hello my friend
I have a project that i use pms5003
Also i use gps,mq131,mq7 and LED 64*128
I CONNECT VCC of pms5003 wire to 5v esp3 and connect gnd to gnd
Then connect rx and tx of pms to tx and rx of esp32
I try any code that you know but i have a bad problem (very very bad)
When i run my code and run the project on my esp
In buad monitor i get something bad
Some answers that i dont undrestand(i just use 9600 baud but my pms respons on 115200 baud)
I send a pic that you can see my problem.
I try all ways for solve this problem but i get bad response on monitor bauds that is not 9600.
IMG_20240119_161217
Can you help me?

SoftwareSerial bug - local variable, dangling pointer

I look at this code and see an error (explain in cppreference).
The variable serial is local (in stack), its lifetime is limited to the area of the constructor. After exiting the constructor, the variable serial will be destroyed, and the variable uart will contain dangling pointer. Copying its address should not prolong the lifetime.

I tried looking for some special case that affects the lifetime of a variable and which will not be "undefined behavior" (0, 1, 2, 3, 4, 5, 6 ). But I couldn't find anything suitable for this code...

If my fears are in vain, please give me a link to a description of this case in the standard or explain how it works.

Problem code:

class SerialPM
{
protected:
  Stream *uart;  // hardware/software serial
....

  SerialPM(PMS sensor, uint8_t rx, uint8_t tx) : pms(sensor)
  {
    SoftwareSerial serial(rx, tx);
    uart = &serial;
    hwSerial = false;
  }

Temperature/Humidity and Formaldehyde calculation are wrong for 5003ST

Hello,
I just test the library with a PMS5003ST and those values were wrong :

  • temperature was - 5.5°C instead of something around 22°
  • Humidity was also bad.

The problems were :

  • int8_t cast instead of int16_t
  • incorrect reading order. The good one, according to the datasheet, is : hcho, temp, rhum.

I post a PR to correct theses points.

I noticed a difference between the sensor and a regular thermometer.
So I also add a feature to add offset to temperature and humidity to correct theses values :

  • void set_rhum_offset(float offset);
  • void set_temp_offset(float offset);
  • float get_rhum_offset();
  • float get_temp_offset();

This is based on the library GHTNew (https://github.com/RobTillaart/DHTNew).

the data is coming intermittently

the serial data is coming once and gives the " sensor data timeout"
i am using a esp8266 nodemcu and pms7003
the pins are connected to the board's rx and tx pins
please respond as fast as possible

Data logger example

You found this library useful and would like to give something back. Here is your chance.
I would appreciate more example projects. PRs are welcomed.

Outline

  • Take measurements at regular intervals.
  • Sleep/low power mode in between measurements.
  • Save measurements to external FLASH or an SD CARD.
  • Timestamp measurements with any of the following options
    • external RTC such as DS3231
    • internal RTC in STM32 or SAMD21 boards
    • NTP for boards with network access such as ESP8266 or ESP32 boards

Wrong has_number_concentration() for PMS5003S/T/ST

Hello,
I think there is an error with has_number_concentration() with PMS5003ST.
According to the datasheet, this sensor have concentration datas

I'm not sure yet, as I only have the 7003 for the moment.
I'll check when I receive the 5003ST, in 2 weeks.

Thanks.

Sleep and wake mode

Hello,
I need to turn the sensor into sleep mode for a long time (several hours).
This is to prevent the fan to turn while the arduino is in deep sleep mode.
It's possible to low the set pin but I'm very limited with the amount pins. This method can save me a pin.

Is it possible to add this to your library please ?
Tested with a PMS7003.

const uint8_t
    msgLen = 7,
    //act[msgLen] = {0x42,0x4D,0xE1,0x00,0x01,0x01,0x71}, // set active mode
    slp[msgLen] = {0x42, 0x4D, 0xE4, 0x00, 0x00, 0x01, 0x73},  // sleep          **<-- UNCOMMENT**
    wak[msgLen] = {0x42, 0x4D, 0xE4, 0x00, 0x01, 0x01, 0x74},  // wake          **<-- UNCOMMENT**
    cfg[msgLen] = {0x42, 0x4D, 0xE1, 0x00, 0x00, 0x01, 0x70},  // set passive mode
    trg[msgLen] = {0x42, 0x4D, 0xE2, 0x00, 0x00, 0x01, 0x71};  // passive mode read

[...]

void SerialPM::sleep() {
  uart->write(slp, msgLen);  // sleep mode 
  uart->flush();
  delay(max_wait_ms * 2);
}
void SerialPM::wake() {
  uart->write(wak, msgLen);  // wake mode 
  uart->flush();
  delay(max_wait_ms * 2);
}

I found the issue #2 about this point, but it seems the code never been implemented.

Cheers,
Frédéric

Support PMS5003S/ST/T

Do you plan on supporting PMS5003T ?

Originally posted by @gbalbinot in #4 (comment)

Message structure

message PMS5003 PMS5003T PMS5003S PMS5003ST
32 bits 32 bits 32 bits 40 bits
header 4 bits 4 bits 4 bits 4 bits
42 4d 00 1c 42 4d 00 1c 42 4d 00 1c 42 4d 00 24
body 26 bits 26 bits 26 bits 34 bits
12 values, 1 reserved 13 values 13 values 15 values, 2 reserved
checksum 2 bits 2 bits 2 bits 2 bits

PMSx003 sensor

The PMSx003 sensor type will infer the sensor type from the message header.
As the PMS5003T/PMS5003S variants have the same header than the PMS5003
they need to be declared explicitly on the SerialPM constructor.

Support for Arduino MKRWifi 1010 (atmelsam)

Hi avaldebe, thank you for the great library.

I would like to use it on my MKRWifi 1010 board with Next-PM sensor , I tried to modify your PM serial Library and use it on my board but no luck.
If you can help me I will appreciate that.
My platformio.ini looks like : https://docs.platformio.org/en/latest/boards/atmelsam/mkrwifi1010.html

[env:mkrwifi1010]
platform = atmelsam
board = mkrwifi1010

My example:

#include <PMserial.h>
SerialPM pms(NextPM, Serial1);  // PM Serial, RX, TX
void setup() {
  Serial.begin(9600);
 // Serial1.begin(9600, SERIAL_8N1, 13, 14);
  pms.init();                   // config serial port
}

void loop() {
  pms.read();                   // read the PM sensor
  Serial.print(F("PM1.0 "));Serial.print(pms.pm01);Serial.print(F(", "));
  Serial.print(F("PM2.5 "));Serial.print(pms.pm25);Serial.print(F(", "));
  Serial.print(F("PM10 ")) ;Serial.print(pms.pm10);Serial.println(F(" [ug/m3]"));
  delay(10000);                 // wait for 10 seconds
}

The errors:

In file included from D:\Anass_PM\PMserial\PMserial.ino:2:0:
C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:64:24: error: 'uart' has not been declared
   SerialPM(PMS sensor, uart &serial) : pms(sensor) {
                        ^~~~
C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h: In constructor 'SerialPM::SerialPM(PMS, int&)':
C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:65:13: error: cannot convert 'int*' to 'Stream*' in assignment
     uart = &serial;
             ^~~~~~
D:\Anass_PM\PMserial\PMserial.ino: At global scope:
PMserial:7:29: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
 SerialPM pms(NextPM, Serial1);  // PM Serial, RX, TX
                             ^
In file included from C:\Users\Asus\OneDrive\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.6\variants\mkrwifi1010/variant.h:165:0,
                 from C:\Users\Asus\OneDrive\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.6\cores\arduino/delay.h:23,
                 from C:\Users\Asus\OneDrive\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.6\cores\arduino/Arduino.h:81,
                 from sketch\PMserial.ino.cpp:1:
C:\Users\Asus\OneDrive\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.6\cores\arduino/Uart.h:45:5: note:   after user-defined conversion: virtual Uart::operator bool()
     operator bool() { return true; }
     ^~~~~~~~
In file included from D:\Anass_PM\PMserial\PMserial.ino:2:0:
C:\Users\Asus\OneDrive\Documents\Arduino\libraries\PMserial_library1/PMserial.h:64:3: note:   initializing argument 2 of 'SerialPM::SerialPM(PMS, int&)'
   SerialPM(PMS sensor, uart &serial) : pms(sensor) {
   ^~~~~~~~
exit status 1
cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'

Thanks in advance.

Problem with init

Hi I made the init and after a few seconds about 10 I'm going to make the first reading. The problem is that sometimes the reading of the three Particulate values ​​is 0.

Support Serial1 on ESP32

Hi, thank you for the great library.

I would like to use it with ESP32 HW Serial1 on custom pins (HW serial could be remapped to almost any pins on this MC) however, the library reinitializes serial interface during the init.
I can fix code in the library, but it isn't a good way.

#ifdef HAS_HW_SERIAL
    static_cast<HardwareSerial*>(uart)->begin(9600, SERIAL_8N1, 16, 17);
#endif

As for me, the library shouldn't reconfigure the interface, just use it, though probably this code was added to simplify usage.
Any thoughts about some kind of workaround?

Need help getting Arduino Mega 2560 w/ PMS5003 to work

FYI, I am a beginner with Arduino and coding in C++, I started working with Arduino stuff just 10 months ago. Since then I've been using the Arduino UNO that used a PMS5003, SD Card Breakout Board, and BME688, all of which using codes from the product page on Adafruit's website.

I ran into memory limitations with the Arduino UNO, thus I want to get the Plantower PMS5003 to work with the Arduino Mega and found this coding library. The Arduino Sketch I used was the HardwareSerial example found in this library and I did not edit it at all other than adding comments.

The wiring was as follows from sensor to MCU:
-VCC to 3.3V
-GND to GND
-TXD to TX0 (pin 1), so this should be going through Serial

When I run the code, this is the output in the serial monitor:

PMSx003 on HardwareSerial
BM⸮ pBM⸮ q Sensor read timeout

Do I need to make changes to the code and/or is the wiring wrong?

Sleep mode

How to turn on sleep mode in this sensor?

PM standard vs under atmospheric environment

Hi,

In PMS5003 datasheet I've found that the sensor is returning 2 different PM values. There is a value described as CF=1,standard particle and a value described as under atmospheric environment. Do you know what is the difference between, for example PM10 standard and PM10 under atmospheric environment? Which value is being read by this library? Is there a possibility to read the other value using this library?

Need option to disable sending command to sensor (active_mode option)

Hello!
I use the same UART channel to read data from sensor (via RX pin of controller) and send debug messages (via TX pin). So there is no connection between controller's TX pin and sensor's RX pin.
In my case PMS5003 sensor works fine without sending any command to it.
Your library sends "passive mode" command in 'init' and 'trigRead' methods:
uart->write(cfg, msgLen); // set passive mode
so I see this data as unreadable text in my debug monitor.
Is it possible to add some option (in constructor, for example) to disable sending any data to UART?
Thanks )

General docs/usage

If you do not understand how to use the library, found an explanation confusing or you found a typo. Leave a message and will try to answer as soon as reasonable.

Thanks for helping to improve the library!

Question about the pm values datatype.

Hello, i have been working with this library recently and have noticed that the datatype of the pm values is uint16_t.
Is there any simple way that i can get those values as floats or doubles or does it require big adjustments?

(If it is relevant, I am using an ESP8266 and a PMS7003.)

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.