meatpiHQ / wican-fw

GNU General Public License v3.0
295 stars 58 forks source link

ELM327 unable to connect to car #144

Open stibbzy opened 3 months ago

stibbzy commented 3 months ago

I just received my WiCan (USB) and having trouble on my BMW i3. When I use Carscanner with a BT OBD2 adaptor it connects just fine and I can get sensor data from the car. However, when I connect Carscanner to the WiCan, it says “succesfully connected to ELM327, but ELM327 wasn't able to establish connection with your car.” The green LED is on and the orange LED is flashing. I’ve tried turning MQTT on and off, and disabled battery alerts. Different bitrates don’t work either. The Carscanner log has a lot of “BUS INIT: …ERROR” messages. I've attached screenshots from Carscanner when it is working via the BT adaptor and when it isn't via WiCan. I've attached the log as well.

IMG_2875 IMG_2881 (1) IMG_2885 IMG_2884 IMG_2883 IMG_2879 IMG_2878 IMG_2877 IMG_2876

Carscanner log.txt

stibbzy commented 3 months ago

@meatpiHQ That didn't have any effect, however, I had left the car just sitting with RX frames pouring in, and a few other IDs showed up, but at much less frequency than the 304 ID (these showed up before your latest suggestion):

Screenshot 2024-06-23 at 4 17 10 PM
meatpiHQ commented 3 months ago

can you show me what's in the frames? part of them are hidden in the screenshot

stibbzy commented 3 months ago

@meatpiHQ This is for 1815: {"bus":"0","type":"rx","ts":35227,"frame":[{"id":126,"dlc":15,"rtr":true,"extd":false,"data":[0,0,0,0,0,0,0,0]},{"id":75126616,"dlc":10,"rtr":true,"extd":true,"data":[0,0,0,0,0,0,0,0]},{"id":160979277,"dlc":3,"rtr":false,"extd":true,"data":[99,6,33,0,0,0,0,0]},{"id":443501415,"dlc":2,"rtr":true,"extd":true,"data":[0,0,0,0,0,0,0,0]},{"id":1815,"dlc":1,"rtr":true,"extd":false,"data":[0,0,0,0,0,0,0,0]}]}

For 443501415: {"bus":"0","type":"rx","ts":37716,"frame":[{"id":286,"dlc":10,"rtr":true,"extd":false,"data":[0,0,0,0,0,0,0,0]},{"id":607,"dlc":15,"rtr":true,"extd":false,"data":[0,0,0,0,0,0,0,0]},{"id":161241413,"dlc":3,"rtr":true,"extd":true,"data":[0,0,0,0,0,0,0,0]},{"id":1441,"dlc":3,"rtr":false,"extd":false,"data":[37,205,16,0,0,0,0,0]},{"id":443501415,"dlc":2,"rtr":true,"extd":true,"data":[0,0,0,0,0,0,0,0]}]}

For 1967: {"bus":"0","type":"rx","ts":37718,"frame":[{"id":475920656,"dlc":3,"rtr":true,"extd":true,"data":[0,0,0,0,0,0,0,0]},{"id":1967,"dlc":12,"rtr":true,"extd":false,"data":[0,0,0,0,0,0,0,0]}]}

meatpiHQ commented 3 months ago

I've never seen anything like this before... dlc= 15 ?? how is that even possible. DLC in a CAN frame is max 8.

stibbzy commented 3 months ago

@meatpiHQ Oh dear lol. All this was brought about because the 3g network in Australia was shut down this month, and now a group of us on Facebook are trying to find a solution to get at least the SOC out of the car.

It is working with OVMS... is there anything in the GitHub code for that which would help?

meatpiHQ commented 3 months ago

ah so the i3 has a 3G connection?

I can send you the new WiCAN pro adapter, it supports all the possible OBD commands. And will let you connect to the LTE using an accessory. https://www.crowdsupply.com/meatpi-electronics/wican-pro

stibbzy commented 3 months ago

@meatpiHQ Oh really? Should that work out of the box like carscanner then if it supports all commands?

meatpiHQ commented 3 months ago

yes absolutely, that's what it's supposed to do. It's WiCAN on steroids or more like an OBDLINK MX with an esp32 as an application processor. The firmware is not 100% yet but I will have something soon.

Send me an email with your shipping address: https://www.meatpi.com/contact

It is working with OVMS... is there anything in the GitHub code for that which would help?

I saw the code it's massive, it will take me a while to find it.

stibbzy commented 3 months ago

@meatpiHQ OK, will do! This is the i3 portion of the OVMS anyway, for what it's worth: https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/tree/master/vehicle/OVMS.V3/components/vehicle_bmwi3

meatpiHQ commented 2 months ago

Hey @stibbzy please try this on WiCAN Pro. Extract the firmware from the zip file and update the device.

