zapshe
Posts: 7
Joined: Tue May 04, 2021 10:45 pm

High Latency with Bluetooth Modules

Sat May 15, 2021 6:10 am

Hello!

I've been using a setup where I hook up a motion sensor and I find out if it has been tripped at a distance through 2 bluetooth modules connected to each other.

The setup is:

Motion sensor detects movement -> Signal is sent to Bluetooth module (through RX) -> Bluetooth module transmits to the other Bluetooth module -> Bluetooth module informs Raspberry Pi Pico (via TX/RX) -> Pico lights an LED.

This setup gives me about 1.4 seconds of latency. However, this slightly different setup is a lot faster:

Motion sensor detects movement -> Signal is sent to Raspberry Pi Pico -> Pico sends data to Bluetooth module (via RX) -> Bluetooth module transmits to the other Bluetooth module -> Bluetooth module informs 2nd Raspberry Pi Pico (via TX/RX) -> Pico lights an LED.


This one has a very reasonable delay (less than .5 seconds). However, this one requires using 2 Pico microcontrollers!

The first setup works perfectly, with the bluetooth module recognizing the "high" output given by the motion sensor into its RX pin and sending some garbage data to the other bluetooth module. Since I only care whether the motion sensor detected movement, what the bluetooth module actually sends out is irrelevant, its only important that it *does* send something out.


Something about the motion sensor makes the delay about 1.5 seconds. My guess is that the delay is caused by the fact that the motion sensor stays "high" for about a second after it detects movement. As soon as the motion sensor goes back down to low, that's when it seems that the Bluetooth module transmits the data.

Is there some way to take in a "high" signal and only transmit a high signal for a split second even though the original source of the signal is still outputting a high signal? A clock maybe?

Any help is appreciated,
Thanks!

zapshe
Posts: 7
Joined: Tue May 04, 2021 10:45 pm

Re: High Latency with Bluetooth Modules

Sat May 15, 2021 7:59 am

So far, I've been looking at getting a Pulse Generator along with an AND logical gate so that the signal to the Bluetooth module lasts only a split second. However, a raspberry pi pico costs only about $10 if you include shipping, and the Generator and AND gate are very cheap but shipping costs bring them to about $10.

If there are ideas on alternatives, that would be appreciated. The equipment I have available is what you can see here:

https://www.banggood.com/Geekcreit-Elec ... rehouse=CN

hippy
Posts: 9926
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: High Latency with Bluetooth Modules

Sat May 15, 2021 3:27 pm

zapshe wrote:
Sat May 15, 2021 6:10 am
Motion sensor detects movement -> Signal is sent to Bluetooth module (through RX)
I would guess the Bluetooth module is expecting to see serial data on its RX pin. So, if you simply provide a high/low signal to RX, it is not certain what will happen, how long it will take to happen.

Using a Pico to detect the signal from the motion sensor and send serial data to Bluetooth RX probably is the best way to do things.

zapshe
Posts: 7
Joined: Tue May 04, 2021 10:45 pm

Re: High Latency with Bluetooth Modules

Sat May 15, 2021 8:22 pm

You're right of course hippy. It's just that the Pico is so versatile and capable that it seems like a waste to have it do something so simple.

I've actually ordered the NE555 chip which I think will work. By setting up the NE555 chip and then providing the motion sensor's data-out as the VCC, I'm hoping it'll pulsate data through the Bluetooth module when the motion sensor gives a "high" output.

If it turns out that this method is unreliable for Bluetooth communication then I'll unfortunately integrate a second Pico.


Any suggestions on simple alternatives are still welcome. It'll take a few days for the NE555 chip to arrive, and I'll still be taking a few cracks at it.

User avatar
nick.mccloud
Posts: 1227
Joined: Sat Feb 04, 2012 4:18 pm

Re: High Latency with Bluetooth Modules

Sat May 15, 2021 9:10 pm

zapshe wrote:
Sat May 15, 2021 8:22 pm
Any suggestions on simple alternatives are still welcome. It'll take a few days for the NE555 chip to arrive, and I'll still be taking a few cracks at it.
Using a 555 to waggle the Rx lead isn't much better than just pulling it high or low, it's still incomprehensible garbage that is likely to cause the module pause.

As you've demonstrated with the Pico, driving the BT module as designed is a much better idea. I'd not waste a Pico on such trivia either - you could use an Arduino supported 8 pin ATtiny. Or PIC Assembly if you want to go hard-core.
Pico/RP2040 ≠ Arduino
Pico = hot rod kit car, Arduino = hot rod kit car wrapped in cotton wool with buoyancy aids & parachute

zapshe
Posts: 7
Joined: Tue May 04, 2021 10:45 pm

Re: High Latency with Bluetooth Modules

Sat May 15, 2021 11:16 pm

Using a 555 to waggle the Rx lead isn't much better than just pulling it high or low, it's still incomprehensible garbage that is likely to cause the module pause.
I actually just tested it with a switch. As soon as an LED lights up indicating that the motion sensor has detected movement, the Pico on the receiving end gets the data as soon as I press a switch which forcibly terminates the "high" signal from the master Bluetooth module. This confirmed my suspicion that the latency is caused due to the Bluetooth module waiting for the "high" signal to disappear before transmitting anything.

So far, there has not been a single occasion where the motion sensor detected motion and the Bluetooth module didn't send out some kind of data (the data itself here doesn't matter). So it seems reliable enough for what I plan to use it for. So I think the NE555 will actually work perfectly for this issue, but we'll see when I test it!


For now, I'm trying to find an alternative to waiting a few days for the NE555 to arrive. However, I feel powerless against this high signal without the proper IC chips for logic control :(


EDIT:

I could have use something else like an ATtiny5 that you've suggested, but I didn't know about it existed until you mentioned it. I don't have anything like that handy and I've already purchased the NE555. These chips are very cheap, but shipping costs makes it unpractical to keep buying IC chips!

zapshe
Posts: 7
Joined: Tue May 04, 2021 10:45 pm

Re: High Latency with Bluetooth Modules

Thu May 20, 2021 5:27 am

Just an update, I received my 555 timers and used one for this project. It works perfectly, with the delay being exactly the same as if if I had the pico connected to it. I'm glad it worked..!

Because the timer is so capable (and because of how cheap it is compared to its shipping cost..) I decided to buy 3 of them, the other 2 will likely come in handy in a future project.

Thanks for all the advice :)

Return to “General”