Unable to get Arduino sensor data
I am unable to retrieve the data from Arduino. Is there anything wrong with my code? I have tried many different ways to get data from the Arduino but still to no avail.
Android Studio Code
package com.example.a17019501.bluetootharduino;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;
import java.util.UUID;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
//Layout//
TextView adapterStatus;
TextView lightValue;
//Bluetooth//
BluetoothAdapter mBluetoothAdapter;
BluetoothDevice mDevice;
Set <BluetoothDevice> pairedDevices;
ConnectThread mConnectThread;
ConnectedThread mConnectedThread;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapterStatus = findViewById(R.id.tvAdapterStatus);
lightValue = findViewById(R.id.tvLightValue);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
adapterStatus.setText("Device does not support bluetooth");
}
else {
adapterStatus.setText("Device support bluetooth");
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, 1);
}
pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
mDevice = device;
}
}
mConnectThread = new ConnectThread(mDevice);
mConnectThread.start();
Log.i(TAG, "Connect to device: " + mDevice.getName());
}
public class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
private final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
public ConnectThread(BluetoothDevice device) {
BluetoothSocket tmp = null;
mmDevice = device;
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) { }
mmSocket = tmp;
}
public void run() {
mBluetoothAdapter.cancelDiscovery();
try {
mmSocket.connect();
} catch (IOException connectException) {
try {
mmSocket.close();
} catch (IOException closeException) { }
return;
}
mConnectedThread = new ConnectedThread(mmSocket);
mConnectedThread.start();
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) { }
}
}
public class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInstream;
public ConnectedThread(BluetoothSocket socket) {
Log.i(TAG, "Connected Thread");
mmSocket = socket;
InputStream tmpIn = null;
try {
tmpIn = mmSocket.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}
mmInstream = tmpIn;
}
public void run() {
byte buffer = new byte[1024];
int bytes;
while (true) {
try {
bytes = mmInstream.read(buffer);
Log.i(TAG, "Buffer read");
String incomingMsg = new String(buffer, 0, bytes);
mHandler.obtainMessage(1, bytes, -1, buffer);
Log.i(TAG, "InputStream " + incomingMsg);
} catch (IOException e) {
e.printStackTrace();
Log.i(TAG, "Error reading input " + e.getMessage());
}
}
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
}
}
}
Handler mHandler = new Handler() {
String s;
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case 1:
s = (String) msg.obj;
if (s!=null) {
lightValue.setText(Integer.parseInt(s));
}
break;
}
}
};
}`
Arduino Code
#include <SoftwareSerial.h>
const int LightSensor = A1; //LightSensor pin at A1
int bluetoothTx = 2; //BTTX at pin 2
int bluetoothRx = 3; //BTRX at pin 3
int sensorValue = 0;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup() {
Serial.begin(9600); // Begin the serial monitor at 9600bps
bluetooth.begin(9600); // Start bluetooth serial at 9600
}
void loop() {
sensorValue = analogRead(LightSensor);
bluetooth.print(sensorValue);
Serial.println(sensorValue);
delay(2500);
}
java android arduino
add a comment |
I am unable to retrieve the data from Arduino. Is there anything wrong with my code? I have tried many different ways to get data from the Arduino but still to no avail.
Android Studio Code
package com.example.a17019501.bluetootharduino;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;
import java.util.UUID;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
//Layout//
TextView adapterStatus;
TextView lightValue;
//Bluetooth//
BluetoothAdapter mBluetoothAdapter;
BluetoothDevice mDevice;
Set <BluetoothDevice> pairedDevices;
ConnectThread mConnectThread;
ConnectedThread mConnectedThread;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapterStatus = findViewById(R.id.tvAdapterStatus);
lightValue = findViewById(R.id.tvLightValue);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
adapterStatus.setText("Device does not support bluetooth");
}
else {
adapterStatus.setText("Device support bluetooth");
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, 1);
}
pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
mDevice = device;
}
}
mConnectThread = new ConnectThread(mDevice);
mConnectThread.start();
Log.i(TAG, "Connect to device: " + mDevice.getName());
}
public class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
private final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
public ConnectThread(BluetoothDevice device) {
BluetoothSocket tmp = null;
mmDevice = device;
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) { }
mmSocket = tmp;
}
public void run() {
mBluetoothAdapter.cancelDiscovery();
try {
mmSocket.connect();
} catch (IOException connectException) {
try {
mmSocket.close();
} catch (IOException closeException) { }
return;
}
mConnectedThread = new ConnectedThread(mmSocket);
mConnectedThread.start();
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) { }
}
}
public class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInstream;
public ConnectedThread(BluetoothSocket socket) {
Log.i(TAG, "Connected Thread");
mmSocket = socket;
InputStream tmpIn = null;
try {
tmpIn = mmSocket.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}
mmInstream = tmpIn;
}
public void run() {
byte buffer = new byte[1024];
int bytes;
while (true) {
try {
bytes = mmInstream.read(buffer);
Log.i(TAG, "Buffer read");
String incomingMsg = new String(buffer, 0, bytes);
mHandler.obtainMessage(1, bytes, -1, buffer);
Log.i(TAG, "InputStream " + incomingMsg);
} catch (IOException e) {
e.printStackTrace();
Log.i(TAG, "Error reading input " + e.getMessage());
}
}
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
}
}
}
Handler mHandler = new Handler() {
String s;
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case 1:
s = (String) msg.obj;
if (s!=null) {
lightValue.setText(Integer.parseInt(s));
}
break;
}
}
};
}`
Arduino Code
#include <SoftwareSerial.h>
const int LightSensor = A1; //LightSensor pin at A1
int bluetoothTx = 2; //BTTX at pin 2
int bluetoothRx = 3; //BTRX at pin 3
int sensorValue = 0;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup() {
Serial.begin(9600); // Begin the serial monitor at 9600bps
bluetooth.begin(9600); // Start bluetooth serial at 9600
}
void loop() {
sensorValue = analogRead(LightSensor);
bluetooth.print(sensorValue);
Serial.println(sensorValue);
delay(2500);
}
java android arduino
Please add more detail on what you have tried. What parts of the code are executing, and which are not? Is the BT even connecting? Including theLog.i()
output from a run of your android program may help. In addition, please describe your hardware setup.
– greeble31
Nov 25 '18 at 18:36
I have solved it by adding sendToTarget() at my mHandler in run(). But the data received is only 1 byte which I am trying to solve using the answer below by SilvioCro.
– Daniel
Nov 26 '18 at 1:59
add a comment |
I am unable to retrieve the data from Arduino. Is there anything wrong with my code? I have tried many different ways to get data from the Arduino but still to no avail.
Android Studio Code
package com.example.a17019501.bluetootharduino;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;
import java.util.UUID;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
//Layout//
TextView adapterStatus;
TextView lightValue;
//Bluetooth//
BluetoothAdapter mBluetoothAdapter;
BluetoothDevice mDevice;
Set <BluetoothDevice> pairedDevices;
ConnectThread mConnectThread;
ConnectedThread mConnectedThread;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapterStatus = findViewById(R.id.tvAdapterStatus);
lightValue = findViewById(R.id.tvLightValue);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
adapterStatus.setText("Device does not support bluetooth");
}
else {
adapterStatus.setText("Device support bluetooth");
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, 1);
}
pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
mDevice = device;
}
}
mConnectThread = new ConnectThread(mDevice);
mConnectThread.start();
Log.i(TAG, "Connect to device: " + mDevice.getName());
}
public class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
private final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
public ConnectThread(BluetoothDevice device) {
BluetoothSocket tmp = null;
mmDevice = device;
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) { }
mmSocket = tmp;
}
public void run() {
mBluetoothAdapter.cancelDiscovery();
try {
mmSocket.connect();
} catch (IOException connectException) {
try {
mmSocket.close();
} catch (IOException closeException) { }
return;
}
mConnectedThread = new ConnectedThread(mmSocket);
mConnectedThread.start();
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) { }
}
}
public class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInstream;
public ConnectedThread(BluetoothSocket socket) {
Log.i(TAG, "Connected Thread");
mmSocket = socket;
InputStream tmpIn = null;
try {
tmpIn = mmSocket.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}
mmInstream = tmpIn;
}
public void run() {
byte buffer = new byte[1024];
int bytes;
while (true) {
try {
bytes = mmInstream.read(buffer);
Log.i(TAG, "Buffer read");
String incomingMsg = new String(buffer, 0, bytes);
mHandler.obtainMessage(1, bytes, -1, buffer);
Log.i(TAG, "InputStream " + incomingMsg);
} catch (IOException e) {
e.printStackTrace();
Log.i(TAG, "Error reading input " + e.getMessage());
}
}
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
}
}
}
Handler mHandler = new Handler() {
String s;
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case 1:
s = (String) msg.obj;
if (s!=null) {
lightValue.setText(Integer.parseInt(s));
}
break;
}
}
};
}`
Arduino Code
#include <SoftwareSerial.h>
const int LightSensor = A1; //LightSensor pin at A1
int bluetoothTx = 2; //BTTX at pin 2
int bluetoothRx = 3; //BTRX at pin 3
int sensorValue = 0;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup() {
Serial.begin(9600); // Begin the serial monitor at 9600bps
bluetooth.begin(9600); // Start bluetooth serial at 9600
}
void loop() {
sensorValue = analogRead(LightSensor);
bluetooth.print(sensorValue);
Serial.println(sensorValue);
delay(2500);
}
java android arduino
I am unable to retrieve the data from Arduino. Is there anything wrong with my code? I have tried many different ways to get data from the Arduino but still to no avail.
Android Studio Code
package com.example.a17019501.bluetootharduino;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;
import java.util.UUID;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
//Layout//
TextView adapterStatus;
TextView lightValue;
//Bluetooth//
BluetoothAdapter mBluetoothAdapter;
BluetoothDevice mDevice;
Set <BluetoothDevice> pairedDevices;
ConnectThread mConnectThread;
ConnectedThread mConnectedThread;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapterStatus = findViewById(R.id.tvAdapterStatus);
lightValue = findViewById(R.id.tvLightValue);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
adapterStatus.setText("Device does not support bluetooth");
}
else {
adapterStatus.setText("Device support bluetooth");
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, 1);
}
pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
mDevice = device;
}
}
mConnectThread = new ConnectThread(mDevice);
mConnectThread.start();
Log.i(TAG, "Connect to device: " + mDevice.getName());
}
public class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
private final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
public ConnectThread(BluetoothDevice device) {
BluetoothSocket tmp = null;
mmDevice = device;
try {
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) { }
mmSocket = tmp;
}
public void run() {
mBluetoothAdapter.cancelDiscovery();
try {
mmSocket.connect();
} catch (IOException connectException) {
try {
mmSocket.close();
} catch (IOException closeException) { }
return;
}
mConnectedThread = new ConnectedThread(mmSocket);
mConnectedThread.start();
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) { }
}
}
public class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInstream;
public ConnectedThread(BluetoothSocket socket) {
Log.i(TAG, "Connected Thread");
mmSocket = socket;
InputStream tmpIn = null;
try {
tmpIn = mmSocket.getInputStream();
} catch (IOException e) {
e.printStackTrace();
}
mmInstream = tmpIn;
}
public void run() {
byte buffer = new byte[1024];
int bytes;
while (true) {
try {
bytes = mmInstream.read(buffer);
Log.i(TAG, "Buffer read");
String incomingMsg = new String(buffer, 0, bytes);
mHandler.obtainMessage(1, bytes, -1, buffer);
Log.i(TAG, "InputStream " + incomingMsg);
} catch (IOException e) {
e.printStackTrace();
Log.i(TAG, "Error reading input " + e.getMessage());
}
}
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
}
}
}
Handler mHandler = new Handler() {
String s;
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case 1:
s = (String) msg.obj;
if (s!=null) {
lightValue.setText(Integer.parseInt(s));
}
break;
}
}
};
}`
Arduino Code
#include <SoftwareSerial.h>
const int LightSensor = A1; //LightSensor pin at A1
int bluetoothTx = 2; //BTTX at pin 2
int bluetoothRx = 3; //BTRX at pin 3
int sensorValue = 0;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup() {
Serial.begin(9600); // Begin the serial monitor at 9600bps
bluetooth.begin(9600); // Start bluetooth serial at 9600
}
void loop() {
sensorValue = analogRead(LightSensor);
bluetooth.print(sensorValue);
Serial.println(sensorValue);
delay(2500);
}
java android arduino
java android arduino
edited Nov 25 '18 at 17:14
Fantômas
32.8k156490
32.8k156490
asked Nov 25 '18 at 14:49
DanielDaniel
41
41
Please add more detail on what you have tried. What parts of the code are executing, and which are not? Is the BT even connecting? Including theLog.i()
output from a run of your android program may help. In addition, please describe your hardware setup.
– greeble31
Nov 25 '18 at 18:36
I have solved it by adding sendToTarget() at my mHandler in run(). But the data received is only 1 byte which I am trying to solve using the answer below by SilvioCro.
– Daniel
Nov 26 '18 at 1:59
add a comment |
Please add more detail on what you have tried. What parts of the code are executing, and which are not? Is the BT even connecting? Including theLog.i()
output from a run of your android program may help. In addition, please describe your hardware setup.
– greeble31
Nov 25 '18 at 18:36
I have solved it by adding sendToTarget() at my mHandler in run(). But the data received is only 1 byte which I am trying to solve using the answer below by SilvioCro.
– Daniel
Nov 26 '18 at 1:59
Please add more detail on what you have tried. What parts of the code are executing, and which are not? Is the BT even connecting? Including the
Log.i()
output from a run of your android program may help. In addition, please describe your hardware setup.– greeble31
Nov 25 '18 at 18:36
Please add more detail on what you have tried. What parts of the code are executing, and which are not? Is the BT even connecting? Including the
Log.i()
output from a run of your android program may help. In addition, please describe your hardware setup.– greeble31
Nov 25 '18 at 18:36
I have solved it by adding sendToTarget() at my mHandler in run(). But the data received is only 1 byte which I am trying to solve using the answer below by SilvioCro.
– Daniel
Nov 26 '18 at 1:59
I have solved it by adding sendToTarget() at my mHandler in run(). But the data received is only 1 byte which I am trying to solve using the answer below by SilvioCro.
– Daniel
Nov 26 '18 at 1:59
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53468688%2funable-to-get-arduino-sensor-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53468688%2funable-to-get-arduino-sensor-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please add more detail on what you have tried. What parts of the code are executing, and which are not? Is the BT even connecting? Including the
Log.i()
output from a run of your android program may help. In addition, please describe your hardware setup.– greeble31
Nov 25 '18 at 18:36
I have solved it by adding sendToTarget() at my mHandler in run(). But the data received is only 1 byte which I am trying to solve using the answer below by SilvioCro.
– Daniel
Nov 26 '18 at 1:59