Is there an ELM327 / obdkey OBD-II adapter Objective-C programming guide? - objective-c

I'd like to start coding against an ELM327 based automotive OBD-II Bluetooth adapter in iOS/Objective-C. Is there a guide/primer on how to get started?
I would imagine the ELM327 adapter is a serial device... I can probably figure out how to establish a Bluetooth connection with the phone, but I haven't any idea where to start with sending/receiving OBD-II messages to/from it.
Is there a pre-existing API for this device?

If you need some OBDKey specific commands let me know. As an example, to access the RPM data, issue the following commands
ATZ\r
ATSP0\r
0100\r
010C\r
These instructions will initialise the OBDKey interface, set the protocol search on to automatic, initialise communcations with the engine managment ECU and send the mode 1 PID 0C command to request engine speed (RPM) data. The value returned in response to the 010C command is actually four time the real engine speed value.
Using sockets and streams in iOS / Objective-C is the best way to set up communications to the OBDKey WLAN (the default IP address is 192.168.0.74, port 23).

The elm327 odb2 device uses AT and ODB commands.
The AT commands are the same as you use on modems, they always start with AT.
When the devices initializes it sends
ELM327 v2.1
>
If you send
ATZ
this will reset device and it will issue "ELM327 v2.1" and > prompt again.
AT commands are used to manage the elm327 device.
ODB commands are in asci hex such as the above example
01 0c
to get the rpm or
01 05
to get coolant temp
At http://www.elmelectronics.com/obdic.html there are data sheet pdf files with more details.
Also you can search ituns for "elm327" and get 2 free books on the subject.
I'm just starting the same project for my generic elm327 wifi device so I dont have any details yet.
I will add comments as soon as I learn anything useful.

Related

How can i make sure my BLE peripheral (NRF52832) gets reconnected again after i have unpaired it?

