I want to receive the remaining tank volume and the current mileage of my car by using OBD II.
Therefore I have bought an OBDII Bluetooth Adapter for my car. I am using the
AndroidBluetoothChat for connecting to devices and establishing a connection, through I can send and receive information.
But when I try to connect to my OBD2 Adapter, I get: Unable to connect.
The OBD2 Adapter is always discoverable and I can pair them normally. Why is that?
The next question is, once i have established a connection, how can I receive Informationen like speed, mileage etc.
I am still a beginner and gratefull for every hint.
i'm in your same project :D
I start with BluetoothChat for understand how use Bluetooth and all works fine.... At the beginning you can chat with your OBD by sending Pids in the EditText from BluetoothChat...
But remember that you need a \r (carriage return) after every commands that you send.
For example if you need the RPM, send a string like "010c\r" and you get a response like 10c410cxx where xx is the value that you must divide by 4 for get the real RMP...
See every pids and data transformation in this table...
REMEMBER that for work the ELM327 (your obd device) need that the car
is ON half turn key or total or you don't get data but only error!
For the pids that you need (if your car support them) you can see all of them in the wikipedia page that i liked.
If you want an automatic dynamic comunication with obd you must change the comunication of the BluetoothChat with some Queue or ArrayList of commands and send them continuosly.....
REMEMBER that the ELM327 can manage one command each time....so send
the first command and wait the response... and again send another
command an wait response...and so on...
I just got started with Raspberry pi and I wanted to make a program on my Raspberry which gets input from an app on my Android/iOS device over bluetooth. I wanted to first check if something like this is possible and second if you have any clues on how to do something like this.
Thanks
PS: Since I just got started I'm only looking for clues and I don't want anyone to write and app for me so don't down vote
You would likely need to establish a network communication between the Raspberry Pi and the device.
For the server:
import socket
HOST = '' # This should receive from all available interfaces.
PORT = 1111 # Random port number.
data = "Test" # Data to send to the client.
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((HOST, PORT))
while True:
s.sendto(data, (HOST, PORT))
print data
On the client, very similar code but add:
data, addr = s.recvfrom(1024)
print addr
print "Message received: ", data
Under the while True
Reference the following for setting up RPI wireless hotspot:
http://elinux.org/RPI-Wireless-Hotspot
The HOST for each is going to be the device IPv4 address, usually in format:
192.168.x.x.
I have not personally found a way without using serials for data communication. The most common way to communicate information between devices is over network. Look into peer-to-peer network solutions.
The code may not work as is, you will need to make client/server-side code specific for your needs.
Reference the following for setting up sockets and a low-level network interface: https://docs.python.org/2/howto/sockets.html
Hopefully this helps.
EDIT:
There is a Bluetooth method for RPI.
Here's a good branch in Github that contains example of the Bluetooth library used in Python:
https://github.com/karulis/pybluez/blob/master/examples/simple
Good references:
Bluetooth programming with Python.
http://people.csail.mit.edu/albert/bluez-intro/c212.html
How to create a Bluetooth tag with RPI.
https://www.raspberrypi.org/magpi/create-a-raspberry-pi-3-bluetooth-tag/
Is there anyone who knows how I can get bluetooth rssi and link quality values in bluez without any file and data transfered ?
I am using bluez in linux to make some bluetooth program.
but I got a question about bluetooth rssi and lq..
although I don't trasmit or receive any file or data, I can get rssi ,lq value in linux
using hci_read_rssi,hci_read_lq..
just through pairing and connection between two bluetooth devices
my program is to transmit files at an odroid board based on linux to an android mobile phone
and check rssi and lq value at The odroid board
actually It is possible I can get those values..
but I don't know how i can get rssi, lq eventhough Odroid board just sends a file
please let me know if there is anyone who knows about that.
You can read the following link but to summarize you don't have to use pybluez:
install bluetooth by:
sudo apt-get install --no-install-recommends bluetooth
You don't have to use pybluez, you can use the following to obtain rssi by the device mac address:
#!/bin/bash
echo "testing rssi /n"> logs1
while (true)
do
hcitool rssi [MAC Address]>> logs1
date +%S
date +%S>> logs1
sleep 0.25
done
if you son't know the mac you can use:
hcitool scan
I have 2 android phones connected with each other via Bluetooth and am able to communicate between them using the BluetoothChat example (using the input/output stream)
I am also able to make a Bluetooth connection between these phones using the HandsFreeProfile by using the following UUID for connection:
private static final UUID MY_UUID =
UUID.fromString("0000111F-0000-1000-8000-00805F9B34FB");
// UUID for Hands free profile
Now I want to send AT commands to one phone(Phone-B) from the other(Phone-A). I can send the command from phone-A to phone-B as String (using input/output streams) and receive it by the phone-B, but I do NOT know how to apply the incoming AT command on phone-B i.e. I don't know how to make phone-B do what AT command wants it to do.
I have read about the intent
android.bluetooth.BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
but I'm not sure how to use this to send AT commands to the phone coz to use the intent some EXTRAS and a CATEGORY needs to be sent and I'm not sure what to send in those. For example below is the excerpt from the android website for the above intent:
*This intent will have 4 extras and 1 category.
EXTRA_DEVICE - The remote Bluetooth Device
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD - The vendor specific command
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE - The AT command type
which can be one of AT_CMD_TYPE_READ, AT_CMD_TYPE_TEST, or
AT_CMD_TYPE_SET, AT_CMD_TYPE_BASIC,AT_CMD_TYPE_ACTION.
EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS - Command arguments.*
I'll really appreciate if someone can help me out and tell me :
Can AT commands be reliably sent between 2 android phones in this way
Post some code to demonstrate how to do this?
Thanks in advance!
See my answer on this question:
How to send AT commands based on BT Hands-Free profile in android?
Hope that was the answer you was after.
I am developing a android application which reads Obd data from vehicle's Obd adapter via bluetooth... I am facing issue while initializing the adapter. I have sent following Obd commands in sequence to initialize the obd :
atz (received OK)
atsp0 (Received OK)
ate0 (Received OK)
0100 (This is the part where issue occurs)...
Some times for this command i receive BUSINIT:ERROR.. And after that for every vehicle command (except AT commands) same error is repeated..
I want to know the Exact initialization sequence ?
It seems your obd initialization and obd protocol selection failed. You should follow these steps:
AT D
AT Z
AT E0
AT L0
AT S0
AT H0
AT SP 0
When protocol selection command response without any error like listed below, your connection is OK and you can request new commands like '0100' command.
Errors:
UNABLE TO CONNECT
BUS INIT... ERROR
?
NO DATA
STOPPED
ERROR
Command Explanation:
AT D -> Set all to defaults
AT Z -> Reset Obd
AT E0 -> Echo off
AT L0 -> Line feed off
AT S0 -> Spaces off
AT H0 -> Headers off
AT SP 0 -> Set Protocol to 0 "Auto", search all protocols and connect it with proper protocol for that obd
For AT SP command, if you know your vehicle's obd interface protocol, you can choose that specific protocol other than make Auto and search all possible protocols. You can use different inputs:
Protocol Parameters: Hex[0,1,2, ... ,B,C]
Auto select protocol and save.
AUTO -> 0
41.6 kbaud
SAE_J1850_PWM -> 1
10.4 kbaud
SAE_J1850_VPW -> 2
5 baud init
ISO_9141_2 -> 3
5 baud init
ISO_14230_4_KWP -> 4
Fast init
ISO_14230_4_KWP_FAST -> 5
11 bit ID, 500 kbaud
ISO_15765_4_CAN -> 6
29 bit ID, 500 kbaud
ISO_15765_4_CAN_B -> 7
11 bit ID, 250 kbaud
ISO_15765_4_CAN_C -> 8
29 bit ID, 250 kbaud
ISO_15765_4_CAN_D -> 9
29 bit ID, 250 kbaud (user adjustable)
SAE_J1939_CAN -> A
11 bit ID (user adjustable), 125 kbaud (user adjustable)
USER1_CAN -> B
11 bit ID (user adjustable), 50 kbaud (user adjustable)
USER2_CAN -> C
Just wanted to put my two cents in. I've been recently developing an application in C++ and LabVIEW to communicate to a ELM-327 - based bluetooth module to retrieve information from my car's ECU. Sometimes the initialization sequence fails, sometimes it works. What I've found is that the 'keywords' bytes of the ECU protocol initialization are sometimes not being detected correctly. I think my bluetooth module is the problem, because it turns out is a chinese clon of a legit ELM-327. How do I know that? If you issue the command ATI , it would reply "ELM-327 ver. 1.5", and according to the manufacturer, they NEVER released a 1.5 version =D
What has worked for me is something like this:
Open communication, send ATZ
ATSP0
ATSS (This enables the recommended protocol search order)
010D
If 4. fails, then close communication, wait 3 or more seconds and GO TO 1
More OBD-II or AT-Commands.
The BUSINIT:...ERROR response means that the ELM-327 was unable to finsh the start-up sequence of the ECU protocol. Also, before sending an OBD-II command, like 010C, you can initialize the communications with the ATSI command, if your can happens to use the ISO-9141-2 or ISO-14230-4 KWP protocols.
You can find out what protocol your car uses if you send the command ATDP to the ELM-327 after succesfull automatic detection.
Hope this helps.
"AT E0"
"AT L0"
"AT ST 00"
"AT SP 00"
Works for me.
And one more thing... I send all these commands one after another with the delay of 500ms! Without a delay the initialization fails almost every time, don't forget, this is bluetooth and it requires more time to send and receive responds...
Your initialisation sequence should work if the hardware is fully OBD-II compatible and the car is OBD-II compliant. If you still get errors on the 0100 command, check the ignition is on and the hardware is fully operational.
0100 is the first command which will reach the actual car.
The AT commands are tor the (ELM327)-chip. So something is wrong with the communication between OBD connector and the car. Connection between your app and the connector is fine.
Obdkey is most likely to be right about the OBD-II compatibility. Please try to use an existing app to prove that, if it doesn't work, something is wrong with your car, or connector.
Btw: It's helpfull to state which obd-II adapter you have, and maybe your car.