Bluetooth logging

Started by HamzaHajeir, December 02, 2020, 09:34:18 AM

HamzaHajeir

Hi

I've read this topic and decided to open a new topic, as advised.
https://lowpowerlab.com/forum/currentranger/bluetooth-logger/

I've a similar issue, Despite I can't connect it to PC because I don't have Bluetooth hardware. Then Fell into using Bluetooth module as receiver, Which then couldn't be a master because it's HC-06 << Some issue to solve lol.

But I've configured HC-06's (labeled ZS-040) baud rate to 230400, Then attached it to CR, Powered On CR, then connected to it from Mobile app (Serial Bluetooth Terminal).

It connects,
But I don't receive any data there. Where could be the issue ?

Note: I've tested the connection between Phone app and PC (when HC-06 connects to it via USB-TTL Converted).

Felix

Upon startup, the CR executes an "AT" command query to this bluetooth serial header, if it receives an "OK" response back within one second timeframe, then it will automatically start logging the sampled values to this serial header. If does this check 2 ways, with and without line ending (crlf characters). This has been confirmed to work with generic HC-06 bluetooth modules that implement the AT command interface.

There are some debug messages printed to the USB serial port upon the completion of this check. It will let you know if the BT module was found and the OK response received.
So I would check this USB output during startup to see what is going on.

mrTheWheel

I had the same problem.

Connected to a FTDI adapter the HC-06 response to the "AT" string is "OK" (both without "\r\n"). Exactly as tested in the code.
Still, using the USB menu entering 'b' reply's with "no bluetooth module found" (or something like that).
I now have changed the code to always set BT_found to "true" and than bluetooth logging works like a charm.

Just my 5 cents

Felix

Do you think this is about the timing of the AT and the OK response?
If so, then it means these generic HC06 modules are more different from vendor to vendor than initially expected.

mrTheWheel

QuoteDo you think this is about the timing of the AT and the OK response?

I don't think so. The response to the "AT" string is instantaneous and nothing happens "in between".

I wonder why the code is there at all. You can switch bluetooth logging "off" and "on" by the USB menu. Maybe switch BT_found to "true" or "false" depending on that choice. In that case the CR will work with most bluetooth devices (both slave ánd master").

HamzaHajeir

For USB connecting, I've read the doc and I have a missing important part to connect CR to USB : USB Isolator.

So I'm thinking of work-arounds like running stm32 to act as BT-06, and control real BT-06. I guess it's prohibited to power it with external battery to not create ground loops, And just stick to the CR battery. Is that right ?

[email protected]

Hi,
i'm new in this forum,
I face the same probleme with HC06 recently bought, what i thing after lot of tests, the 3V power supply from DR is not enough, with external 5V its working fine.
Is any possibility to supply it from Vin? where we can pick up Vin on board?

I also observe sometime DR doesn't sent AT but AP, maybe a speed probleme?

Thanks

Felix

Ugh  :'( :(
The HC06 used to work just fine on the 3.3v regulated output on the header. Not anymore?
USB isolation is not necessarily required depending how you have your CR connected.

I'm going to stop recommending this chinese HC06 garbage in any future releases, its causing more problems than it's worth the trouble, USB is far faster anyway.
You could use an external USB-serial adapter with that BT header but then you're in the same position as connecting straight to USB.

And a warning:
Be very careful how you connect various external things to the CR, don't randomly or experimentally combine grounds and voltages to power things attached to the CR, or you can damage it. Have a full understanding  or how the device works and read the guide warnings before doing things like that.

HamzaHajeir

Quote from: Felix on December 06, 2020, 11:13:25 AM
USB isolation is not necessarily required depending how you have your CR connected.

To tide things up in my head: If I connected the DUT to Input terminals, CR powered by battery, and used USB interface, Does that create ground loops ? Or is it dangerous thing to do ?

What If I used BT Header and left +3.3V unconnected, Does that help in any way ?

Felix

#9
So your DUT works without any energy?  :o

If its battery powered then it's OK. Otherwise if you have an isolated PSU it's also OK. If an earth grounded PSU then it becomes tricky because your USB/PC is also earth grounded, and the CR is not common earth ground between the input and USB, causing a potential ground loop through it.

Read the guide for more details, I will not repeat it here.

HamzaHajeir

Quote from: Felix on December 06, 2020, 06:29:29 PM
So your DUT works without any energy?  :o
If its battery powered then it's OK.
Read the guide for more details, I will not repeat it here.

We're breaking physics  :P  8)

That's more clear to me now, So there's a way to -at least- program the CR for BT purposes. ;)
And another way to log via Serial while DUT is Battery operated.

Thanks, And I'll feedback any useful info to this thread.


peteb

Felix, wrt the HC-06, I think this is a startup timing issue.

I had no problems with earlier firmware but the latest firmware was failing to detect the HC06. I ended up adding a soft-reset option to the menu - just calls setup() - and that resulted in a successful detection after any soft-reset. Hence suspected a timing problem. So I added a delay() just before the BT detection code (i.e. before setting baud rate/sending "AT"). With a 200ms delay it always failed to detect but with 500ms it always worked. Ended up adding a delay(1000) to be on the safe side. Been good since.

Felix

peteb,
Thanks, good to know, I made that change in the code.

HamzaHajeir

Flashing CR with newest code solves the issue well!..


DanHam

Is there a way to calibrate the UART talking to the BT HC06?  I was trying to debug why the CR would not communicate with the HCC06 and realize the baud rate is ~2142000 not 230400 testing this on with another MCU if the Baud rate is reduced this much the HC06 will not respond.