Passing objects from smartphone app to Arduino through bluetooth - arduino

I'm writing a windows mobile app that connects to an Arduino board.
Currently in order to pass data i'm sending strings from and to the Arduino board.
Is there a way to pass objects or formatted data?

you could use json, which is very easily parsable on the mobile phone side.
it all depends on the kind of data you want to send.

As the arduino is a simple C++ device, you may go with a c structure or a binary object. If you are connecting from windows mobile OS <=6.5.3, you can write in c++ or c# (or vb). You can then use a serialized to convert from/to a structure/object. How many data do you need to transfer? And what types?

Related

How to send Struct data from app to ESP32 over BLE?

I want to send struct data from my flutter app to ESP32 over BLE. Is it possible? if yes, How?
Yes it is possible. You can send serialized data over BLE. Serializing data means converting your data into binary data (googling serialization will give you more information). You can use any serialization library you want. Choose one that has both Flutter and ESP32 support. I've used PROTOBUF before and I thought it was pretty cool, but it doesn't have ESP32 support. I've used JSON before and it works wonderfully in Flutter, but I'm not sure if there's a ESP32 library.
Let me know if this helped!

STM32 usb cdc characters sending-receiving understanding

I'm trying to send data from C# app to the one STM32 dev board via USB CDC. I have problem with method SerialPort.Write() because write method send only first character instead of all characters of array or string. Same situation is it with serial terminals (terminte, cutecome,..) when attempt to send string. Can someone explain me how cdc usb really works. Does STM32 send data in same manner, character by character in each frame? I didn't use logic analyzer to see signals but that will be next step maybe.
If anyone has picture of usb cdc frame please share.
When I send string from STM32 dev board to the C# app that works fine. Any idea is welcome
The C# SerialPort.Write function is capable of writing an entire string at once if you call it the right way. The bytes of the string will be passed on to your operating system's USB drivers, which will split it up into packets according to the max packet size for the endpoint specified in your device's USB descriptors. Then those packets will be sent to the device, one packet at a time.
I suspect that there is a bug in your STM32 code, but since you have not posted an MCVE it will be difficult to help you debug any code.

Using android GPS for Arduino

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.

conceiving a bus can adapter using stm32

So here is the thing, I want to conceive a universal BUS CAN adapter using stm32 with a desktop interface using Qt.
Still in the conception phase, I'm wondering how to treat the frames coming from the stm to PC GUI, weather 1) as a USB frame; in this case, how to encapsulate and decapsulate them into CAN frames and is there a Qt library to facilitate the job, or 2) as a CAN frame in this case I found the QCanBusDevice and QCanBusFrame Class which seem to be so helpful but in this case a CAN plugin must be specified during the object creation. So what should i do?
It doesn't really matter what you do because you're designing a custom protocol that rides on top of USB. Here you have an option of implementing a USB communications class device so that you don't need custom drivers nor libusb - especially given that the performance of libusb on Unixes is abysmal.
Once the data is available to the userspace, you can access it using QSerialPort. You'll have to frame the CAN frames somehow, as serial port is a stream-oriented transport and doesn't know of any packets. Most trivially, you can encapsulate the frames using RFC 1662 HDLC octet-stuffed framing. You can encapsulate the commands to your device, and their responses, in the same fashion, using one of the fields, e.g. the ADDRESS field, to multiplex CAN data and commands/responses.
If you now wish to expose this device to the Qt Serial Bus framework, you'll have to write a custom CAN plugin to access it.
To give some idea of how much code this is: total for Qt code and microcontroller code should be well under 1500 lines for a proof-of-concept. A minimal demo would be probably <400 lines of Qt code and <400 lines of STM32 code.

How to send integers from an Arduino device to a desktop?

I'm new to Arduino and I'm struggling to find a way to send integer value from the Bluefruit Feather 32u4 to my desktop app. I'm trying to send data through my BLE connection like this:
int value = 300;
ble.println(value);
However, I think that this function isn't for that, cause in the desktop app, what I get is a string. The code I wrote for that BLE client was based on the example provided by Microsoft (available here). Any suggestions on what should I be doing to send integer values from the Arduino device to the desktop?

Resources