Hi!
I’ve been trying to use the "Grove - Laser PM2.5 (HM3301) through the Grove HAT of my Raspberry Pi Zero W using the “grove.i2c” library provided with grove.py, using my Python script “grove_laser_pm_2_5_hm3301.py” (attached).
However, I always fail to read values from the sensor even if I can clearly detect it on i2c (below the “i2cdetect” command result and the error on script’s execution):
Also, I’m confused, the wiki (and also on the board and i2cdetect) says the Sensor I2C address is 0x40 but the documentation give 0x80?
Thus, what is the procedure to read a value? (Correct address, sequence and/or command?)
Thanks
grove_laser_pm_2_5_hm3301.pdf (215 KB)
Hello,
have the same problem. It seems that the I2C protocol is not implemented correctly.
Here are some screenshots from a protocol analyser:
Correct behaviour (tested with a I2C light sensor):
Here you will see the problem:
Just one write command and afterwards an error condition occurred.
BR
Marc
Thank you Mark for the valuable inputs and screenshots
If I understand it correctly: it means the I2C on the board isn’t properly working?
(I also tried to communicate with the board with “smbus” instead of “grove.i2c”/“smbus2” and it yields to the same results)
I looked for a workaround based on the datasheet:
It seems we might be able to use UART with this module if we read the datasheet but it seems Rx and Tx are not connected to the connectors if you look at the schematic (Pin4 & 5):
I also wonder about something else:
I actually start to think that opposed to what the Wiki says, it can only be powered with 5V but 3.3V communication compatible. Hence, if powered with 3.3V it might misbehave. (If I have time, I’ll check that tonight with a quick tweak and get back at you after it)
Sorry for this long post.
Hello funkihoo,
I found this pHat from Pimoroni…
https://shop.pimoroni.com/products/enviro-plus
There is an connector on the backside for a PMS5003 dust sensor. It seems that the HM-3301 is the same or the same series of sensors.
From the data sheet the connector has the same pinout as the HM-3301, but not quite sure.
Maybe somebody from Seeed can answer the question???
Best regards
Marc
Hi marc,
It seems my “tweak” didn’t make any difference.
Interesting remark, I’ll check more on those similar series of sensors and see if anything pops out.
I would be interested by a Seeed anwser too.
Sincerely Anthony
Hi there~
I talked to product manager and software team, they will work on the python grove.py library. Keep you posted. thanks.
Hi Anthony, hi Bill,
I’ve been working on a library for the Raspberry PI using the Grove Hat for PI Zero and I did manage to read the sensor values, however they don’t seem to check out.
What’s different about my code is that I use the SMBusWrapper from SMBus2 and I don’t use the read/write addresses, I just use the device address (0x40).
Whenever I try to use the read/write address (0x80/81) I get the same error as you.
I’ve added my preliminary work in attachment.
This outputs something similar to:
</s>[0, 255, 0, 0, 0, 19, 0, 28, 0, 35, 0, 19, 0, 28, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 163]<e>
Where 163 (the last byte) should be the checksum of the other 28 bytes. (which is obviously not correct)
Bill, feel free to use my code for the official Seeed library. I’ve actually modeled it after the SGP30 library.
I’m giving up for today, but will continue to work on it during the week.
HM330X_v2.zip (1.4 KB)
Hi there~
thanks for the sharing and i already pass to software team. they will work on this python library. I will keep you posted on the forum. thanks.
Hi Bill,
Any update on this? Unfortunately, I haven’t been able to look into it further myself.
Should you need any additional info in regards to the code snippet, I am available for questions.
Hi there~
The software team is still working on, it will be ready by today as best case. thanks.
Hi there~
For hardware, you can connect the vcc to 3.3v, gnd to gnd, scl to scl and sda to sda as well.
For software, Please follow below instructions to read the data.
- Enable I2C through sudo raspi-config
- Set I2C frequency as 20khz, by adding the content : dtparam=i2c_arm_baudrate=20000 @ end of config.txt.
</s>sudo vim /boot/config.txt<e>
-
Install dependienies
</s>pip install smbus2<e>
-
Run the python code
</s>cd ~
wget https://raw.githubusercontent.com/Seeed-Studio/grove.py/master/grove/grove_PM2_5_HM3301.py
python grove_PM2_5_HM3301.py<e>
- Here is the output. thanks.
[code]
PM1.0 Standard particulate matter concentration Unit:ug/m3 = 36
PM2.5 Standard particulate matter concentration Unit:ug/m3 = 48
PM10 Standard particulate matter concentration Unit:ug/m3 = 55
PM1.0 Atmospheric environment concentration ,unit:ug/m3 = 28
PM2.5 Atmospheric environment concentration ,unit:ug/m3 = 41
PM10 Atmospheric environment concentration ,unit:ug/m3 = 51
PM1.0 Standard particulate matter concentration Unit:ug/m3 = 36
PM2.5 Standard particulate matter concentration Unit:ug/m3 = 48
PM10 Standard particulate matter concentration Unit:ug/m3 = 55
PM1.0 Atmospheric environment concentration ,unit:ug/m3 = 28
PM2.5 Atmospheric environment concentration ,unit:ug/m3 = 41
PM10 Atmospheric environment concentration ,unit:ug/m3 = 51
PM1.0 Standard particulate matter concentration Unit:ug/m3 = 36
PM2.5 Standard particulate matter concentration Unit:ug/m3 = 48
PM10 Standard particulate matter concentration Unit:ug/m3 = 55
PM1.0 Atmospheric environment concentration ,unit:ug/m3 = 28
PM2.5 Atmospheric environment concentration ,unit:ug/m3 = 41
PM10 Atmospheric environment concentration ,unit:ug/m3 = 51
PM1.0 Standard particulate matter concentration Unit:ug/m3 = 36
PM2.5 Standard particulate matter concentration Unit:ug/m3 = 48
PM10 Standard particulate matter concentration Unit:ug/m3 = 55
PM1.0 Atmospheric environment concentration ,unit:ug/m3 = 28
PM2.5 Atmospheric environment concentration ,unit:ug/m3 = 41
PM10 Atmospheric environment concentration ,unit:ug/m3 = 51[/code]
Hi Bill,
Thanks for the fast work! I’ll try it out tonight and get back to you with my results.
Works like a charm. Looks like my values are relatively low, so I’d have to test with another sensor to see how they stack up.
But at least the sensor is producing consistent output now.
Thanks for the help!
Hi everyone,
Sorry for not posting lately, quite busy.
Thank you Bill for the module !
I tested it and it works great on my side too
Hi guys !
I know this tutorial has been created long time ago, like 4 years ago… but I really need your help.
I need to use this sensor connected to I2C port of GrovePi, with other environmental sensors (air quality, temp&hum, dust, tVOC & CO2eq) on a Raspberry Pi 4B.
Because I’m working on Python 3.7.3, I use commands like pip3 and python3 to execute my scripts.
That’s why this tutorial does not work like that and especially, I got an error about SMBusWrapper.
What could you advise me to do ?
Thanks in advance !!!
Cheers
Sua