chuckjay
New Member
Posts: 22
Raspberry Pi: Yes
Other Device: MacIntosh, Arduino
|
Post by chuckjay on Jul 14, 2021 10:13:21 GMT -8
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?
Thanks, chuck Barker
|
|
|
Post by SDL on Jul 14, 2021 10:21:10 GMT -8
Chuck,
Somehow you have the wrong pins wired into the HM3301. D21/D26 connects GPIO 21 and GPIO 26, not 20/21.
Get the test program working. Make sure the pins are set up in the test program and communicated to the HM3301 driver.
BP
|
|
chuckjay
New Member
Posts: 22
Raspberry Pi: Yes
Other Device: MacIntosh, Arduino
|
Post by chuckjay on Jul 14, 2021 11:03:42 GMT -8
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.
|
|
|
Post by SDL on Jul 14, 2021 15:33:42 GMT -8
mySDA = 21 mySCL = 20 from the HM3301 test program.
You are starting the pigpio library as shown in the README.md? If you don't do that, nothing will work.
BP
|
|
chuckjay
New Member
Posts: 22
Raspberry Pi: Yes
Other Device: MacIntosh, Arduino
|
Post by chuckjay on Jul 15, 2021 6:40:30 GMT -8
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[4]<<8 | data[5] IndexError: list index out of range
|
|
|
Post by SDL on Jul 17, 2021 7:31:19 GMT -8
Are you running pigpiod?
Please post your code for testSDL_Pi_HM3301.py so I can check the mapping and post a picture of the Pi showing the entire grove cable from the Pi2Grover to the HM3301.
Thanks!
BP
|
|
chuckjay
New Member
Posts: 22
Raspberry Pi: Yes
Other Device: MacIntosh, Arduino
|
Post by chuckjay on Jul 17, 2021 8:52:02 GMT -8
 testSDL_Pi_HM3301.py: # test HM3301 Laser Dust Sensor # must run "sudo pigpiod" before starting import SDL_Pi_HM3301 import time import traceback import pigpio mypi = pigpio.pi() mySDA = 21 mySCL = 20 hm3301 = SDL_Pi_HM3301.SDL_Pi_HM3301(SDA=mySDA, SCL=mySCL, pi=mypi) time.sleep(0.01) try: while 1: myData = hm3301.get_data() print ("data=",myData) if (hm3301.checksum() != True): print("Checksum Error!") myAQI = hm3301.get_aqi() hm3301.print_data() print ("AQI=", myAQI) time.sleep(3) except: print ("closing hm3301") print(traceback.format_exc()) hm3301.close()
|
|
|
Post by SDL on Jul 19, 2021 18:39:20 GMT -8
That looks perfect. I see you are running a Pi Zero W, but it should still work.
Is everything else reporting?
Now, do a screen shot after a reboot, starting up pipgiod and then running the test program. I want to see it all.
BP
|
|
chuckjay
New Member
Posts: 22
Raspberry Pi: Yes
Other Device: MacIntosh, Arduino
|
Post by chuckjay on Jul 20, 2021 6:55:25 GMT -8
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. Thanks for your help, chuck Barker Attachments:

|
|
|
Post by SDL on Jul 20, 2021 7:08:45 GMT -8
OK, I duplicated your problem. Looks like there is a problem with the SDL_Pi_HM3301 library. I'll add it to the bug list. However, I think the dust sensor works correctly. Go into the SDL_SkyWeather2_Pi directory and run: pi@SwitchDocLabs:~/SDL_Pi_SkyWeather2 $ sudo python3 testDustHM3301.py SkyWeather2.JSON File does not exist testDustHM3301.py:19: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings. GPIO.setup(config.DustSensorPowerPin, GPIO.OUT) b'' b'' data= [2, 3, 3, 2, 3, 3] PM1.0 Standard particulate matter concentration Unit:ug/m3 = 2 PM2.5 Standard particulate matter concentration Unit:ug/m3 = 3 PM10 Standard particulate matter concentration Unit:ug/m3 = 3 PM1.0 Atmospheric environment concentration ,unit:ug/m3 = 2 PM2.5 Atmospheric environment concentration ,unit:ug/m3 = 3 PM10 Atmospheric environment concentration ,unit:ug/m3 = 3 AQI= 12
See what that does. Also, make sure you are using the HM3301 repository. The SkyWeather2 copy may be out of date. github.com/switchdoclabs/SDL_Pi_HM3301BP
|
|
chuckjay
New Member
Posts: 22
Raspberry Pi: Yes
Other Device: MacIntosh, Arduino
|
Post by chuckjay on Jul 21, 2021 12:01:38 GMT -8
I'm getting the same sort of results:
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[4]<<8 | data[5] 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?
|
|
|
Post by SDL on Jul 22, 2021 7:43:55 GMT -8
Did you try this?
Also, make sure you are using the HM3301 repository. The SkyWeather2 copy may be out of date.
github.com/switchdoclabs/SDL_Pi_HM3301
BP
|
|
chuckjay
New Member
Posts: 22
Raspberry Pi: Yes
Other Device: MacIntosh, Arduino
|
Post by chuckjay on Jul 22, 2021 11:54:08 GMT -8
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?
|
|
|
Post by SDL on Jul 22, 2021 13:31:22 GMT -8
No, you shouldn't. Here is a picture of my test setup that worked. BP Attachments:
|
|