How to send data from Raspberry Pi Python Script to Android App - android-studio

My senior project partner and I are trying to send data from a Raspberry Pi 4B to an Android Smartphone that is using Android Studio to make an app. The goal is to send multiple data readings from different sensors that are read in the python script in Raspberry Pi to an Android Smartphone. We have been having immense trouble with this and have looked off of many different posts to have nothing work. We have little to no experience with python and android studio. Any help would be appreciated.

Allow me to provide one possible solution. Since you are already using python in the raspberry pi to collect data from sensors, you could extend the script to relay that data to a HTTP REST api endpoint within the pi, using some HTTP microservice libraries like flask, bottle, etc. After this you need to open the communication between the raspberry pi and your phone which are connected via a USB cable. The simplest way of doing so would be to forward the port of your microservice using adb, like so
adb forward tcp:8080 tcp:8080
The above command needs to be run on the raspberry pi (after you setup up adb in it). The above command forwards the raspberry pi port 8080 to the android phones port 8080. Now the only thing you need to do is setup your app to periodically send HTTP requests to the local port 8080 and retrieve the information from raspberry pi. I do not have much experience with Android development so you have to research further on the viability of the app communicating with the forwarded port (permissions and security procedures to be bypassed), but this would be one of the simplest ways to setup communication involving an android device.

Related

Reading Bluetooth data and command (Raspberry pi 3)

I am currently working on a project that make me control media center and a few domotic parts in my living room.
I have connected on my raspberry pi 3 a NAS, my Spotify account (with hifiberry, controls to close my amp, my PC and a few lights...
At first to control it all I programmed a web server that I can access on my phone. That made the job but it is not completely user friendly since I have to have my phone go to the interface and do whatever I have to... And I'm not a web designer 😁 it's far from perfect!
I've made some research and I have decided to build a bluetooth remote control (raspberry pi 3 do have Bluetooth low energy).
Since nothing exist as I want, it is going to be a custom one made with Arduino mini and hm10 module.
But I'm stuck on the raspberry part!
How can I read the Bluetooth data send by my remote and launch scripts according to the command sent?
Via a serial listener of some kind?
Yes, in fact, you should use a serial port to connect your pi with Bluetooth module.
You then use software input information for your purposes, but you must first implement the hardware and hardware interface first.
You can build application software with the Python programming language.

Enable both WiFi and Ethernet on Pi running Stretch

I'm working on a project where a Raspberry Pi 3 runs a python server which controls some arduino's that are connected to the same router via a switch. I'm using a websocket to display a GUI in my browser.I need to be able to use the gui over my primary network connection which has internet acces. The situation looks like this :
The problem is that I can't get both WiFi and Ethernet to work, just one at a time. This has mainly to do with running Stretch, but downgrading is not an option. On older Raspbian version's I could use the allow hotplug or auto setting in the interfaces file to make sure both interfaces are up. But I've heard you should not touch the interfaces file on Stretch. Can someone tell me how to do it ?:) Thanks a lot!

Bluetooth LE from Cordova app to Linux device

I need some guidance. In a nutshell, I need to be able to configure and control a device with the smart phone app over BLE.
For example, change IP address of my Raspberry Pi. To make that happen, I need 2 things.
Simple Android/iOS app that takes IP address parameters as an input, and then communicates over Bluetooth to the RPi. Note that the device needs to be discovered and connected from within the app (without going to "Settings" and pairing).
Build some server process on the Raspberry Pi that listens to USB Bluetooth dongle, receives the command with parameters and acts accordingly.
So I need help building the BLE portion of this project.
I have several years of smartphone app development experience, and 10+ years of Linux system programming. In other words, building a simple Cordova app, as well as Linux process that changes IP address is really not an issue.
However, I am totally new to Bluetooth. Can you point me to the right direction? I am sure this problem has already been solved few thousand times. Is there a tutorial? Or maybe a skeleton code I use as a starting point? Also, any recommendation for BLE USB dongle?
Thanks a lot!
I think it will be harder to find a better guide to implement low energy technology on the RaspberryPi than this one :
https://learn.adafruit.com/downloads/pdf/pibeacon-ibeacon-with-a-raspberry-pi.pdf
After this , you can download a random app on the Playstore/Appstore and check that your RaspberryPi is actually acting as a BLE device.
Finally you can start creating your own app using several available BLE plugins like :
https://github.com/randdusing/BluetoothLE
https://github.com/don/cordova-plugin-ble-central

Connecting Smart Watch to Raspberry Pi

I am developing project on Raspberry Pi and I need to add feature of measuring heart rate. I want to use Smart Watch to do that but I do not know which smart watch provide environment which allows me to implement wireless communication between watch and Raspberry (Raspbian OS) easily. Thank you in advance for each answer.
I don't think any smart-watch allows direct connection between Raspberry Pi and smart-watch. It is not recommended on android developer site to open lower level sockets as well. You can send smart-watch's sensor data to Phone and then send it to Raspberry Pi.

Node.js on Raspberry Pi

I want to have Node.js running on a RPi and a browser running on the same RPI at the time and the two talking to each other. I know I can do this over a network with a separate client machine - but I want to control the RPi I/O pins with the browser running in the RPi. Is this possible?
I would recommend using the pi-gpio npm package on Node.js. Your browser then controls the GPIO pins thru Node.js.

Resources