How to connect Android device to WiFi camera + Arduino using Android Studio

  • Replies:0
Shounak Ray
  • Forum posts: 2

Apr 1, 2018, 2:52:16 AM via Website

Hello Everyone,

I have an OnReal Wifi camera which emits its own wifi an android can connect to. Below is a link to the specific camera:
...amazon.com/OnReal-Camera-Hidden-Compatible-Android/dp/B01K9TQUXC

Now, overall, the ultimate goal is:
1. To wirelessly connect Android device to the camera (using its wifi) {Android Studio}
2. To wirelessly connect to Arduino microcontroller using BLE (the HC-05) module {Android Studio}
- The Arduino microcontroller will be hooked up to an Arduino ultrasonic sensor.
3. Click the video button on the camera to begin video {Physically}
4. Make the pre-connected Android device receive the video stream from the camera {Android Studio}
5. Make the pre-connected Android device receive (Serial?) input from the Arduino microcontroller {Android Studio}
6.1. If the distance is greater than 'x' cm (as received from the Arduino), then save the live frame - preferably to the cloud (Firebase?) - at that instant from camera's video stream {Android Studio}
6.2. Else if the distance is less than 'x' cm (as received from the Arduino), then [nothing new happens; inputs are still continued to be received {Android Studio}
7. (At some point), click the video button on the camera to stop video {Physically}
8. Now, the Android device has sent a number of images to the cloud (Firebase?) {Android Studio}
9. Android device pulls those images from the cloud and calls Image Recognition API - preferably requiring no internet (although MS API would be fine) {Android Studio}
10. Uses API to associate each image with a set of tags + creates a list/vector to store these sets of tags {Android Studio}
11. The user presses a button on the screen and uses (Google?) Voice Recognition to say the name of an object {Android Studio}
12. The Android device tries to find matches of the user's query in the created list/vector {Android Studio}
13. Displays at maximum 3 images which had a match with the user's query {Android Studio}
14. (At some point) user presses a button to clear all frames/images stored in the cloud (Firebase) {Android Studio}

I have researched some broken down examples of my project (the .java's + .xml's + etc...) but none compile... :-(.
I have attached my Arduino Code (which does compile) as well for further reference.

Any code (manifest xml, layout xml's, java's, etc...) and further guidance would be very much appreciated!

Thanks.

Arduino Code

/*
This Arduino-Code is written for Visualizating measurement data from a microcontroller via Bluetooth.
Before starting this application, the Bluetooth-Module (HC-05) has to be coupled to the Smartphone.In the special case of the HC-05 the default PinCode for initiating the Coupling-Process is "1234".
Wiring: GND of HC-05 to GND Arduino, VCC of HC-05 to VCC Arduino, TX HC-05 to Arduino Pin 10 (RX) RX HC-05 to Arduino Pin 11 (TX)
*/

#include <SoftwareSerial.h>
SoftwareSerial BTserial(10, 11);

//The first two pins are for getting the sensor input from the ultrasonic sensor
//The remaining pin is for the led
int echoPin = 4, trigPin = 5, ledpin = 2;
int distance {};
void setup()
{
  pinMode(echoPin, INPUT);
  pinMode(trigPin, OUTPUT);
  BTserial.begin(9600);
}

void loop()
{
  distance = getUltrasonicDistance(trigPin, echoPin);

  //The semicolon is there so the Android knows when it will receive a distance value (needed?)
  BTserial.print(";");
  BTserial.print(distance);
  BTserial.print(";");

  //I can edit this if needed.
  delay(20);

}

//Functions which gets the distance...
int getUltrasonicDistance(int trigPin, int echoPin)
{
  int distanceCentimeters;
  float pulseLenMicroseconds;

  //Bit-bang a small square wave on the trig pin to start the range finder
  //The LOW AND HIGHS SIMPLY MEAN ON AND OFF
  digitalWrite(trigPin, LOW);
  delayMicroseconds(20);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(100);
  digitalWrite(trigPin, LOW);

  //Measures the pulse length from the echo pin
  pulseLenMicroseconds = pulseIn(echoPin, HIGH);

  //The program calculates the distance (in centimeters) using the speed of sound
  distanceCentimeters = pulseLenMicroseconds / 29.387 / 2;

  //returns the distance, an int
  return distanceCentimeters;
}
Be the first to answer