Closed ghost closed 7 years ago
Hi,
I haven't seen that error message so far. It seems to be a problem with the Bluetooth LE communication between your RasPi and the sensor. I have it working on a "RaspberryPi W Zero", but I'm not sure if they both use the same Bluetooth hardware...
How far are the RasPi and the Sensor apart? If it's more than 3 meters you might try moving it closer. But apart from that I'm not sure how I can help you there...
Hey, it was indeed an issues with the raspbian image. I've reinstalled it and the bluetooth is now working as it should. However I still cant communicate with the sensors.
If I run it now I get the following:
root@plantgateway:~# plantgateway
[Errno 104] Connection reset by peer
[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
[Errno 104] Connection reset by peer
[Errno 104] Connection reset by peer
[Errno 104] Connection reset by peer
[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B9:06 (otherplant) with reason: Failed to connect to peripheral C4:7C:8D:65:B9:06, addr type: public
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B9:06 (otherplant) with reason: Failed to connect to peripheral C4:7C:8D:65:B9:06, addr type: public
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B9:06 (otherplant) with reason: Failed to connect to peripheral C4:7C:8D:65:B9:06, addr type: public
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
could not read data from C4:7C:8D:65:B9:06 (otherplant) with reason: Failed to connect to peripheral C4:7C:8D:65:B9:06, addr type: public
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
could not read data from C4:7C:8D:65:B9:06 (otherplant) with reason: Error from Bluetooth stack (comerr)
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B9:06 (otherplant) with reason: Error from Bluetooth stack (comerr)
Could not get data from 2sensor(s): Rihanna, otherplant.
the debug log looks like this (over and over):
Sat, 23 Sep 2017 20:00:12 INFO loaded config file from /root/.plantgw.yaml
Sat, 23 Sep 2017 20:00:12 INFO Getting data from sensor Rihanna
Sat, 23 Sep 2017 20:00:14 DEBUG connected to device C4:7C:8D:65:B8:FF
Sat, 23 Sep 2017 20:00:14 ERROR could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/plantgw/__init__.py", line 192, in process_all
self.process_mac(sensor)
File "/usr/local/lib/python2.7/dist-packages/plantgw/__init__.py", line 169, in process_mac
sensor.get_data()
File "/usr/local/lib/python2.7/dist-packages/plantgw/misensor.py", line 34, in get_data
self._fetch_35()
File "/usr/local/lib/python2.7/dist-packages/plantgw/misensor.py", line 52, in _fetch_35
self.peripheral.writeCharacteristic(0x33, bytes([0xA0, 0x1F]), True)
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 502, in writeCharacteristic
return self._getResp('wr')
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 369, in _getResp
resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 332, in _waitResp
raise BTLEException(BTLEException.COMM_ERROR, "Error from Bluetooth stack (%s)" % errcode)
BTLEException: Error from Bluetooth stack (comerr)
I'm using a RaspberryPi W Zero I will try moving them closer (they are about 3m apart)
Edit: after moving them to about 50cm apart nothing has changed. Could it be that I have installed the latest firmware on the sensors?
I have Bluez 5.47 running
I am seeing similar problems on my pi Zero W.... can I ask, which image are you using and how you got it to work with BT ?
I am now seeing the following (but had the "Helper Exited" earlier:
pi@raspberrypi:~ $ plantgateway
Exception ignored in: <bound method Peripheral.__del__ of <bluepy.btle.Peripheral object at 0xb64f0ef0>>
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 520, in __del__
self.disconnect()
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 416, in disconnect
self._writeCmd("disc\n")
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 268, in _writeCmd
self._helper.stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe
I am using the raspbian lite, but I think it could have been because I also updated my raspberry's firmware and then flashed it with pi baker.
I made my own gateway now with this https://github.com/open-homeautomation/miflora and a bit of python code. Its not as fancy as the plantgateway but it gets the job done for me.
You can use the demo.py to see if you can get it working that way.
I'm running:
$ cat /etc/issue
Raspbian GNU/Linux 8 \n \l
$ cat /etc/debian_version
8.0
I guess this was a bug in bluepy: https://github.com/IanHarvey/bluepy/issues/223#issuecomment-343994711
I just updated the requirements to version 1.1.4 of bluepy
I'm experiencing the same after upgrading plantgateway (on a pi2). Bluepy is installed by plantgateway and meets the required version.
Sun, 26 Nov 2017 15:33:28 INFO try 3 of 6: could not process sensor(s) aloevera. Waiting 4 sec for next try
Sun, 26 Nov 2017 15:33:32 INFO Getting data from sensor aloevera
Sun, 26 Nov 2017 15:33:34 DEBUG connected to device XX:XX:XX:XX:XX:XX:XX
Sun, 26 Nov 2017 15:33:34 ERROR could not read data from XX:XX:XX:XX:XX:XX(aloevera) with reason: Error from Bluetooth stack (comerr)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/plantgw/__init__.py", line 195, in process_all
self.process_mac(sensor)
File "/usr/local/lib/python2.7/dist-packages/plantgw/__init__.py", line 172, in process_mac
sensor.get_data()
File "/usr/local/lib/python2.7/dist-packages/plantgw/misensor.py", line 34, in get_data
self._fetch_35()
File "/usr/local/lib/python2.7/dist-packages/plantgw/misensor.py", line 52, in _fetch_35
self.peripheral.writeCharacteristic(0x33, bytes([0xA0, 0x1F]), True)
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 502, in writeCharacteristic
return self._getResp('wr')
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 369, in _getResp
resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 332, in _waitResp
raise BTLEException(BTLEException.COMM_ERROR, "Error from Bluetooth stack (%s)" % errcode)
BTLEException: Error from Bluetooth stack (comerr)
@syphernl that seems to be an issue in bluetooth communication within bluepy. I'm not sure what I can do there. Please file the bug report with https://github.com/IanHarvey/bluepy
@ChristianKuehnel Problem seems to have been that I was using a python2.7 version of Plantgateway (and thus bluepy). Removing and reinstalling using pip3
seems to have fixed the issue!
Hey,
I get the following errors:
hcitool lescan works and I can see the sensors but no go.
bluetoothctl show the following: