Connecting a Raspberry-Pi to Android phone wirelessly - android

I am trying to wirelessly connect my android phone to a Raspberry-Pi, so I can then make a controller app to interact with the RPi.
I have just bought a dongle, as I was thinking of using Wifi-Direct. However this doesn't look as simple as I originally thought.
There's not much information out there on how to do this, and I am completely new to RPis.
I have found the odd tutorial like this: https://www.youtube.com/watch?v=6GPv8TfZqe4
But it seems overly complicated and I am not sure if they applicable to my dongle.
I am thinking there must be a more simple way to do this(e.g. through wpa_gui on Raspbian)
Any suggestions on how I could achieve this?

You can try:
SSH to raspberry Pi with given credentials (if both devices are connected to the network... but that may not always be doable)
Setup web API/app on RPi and use it via browser on Android (like https://github.com/NeonHorizon/berryio )
Use Bluetooth UART: Adafruit has a full blown Bluetooth UART board, and Chinese make many slave (or master) UART serial boards. This way you could open a serial connection from the phone - and with luck you would get the terminal which by default is cloned to UART in RPi (or it would get your script running on Pi and handling incoming UART messages).

Related

Control Raspberry Pi with phone

I am new to Raspberry Pi. I wish to turn on/off a light and play some sounds on the Pi from my phone both Android and iPhone. It is a kids toy that I am prototyping.
I need the setup to be easy for any user to download the app and just connect to the Pi with little trouble. I dont want the Pi connected to the internet so no external api services.
I have search for tutorials but surprising nothing other than using a service.
Could anyone poin me in the right direct. I dont have a preference over bluetooth of wifi. Just one that is easy for a kid or parent to setup.
Thanks
You mentioned playing sounds, you need a beeper (if those sounds are more complicated, use a speaker). Also, you need those lights connected to GPIO (USB is also a viable option, by simply turning on/off the USB port).
Issuing a USB Hub class request (CLEAR_FEATURE PORT_POWER) to port 2 on the LAN9514 will > deactivate the USB output power switch.
There's an app for that:
https://github.com/codazoda/hub-ctrl.c
This is a bit harder to setup, but you don't need any soldering with this. Then, you need to setup an AP for the kids to connect to the Raspberry Pi's website (should be a website, app is harder to make). Also why you don't want the Raspberry Pi to connect to the internet?
Are the lights you want to turn on/off wired to the Raspberry Pi (for example via GPIO)?
You need to install one of the open source automation software (like OpenHAB or Home Assistant, etc.). Disable port forwarding to the Raspberry Pi (usually you need to do this port forwarding, so here you don't need to do anything).
In this case, the IP is a local IP, and you get local access only.
Then probably you need is already implemented by someone from the community, or you need to develop a simple script to achieve what you want.

Communication between android phone and Raspberry Pi over WiFi without external modem/router?

I want to control Raspberry Pi 3 with an android application via WiFi, without external modem/router/...
This application needs to do the followings:
send commands to RPi
send/receive files to/from RPi
So far, I have setup RPi as a wireless access point, and I'm able to find RPi in my android phone via WiFi and connect to it.
But the question is how can I communicate with it after being connected !?
Firstly, I thought using SSH. I tried some ready apps like JuiceSSH. And it was successful. I was able to SSH into RPi and execute commands.
But then I thought maybe there's no need to SSH. Because the RPi itself is a wireless access point, and my android phone is connected to it.
Now here is my question:
Are there any methods (other than SSH) to send commands to RPi or send/receive files to/from RPi after connecting to it !? If so, how can I implement it?
Any sample codes or examples are really appreciated. Thanks.
I don't see a point of not using SSH merely because RPI act as as Wireless access point. Anyways if it's a basic Shell access you need to the RPI from the phone, SSH or Telnet can be easy to setup.
If you are in capacity to implement your own server inside the RPI by code and do something inside the code, gRPC can come handy, given it's available in many languages.
Ex: gRPC server in the RPI, gRPC client in the android app. Basically gives simple client-server system.
There are many other ways to achieve the same thing, depending on your exact requirements and constraints.
Or you can simply start a webserver inside the RPI and use the browser in the phone to access it. This seems more simple and robust.
http://www.instructables.com/id/Python-Web-Server-for-your-Raspberry-Pi/
http://www.instructables.com/id/Raspberry-Pi-Android-App-communication/

Method to Connect Arduino to Mobile Phone Using TinyWifi Shield

I'm new to Arduino development. My device is TinyDuino from TinyCircuits. I'm looking for a way that will allow me connect my Arduino device to my Android phone (Android app) , via TinyWifi shield. Yet all the methods I found are for specific module or specific shield. I'm looking for some way that works with my device or something general that could be modified to work with any shield.
Depends on what actions you want to do after you connect with your phone.
If you only want manual exchange of simple data, you can use term apps. For WiFi, find WiFi Term. For Bluetooth (Tinycircuit's BLE module), find BLE term. There are many available.
If you need more complicated action, you need to write your own app for it.

Android 2.2. How to set up serial port(com,rfcomm) port?

I a trying to connect my Nexus One with Android version 2.2.1 with my pc and use a terminal program such as windows terminal or hyper terminal to communicate. To do this I believe I need to set up an outgoing serial com port. I have paired the devices. When I go on my PC to Bluetooth -> settings -> "add com port" the android device does not display.
What am I missing?
Does android 2.2.1 support spp? The documentation says it does.
Do I need to root the android to add spp?
Has anyone succeeded in this?
My final goal is to write an android app that communicates with an old school bluetooth device that requires com ports? Getting the android to communicate with the pc is an interim step.
I have tried everything I can think of in my android app to connect to my pc and android device but have not been successful. My android app is essentially the same as Serial over Bluetooth submitted by xCaffeniated but with fewer comments. Any suggestions?
Try beginning with the BluetoothChat sample application. You will then have to alter the UUID used to the generic SPP UUID,
00001101-0000-1000-8000-00805F9B34FB
From this point you pretty much have everything you need.
I have had issues pairing in the BluetoothChat program. So I was required to pair to my computer using the settings menu and then entering the BluetoothChat Program. In BTChat go to the menu and hit connect to a device, choose your computer. I can only speak for windows XP SP3 which is what I'm using. At this point on my machine I receive a task bar pop up asking me if I would like to allow my device to connect as a serial port. I allow it to. Now your phone is associated as the serial port profile on the computer, which you can associate with a specific com port.
Based on bluetooth spec,
http://www.bluetooth.com/SiteCollectionDocuments/SPP_SPEC_V12.pdf,
2.3 User Requirement, "... Any legacy application may be run on either device, using the virtual serial port as if there were a real serial cable connecting the two devices (with RS232 control signalling)." In 4.3 Remote Port Negotiation, "...There is a requirement to do so if the API to the RFCOMM adaptation layer exposes to those settings (e.g. baud rate, parity)... RFCOMM as such will not artificially limit the throughput based on baud rate settings,..."
In my opinion, since Android (2.2) offers no APIs to set up and open a serial port, they may not be necessary as long as you can discover the remote BT device and make a connection to it. I have tried it and it seems working with:
...
sock = device.createRfcommSocketToServiceRecord(myUUID);
sock.connect();
...
where final UUID myUUID= UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); You may need to take care of Bluetooth Permission and Setup in your application as described in
http://developer.android.com/guide/topics/wireless/bluetooth.html
There might be some issues with the connect() call, i.e. Service is not available or connect is refused, which could be resolved by making sure:
The remote BT device be discovered, and
It must be set to use PIN code (for instance 0000), and
It must be paired successfully with your Android device
These steps must be completed prior to running your application (which has connect call).
Hope this help.
George
There is definitely some funny business regarding how the AT set is implemented on the AOS. The problem is that it is hard to know if you're actually talking directly to Modem or through several abstraction layers (more likely). For a best up-to-date review of the AT Commands available on the AOS platform, plus HW, please see the post:
"How to talk to the Modem with AT commands"
http://forum.xda-developers.com/showthread.php?t=1471241

Read data from an Android USB attachment

Is there anyway to read data from an attachment through the USB port on an Android device? In particular, an EKG. Most the work can be done by the hardware of the device to simplify the output to a single number, a voltage reading. If its not possible, what about modifying an accessory that can already communicate with an android device? Thinking of devices that attach to android phones, what about sending the data as an audio signal to be read as the microphone from a headset and then analyzing the audio signal to convert it to a number that can be used to display a value.
Any ideas on how to make this work?
The Android handset can't be used as a "USB Host" (it's in the google android wishlist as a bug/enhancement request). That's what you'd need to connect regular USB devices like your EKG monitor and memory card readers, etc. to it. I wish it could do this too and star'd that enhancement to vote for it...
I'm not sure if this will work for you, but here's something I did recently for a project where I needed a smartphone to communicate with a host PC.
I used ADB on the PC to do port forwarding and then I used sockets to do the communication. Server socket on the phone, client on the PC. I can give you more details if you want.
Of course, the clear requirement here is to be able to install and execute code on the "device" which I don't think is applicable to your problem. Other than that, I found no other way to communicate over a USB connection through Android.

Categories

Resources