-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP8266 #9
Comments
Try this: #include <ESP8266WiFi.h>
#include "ELMduino.h"
const char* ssid = "WiFi_OBDII";
const char* password = "your-password";
//IP Adress of your ELM327 Dongle
IPAddress server(192, 168, 0, 10);
WiFiClient client;
ELM327 myELM327;
uint32_t rpm = 0;
void setup()
{
Serial.begin(115200);
// Connecting to ELM327 WiFi
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid);
// WiFi.begin(ssid, password); //Use this line if your ELM327 has a password protected WiFi
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Connected to Wifi");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
if (client.connect(server, 35000))
Serial.println("connected");
else
{
Serial.println("connection failed");
ESP.reset();
}
myELM327.begin(client);
}
void loop()
{
float tempRPM = myELM327.rpm();
if (myELM327.status == ELM_SUCCESS)
{
rpm = (uint32_t)tempRPM;
Serial.print("RPM: "); Serial.println(rpm);
}
else
{
Serial.print(F("\tERROR: "));
Serial.println(myELM327.status);
delay(100);
}
} |
Thanks for your Response ! I hope this is Right ?:float tempCOOLANT = myELM327.queryPID(SERVICE_01,ENGINE_COOLANT_TEMP); void loop() if (myELM327.status == ELM_SUCCESS)
|
I was able to help another user successfully query non-rpm/non-speed PIDs in issue #4. Keep in mind, you have to check Here's an example: // modified test + my custom PIDs
// based purely on library
#include "BluetoothSerial.h"
#include "ELMduino.h"
#define ELM_PORT SerialBT
#define ESP_BLUETOOTH_NAME "ESP32"
BluetoothSerial SerialBT;
ELM327 myELM327;
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
Serial.begin(115200);
ELM_PORT.begin(ESP_BLUETOOTH_NAME, true);
Serial.println("Attempting to connect to ELM327...");
if (!ELM_PORT.connect("V-LINK"))
{
Serial.println("Couldn't connect to OBD scanner - Phase 1");
while (1);
}
if (!myELM327.begin(ELM_PORT))
{
Serial.println("Couldn't connect to OBD scanner - Phase 2");
while (1);
}
Serial.println("Connected to ELM327");
for (int a = 0; a < 10; ++a)
{
digitalWrite(LED_BUILTIN,HIGH); delay(100);
digitalWrite(LED_BUILTIN,LOW); delay(100);
}
}
void loop()
{
int32_t rpm = -1;
int32_t soot = -1;
int32_t burn = -1;
float litersLeft = -1;
/////////////////////////////////////////////////////// RPM
float tempRPM = myELM327.rpm();
Serial.print("Payload received for rpm: ");
for (byte i = 0; i < PAYLOAD_LEN; i++)
Serial.write(myELM327.payload[i]);
Serial.println();
if (myELM327.status == ELM_SUCCESS)
{
rpm = (int32_t)tempRPM;
Serial.print("RPM: "); Serial.println(rpm);
}
else
printError();
/////////////////////////////////////////////////////// Soot
if (myELM327.queryPID(34, 13162))
{
int32_t tempSoot = myELM327.findResponse();
Serial.print("Payload received for soot: ");
for (byte i = 0; i < PAYLOAD_LEN; i++)
Serial.write(myELM327.payload[i]);
Serial.println();
if (myELM327.status == ELM_SUCCESS)
{
soot = tempSoot;
Serial.print("Soot: "); Serial.println(soot);
}
else
printError();
}
/////////////////////////////////////////////////////// Liters
if (myELM327.queryPID(34, 4906))
{
int32_t tempLitersLeft = myELM327.findResponse() / 64.0;
Serial.print("Payload received for liters: ");
for (byte i = 0; i < PAYLOAD_LEN; i++)
Serial.write(myELM327.payload[i]);
Serial.println();
if (myELM327.status == ELM_SUCCESS)
{
litersLeft = tempLitersLeft;
Serial.print("Liters: "); Serial.println(litersLeft);
}
else
printError();
}
/////////////////////////////////////////////////////// Burns
if (myELM327.queryPID(34, 8434))
{
int32_t tempBurn = myELM327.findResponse();
Serial.print("Payload received for DPF burns: ");
for (byte i = 0; i < PAYLOAD_LEN; i++)
Serial.write(myELM327.payload[i]);
Serial.println();
if (myELM327.status == ELM_SUCCESS)
{
burn = tempBurn;
Serial.print("DPF burns: "); Serial.println(burn);
}
else
printError();
}
for (int a = 0; a < 5; ++a)
{
digitalWrite(LED_BUILTIN,HIGH);
delay(200);
digitalWrite(LED_BUILTIN,LOW);
delay(200);
}
}
void printError()
{
if (myELM327.status == ELM_SUCCESS)
Serial.println(F("\tELM_SUCCESS"));
else if (myELM327.status == ELM_NO_RESPONSE)
Serial.println(F("\tERROR: ELM_NO_RESPONSE"));
else if (myELM327.status == ELM_BUFFER_OVERFLOW)
Serial.println(F("\tERROR: ELM_BUFFER_OVERFLOW"));
else if (myELM327.status == ELM_GARBAGE)
Serial.println(F("\tERROR: ELM_GARBAGE"));
else if (myELM327.status == ELM_UNABLE_TO_CONNECT)
Serial.println(F("\tERROR: ELM_UNABLE_TO_CONNECT"));
else if (myELM327.status == ELM_NO_DATA)
Serial.println(F("\tERROR: ELM_NO_DATA"));
else if (myELM327.status == ELM_STOPPED)
Serial.println(F("\tERROR: ELM_STOPPED"));
else if (myELM327.status == ELM_TIMEOUT)
Serial.println(F("\tERROR: ELM_TIMEOUT"));
else if (myELM327.status == ELM_GENERAL_ERROR)
Serial.println(F("\tERROR: ELM_GENERAL_ERROR"));
}
delay(500);
} |
Seeing as @Felix-Jost was able to get it to work for an ESP8266, I'm closing this ticket. |
I want to read PIDs over my ESP8266 WiFi Modul.
How can i implement your ELM Duino to read Pids over the wifi connection ?
When i enter 010C in my serial monitor iam get the right answer from the ELM327 so the connection should be fine ?
But now i dont no know how i can use ur ELMDuino sketch to simplify things and get the data to be print in to my serial monitor ?
`#include <ESP8266WiFi.h>
const char* ssid = "WiFi_OBDII";
const char* password = "your-password";
//IP Adress of your ELM327 Dongle
IPAddress server(192, 168, 0, 10);
boolean last_in = false;
WiFiClient client;
void setup() {
Serial.begin(115200);
delay(10);
// Connecting to ELM327 WiFi
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid);
// WiFi.begin(ssid, password); //Use this line if your ELM327 has a password protected WiFi
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Connected to Wifi");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
if (client.connect(server, 35000)) {
Serial.println("connected");
Serial.println("<ATZ");
// Make a Request
client.println("ATZ");
}
else {
Serial.println("connection failed");
ESP.reset();
}
}
void loop() {
if (!client.connected()) {
Serial.println("CLIENT DISCONNECTED - RESET!");
client.stop();
ESP.reset();
}
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
if (!last_in) {
Serial.println("");
Serial.print(">");
last_in = true;
}
char c = client.read();
/Serial.print(" 0x");
Serial.print(c, HEX);/
Serial.print(c);
}
// as long as there are bytes in the serial queue,
// read them and send them out the socket if it's open:
while (Serial.available() > 0) {
if (last_in) {
Serial.println("");
Serial.print("<< ");
last_in = false;
}
char inChar = Serial.read();
if (client.connected()) {
client.print(inChar);
}
}
}`
The text was updated successfully, but these errors were encountered: