Hi! I'm not having any luck getting my HM3301 to work with my system. First there is confusion regarding which pins should be used. I think I have everything set up to use 21 for SDA and 20 for SDL. Second, the tutorial for using the HM3301 has a picture which apparently shows the cable from the HM3301 going to the connector for D21/D26 according to the Pi2Grover product specification. I have tried to specify different pins and used different connectors on the Pi2Grover, but I always get an error when I run testSDL_Pi_HM3301.py saying list index out of range. Adding debug statements to the software shows that hm3301.get_data() is returning a -82 only. This leads me to believe the software is not successfully talking to the HM3301. Any ideas on what to try next?
I'm using the connector that the Pi2Grover specification diagram indicates is D20/D21. (Bottom row, 2nd from the left, looking at the board with the GPIO connector at the top.) The HM3301 tutorial looks like it's going to the D21/D26 connector, which is one of the sources of confusion. I put a print statement in the driver to verify it was using the expected values.
Here is the output of testSDL_Pi_HM3301.py, including my print statements. The first print is in the __init__ method for SDL_Pi_HM3301 and prints the arguments passed to it. The second print is the count and data vector from the call to self.pi.bb_i2c_zip() in read_HM3301_data().
<pipio.pi host=localhost port=8888> 21 20 128 -82  closing hm3301 Traceback (most recent call last): File "testSDL_Pi_HM3301.py", line 21, in <module> myData = hm3301.get_data() File "/home/pi/SDL_Pi_SkyWeather2/SDL_Pi_HM3301/SDL_Pi_HM3301.py", line 85, in get_data self.parse_data(data) File "/home/pi/SDL_Pi_SkyWeather2/SDL_Pi_HM3301/SDL_Pi_HM3301.py", line 74, in parse_data self.PM_1_0_conctrt_std = data<<8 | data IndexError: list index out of range
Okay, first, a few things about my set up: The processor is a Raspberry Pi 3A+. I am using VNC to remote into the Pi from my iMac desktop. I am putting together a "do-it-yourself" solar powered SkyWeather2 starting from the basic Weather Rack2. All of the other sensors are working fine. The HM3301 is from a Solar Wireless Air Quality Sensor kit. As you can see from the picture I sent, it's plugged into the Pi through the Pi2Grover board.I haven't tried getting the HM3301 working as part of the Solar Wireless Air Quality Sensor Kit, but I'm thinking of trying that next.
I am attaching 2 screenshots - one of the freshly booted system, and one showing the startup of pigpiod and testSDL_Pi_HM3301.py.
sudo python3 testDustHM3301.py ./SkyWeather2.JSON File exists b'' b'' <pipio.pi host=localhost port=8888> 21 20 128 -82  Traceback (most recent call last): File "testDustHM3301.py", line 50, in <module> myData = DustSensor.get_data() File "/home/pi/SDL_Pi_SkyWeather2/DustSensor.py", line 146, in get_data myData = hm3301.get_data() File "./SDL_Pi_HM3301/SDL_Pi_HM3301.py", line 85, in get_data self.parse_data(data) File "./SDL_Pi_HM3301/SDL_Pi_HM3301.py", line 74, in parse_data self.PM_1_0_conctrt_std = data<<8 | data IndexError: list index out of range
I think I see what may be a problem. testDustHM3301.py tries to turn on the dust sensor using DustSensorPowerPin, but my only connections are through the single Grove connector. I don't don't have a separate power connection. Doesn't it get its power through the Grove connector? If not, how do I get power to it?
Last Edit: Jul 21, 2021 12:03:48 GMT -8 by chuckjay
Yes, I tried what you suggested. I downloaded a fresh copy of the repository and got the same results using the testDustHM3301.py app - bad read from the HM3301 as if it wasn't there. Do I need to connect a separate pin for power?