I already know how to establish a wifi connection with the OBD2 adapter, but I have no idea how to request information from it. Like 010C is the command to return the engine RPM in hex form, but how do I even send "010C" to the OBD2 adapter? I can find answers and even OBD frameworks for languages like Java and Python, but nothing for swift. Thanks.
3 Answers
If you have already established a socket communication to the WiFi adapter, then either bind the socket to a pair of NSStream
s and send/receive data using those or use the CoreFoundation
API or the low-level posix
API to send/receive data.
Chances are you might want something more high-level though. I have created an OBD2 library for iOS and macOS at https://github.com/mickeyl/LTSupportAutomotive. It's written in Objective-C and would need Swift bridging headers to make it useful for you, but that might be a good way for you to dive more into the topic.

- 4,455
- 3
- 31
- 67
Our java implementation requires converting String messages, like "010C" or "ATZ" to byte[] and then sending those bytes to the OBD2 adapter. I imagine you'll have to do the same for swift.
Here is a resource on working with OBD2 adapters that may help you: http://elmelectronics.com/DSheets/ELM327DS.pdf

- 401
- 5
- 7
You need to know OBD protocol such as: ISO 9141-2
, KW-2000
, ISO 14230-4
, SAE J1850
and CAN ISO 15765-4
(11 bit or 29bit).
Take a look at this reference to get more information.
You can find PID OBD2
here.

- 3,208
- 9
- 22
- 33

- 5
- 3