Bluetooth/Wifi data into bubble

Hello community,

In my project I have to extract data coming from sensors in a hardware. The data collect will have multiple entries during the day. How to set up a connection between the Bubble mobile app and the hardware properly and store in the bubble database.

That’s going to have to be via an API call.
You can expose a backend workflow as an API call that expects your sensor data as a JSON.

I’ve done this a ton with ESP8266 and ESP32 systems - also with a RPi Zero. Works like a charm.
There’s no way to set up a realtime data stream to Bubble via something like sockets or UDP though. HTTP is the only way!

2 Likes

So the external device is basically just sending a stream of webhooks to the app?

Yup. Depends on the use case really, but one API call every few seconds or a few times a minute usually does the trick.

1 Like

your comment was interesting and may lead to a solution for one app that i am building.

do you think that this approach could be used to connect to + check if the a specific device (mobile phone) is paired via bluetooth with another device (sound system)?

if so, could you please ellaborate or give some hint on how to implement that?

Yes, that can be done

It does have some security concerns, so please be careful about those as you use such a functionality.

There is a way to do this using the browser’s Bluetooth API - this works differently for different browsers though.

  1. Create a button with id ‘getDevices’

  2. Then add an HTML element and dump this code into it:

     <ul id="deviceList"></ul>
     <script>
     document.getElementById('getDevices').addEventListener('click', async () => {
     try {
         const device = await navigator.bluetooth.requestDevice({
             acceptAllDevices: true
         });
    
         const ul = document.getElementById('deviceList');
         const li = document.createElement('li');
         li.textContent = `Name: ${device.name}, Id: ${device.id}`;
         ul.appendChild(li);
     } catch (error) {
         console.error('Bluetooth Error:', error);
     }
    });
    
    </script>
    

This should show a list of Bluetooth devices available when you click the button.

More details:

1 Like