Can't read HM-3301 values with grove.i2c

Grove is a modulated, ready-to-use tool set.
Much like Lego, it takes a building block approach to assembling electronics.

Moderators: lily.li, violet, jeremy882, crail.lyu969

funkihoo
Pre-kindergarten
Pre-kindergarten
Posts: 4
Joined: Thu Jun 13, 2019 9:42 am

Can't read HM-3301 values with grove.i2c

Post by funkihoo » Thu Jun 13, 2019 3:58 pm

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):
Image

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?
Image

Thus, what is the procedure to read a value? (Correct address, sequence and/or command?)

Thanks ;)
Attachments
grove_laser_pm_2_5_hm3301.pdf
Copy/Pasted from Python script to attach it here!
(215.02 KiB) Downloaded 174 times

marc.peucker
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Thu Jun 13, 2019 4:55 pm

Re: Can't read HM-3301 values with grove.i2c

Post by marc.peucker » Thu Jun 13, 2019 4:57 pm

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):
Image

Here you will see the problem:
Image

Just one write command and afterwards an error condition occurred.
BR
Marc

funkihoo
Pre-kindergarten
Pre-kindergarten
Posts: 4
Joined: Thu Jun 13, 2019 9:42 am

Re: Can't read HM-3301 values with grove.i2c

Post by funkihoo » Fri Jun 14, 2019 10:34 am

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:
Image
Image

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):
Image

I also wonder about something else:
Image
Image

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.

marc.peucker
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Thu Jun 13, 2019 4:55 pm

Re: Can't read HM-3301 values with grove.i2c

Post by marc.peucker » Sun Jun 16, 2019 4:51 am

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

funkihoo
Pre-kindergarten
Pre-kindergarten
Posts: 4
Joined: Thu Jun 13, 2019 9:42 am

Re: Can't read HM-3301 values with grove.i2c

Post by funkihoo » Sun Jun 16, 2019 6:44 pm

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

bill.yu
Junior-7
Junior-7
Posts: 732
Joined: Mon Apr 02, 2018 11:05 am

Re: Can't read HM-3301 values with grove.i2c

Post by bill.yu » Mon Jun 17, 2019 5:13 pm

Hi there~

I talked to product manager and software team, they will work on the python grove.py library. Keep you posted. thanks.

doccie
Pre-kindergarten
Pre-kindergarten
Posts: 4
Joined: Fri Jun 14, 2019 4:51 pm

Re: Can't read HM-3301 values with grove.i2c

Post by doccie » Tue Jun 25, 2019 4:38 am

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:

Code: Select all

[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]
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.
Attachments
HM330X_v2.zip
(1.4 KiB) Downloaded 39 times

bill.yu
Junior-7
Junior-7
Posts: 732
Joined: Mon Apr 02, 2018 11:05 am

Re: Can't read HM-3301 values with grove.i2c

Post by bill.yu » Tue Jun 25, 2019 3:44 pm

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.

doccie
Pre-kindergarten
Pre-kindergarten
Posts: 4
Joined: Fri Jun 14, 2019 4:51 pm

Re: Can't read HM-3301 values with grove.i2c

Post by doccie » Mon Jul 08, 2019 3:16 pm

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.

bill.yu
Junior-7
Junior-7
Posts: 732
Joined: Mon Apr 02, 2018 11:05 am

Re: Can't read HM-3301 values with grove.i2c

Post by bill.yu » Tue Jul 09, 2019 12:17 pm

Hi there~

The software team is still working on, it will be ready by today as best case. thanks.

Post Reply