Go Down

Topic: Extracting PM2.5 data from new Honeywell HPM Particle Sensor via serial UART (Read 4241 times) previous topic - next topic

ralphvn86

Thanks - will try and get hold of one from family. I've continued tinkering in the meantime, and radically simplified my code (see bottom) to start always reading at the 66..77.. point, as this consistently comes up in the code. Tried with second sensor not exposed to 5v Rx/Tx and getting exactly same output, and also set up smoke chamber to get particles high enough to trip past the 256 figure.

Output is pasted below. My working hypothesis is PM2.5 = (line 105*256) + line 106, as this aligns with the experiments I'm doing. PM10 would be 107*256 and 108

Having been looking at other sketches pinging these kind of sensors, there seems to be some interesting mixing between uint8_t and uint16_t in the libraries.

Am I missing something silly here around how I'm reading the data into the array? Tried changing the 8_t to 16_t, but that breaks the readbytes function.

100:  77
101:  0
102:  28
103:  0
104:  0
105:  1
106:  192
107:  1
108:  199
109:  0
110:  0
111:  0
112:  0
113:  0
114:  0
115:  0
116:  0
117:  0
118:  0
119:  0
120:  0
121:  0
122:  0
123:  0
124:  0
125:  0
126:  0
127:  81
128:  0
129:  2
130:  133
131:  66 (the first reading, but confirming I've closed the loop)

Wondering if chunking anything into 16 not 8 would get it to look like more like the datasheet, as at the moment, I feel I'm getting a reliable output, but that it doesn't resemble the datasheet one bit (or byte).

Thanks

Code: [Select]
#include "SoftwareSerial.h"
SoftwareSerial mySerial(12,13);  //Using pin 12 for Rx and pin 13 for Tx
byte autosend[] = {0x68, 0x01, 0x40, 0x57};
 
#define LENG 32   
uint8_t buf[LENG];
int PM2_5Value=0;         //define PM2.5 value

void setup()
{ Serial.begin(9600);       
  mySerial.begin(9600);   
  mySerial.setTimeout(6000);
  delay(2000);
  mySerial.write(autosend,4); 
}

void loop()
{ Serial.println(" ");
 // mySerial.write(readpart,4);
  if(mySerial.find(66)){   
  if(buf[1] = 77){mySerial.readBytes(buf,LENG);
  PM2_5Value=((buf[5]*256) + buf[6]);}
} delay(2000);

  Serial.print("PM2.5 = ");
  Serial.println(PM2_5Value);
for(int i = 0; i < 32; i++)
{ Serial.print(i+100);
  Serial.print(":  ");
  Serial.println(buf[i],DEC);
}}

 

Your code looks okay, 66 is the first byte followed by 77 for the header, 101 and 102 is the MSB and LSB for the length (always 28 at the moment).

You have to take the sum off al the bytes, header + length + 26 data bytes what should correspond with byte 129 (MSB) and 130 (LSB) as an uint16_t.

jonselfphoto

Has anyone gotten this working yet? I'm having trouble with mine as well. The datasheet on Honeywell's website says it will work with either 5V or 3.3V, I'm not sure why people are saying this isn't the case...

john_m0ers

The way I read the datasheet, it has its own on board regulator with 5v being the input. It also quite clearly states that the uart levels are 3.3v. If 5v is applied here I would imagine it would destroy the pin driver.
john

jonselfphoto

The way I read the datasheet, it has its own on board regulator with 5v being the input. It also quite clearly states that the uart levels are 3.3v. If 5v is applied here I would imagine it would destroy the pin driver.
john
I just got another HPMA115S0 and a level shifter to try out. I will keep everyone updated if I get things working!

The level shifter is here.

BartBkkm

I am encountering exactly the same problem as described below. Did you already find a solution now, Latsbben?

I am also trying to extract data from a HPM dust sensor but have encountered some other problems than the ones discussed above. Since I am new to Arduino I am not able to figure out whether it is the programming, the wiring or something else that is causing the problem.

I have an Arduino UNO and use the example and library available at Github: https://github.com/felixgalindo/HPMA115S0.

I am using a separate 5V battery as power source for the sensor to ensure correct voltage.

I have tried to connect the RX/TX from the sensor to the RX/TX on the board, and pin 10/11 on the board. I have also tried to connect/disconnect the 3.3 V.

When I am using 9600 baud in the serial monitor I get only gibberish, but when I am turning it to 57600 I get readable text saying:

PS- Reading Particle Measurements...
PS- Sending cmd 68 1 4 93
PS- Waiting for cmd resp

And then repeats this every second endlessly and does not change when I change the wiring.

Anyone have a suggestion for what to do overcome this problem?
I would also like to try the solution as quoted below, but I can't seem to figure out how to disable this 'Auto Send'. Can anyone explain this to me?

Hi chris
originally i had same problem,,
so I try to stop Auto Send(default seems enabled)  0x68 0x01 0x20 0x77.
then try again start measurement,
he return  165 165 (0xA5 0xA5)

seems when Auto Send is enabled,
you start particle measurement,
he will send "auto send" to you,

jonselfphoto

I am encountering exactly the same problem as described below. Did you already find a solution now, Latsbben?

I would also like to try the solution as quoted below, but I can't seem to figure out how to disable this 'Auto Send'. Can anyone explain this to me?


What kind of Arduino are you using? The TX/RX inputs on the Arduino Uno are using 5V while they sensor uses 3.3V. This requires the use of something like the level shifter I mentioned above here.

As far as disabling AutoSend goes, this code
 here should take care of that in line 39. "void HPMA115S0::Init()" is used when you declare "hpma115S0.Init();" in your Arduino code.

I've gotten mine working great! I'll post the code and pictures of how I've wired everything for you all later on tonight in about 10 hours after work.

BartBkkm

I used the 5V and ground port of an Arduino Uno to power the honeywell and the RX and TX ports of an Arduino Feather 32u4 to read the honeywell. The Arduino feather ports also only use 3.3V right?

I'm really curious to see your code and setup.

Thank you for your reply!

BartBkkm

Hey All,

I found my error last week.
Because the honeywell sensor communicates in the form of multiple serials, and the arduino UNO only has one serial port, a virtual serial port is defined in the code as found on GitHub.

I did not understand this, and plugged my RX/TX wires in the regular serial ports (pin 0 and 1 of the Arduino feather) and not in my virtual serial ports (pin 10 and 11 as in the code available on GitHub Lattsben mentioned earlier.

It is now fully functioning as intended!

chris_chiswell

If you only need low/med/high indication I'd suggest a IR LED based solution like the SM-PWM-01C we make, which is mainly used in the Chinese Air Purifier market, we've even put some code on Github for it outputting the US EPA Colour Codes for PM2.5.

Later this year we will have our own laser based solution (like the Plantower and Honeywell solutions mentioned), and I've already got the Arduino code so will publish when we launch. SM-UART-01L will be part number, it'll be in Mouser, Farnell et al when launched.

Just wondered about an update on this - can see the datasheet on this on your own site, but haven't seen this sensor out in the wild yet? Is the sensor and arduino code available yet?

OlivDls

Hi folks,

I just wanted to share my experience. I've wired the HPMA115S0 sensor to an Arduino Nano (chinese clone to be fair...) and it works well.
- I've used two voltage dividers (1K/2K, one for RX & one for TX) to convert the 5V logic level from the Nano to the 3.3V used by the sensor
- The code comes from Felix Galindo (here on GitHub), big thanks to him, it saved my day !

I've attached a pic of the wiring (edited on KiCAD). The typical answer I got from the sensor is
PS- Reading Particle Measurements...
PS- Sending cmd: 68 1 4 93
PS- Waiting for cmd resp...
PS- Received valid data!!!
PM 2.5: 6 ug/m3
PM 10: 7 ug/m3
PS- Reading Particle Measurements...
PS- Sending cmd: 68 1 4 93
PS- Waiting for cmd resp...
PS- Received valid data!!!
PM 2.5: 7 ug/m3
PM 10: 8 ug/m3
and so on....

The values are really consistent, it goes to 0ug/m3 when I put the sensor in the cleanroom (a real one for microelectronics) and 8-9ug/m3 when I take the device outdoor

Go Up