MAXREFDES100传感器数据BLE传输存储及PC连接技术咨询
Answers to Your MAXREFDES100 BLE Data Questions
Hey there! Since you're new to this space, let's walk through each of your questions clearly and practically:
1. How to store real-time BLE sensor data on a mobile device?
The official app only lets you monitor data, so you have two solid options here:
- Use a third-party BLE tool with export features: Apps like nRF Connect for Mobile or LightBlue Explorer let you connect to your MAXREFDES100, subscribe to sensor data characteristics, and export the received data to a CSV file directly to your phone's storage. This is a quick way to test without writing code.
- Build a simple Android app for custom storage: If you need more control (like automatic background storage or custom formatting), you'll want to use Android Studio with the BluetoothGatt API. Here's a rough breakdown of the steps:
- Request necessary permissions:
BLUETOOTH_SCAN,BLUETOOTH_CONNECT, and storage permissions (useWRITE_EXTERNAL_STORAGEfor older Android versions, orMediaStorefor Android 10+). - Scan for and connect to the MAXREFDES100's BLE device (look for its default name or use its service UUID from the official docs).
- Subscribe to the sensor data characteristic (each sensor has a specific UUID—check the MAXREFDES100 HDK manual for these).
- In the
onCharacteristicChangedcallback, capture the raw data, convert it to a readable format (like CSV lines), and write it to a file.
- Request necessary permissions:
Here's a quick code snippet for the file-writing part:
// Inside the BluetoothGattCallback's onCharacteristicChanged method @Override public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { super.onCharacteristicChanged(gatt, characteristic); byte[] rawSensorData = characteristic.getValue(); // Convert raw bytes to a CSV-friendly string (adjust based on your sensor's data format) String dataLine = String.format("%d,%d,%d\n", rawSensorData[0], rawSensorData[1], rawSensorData[2]); // Write to a file in your app's private storage (no extra permissions needed here) try (FileOutputStream fos = getApplicationContext().openFileOutput("sensor_data.csv", Context.MODE_APPEND)) { fos.write(dataLine.getBytes()); } catch (IOException e) { e.printStackTrace(); } }
2. Can I transfer data directly to a PC via BLE instead of USB?
Absolutely! Modern PCs (Windows 10+, macOS, most Linux distros) have native BLE support. You have a few options:
- Third-party desktop tools: nRF Connect for Desktop (Windows/macOS/Linux) or LightBlue (macOS) let you scan, connect, subscribe to characteristics, and export data to files. This is the fastest way to get started without coding.
- Custom PC script: If you want automation, use a library like
bleak(Python, cross-platform) to write a simple BLE client. Here's a minimal example:
from bleak import BleakClient, BleakScanner import asyncio # Replace with your MAXREFDES100's sensor service and characteristic UUIDs SENSOR_SERVICE_UUID = "0000ffe0-0000-1000-8000-00805f9b34fb" SENSOR_CHAR_UUID = "0000ffe1-0000-1000-8000-00805f9b34fb" async def collect_sensor_data(): # Scan for the device devices = await BleakScanner.discover() target_device = next((d for d in devices if "MAXREFDES100" in d.name), None) if not target_device: print("Device not found!") return # Connect and subscribe to data async with BleakClient(target_device.address) as client: print(f"Connected to {target_device.name}") def data_callback(sender, data): # Convert raw bytes to a string and append to file with open("pc_sensor_data.csv", "a") as f: f.write(f"{data.hex()}\n") await client.start_notify(SENSOR_CHAR_UUID, data_callback) # Keep the script running until you press Enter input("Press Enter to stop collecting data...") await client.stop_notify(SENSOR_CHAR_UUID) asyncio.run(collect_sensor_data())
Just make sure your PC's BLE adapter is enabled, and the MAXREFDES100 is within range.
3. Is there open-source code available? If not, do I need to write scripts for both Android (storage) and mbed (board)?
Open-source options first:
- Check GitHub for projects tagged with
MAXREFDES100andBLE—you'll find community-built Android/Python clients, and even modified mbed firmware examples. Maxim also hosts official mbed OS firmware for the MAXREFDES100 on their mbed page, which already includes BLE support for sensor data transmission. You probably won't need to rewrite the board-side code from scratch unless you want to customize data formatting or sampling rates.
If you need to build from scratch:
- Board side (mbed): The official mbed firmware already handles sensor reading and BLE broadcasting. You can tweak it to adjust which sensors are active, how often data is sent, or the data packet format. The key parts are initializing the sensors (like MAX30001 for biopotentials, MAX86150 for accelerometer), reading their data, and writing it to the BLE characteristic to trigger notifications.
- Mobile side (Android Studio): As mentioned in question 1, you'll need a simple BLE client app to connect, subscribe, and store data. You don't need a fancy UI—even a basic activity with background data collection will work.
Pro tips for beginners:
- Start with third-party tools (nRF Connect) to confirm BLE data is being sent correctly before writing code.
- Get the PC-side Python script working first—it's easier to debug than Android code.
- Keep the MAXREFDES100 HDK manual handy—it lists all BLE service/characteristic UUIDs and sensor register details, which are critical.
内容的提问来源于stack exchange,提问作者NikaY
相关产品推荐
相关产品推荐

