PMS7003 Arduino Library by Soldered 1.0.0
This is a library for the PMS7003 Board by Soldered
Loading...
Searching...
No Matches
SerialPM Class Reference

#include <PMserial.h>

Inherited by PMS7003.

Public Types

enum  STATUS {
  OK , ERROR_TIMEOUT , ERROR_PMS_TYPE , ERROR_MSG_UNKNOWN ,
  ERROR_MSG_HEADER , ERROR_MSG_BODY , ERROR_MSG_START , ERROR_MSG_LENGTH ,
  ERROR_MSG_CKSUM
}
 

Public Member Functions

 SerialPM (PMS sensor)
 
 SerialPM (PMS sensor, HardwareSerial &serial)
 
 SerialPM (PMS sensor, uint8_t rx, uint8_t tx)
 
 SerialPM (PMS sensor, Stream &serial)
 
 SerialPM (PMS sensor, uint8_t rx, uint8_t tx)
 
void init ()
 
STATUS read (bool tsi_mode=false, bool truncated_num=false)
 
 operator bool ()
 
void sleep ()
 
void wake ()
 
bool has_particulate_matter ()
 
bool has_number_concentration ()
 
bool has_temperature_humidity ()
 
bool has_formaldehyde ()
 
Stream * getSerialPort ()
 
void setSerialPort (Stream *serial)
 
void set_rhum_offset (float offset)
 
void set_temp_offset (float offset)
 
float get_rhum_offset ()
 
float get_temp_offset ()
 
void print_buffer (Stream &term, const char *fmt)
 
uint16_t waited_ms ()
 
uint16_t bytes_read ()
 

Public Attributes

union { 
 
   uint16_t   data [9] 
 
   struct { 
 
      uint16_t   pm [3] 
 
      uint16_t   nc [6] 
 
   }  
 
   struct { 
 
      uint16_t   pm01 
 
      uint16_t   pm25 
 
      uint16_t   pm10 
 
      uint16_t   n0p3 
 
      uint16_t   n0p5 
 
      uint16_t   n1p0 
 
      uint16_t   n2p5 
 
      uint16_t   n5p0 
 
      uint16_t   n10p0 
 
   }  
 
};  
 
union { 
 
   float   extra [3] 
 
   struct { 
 
      float   temp 
 
      float   rhum 
 
      float   hcho 
 
   }  
 
};  
 
STATUS status
 

Protected Types

enum  { serModeHardware , serModeSoftware , serModeManual }
 

Protected Member Functions

STATUS trigRead ()
 
bool checkBuffer (size_t bufferLen)
 
void decodeBuffer (bool tsi_mode, bool truncated_num)
 
uint16_t buff2word (uint8_t n)
 

Protected Attributes

Stream * uart
 
PMS pms
 
enum SerialPM:: { ... }  hwSerial
 
uint8_t rx
 
uint8_t tx
 
float temp_offset = 0.0
 
float rhum_offset = 0.0
 
uint16_t wait_ms
 
uint8_t buffer [BUFFER_LEN]
 
uint8_t nbytes
 

Static Protected Attributes

static const uint16_t max_wait_ms = 1000
 
static const uint8_t BUFFER_LEN = 40
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
serModeHardware 
serModeSoftware 
serModeManual 

◆ STATUS

Enumerator
OK 
ERROR_TIMEOUT 
ERROR_PMS_TYPE 
ERROR_MSG_UNKNOWN 
ERROR_MSG_HEADER 
ERROR_MSG_BODY 
ERROR_MSG_START 
ERROR_MSG_LENGTH 
ERROR_MSG_CKSUM 

Constructor & Destructor Documentation

◆ SerialPM() [1/5]

SerialPM::SerialPM ( PMS sensor)
inline

◆ SerialPM() [2/5]

SerialPM::SerialPM ( PMS sensor,
HardwareSerial & serial )
inline

◆ SerialPM() [3/5]

SerialPM::SerialPM ( PMS sensor,
uint8_t rx,
uint8_t tx )
inline

◆ SerialPM() [4/5]

SerialPM::SerialPM ( PMS sensor,
Stream & serial )
inline

