This project has moved and is read-only. For the latest updates, please go here.

recurring bthConnect() returned -1 error

Sep 27, 2015 at 7:08 PM
just installed SBFspot on a raspberry pi, and initially all seemed to work fine.

after a while, i saw no updates on pvoutput appearing, so i checked if SBFspot was still working, and found out that it now gave a connection error:

CRITICAL: bthConnect() returned -1

restarting the pi seems to sometimes restore connection, but not always.

as seen by lsusb, my BT Dongle should be working fine (Cambridge chipset should work on pi's...)

any suggestions what is going on here?

joost@pilogger ~/scripts $ sudo hcitool inq
Inquiring ...
    00:80:25:24:B4:C5       clock offset: 0x000a    class: 0x001f08
joost@pilogger ~/scripts $ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 007: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 005: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
joost@pilogger ~/scripts $ /usr/local/bin/sbfspot.3/SBFspot -v -finq -nocsv
SBFspot V3.1.2
Yet another tool to read power production of SMA solar inverters
(c) 2012-2015, SBF (https://sbfspot.codeplex.com)
Compiled for Linux (LE) 32 bit

Commandline Args: -v -finq -nocsv
Reading config '/usr/local/bin/sbfspot.3/SBFspot.cfg'
Sun Sep 27 20:00:00 2015: INFO: Starting...
sunrise: 07:31
sunset : 19:23
Connecting to 00:80:25:24:B4:C5 (1/10)
Connecting to 00:80:25:24:B4:C5 (2/10)
Connecting to 00:80:25:24:B4:C5 (3/10)
Connecting to 00:80:25:24:B4:C5 (4/10)
Connecting to 00:80:25:24:B4:C5 (5/10)
Connecting to 00:80:25:24:B4:C5 (6/10)
Connecting to 00:80:25:24:B4:C5 (7/10)
Connecting to 00:80:25:24:B4:C5 (8/10)
Connecting to 00:80:25:24:B4:C5 (9/10)
Connecting to 00:80:25:24:B4:C5 (10/10)
Sun Sep 27 20:03:25 2015: CRITICAL: bthConnect() returned -1
joost@pilogger ~/scripts $
Sep 27, 2015 at 9:51 PM
Edited Sep 27, 2015 at 9:58 PM
dear joost, allow me to raise some questions/remarks about your system (and setup)

jvogels wrote: initially all seemed to work fine.
Sun Sep 27 20:00:00 2015: INFO: Starting...
sunrise: 07:31
sunset : 19:23
Connecting to . . . . . . . . (10/10)
Sun Sep 27 20:03:25 2015: CRITICAL: bthConnect() returned -1

?1? from your info, one can not find which type of inverter is used
-1.a- since the "failure" is encountered after sunset it is not clear whether your inverter will/can reply ??
-1.b- can you be more specifiq on your phrase "all seemd to work fine"
your operation was working fine since: -to-day; -yesterday; -week; -month; ??
-1.c- any other experience in access to your inverter, eg: -SBFspot-on-Windows; -SunExplorer; -. . . ??

?2? for problem solving reasons an "output-log" using the options -d5 -v5 is highly appreciated for
-2-a- one succesfull execution (during daytime)
-2-b- for an unsuccessfull execution
-2-c- if you allow the csv outputs (omit option -nocsv) (for a limited number of executions)
the xxxx-spot.csv file might give some usefull information as well
note: to save the output-log you can use "redirect" to complete the command, the log-files
are written into the "working-directoryfor the command" - example of command
sbfspot.exe -d5 -v5 1>success-log-out.txt 2>success-log-err.txt

?3? about the interaction between RPi and BTdongles <-> Inverters several earlier discussing/issues have been raised
please take the time to read a few
-3.a- for instance, if BT-signal strength is not "at best" (eg obstacles, . . . )
then I did encounter problems with ALL OF MY BTdongles
for most of them a HARD reset (physical unplug) was needed to reestablish connections
with good connection "most of my BT dongles remain operational for several weeks
-3.b- you indicated the chipset of your dongle,
can you inform on the type of BTdongle, and control whether it is part of the list of known good working brands

kr wim
Sep 28, 2015 at 11:19 AM
Edited Sep 28, 2015 at 2:07 PM
  1. I have a SMA SB-2000-HF 30 inverter.
1.a:
It also happens today, when the inverter is awake

1.b:
As said, i installed SBF spot yesterday (clean install, no upgrade).

The exe script works fine when started manually, and the daemon uploaded the data to pvoutput. Also, some of the cron scheduled runs of SBFtool did result in connection and data stored. But after a short while, nothing gets stored, and when running SBFtool manually, the CRITICAL: bthConnect() returned -1 error appears.

When i reboot the pi, bluetooth connection is restored again, but it will only work for about 1-3 runs, and then the error appears again, and after that, no reconnection is possible so it seems.

1.c before using this, i used another windows program called SUNNYlog, using the same bluetooth dongle.

2.
i have made both (success and failure) txt files, but unfortunately, the success log is too long to post here directly. Is it possible, and if yes, how do i attach files to this forum thread?

3a. in the success log, BT strenght is given: 63% signal strenght in most cases
3b. It is a Logilink BT dongle, with this chipset: 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) I already have this dongle for quite some time, so i'm not sure what exact type it is. i guess i't just the BT 2.0 version though...

edit: ran detailed info on it:

Device: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 224 Wireless
bDeviceSubClass 1 Radio Frequency
bDeviceProtocol 1 Bluetooth
bMaxPacketSize0 64
idVendor 0x0a12 Cambridge Silicon Radio, Ltd
idProduct 0x0001 Bluetooth Dongle (HCI mode)
bcdDevice 52.76
iManufacturer 0
iProduct 2
iSerial 0
bNumConfigurations 1

This is the info hcitool gives when it stopped working:
joost@pilogger ~/scripts $ hciconfig -a
hci0: Type: BR/EDR Bus: USB
    BD Address: 00:15:83:48:5D:BE  ACL MTU: 384:8  SCO MTU: 64:8
    UP RUNNING
    RX bytes:427 acl:0 sco:0 events:22 errors:0
    TX bytes:100 acl:0 sco:0 commands:20 errors:2
    Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
    Packet type: DM1 DH1 HV1
    Link policy:
    Link mode: SLAVE ACCEPT
    Name: 'Bluetooth2.1+EDR CLASS1'
    Class: 0x000000
    Service Classes: Unspecified
    Device Class: Miscellaneous,
    Can't read version info hci0: Connection timed out (110)
and this is the info after a reboot:
joost@pilogger ~ $ hciconfig -a
hci0: Type: BR/EDR Bus: USB
    BD Address: 00:15:83:48:5D:BE  ACL MTU: 384:8  SCO MTU: 64:8
    UP RUNNING PSCAN
    RX bytes:1377 acl:0 sco:0 events:61 errors:0
    TX bytes:1238 acl:0 sco:0 commands:61 errors:0
    Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x59 0x83
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
    Link policy: RSWITCH HOLD SNIFF PARK
    Link mode: SLAVE ACCEPT
    Name: 'pilogger-0'
    Class: 0x420100
    Service Classes: Networking, Telephony
    Device Class: Computer, Uncategorized
    HCI Version: 2.1 (0x4)  Revision: 0x149c
    LMP Version: 2.1 (0x4)  Subversion: 0x149c
    Manufacturer: Cambridge Silicon Radio (10)
looks like the BT dongle "crashes" after encountering some error.

Unplugging the BT adapter and replugging does not work for me, the pi won't "hotplug" this adapter, maybe because i plugged it into a powered USB-hub? Only restarting seems to do the trick...
Sep 28, 2015 at 4:55 PM
Hello,

Questions: What model of Raspberry PI are you using? RPi B, RPi B+ or RPi 2? What OS are you running? Forgive me if this info is in the thread and I missed it.


Regards,
Ron
Sep 28, 2015 at 8:14 PM
Unplugging the BT adapter and replugging does not work for me, the pi won't "hotplug" this adapter, maybe because i plugged it into a powered USB-hub? Only restarting seems to do the trick...
Try it without the hub first.
Sep 28, 2015 at 10:00 PM
What model of Raspberry PI are you using? RPi B, RPi B+ or RPi 2?
I use a model B, with raspbian

@SBF i will try that, but it wont be a good fix, as the dongle seems to stop working properly at least 5 times a day...

My signal strenght is btw not all too good ~60-65%, and my pi is quite some distance away from the inverter (inverter at the attic, Pi in the shed in my backyard ~ 9 meters apart). Cannot do anything about that though, as in my shed i have a Soladin 600 inverter that i also want to log using this pi. That inverter uses rs232 connection, so i have to be close to that inverter. After all, wouldnt it be overkill to use two raspberry pi's on similar, rather low demanding jobs?

I can try to buy another dongle, but i only want to do that if i am sure that this is a non-compatible BT dongle, and buying another one is going to solve the problem.
Sep 28, 2015 at 10:16 PM
SBF wrote:
Unplugging the BT adapter and replugging does not work for me, the pi won't "hotplug" this adapter, maybe because i plugged it into a powered USB-hub? Only restarting seems to do the trick...
Try it without the hub first.
plugging it in the pi directly does bring it back up again, so no i will have to see whether this fixes the issues...
Sep 29, 2015 at 12:37 AM
Hi,

Two things. First, the signal level is too low. I have found from experience that anything below 70% will be intermittent at best.
The RPi really needs to be much closer to the SMA inverter. You could use a RS232 repeater for the other inverter. But really, why go to the expense of a repeater when a second RPi is less expensive. I'm fortunate to live near a Micro Center computer store. They sell the RPi 2 for $25 USD. It always nice to have another toy :)


Second, the Bluetooth adapter needs to be plugged in directly in the RPi B on the bottom port (I don't remember why).

Have you preformed a: sudo apt-get update
sudo apt-get upgrade
lately?


73
Ron / W4MMP
On 9/28/2015 17:01, jvogels wrote:

From: jvogels

What model of Raspberry PI are you using? RPi B, RPi B+ or RPi 2?
I use a model B, with raspbian

@SBF i will try that, but it wont be a good fix, as the dongle seems to stop working properly at least 5 times a day...

My signal strenght is btw not all too good ~60-65%, and my pi is quite some distance away from the inverter (inverter at the attic, Pi in the shed in my backyard ~ 9 meters apart). Cannot do anything about that though, as in my shed i have a Soladin 600 inverter that i also want to log using this pi. That inverter uses rs232 connection, so i have to be close to that inverter. After all, wouldnt it be overkill to use two raspberry pi's on similar, rather low demanding jobs?

I can try to buy another dongle, but i only want to do that if i am sure that this is a non-compatible BT dongle, and buying another one is going to solve the problem.

Sep 29, 2015 at 11:25 AM
dear joost, as ron is stating the signal strength is not good enough

i recommend that you look in the various discussions point about BT problems on the forum,
-a- my simple solution for the distance was to use an USB extension cable (a good one of 5meter cost you <11Euro)
  be aware for obstacles and position of BTdongle towards the inverter,
-b- be aware that we experienced for several dongles, hence the list in "documentation" that they lack "long-term" stability
  long-term meaning fault free in continious operation during > 5days
-c- if you can find/buy a class1 dongle that is in the list,
 don't wait -> it will avoid wasting time  (from experience class1 works fine upto 18meters)
note: it is a pitty that you can not identify the type of your BT-dongle (from your information it is a class2 and not a class1)
  • from experience a class2 (class2 indicates send-power of dongle - ) ( (class2 =/= as BT2.0)
    should be used with a distance below 4meter (direct view)
sending files from a discussion is not an option,
-e- you can use private e-mail instead, be aware that not all members have their email address in public

kr wim
Sep 29, 2015 at 7:33 PM
rlpatton wrote:
Hi, Two things. First, the signal level is too low. I have found from experience that anything below 70% will be intermittent at best. The RPi really needs to be much >closer to the SMA inverter. You could use a RS232 repeater for the other inverter. But really, why go to the expense of a repeater when a second RPi is less >expensive. I'm fortunate to live near a Micro Center computer store. They sell the RPi 2 for $25 USD. It always nice to have another toy :) Second, the Bluetooth >adapter needs to be plugged in directly in the RPi B on the bottom port (I don't remember why). Have you preformed a: sudo apt-get update sudo apt-get >upgrade lately?
I have updated the install (apt-get update && apt-get upgrade) right after writing a fresh raspbian on the card, so yes, my raspbian is up-to date. One oftion is ofc to buy my third raspberry pi, (one model B is acting as a BTsync fileserver for about two years now, without any glitches, this one i bought for PV logging purposes specifically, but i actually think that i should log my "smart electricity/gas consumption meter" as well, and that one is yet in another location (basement), with only P1 connection... So yes, that is an option if all else fails...

SillieWimons wrote:
dear joost, as ron is stating the signal strength is not good enough

i recommend that you look in the various discussions point about BT problems on the forum,
-a- my simple solution for the distance was to use an USB extension cable (a good one of 5meter cost you <11Euro)
  be aware for obstacles and position of BTdongle towards the inverter,
-b- be aware that we experienced for several dongles, hence the list in "documentation" that they lack "long-term" stability
  long-term meaning fault free in continious operation during > 5days
-c- if you can find/buy a class1 dongle that is in the list,
 don't wait -> it will avoid wasting time  (from experience class1 works fine upto 18meters)
note: it is a pitty that you can not identify the type of your BT-dongle (from your information it is a class2 and not a class1)
  • from experience a class2 (class2 indicates send-power of dongle - ) ( (class2 =/= as BT2.0)
    should be used with a distance below 4meter (direct view)
sending files from a discussion is not an option,
-e- you can use private e-mail instead, be aware that not all members have their email address in public

kr wim
I read the other issues, so i know that bad reception is the problem to focus on.
I don't understand why one bad reception event (iow: 10 failed attempts) results in the total disruption of the logging cycle, and the apparent "crash" of the BT dongle.

Shortening the distance by using a USB extension cable is not really an option: The SMA inverter is high up in the attic (inverting the power from the solar panels on the roof) , the Soladin 600 is actually outside of the house, in the shed (fyi; i bought a second installation and installed that myself on my shed in the backyard; 640 Wp CIS panels placed on a shed measuring 2*3 meters, that's what i call efficient use of roof space ;) )

You identified the class by this code?
  Class: 0x420100
I thought this info gave the class;
  bDeviceSubClass 1 Radio Frequency
Please confirm this, cannot find anything googling the internet.
If so, the best and cheapest solution is indeed to buy a BT dongle from the list in the documentation part.

...and decide within a month to buy another Pi to monitor my power and gas consumption as well... ;) if anybody knows about a good open source project for monitoring smart meters, please let me know
Oct 4, 2015 at 10:03 PM
For some reason, i have a stable connection with my inverter for several days now (sept 29th onwards). So maybe, it will work out fine with this setup as well after all...
Oct 5, 2015 at 9:17 AM
dear joost, -not to be negative, but from experience -> it might function well for more then a week - then ??? failure after failure - i'll cross fingers for you
QUOTE:
I don't understand why one bad reception event (iow: 10 failed attempts) results in the
total disruption of the logging cycle, and the apparent "crash" of the BT dongle.
!!! The crash of the BTdongle is the cause -> this results in failing attempts
one has not yet found a fail-proof "set-of-commands" that does reset the BT-dongle

about class1 or class2
-Cambridge Silicon Radio had two chipsets in use for the BTdongles - one is class2 - the other class1
-Logilink had several BTdongles available (i'm using the BT0009 since 3years - it delivers perfect communication)

kr wim