I've managed to write a Python program for my Raspberry Pi that interacts with BLE via D-Bus and can register GATT services and store data in chatacteristics that external devices can read. However, my goal is to send images from my Raspberry Pi (peripheral) to an Android/iOS device (central). I've started searching for information on how to do that and discovered that there is a pretty low limit on how much data can be stored in a GATT characteristic (answers range from 20 to 512 kB). Because of this limit, the larger data must be split into chunks and transferred using a rather complicated algorythm involving GATT notifcations. That made me wonder if I'm on the right path. It looks like an overhead to implement such a complicated algorythm to send an image via Bluetooth and the low data size limit makes me think that BLE isn't meant for this. Maybe I should just use classic Bluetooth with sockets? Or maybe someone can point me to an example of an application which sends image via BLE, because I couldn't find anything useful on the internet. I mainly chose to use BLE because I want to write the Android/iOS application using React Native and it only supports BLE client. Does iOS even support Bluetooth classic?
Related
I am working on a python project which involves real time communication between a Raspberry Pi device and Cloud server. After receiving data in the cloud server in real time, I have to display the output in a web application in real time as well. What is the correct way to do this ?
As web applications use socket.io (web sockets) and communication between Raspberry Pi and cloud can be done through a normal socket, I am confused on whether to proceed with normal socket or web socket.
Any feedback will be greatly appreciated.
It all depends on whether you want to work with the TCP stack or the HTTP stack, while TCP sockets have a smaller footprint, HTTP sockets have better support with high level libraries. If you don't need multiple simultaneous connections or high latency requirements, they are both identical, so go with the one that is easier to work with, ie the web socket.
I am working on a project where I need to detect objects from IP camera on PC using TensorFlow and the data of the detected object to raspberry pi and control its GPIO pins accordingly.
I am using python on both ends.
I read somewhere to form a client-server network between the two.
I need some ideas on how to approach this problem. Thank you. I hope my question was clear.
Extra Information: I am currently using Raspberry pi on PC via ethernet cable. Also, both raspberry pi and my PC are connected to the same Wifi router. I hope this information helps.
You can use sockets to make the Raspberry Pi and your PC communicate. You can use socket.accept(conn, address) to accept a connection and conn.recv(buffer) to receive data.
I'm a big fan of using Redis for this type of thing. It has a small footprint, is simple to set up and is lightning fast. It is a "networked data structure server". "Networked" means that its clients can be on the same machine or anywhere on the network. The data structures it serves include:
strings
integers
atomic integers
lists
queues
sets
sorted sets
hashes
There are bindings for Python, C, C++, PHP, Ruby and rather brilliantly, the shell. That means you can inject values into queues, lists or sets directly from any Terminal on your network whilst your app is running, in order to test it or monitor it.
Example here.
I need help to setup my project. In particular, my project is a C/C++ project.
This project involves different components that must communicate exploiting Bluetooth Low Energy.
Components:
The components can be classified into two different categories: a mobile component (such as a tablet android or an Ipad) and a raspberry component (a Raspberry Pi W board with a BLE adapter). In the system, there can be 1 mobile component and from 1 to N raspberry components
Desired Behavior:
According to the project requirements, the Raspberry components should notify their presence in order to be detected from the tablet. The tablet has to scan for nearby raspberry and eventually connect to one of the scanned devices. Once the connection is established the tablet has to send at least two strings to the raspberry.
I downloaded the last version of Bluez and I saw the python scripts in the test folder: example-gatt-server and example-advertising. Unfortunately, I have no experience with python. So I looked for an equivalent C code but didn't find anything.
Can anyone help me to find a GATT server in C able to advertise and receive connection request?
Is it correct for my requirements to implement the code for the Raspberry as the one in the gatt-server-example?
Thanks
[EDIT]:
My boss agrees with me to use these python scripts instead of using some C/C++ equivalent. As said before I have no experience using python, so I need some help.
Which types of data are accepted from the gatt-server? Can I pass a string to it?
If I want to modify two of the implemented services (the ones identified using UUID 12345678-....) to pass a string can I do this?
In the gatt-server example, there is a service that seems to deal with the encryption mechanism. If I try to send the string "goofy" is this encrypted, sent and decrypted once received by the gatt-server?
Thanks
I may be confusing a few concepts here so any help is appreciated.
Q1: Is it possible to attach any sensor in the world to the USB on my computer as long as it gives me analog data, and read its output? (e.g. pH, temperature, oxygen sensor etc as long as it gives me analog data)
Q2: If so, then what is the simplest way in python for me read such data.
Comment: I am trying to bypass using PLC's, and trying to see if I can get the output from the sensor directly to the PC. (I do not have drivers for these sensors)
Actual Need: I have an oxygen sensor connected to my computer via a USB. The oxygen sensor is able to send out analog data. The obvious way is to go through a PLC. However, I would like a solution which by-passes PLC's so I can connect the sensor directly to my PC via USB.
The USB port on your computer cannot read analog data because USBs work with digital signals. You would need an analog-to-digital converter (ADC).
as #digitaLink answered, it is not possible directly via USB and yes, the obvious way is to use a PLC.
I would go the PLC way - in fact, I did it a few times in the past - and start with an Arduino and later develop a custom PCB, put it in a box and done.
Another possibility is to use a raspberry pi (or similar SBC), which has the GPIOs you can use for analog read.
Edit: there is another possibility.
The sensor you use now is _very_likely_ a PLC in itself, that is, the sensor is attached to a microcontroller that uses the USB port for serial communication. Now, the drivers you are missing do nothing else but decode the data coming through the serial port. Take a look inside your harware and try to find out what components there are in.
So what you could do is to try to find out how to communicate with the sensor via a serial terminal. It is probably possible to monitor serial communication (although I must admit, I don't know how to do that), reverse engineer the code and write your own driver in python. You could learn a lot from this, even if you don't succeed.
I am trying to send some data between 2 raspberry pi's over wifi without them being connected to a network.
I want it to work similar to the way beacons and probe requests work, where a broadcast can be sent out the wireless interface.
the data I want to send will be the hostname of the device and the time the packet was sent.
I've been trying to figure this out for the last few days but I cannot get anything to work without them being on the same network.
Is anybody able to point me in the right direction?
I'm not too fussed about what language I use. I have been trying python and C with little success.
Note: This is not really an answer, just some ideas to research, so feel free to edit or comment with corrections.
There are 6 modes a wifi adapter can operate in. From wikipedia:
Master (acting as an access point), Managed (client, also known as station), Ad hoc, Mesh, Repeater, and Monitor mode.
But I believe not all wifi adapters support all modes, so make sure you have suitable hardware.
I would suggest adhoc or mesh would be the most suitable to your purpose. With adhoc mode at least the devices would need to be configured beforehand to use the same SSID and channel. This may not apply to mesh mode.
A quick search yields a few links in regards to using Raspberry Pis in a mesh network:
http://hackaday.com/2012/11/14/mesh-networking-with-multiple-raspberry-pi-boards/
Wireless mesh networking on Raspberry Pi using batman-adv protocol
http://www.netlore.co.uk/airmesh/?page=about
I would also look at using the Dot11* family of packets in the excellent Python Scapy library (not to be confused with Scrapy). You should be able to craft custom packets and transmit them if the interface is in the right mode. Here's a project that creates fake access points that probably contains good info: https://github.com/rpp0/scapy-fakeap