◆ SerialPM() [5/5]

SerialPM::SerialPM ( PMS sensor,
uint8_t rx,
uint8_t tx )
inline

Member Function Documentation

◆ buff2word()

uint16_t SerialPM::buff2word ( uint8_t n)
inlineprotected

◆ bytes_read()

uint16_t SerialPM::bytes_read ( )
inline

◆ checkBuffer()

bool SerialPM::checkBuffer ( size_t bufferLen)
protected

◆ decodeBuffer()

void SerialPM::decodeBuffer ( bool tsi_mode,
bool truncated_num )
protected

◆ get_rhum_offset()

float SerialPM::get_rhum_offset ( )
inline

◆ get_temp_offset()

float SerialPM::get_temp_offset ( )
inline

◆ getSerialPort()

Stream * SerialPM::getSerialPort ( )
inline

◆ has_formaldehyde()

bool SerialPM::has_formaldehyde ( )
inline

◆ has_number_concentration()

bool SerialPM::has_number_concentration ( )
inline

◆ has_particulate_matter()

bool SerialPM::has_particulate_matter ( )
inline

◆ has_temperature_humidity()

bool SerialPM::has_temperature_humidity ( )
inline

◆ init()

void SerialPM::init ( )

◆ operator bool()

SerialPM::operator bool ( )
inline

◆ print_buffer()

void SerialPM::print_buffer ( Stream & term,
const char * fmt )
inline

◆ read()

SerialPM::STATUS SerialPM::read ( bool tsi_mode = false,
bool truncated_num = false )

◆ set_rhum_offset()

void SerialPM::set_rhum_offset ( float offset)
inline

◆ set_temp_offset()

void SerialPM::set_temp_offset ( float offset)
inline

◆ setSerialPort()

void SerialPM::setSerialPort ( Stream * serial)
inline

◆ sleep()

void SerialPM::sleep ( )

◆ trigRead()

SerialPM::STATUS SerialPM::trigRead ( )
protected

◆ waited_ms()

uint16_t SerialPM::waited_ms ( )
inline

◆ wake()

void SerialPM::wake ( )

Member Data Documentation

◆ [union]

union { ... } SerialPM

◆ [union]

union { ... } SerialPM

◆ buffer

uint8_t SerialPM::buffer[BUFFER_LEN]
protected

◆ BUFFER_LEN

const uint8_t SerialPM::BUFFER_LEN = 40
staticprotected

◆ data

uint16_t SerialPM::data[9]

◆ extra

float SerialPM::extra[3]

◆ hcho

float SerialPM::hcho

◆ []

enum { ... } SerialPM::hwSerial

◆ max_wait_ms

const uint16_t SerialPM::max_wait_ms = 1000
staticprotected

◆ n0p3

uint16_t SerialPM::n0p3

◆ n0p5

uint16_t SerialPM::n0p5

◆ n10p0

uint16_t SerialPM::n10p0

◆ n1p0

uint16_t SerialPM::n1p0

◆ n2p5

uint16_t SerialPM::n2p5

◆ n5p0

uint16_t SerialPM::n5p0

◆ nbytes

uint8_t SerialPM::nbytes
protected

◆ nc

uint16_t SerialPM::nc[6]

◆ pm

uint16_t SerialPM::pm[3]

◆ pm01

uint16_t SerialPM::pm01

◆ pm10

uint16_t SerialPM::pm10

◆ pm25

uint16_t SerialPM::pm25

◆ pms

PMS SerialPM::pms
protected

◆ rhum

float SerialPM::rhum

◆ rhum_offset

float SerialPM::rhum_offset = 0.0
protected

◆ rx

uint8_t SerialPM::rx
protected

◆ status

STATUS SerialPM::status

◆ temp

float SerialPM::temp

◆ temp_offset

float SerialPM::temp_offset = 0.0
protected

◆ tx

uint8_t SerialPM::tx
protected

◆ uart

Stream* SerialPM::uart
protected

◆ wait_ms

uint16_t SerialPM::wait_ms
protected

The documentation for this class was generated from the following files: