Bluetooth binary communication losed bytes - bluetooth

I work on a bluetooth communication between samsung Galaxy tab and a custom device.
On the custom device there is a PIC32 (Microchip) and a bluetooth RN-42. The communication between the PIC and RN-42 is serial (UART).
When I use text protocol all is working fine but with binary protocol the frame sent by the custom device are truncated (8 bytes are missing).
If I add 8 bytes at the end of the frame, complete answer is received by the client.
I have made some tests with several clients (Galxy tab, macbook...) and the result is the same.
I have verified on debug mode than all bytes are sent by the PIC32.
Is someone has encountered this kind of problem ? Any help will be appreciate.

The problem was in the PIC UART configuration.
I have added this line and now it works.
UARTSetFifoMode(UART2, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY);

Related

yj-16009 iBeacon Proximity BLT beacon

I'm making a project with Esp32 whroom, so I bought the yj-16009 iBeacon DataSheet and I'm trying to get it to work as wireless Bluetooth proximity sensor like in this Video
I used the this code from the video and the esp32 is monitoring and showing BLT scanning results like this the results shown are after I turned off any BLT device around so first I don't understand what it is reading, and second after I turn on the iBeacon the results remain with the same range of numbers no matter if I get the iBeacon closer or farther, therefor I came to the conclusion that it doesn't recognize the iBeacon sensor for some reason.
I also download an app named LightBlue which does recognize the iBeacon sensor.
My question is if anyone knows how to make the esp32 recognize the iBeacon sensor. Another thing I tried to find any information about this sensor and there is no info about it anywhere. I have read on other questions here that it might need to be programmed somehow which I don't know how to do because there is no info online. So if anyone is familiar with this kind of sensor and can help me figure how to make the ibeacon to work like the video above as a Bluetooth Proximity device it would be a blessing.
The code you reference is just scanning for any BLE advertisements (iBeacon or otherwise) and printing out the RSSI signal strength of each detection. The reason you do not see the RSSI change when you move the beacon is because the ESP32 is probably picking up non-iBeacon adverts from your phone, laptop and other Bluetooth enabled devices in the vicinity which are not moving (there are more around you than you think!)
In order to make the device detect iBeacon only (and not all the other devices) you need to change the C code to do a few more things:
Access the bytes of the advertisement payload and use them as follows:
Compare the beginning of these bytes to see if they include the iBeacon byte sequence FF 4C 00 02 15
If the above byte sequence is not in the advertising data, ignore that detection — it is not an iBeacon advert
If it does include that byte sequence, decode the next 16 bytes as the iBeacon uuid, the next two bytes as the major and the next two bytes as the minor. See my answer here: What is the iBeacon Bluetooth Profile
Print out the identifiers along with the RSSI that the code already prints.

How to monitor XBee GPIO data through X-CTU console?

I'm using PIR sensor for motion detection and XBee s2c for transmission. The remote(transmitting) XBee, connected to PIR, is configured as below
CE=0
DH=0
DL=0
D4=3
IR=3E8 (500ms)
IC=FF (Change Detection on all pins)
The base(receiving) XBee is configured as below
CE=1
DH=0
DL=FFFF
D4=5
At the base, GPIO4 is connected to an LED. I have performed a simple test as mentioned here to check whether the GPIO is working or not. It's working as mentioned with above given DH & DLs. As D4 is configured to 5, the LED glows all time. Theoretically, whenever PIR sends high, LED should be off and vice-versa. But I am having two problems
The console of remote XBee is not showing any frames being sent but console of base XBee is showing the receiving frames and it is receiving correct data of PIR.
The pin D4 of base is not following the data being received i.e, it stays high all time.
I have observed the frames being received and they are showing the response of PIR as intended. How is the pin D4 not following the frames being received? I have followed this tutorial for DIO lines passing of XBee.
Make sure you're running the 802.15.4 (ATVR=0x20XX) or DigiMesh firmware (0x90XX) and not the ZigBee firmware (0x40XX). Looking at the options in XCTU, I don't think ZigBee firmware supports I/O line passing.
And looking at that knowledge base article, you might need to set ATIT on the remote and ATT4 and ATIA on the base. If those registers aren't available, then you're probably running a firmware version that doesn't support I/O line passing.

bluetooth module HM-15 and Arduino scanning for iBeacons

I bought a HM-15 BLE bluetooth module and successefully connected to Arduino. I am able to sent At commands and I would like to use it for scanning for iBeacons and get their major and minor.
Using AT+DISC? I can see the beacon address but I cannot connect to it and now I am stuck on how to retrieve major and minor
Can you help me? Here is the datasheet of the module:
http://www.elecrow.com/download/bluetooth40_en.pdf
Thanks
Bluetooth beacons do not require a connection and you read the identifiers directly from the advertisement.
Read section 19, Start a discovery scan, and learn how to read and decode the bytes in the discovered peripherals. The exact byte layout varies for different beacon types. For AltBeacon, an open source beacon variant, you can see the byte layout here: https://github.com/AltBeacon/spec
To decode a proprietary beacon format, you will need to learn how that beacon layout differs from the example linked above.
Old question, but just for the record, you can use AT-DISI?
This will scan for beacons, including iBeacons and also AltBeacons. The response from HM-10 will include RSSI for each.
PS: I'm assuming HM-15 and HM-10 operate the same way. Probably not exactly a fully reasonable assumption.

Arduino 1.05 SoftwareSerial Library

I am new to Arduino and I have 2 issues when I tried the BluetoothShieldDemo.
I can only send data from bluetooth module(through serial monitor) to phone but I cannot send from phone to bluetooth module(to display it in serial monitor). I used oscilloscope to check there is signal in the Arduino board RX pin but no data display in the serial monitor. I suspect it is an IO issue so I changed the IO from digital pin 6 and 7 to digital pin 2 and 3, then digital pin 4 and 5. But it is still not working. Then I change the code to use hardware serial (Serial1) and it is working now. I just wonder why it is not working with the SoftwareSerial.
Although I can send and receive data, I cannot change the bluetooth name. The bluetooth module has no response when the below commands are sent. Is it the bluetooth module is in some kind of locked mode? Or the command is different from manufacturer? The bluetooth module that I got has a single CSR 31A2 chip on it. But the other shield that I saw on the web has 2 chips and it is with CSR BC417.
Codes:
blueToothSerial.print("\r\n+STWMOD=0\r\n");
blueToothSerial.print("\r\n+STNA=BluetoothSlave\r\n");
blueToothSerial.print("\r\n+STOAUT=1\r\n");
blueToothSerial.print("\r\n+STAUTO=0\r\n");
delay(2000);
blueToothSerial.print("\r\n+INQ=1\r\n");
Thanks in advance!
1- When using SoftwareSerial, how are you declaring the pins (Input/Output)?, Are you pulling serial data right (giving it enough time between data transmission, but reading at the right time)?
2- Find the datasheet of your module and see what commands does it support.

RN-41 bluetooth and dsPIC

Having a couple of issues with what I was hoping to be fairly straight forward.
I've been transmitting data from my PIC to a PC via RS232 at a baudrate of 115200. I've recently got a RN-41 bluetooth module and was hoping the switch would be as simple as powering the module and connecting the PIC TX (via a max3232) to the RN-41's RX, as the online community has led me to believe.
I'm able to connect to it and pair it to the computer, I'm also able to use PUTTY/Realterm to change the parameters, like the name and baudrate. Finally, by connecting a link to the RX and TX on the bluetooth module and powering it, I'm able to ping text by sending and echoing it using PUTTY, so I'm fairly sure the module isn't broken.
However, when I try to transmit my data from the PIC to the bluetooth module, and view it using realterm (which was working fine with the wired connection) I'm getting data received, but it's not what is expected. I'm expecting a packet of 25 bytes, with a header value of 2, I'm getting around 12-15 bytes and a header of -65.
The first value, -65, is always the same, and the other data can change, which really suggests a baudrate problem, but I've tried a variety of baudrates (changed in my UART code, the bluetooth parameters, and in realterm), and the data doesn't change at all; always wrong.
What have I missed? Anything I need to change in the Bluetooth configurations? I've also checked the parity bit, stop bit, etc, all the same as each other.
The problem was the MAX3232 circuitry. It was necessary for the RS232 connection I was using prior, but when I wanted Bluetooth, which required TTL signals, I was feeding it the same RS232 data!
Making a link straight from the PIC to the Bluetooth receiver solved this problem. Hope this helps someone else in the future!

Resources