wican-fw_obd_pro_v298-5-gc28f6be-dirty.zip

First set the protocol to: AutoPID

image

Then add a new custom pid and fill in the parameters below, then press the store button then reboot the device. If it works you should see a mqtt message on topic "soc_topic" with the soc value.

Initialisation: ATAT1;ATCEA07;ATTAF1;ATFCSH6F1;ATSH6F1;ATFCSD07300000;ATFCSM1;ATCRA607; Name: SoC PID: 22DDBC Expression: [B6:B7]/10 Period: 2000 Send_to: soc_topic

image
stibbzy commented 2 months ago

@meatpiHQ Ahh so close! So after configuring as above, the soc_topic is returning 410.5... My battery SoC reported by Carscanner (when in elm327 mode) is 46.4%... I tried with 'Expression' set at just 'V' but it returned 0.

meatpiHQ commented 2 months ago

@stibbzy can you please send me the carscanner log when using WiCAN pro to read the SoC? Set the protocol back to elm327 to carscanner.

stibbzy commented 2 months ago

@meatpiHQ Log is attached, with tonight’s results right down the bottom. Bmwi3log08072024.txt

meatpiHQ commented 2 months ago

@stibbzy Please try this firmware with this new Initialisation string, I also added "raw" value to the mqtt message, this will help to debug the issue.

Initialisation:

ATE0;ATH1;ATAL;ATPBE101;ATSPB;ATBI;ATSH6F1;ATAT0;ATSTFF;ATCRA607;ATCEA07;ATFCSH6F1;ATFCSD07300800;ATFCSM1;

wican-fw_obd_pro_v298-7-g92a9d58-dirty.zip

I tried with 'Expression' set at just 'V' but it returned 0.

You cannot use V, instead I enabled byte array. [B6:B7]/10 will take the value of byte 6 and 7 and divide it by 10.

stibbzy commented 2 months ago

@meatpiHQ Ok, so after applying the firmware, the calculated result is the same (410.5), but I can see the raw frame and can see it reporting the correct SoC. This is a screenshot:

Screenshot 2024-07-09 at 8 11 29 AM

Per my previous comment:

Apparently, 22DDBC is the battery SOC and that is present in my log, eg:

22DDBC 607F1037F2278 607F1100962DDBC027D 607F121031C0050FFFF

If I just take the first frame and convert the last byte? 027D into decimal, I get 637, and my current SOC according to Carscanner is 63.7%. I then ran the car down to 63% SOC according to Carscanner, and the byte returned was 0276 in the log, which is a perfect match.

I can see that the value after 62DDBC in my new result is 03E8, which is decimal 1000. Divide by 10 is 100. Since I fully changed the car last night, this is a match for the actual SoC.

Also note that the front page is still reporting a battery voltage of 0. I don't know if this means it won't go into low power mode, so I've been pulling it off the OBD port in between tests.

meatpiHQ commented 2 months ago

@stibbzy ok I know whats going on. Try this

Expression: [B11:B12]/10

stibbzy commented 2 months ago

@meatpiHQ That gave 844.8, which is 2100 hex, which is in the second frame. I played around with the byte array while referencing the response, and it really seemed like [B11:B12]/10 was correct. I finally set it back to that, and suddenly it reported SoC 100! But the raw response was 0A (10 dec). Pulled it out of the OBD port and reinserted, the SoC remained at 100 and the full frame was reported again.

So it seems to be working, apart from the battery voltage!

meatpiHQ commented 2 months ago

@stibbzy Great! I still don't fully understand this, the response for the PID request seems to be either 2 frames or 3 frames. BMW are always so special. Let me know if you see any jump in the battery SoC value.

So it seems to be working, apart from the battery voltage!

I'm aware of the issue, this still needs a bit of work.

Btw have you tried BimmerCode and BimmerLink Apps?

stibbzy commented 2 months ago

@meatpiHQ Yep, I've used BimmerCode to disable the OBD alarm and modify other features. So if I leave the unit plugged in, will it detect the 12v level and go into low power mode at the moment?

meatpiHQ commented 2 months ago

@stibbzy good to know that it works with BimmerCode.

So if I leave the unit plugged in, will it detect the 12v level and go into low power mode at the moment?

Lower power mode is not ready yet, still needs a bit more work. I'll send you a firmware update when it's ready.

stibbzy commented 2 months ago

@meatpiHQ Ahh ok, that means it's not usable as yet as a permanent install.

Can the WiCAN Pro be powered externally? That is why I originally went with the WiCAN USB, as I have a nice 70Wh battery in the car powering my Dashcam.

meatpiHQ commented 2 months ago

@stibbzy yeah not ready for permanent install yet but it will be soon.

No it cannot be powered from the USB connector.