A little new to NRF52, so please pardon if this turns out to be a noob question. I'm using nrf52832 as a peripheral and loading the standard SDK peripheral example of GATTS ( any other does result in the same).
After configuring that device i try to connect my phone to it , which happens succesfully. But after unpairing my phone and trying to configuring again my phone cant pair with the device.
Phone shows:
Could'nt pair .Check settings of this device.
Sniffer shows:
Rcvd pairing failed: Pairing not supported.
I do understand that some thing is getting stored in persistent memory. So how do i remove it or how do i load that data again.
Mobile app Logs:
Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST
Sounds like you've triggered one of the default security features of the nRF.
The nRF knows it has an encryption key with the phone (as it's been paired before), but the phone doesn't know the key (because you unpaired it and it deleted the key), so the nRF assumes someone is trying to spoof the real phone and drops the connection as defense.
Not sure which nRF SDK you're using, but if you search for peer_manager in the initialisation routine you should see an option to allow keys to be over-written.
Here's the relivent docs. One quick-fix, if security isn't a concern, is to delete all bonding info on the nRF with pm_peers_delete()

Silicon Labs CP2102 interface. How to talk using minocom

I have an infrared thermometer which operates on a virtual serial port over USB, which I am trying to use on a Linux intel and next on a raspberry Pi. The system did not enumerate a /dev/ttyUSB device.
I found a piece of a solution here :
Cygnal Integrated Products serial port on Linux
I reprogrammed the product_ID and can now see it as /dev/ttyUSB0.
But trying to talk to the thermometer with minicom doesn't work.
minicom keeps saying "disconnected" despite the "9600 8N1" indication.
I must say, I had many attempt to work with this kind of communication over USB/serial adapter trying using many different terminal emulator like screen or minicom but without any success at all !
I'm not even sure about the right way to send request and receive data.
Here is the documentation I'm using trying to talk to the thermometer :
http://www.optris.com/interfaces?file=tl_files/downloads/Manuals/addendums-de-en/ct-ctlaser-commands.pdf
Edit :
I'm now trying to use PySerial Python library in a Python script with an Arduino as a target (to act as my thermometer, the arduino runs a simple code that takes the data received and send them back to my Python console.) But still, there is so many confusion possible between ASCII, Hexa, binary, that I'm not capable of debugging anything as I don't know where the transformation between different format takes place !
The communication is working as I can get some data forth and back from my Python console through the Arduino. But I can't get sending hexadecimal data and getting any response back in hexadecimal format. + You say "Your latest question puts you in the off-topic category. ", what do you mean ? Sorry of being so confused.

Bluetooth HCI command for enabling BLE advertising

I am currently trying to write some test scripts to get a bluetooth device fcc certified. I have been following these two sites http://processors.wiki.ti.com/index.php/CC256x_VS_HCI_Commands,
http://processors.wiki.ti.com/index.php/WL18xx_Bluedroid_Bluetooth_RF_Testing. I've been using the later to convert commands from the former into tests that the bluedroid test tool will recognize. I have had success for the most part, but I need away to turn on BLE advertising mode and cannot find a way to do it. The bluetooth chip I am using is a Pan13xx from Panasonic. If anyone could point me in the right direction that would be amazing.
Thanks in advance.
I haven't tried this, but according to the Bluetooth 4.2 spec (Vol 2, Part E, 7.8.9 Page 1284):
HCI_LE_Set_Advertise_Enable is the command for starting/stopping advertising.
It takes an Advertising_Enable parameter which is defined as:
0x00: Advertising is disabled (default)
0x01: Advertising is enabled.
0x02 – 0xFF: Reserved for future use Value
and returns Status which is defined as:
0x00: LE_Set_Advertise_Enable command succeeded
0x01 – 0xFF: LE_Set_Advertise_Enable command failed

Creating a Customized MODBUS Program for a Remote Terminal Unit

I have here a unit of King Pigeon S275 Remote Terminal Unit..
this RTU has communication modules for GSM, GPRS and TCP/IP (via RJ45 connection)
I can also communicate with this RTU by connecting it to my computer via USB .
The Manual I uploaded in this link...
https://www.mediafire.com/?gnfzfz5l7pess1p
This RTU can be configured using a configurator Software that is included in the purchase. By using that configurator software, you can also see the data/readings of all sensors connected to it, you can also see the status of all Digital Input/contacts connected to the RTU...
I have been researching about MODBUS the past days and I would like to create my own MODBUS program so that the S275 RTU can also send the sensors' data, or all the I/O data to my own program....
However ... I still do not know where I can start ...
Can I make this Modbus Program
1. using VB?
2. using PHP?
What other parameters do I need to know ?
and tutorials for making this modbus software...
I also uploaded here the S275's;
1. GPRS Custom Protocol
2. MODBUS TCP Handshake Communication Protocol
3. Register Address
https://www.mediafire.com/?khnfu53a4p12nrd
Thanks
PHP and ModBus sounds challenging. You want to control a serial port via PHP.
The easiest way is to get/purchase a library for ModBus/RTU.
Otherwise you have to implement the whole protocol by yourself from http://www.modbus.org/specs.php
You can use nmodbus API to add how reference in your VB or C# project.
There you have the manual.
Supports serial ASCII, serial RTU, serial over USB ASCII, serial over USB RTU, TCP, and UDP protocols.
These kinds of RTU’s are pretty inexpensive which means your greatest cost will be the time you will spend developing and debugging a driver. With that in mind I would first check if the RTU comes with its own OPC Server. Implementing an OPC client in C# or vb.net is very straight forward with plenty of code example out there. Some examples can be found here:
https://opcfoundation.org/developer-tools/developer-kits-unified-architecture/-net-stack-and-sample-applications/
If the RTU does not come with its own OPC server then, you can purchase a Modbus OPC Server from $900 to $2000 which will still be much more cost effective than writing and debugging your own driver and tends to be easier to setup. It will also significantly reduce the time to deliver your solution to your end customer which will be important if keep to project schedule is critical. I would check out, https://www.kepware.com/ and http://www.matrikonopc.com/
The other advantage of OPC is that it is a standardized interface which means should the RTU be replaced with a different model that supports a different protocol you would only have to purchase a new OPC server without the need to update your source code.
If the RTU does not have an OPC server or spending up to $2000 also not an option then there is plenty of open source implementations of the Modbus protocol, however implementation tends to be a bit more complex.
No problem, I used PHPModBus in several projects and it works like a charm!
This library supports Modbus TCP and UDP.
Try it, it is quite easy and straightforward.

Send and receive data simultaneously on Parallel Port

If I understand the parallel port right, sending data from (D0 to D7) simultaneous, but that it can control the sticks individually?
example:
D0 = Input
D1 = Input
D2 = Output
...
...
...
D7 = Input
would it work?
what I want to do is to both send and receive data simultaneously.
Data wires (D0-D7) are being read or set simultaneously. For various tecniques for bidirectional I/O read the attached articles:
Standard parallel port: http://www.beyondlogic.org/spp/parallel.htm
EPP: http://www.beyondlogic.org/epp/epp.htm
ECP: http://www.beyondlogic.org/ecp/ecp.htm
This site is a good source for programming the parallel port.
The basic idea is that you need a DLL, add-on or library that allows you to access the I/O Ports of the PC. For Windows XP on up you need a specific driver that will allow you do this as the OS doesn't offer access out of the box.
The Parallel port will generally reside at one of three address 278,378, 3BC. This port. have the bytes you are reading or writing.
The (base)+1 port allows access to the status bytes. IE. 279,379, 3BD
The (base)+2 port allows access to the control bytes. IE. 27A,37A,3BE
The parallel port documentation will tell not only how to implement the common modes (like bi-directional) but how to control the port at the byte level to implement your own custom.
Back in the day there was only the standard mode available. You pump out your bytes at the (base) port. Some application, like mine, manipulated individual bits of that ports as form of cheap Digital I/O Controller. We did use the status and control bytes as additional inputs and outputs. There were commands you can send to the Parallel Port chip configure the modes precisely.
Today there are are hundreds of sites with example of using the Parallel Port to solve all kinds of problems. I would be surprised that one of doesn't have something you can use for you specific application.
Again the book I recommend starting with is Parallel Port complete. It tells just about everything you need to start with. If your application is too esoteric for that book it will give a springboard from which you can find the exact setup you need.
Of course by sending a number that has just the required bit set (2n) you'd get the expected result.
I'm not sure about bidirectional access though. I guess it's achieved by using control pins along with the data pins but that's just a guess.
Parallel ports doing EPP or ECP only allow D0-D7 to be all input or all output. Trying to do otherwise may fry your hardware.
See http://www.nor-tech.com/solutions/dox/ieee1284_parallel_ports.pdf, page 6.
However, parallel ports have several control lines that may be useful if you only need a small amount of input/output in the "other" direction.
I believe its bit 5 in the port's control register (base address + 2) that switches direction. (no hardware line attached)