Airthings / waveplus-reader

MIT License
133 stars 61 forks source link

Unable to connect #19

Closed nullnullnul closed 4 years ago

nullnullnul commented 4 years ago

By following the tutorial steps, the output in Raspberry Pi3b+ with Rasbian latest is the following:

sudo python2 read_waveplus.py 2930034778 10

Press ctrl+C to exit program

Device serial number: 2930034778 ╭──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──────────────╮ │ Humidity │ Radon ST avg │ Radon LT avg │ Temperature │ Pressure │ CO2 level │ VOC level │ ├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤ Traceback (most recent call last): File "read_waveplus.py", line 221, in waveplus.connect() File "read_waveplus.py", line 137, in connect self.periph = Peripheral(self.MacAddr) File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 361, in init self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 410, in _connect "Failed to connect to peripheral %s, addr type: %s" % (addr, addrType)) bluepy.btle.BTLEException: Failed to connect to peripheral 80:6f:b0:e4:b2:e2, addr type: public

nullnullnul commented 4 years ago

And testing through btle.py: sudo python btle.py 80:6F:B0:E4:B2:E2 Connecting to: 80:6F:B0:E4:B2:E2, address type: public Traceback (most recent call last): File "btle.py", line 786, in conn = Peripheral(devAddr, addrType) File "btle.py", line 361, in init self._connect(deviceAddr, addrType, iface) File "btle.py", line 410, in _connect "Failed to connect to peripheral %s, addr type: %s" % (addr, addrType)) main.BTLEException: Failed to connect to peripheral 80:6F:B0:E4:B2:E2, addr type: public


sudo python btle.py 80:6F:B0:E4:B2:E2 random Connecting to: 80:6F:B0:E4:B2:E2, address type: random Traceback (most recent call last): File "btle.py", line 786, in conn = Peripheral(devAddr, addrType) File "btle.py", line 361, in init self._connect(deviceAddr, addrType, iface) File "btle.py", line 410, in _connect "Failed to connect to peripheral %s, addr type: %s" % (addr, addrType)) main.BTLEException: Failed to connect to peripheral 80:6F:B0:E4:B2:E2, addr type: random

nullnullnul commented 4 years ago

After a reboot, a night rest and powering off bluetooth agents I managed to get one reading. But never received a second one, as error would appear.

sudo bluetoothctl power off power on agent off agent on scan off scan on

After which: sudo python read_waveplus.py 2930034778 60

Press ctrl+C to exit program

Device serial number: 2930034778 ╭──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──── ──────────┬──────────────╮ │ Humidity │ Radon ST avg │ Radon LT avg │ Temperature │ Pressure │ CO 2 level │ VOC level │ ├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──── ──────────┼──────────────┤ │ 27.0 %rH │ 9 Bq/m3 │ 9 Bq/m3 │ 22.4 degC │ 1013.84 hPa │ 645.0 ppm │ 48.0 ppb │ Traceback (most recent call last): File "read_waveplus.py", line 221, in waveplus.connect() File "read_waveplus.py", line 137, in connect self.periph = Peripheral(self.MacAddr) File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 361, in init self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 410, in _connect "Failed to connect to peripheral %s, addr type: %s" % (addr, addrType)) bluepy.btle.BTLEException: Failed to connect to peripheral 80:6f:b0:e4:b2:e2, addr type: public


After which: sudo python read_waveplus.py 2930034778 60

Press ctrl+C to exit program

Device serial number: 2930034778 ╭──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──────────────╮ │ Humidity │ Radon ST avg │ Radon LT avg │ Temperature │ Pressure │ CO2 level │ VOC level │ ├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤ Traceback (most recent call last): File "read_waveplus.py", line 221, in waveplus.connect() File "read_waveplus.py", line 137, in connect self.periph = Peripheral(self.MacAddr) File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 361, in init self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 410, in _connect "Failed to connect to peripheral %s, addr type: %s" % (addr, addrType)) bluepy.btle.BTLEException: Failed to connect to peripheral 80:6f:b0:e4:b2:e2, addr type: public

nullnullnul commented 4 years ago

There seems to be inconsistency and alot of unstability on the connection. The distance is not a factor here, as it works the same from 5cm to 10m.

Sometimes the sensor is able to connect and provide its information, but it never lasts longer than few readings. Then it fails for n amount of times and continues with successful reading.

MartyTremblay commented 4 years ago

It appears that this issue might be related. https://github.com/Airthings/waveplus-reader/issues/14

nullnullnul commented 4 years ago

Can't say I solved it, but I managed to get it to work and with rather stable output by using another code, from https://github.com/hpeyerl/airthingswave-mqtt. The root cause is still unknown, It could have had the Wave Plus device connected to mobile app which might have interfered on something. But either way, now I am collecting data through a set container as MQTT messages.