I can't find example how to do BLE pairing with Seeed XIAO nrf52840 board. It doesn't matter to me if it will be Arduino or Circuitpython libraries. Is there something like this somewhere?
I would like to use this board for my project, but would like to ensure that anyone cannot read or change values in the BLE services.
My idea of use is that on the server side I select the device I want to pair with and on the device side I confirm the pairing manually e.g. with a button. From that point on, the server can then communicate with the unit and read or change its values.
Thank you
With Arduino you could try this example: https://github.com/adafruit/Adafruit_nRF52_Arduino/tree/master/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey
I am actually trying to implement this feature as well. I was trying in CircuitPython, but I could not find a suitable way. I opened an issue, as there was nothing in their documentation to help.
UPDATE 2023-01-03 - In CircuitPython BLE security is not yet implemented, see answer to the issue I opened.
Related
I'm trying to figure out, how to connect two hm-10 module, when I do not know the slave MAC address. Imagine you have an electric longboard and lost you remote. You got yourself a new one and now want to pair with the board.
In the data sheet I cannot find any useful functions, to make this process easy.
I thought about making an unique name of the slave device and by making a pairing button on the master device. The pairing button would set the master device in the pairing mode (AT-ROLE1, AT+IMME1 in order to execute AT+DISC?). The results of the AT+DISC? command would be saved to an array and after finding the unique name of slave device, the index of the device/MAC address would be saved and used as a parameter for establishing the connection.
I'm using the firmware version v707.
The problem is, I do not find this solution as elegant and I think there must be a better way to do that, but I cannot find any information about it. Did anyone tried to do that and maybe has some insight? I'd very much appreciate it.
Only way I can think of on the HM10 is setting a unique name and scanning for that name.
Another way I have seen is some devices allow you to see service UUIDs in the advertising information so you can connect to the device that has the desired service UUID. But this doesn't seem possible on the HM10
Can I use a RaspberryPi OR other device for all my inputs remotely and then send that data to be used in a calculation on a desktop and then send an answer back to the raspberry pi?
This is an idea for my prject.
This is a bit difficult to answer without a lot more detail, such as the sensors you are using and what you are looking to do with the data. I'm guessing you are reading a sensor using GPIO pins, doing a calculation on another computer, and then doing something with whatever is calculated on the RPi again?
The short answer is you probably can, but remember that the Raspberry Pi is very capable and you may be able to do the computation on your data locally on the Pi itself. If you are processing the data with python or uploading it to a server you should be able to do that all from the Pi.
If you truly need to do something with the data on a separate system, I would look into using an Arduino microcontroller of some sorts instead. A wifi-enabled build (such as the popular ESP-8266 variants) will be able to quickly read sensor data without the overhead of running a full OS, while still being able to transmit wireless to your computer. There are also countless resources and tutorials for doing so that you can access to help there.
If you are set on using the Pi, or are just more comfortable using it, then there are tons or resources for how to transit data from your sensors including plenty of Stack Overflow questions such as this one
I'm currently doing my project on IOT.I need a GPS for that.I would like to use my Mobile's GPS for Arduino. How can the connection can be done?
Actually, your question is a little broad. But I would give you some tips to do it.
If you want to get your Android phone GPS data you need to create two apps; one for the Android side and one for the Arduino side. The procedure can be something like this:
Read Phone's GPS data based on what you need (E.g Lat/Long or other GPS parameters).
Create a JSON based on the data, e.g:
{
"lat": 1.234,
"lng": 5.678,
"speed": 100,
"hdop": 1.2
}
Send data to Arduino board through a proper connection (I will explain this).
Get data in Arduino board from the proper connection.
Parse received data (e.g JSON) and convert it to desired variables inside your Arduino code.
Continue your work with the received GPS data.
Let me explain a little more about proper connection. There are many options to do that. A simple option is to use Android Bluetooth and based on that on the Arduino side you need a Bluetooth receiver module which there are many out there like HC-05.
There are a bunch of tutorials to get a Bluetooth module working that you can find based on your Bluetooth module like this.
Another solution for the connection is to use wifi. For the Arduino side, you can use esp8266 and directly program it. There are some variants for it like Node-MCU
which has a builtin circuit to directly program it with an Arduino IDE software.
You can also go one step forward and use the newer ESP32 module which has both wifi and Bluetooth.
The good thing about using esp modules is that there are good APIs for creating your app and. You can find more about that on similar projects like here and here.
I bought one of these:
https://www.aliexpress.com/item/Smart-finder-Key-finder-Wireless-Bluetooth-Tracker-Anti-lost-alarm-Smart-Tag-Child-Bag-Pet-GPS/32806261079.html
As far as I can tell it is a BLE (Bluetooth Low Energy) location tag.
I downloaded the app for it onto my iphone, and the app instantly recognised it and connected to it. The iPhone app seems to know how far away the tag is - it has a little map of the local area and says how many feet away. I was able to set the device name via the app, but I'm not sure if that set it locally or on the tag itself. The iPhone app also has a "find" button - when you press it, the tag beeps.
So I want to know how I can program this thing myself. I want to be able to identify it when it is nearby, connect to it and make it beep. I've searched for quite a while but not come up with much.
I'm assuming (wrongly/rightly?) that there is some general standard or approach for talking to these BLE location devices and carrying out the basic functions with them - but what is that standard - where is the documentation?
Does anyone have any idea how to program these BLE location tag devices?
BLE devices typically communicate using GATT, either using standard GATT services, or custom ones. The command to make it beep is probably implemented using a custom GATT service.
For finding out the distance to the beacon, typically the RSSI is used. This is a measure of the received power. It needs to be compared to the output power at the emitter. Usually beacons will put their output power in advertisement data, so it can be used without connecting to them. Here since the app is also able to send commands to the beacon, chances are it keeps a connection to it and has a custom GATT protocol to retrieve the output power.
Here is what I would suggest:
Read up on BLE, especially advertising and GATT. For instance read this for advertising and this for GATT. The full BLE spec is available here but should be used for reference and not introduction
Sniff the communication between your device and your phone. You can see this other answer of mine to get started
Replicate the communication protocol in you own app. For that you'll need to use your target platform's BLE libraries. For instance for iOS it is CoreBluetooth
Not sure if to posted this on SO.
I'm looking at pretty simple BLE Device. It has a two LEDS (to simplify) that can be switched on or off.
While browsing the GATT profiles, i can't find which profile i should use. Most of them send something back (like a temerature) to the client (upon request).
I need the opposite: switch something on/off of the BLE decive (server). In my case, the client (a iPhone) would send a command to switch on/off LED-1 or LED -2.
What service profile i should use?
Thanks.
I'm using the nRF8001 development kit & nRF Studio for making the services.h
If the LED's are just to be turned on/off there probably isn't any specific profile that they belong to. You probably need to know the handle and write directly to the attribute some value that maps to on or off. Maybe you can figure it out by listing all attribute characteristics. (unfortunately I don't know how to do that specifically on the iPhone)
I noticed that you are using the nRF8001 development kit. So, first thing you need to check is whether the LEDs are connected to IO port of the micro-controller on the kit or directly connected to IO port on BLE chip.
If it connected to micro-controller on the kit then you need to program the kit to handle the received bluetooth data to control led. (It would have a high chance it is in this situation)
If it connected to BLE chip, it means you need to program the ble chip first.
Usually, useful GATT profiles are user specified. It means you need to define the profile yourself. And, I believe some part of the kit or the studio would allow you to do modifications to the profile.
There is only one default GATT profile you should use -- GAP which is to define the defaults like name of the ble device. The others usually are user self-defined profiles.