pyHPSU icon indicating copy to clipboard operation
pyHPSU copied to clipboard

ELM not working

Open m-reuter opened this issue 3 years ago • 27 comments

Hi, can anyone help me get started?

I bought the ELM that is linked in the readme, "bbfly Forscan Elm327 ELMconfig USB VINT-TT55502 mit MS-CAN für Ford OBD2 Diagnose" but cannot get it to work (actually I tried with two of these, to make sure it is not broken - bought from different vendors, but otherwise the same ). Both show the same problems. Also, my heat pump is Rotex HPSU compact ultra. I know the folks at FHEM use the same adapter and it works for them. My goal is to run pyHPSU in a docker and push info (both ways) via MQTT to homeassistant.

I usually get (but not always) when I run for the first time after connecting: pyHPSU.py -d ELM327 -p /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 -v 2 -c flow_rate error - Error sending AT PP 2F ON (rc:AT PP 2F ONOK)

and when I run it a second time: pyHPSU.py -d ELM327 -p /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 -v 2 -c flow_rate warning - sending cmd 31 00 FA 01 DA 00 00 (rc:NO DATA) warning - retry 1 command flow_rate (also when trying other commands)

I have a Raspberry Pi 4 B. Is the ELM working for anyone in this constellation? What ELM are you using? Or do I need to get a PICAN hat? If so, does the PICAN 2 work on the Raspi 4?

Thanks for any help.

P.S. I connected to Rotex first from the female OBD 16 pin connector with 2m wire. Then, because I was unsure if wires are twisted pairs in that cable, I now use an ethernet cable with a twisted pair. Either way same result. Also, I run pyHPSU in a docker, but given that the ELM reacts I think that works fine. In the meantime, I will re-build that docker to be double sure that I am running the latest version but I built it just a couple of weeks ago.

m-reuter avatar Mar 12 '21 22:03 m-reuter

I tried the same ELM327 adapter and got the same bad result. :-( The command „AT Z“ is answered with „ELM327 v1.5“. Zanac wrote that Version 1.5 is a China clone where the PP command is not implemented correctly. Can anybody with a working adapter confirm that? What version should a working adapter have? Pics of my board showing the microprozessor PIC18F25K80 that emulates the ELM327:

56599AB9-4849-48EC-849C-2D7967A256CD 8F6BBEF2-84B9-4B9C-9B76-66484468622E

regards Karl

KalaNagHTD avatar Mar 13 '21 06:03 KalaNagHTD

Or do I need to get a PICAN hat? If so, does the PICAN 2 work on the Raspi 4?

I'm using a Raspi 4 with the PICAN 2 duo. Works without any problems.

Regards Martin

martinbischofff avatar Mar 13 '21 16:03 martinbischofff

Today I tried the RS485 CAN Hat also without any success, although I am not sure if it can be seen, because either way (conntected to rotex or not) I get this: pyHPSU.py -c t_hs error - Not aquired bus warning - msg not sync, retry: 1 ...

I do see the can0 in ifconfig (outside the docker) but I don't have ifconfig in the docker image, to check there.

Another thing:

When I connect the Rotex this happens (also occured with the ELM before): Rotex goes into "Absenk" (sorry, don't know the english) mode and I cannot see any room temp (only "-") I have to restart the Rotex again after that. This behavior is a little scary. It happens without sending a command, only attaching the two (hi, lo) CAN cables.

m-reuter avatar Mar 13 '21 17:03 m-reuter

With ifconfig my Pican2 shows up as follows:

can0: flags=193<UP,RUNNING,NOARP> mtu 16 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC) RX packets 2682935 bytes 18780545 (17.9 MiB) RX errors 1 dropped 1279 overruns 0 frame 1 TX packets 166256 bytes 1163792 (1.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

with dmesg I see the following:

[ 8.342024] CAN device driver interface [ 8.359017] mcp251x spi0.0 can0: MCP2515 successfully initialized.

Does your Waveshare RS485 CAN Hat show similar lines?

Did you modify the config.txt according to the RS485-CAN-HAT-user-manual? (https://www.waveshare.com/w/upload/2/29/RS485-CAN-HAT-user-manuakl-en.pdf)

dtparam=spi=on dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25,spimaxfrequency=200000

KalaNagHTD avatar Mar 13 '21 20:03 KalaNagHTD

I forgot to mention: The error message „error - Not aquired bus“ shows up, when the CAN board is not initialiced correctly in the config.txt

KalaNagHTD avatar Mar 14 '21 05:03 KalaNagHTD

Thanks Karl,

I had the config.txt adjusted already:

# RS485 CAN Hat
# https://www.waveshare.com/w/upload/2/29/RS485-CAN-HAT-user-manuakl-en.pdf
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25,spimaxfrequency=1000000

Ifconfig shows only zeros (which could be ok after a reboot without sending anything).

can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

And I had this (same as in README) in /etc/network/interfaces also:

auto can0
iface can0 inet manual
     pre-up /sbin/ip link set $IFACE type can bitrate 20000 triple-sampling on
     up /sbin/ifconfig $IFACE up
     down /sbin/ifconfig $IFACE down

I'll probably have to try outside of docker, if I start inside docker I get the errors and also the TX RX packages do not change. This is my docker command docker run --name pyhpsu -v /home/pi/projects/pyHPSU-docker-cmds:/etc/pyHPSU --network host -it --rm --entrypoint /bin/bash pyhpsu

and I pass -network host to have can0 available inside docker (maybe that part is not working properly). Maybe I can test this with picocom but not sure how I connect it to the can0 device, it only worked with /dev devices so far. thanks.

m-reuter avatar Mar 14 '21 10:03 m-reuter

I tried the same ELM327 adapter and got the same bad result. :-( The command „AT Z“ is answered with „ELM327 v1.5“. Zanac wrote that Version 1.5 is a China clone where the PP command is not implemented correctly. Can anybody with a working adapter confirm that? What version should a working adapter have? Pics of my board showing the microprozessor PIC18F25K80 that emulates the ELM327:

8F6BBEF2-84B9-4B9C-9B76-66484468622E

regards Karl

With regard to the findings in the project „fhemHPSU“ my Adapter ELM v.1.5 with the PIC18F25K80 should do the job!

URL: wiki.fhem.de/wiki/Rotex_HPSU_Compact#ELM327_OBD2_Adapter

KalaNagHTD avatar Mar 14 '21 13:03 KalaNagHTD

So what do people get when they run pyHPSU without anything attached to the CAN interface? Is it the same as

exception - Error sending msg
error - Not aquired bus
warning - msg not sync, retry: 1
error - Not aquired bus
...

and is there any way to check if my can0 interface works without connecting it? Then I'd know if I need to debug on the raspi side or if it could be the cable connection (at least for the can hat version). For ELM I think the problems is likely on the software/driver/raspi side given that:

  • I can contact it (e.g. via picocom ) and interact
  • pyHPSU works for KarlaNag when he uses the can0 interface but same cable connection attached to ELM does not work
  • and it should work theoretically according to the readme and according to the people at fhemHPSU

Also I modified pyHPSU.py to work from a local directory without having to install it, so I can test without docker. Only had to change the hard-coded paths everywhere.

Any help would be apprechiated. Thanks.

m-reuter avatar Mar 16 '21 20:03 m-reuter

In order to clarify that I removed the CAN-connection from my Pican2 and got the same message („Error - Not aquired bus“) After reconnecting the CAN the message remained the same and I had to power reset the Pi to get the unit working again.

KalaNagHTD avatar Mar 17 '21 09:03 KalaNagHTD

Thanks @KalaNagHTD for testing! In the meantime I obtained a Pican2 hat (my 4th CAN device after two ELMs and the RS485 CAN Hat) and with the Pican2 on Raspi 4b it finally works (both inside and outside docker).

Given that there was little response here with respect to those other two devices I would advise to remove those buying recommendations from the README until we know what is causing these problems: Could be changes in the code, could be incompatibility with some more recent RasPi (I have 4b) or incompatibility with the compact ultra model of Rotex. We don't know.

Also it would be great if anyone who has a running setup with either the ELM or the RS485 CAN Hat can post details of his Hardware (exact CAN device, computer, and heatpump model) and Software setup here.

Happy to try a couple things, will probably keep one of the ELMs around and will return the RS.. hat and 2nd ELM.

m-reuter avatar Mar 17 '21 15:03 m-reuter

Just wanted to say that the RS485 CAN Hat works fine with my old Pi2 which I'm using. Added the config to /boot/config.txt and the rest was straight forward. # CAN dtparam=spi=on dtoverlay=mcp2515-can0,oscillator=12000000,interrupt=25,spimaxfrequency=1000000

evildad avatar Dec 22 '21 14:12 evildad

Good news for budget sensitive projects! Thank you!

KalaNagHTD avatar Dec 22 '21 16:12 KalaNagHTD

Just wanted to say that the RS485 CAN Hat works fine with my old Pi2 which I'm using. Added the config to /boot/config.txt and the rest was straight forward. # CAN dtparam=spi=on dtoverlay=mcp2515-can0,oscillator=12000000,interrupt=25,spimaxfrequency=1000000

Hi! I want to connect to my HPSU too and I have the RS485 Can Hat. Can you tell me which connections did you use? I mean, I can see that we have the CAN-H and CAN-L on the RS485 Hat but not the GND. I guess I can use any GND from the Pi? Or GND is not needed? Thanks!

acalatrava avatar Jul 28 '22 07:07 acalatrava

Hi @acalatrava , sorry for my late answer, CAN-H and CAN-L with twisted pair cable is working for me, GND is not needed.

evildad avatar Aug 03 '22 18:08 evildad

Hi, can anyone help me get started?

I bought the ELM that is linked in the readme, "bbfly Forscan Elm327 ELMconfig USB VINT-TT55502 mit MS-CAN für Ford OBD2 Diagnose" but cannot get it to work (actually I tried with two of these, to make sure it is not broken - bought from different vendors, but otherwise the same ). Both show the same problems. Also, my heat pump is Rotex HPSU compact ultra. I know the folks at FHEM use the same adapter and it works for them. My goal is to run pyHPSU in a docker and push info (both ways) via MQTT to homeassistant.

I usually get (but not always) when I run for the first time after connecting: pyHPSU.py -d ELM327 -p /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 -v 2 -c flow_rate error - Error sending AT PP 2F ON (rc:AT PP 2F ONOK)

and when I run it a second time: pyHPSU.py -d ELM327 -p /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 -v 2 -c flow_rate warning - sending cmd 31 00 FA 01 DA 00 00 (rc:NO DATA) warning - retry 1 command flow_rate (also when trying other commands)

I have a Raspberry Pi 4 B. Is the ELM working for anyone in this constellation? What ELM are you using? Or do I need to get a PICAN hat? If so, does the PICAN 2 work on the Raspi 4?

Thanks for any help.

P.S. I connected to Rotex first from the female OBD 16 pin connector with 2m wire. Then, because I was unsure if wires are twisted pairs in that cable, I now use an ethernet cable with a twisted pair. Either way same result. Also, I run pyHPSU in a docker, but given that the ELM reacts I think that works fine. In the meantime, I will re-build that docker to be double sure that I am running the latest version but I built it just a couple of weeks ago.

I have the same issue with my USB PIC18F25K80. How about you? Do you still use it? I remember that someone has used it with fhem.

ap20132022 avatar May 14 '23 20:05 ap20132022

Not sure about your ELM. I have rotex compact ultra also and used the pican 2 hat with success in the past. I also created an Addon for Homeassistant: https://github.com/m-reuter/ha-addons/tree/master/pyhpsu2mqtt

However after updating my PI 4 to Debian for a supported Homeassistant install, I cannot reach my pican any longer (I think drivers are missing from the kernel). So far I could not get that fixed, was planing on waiting for support in a newer kernel version, which I think is on the release list. If anyone has a pican 2 hat running with debian, let me know how you did it. Thanks.

m-reuter avatar May 14 '23 20:05 m-reuter

I'm having a similar problem @m-reuter. Using RS485 CAN HAT with pi3b+. I get this error - Error opening bus can0. I don't know what to do

If i run the command; python3 /usr/local/bin/can_logger.py -c can0 -v -i socketcan

I can see all the log's, so i think that the can interface is working properly.

Vortecsz avatar Jul 24 '23 23:07 Vortecsz

Do you have the right frequency in /boot/config.txt? I have 2 CAN HATs, with different crystals on it. The old one needs:

dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25,spimaxfrequency=1000000

and the newer one:

dtoverlay=mcp2515-can0,oscillator=12000000,interrupt=25,spimaxfrequency=2000000

svde avatar Jul 25 '23 05:07 svde

Yes I have the one with the 12000 crystal. And I have the correct configuration. Did you do anything else to make it work?

ifconfig; can0: flags=193<UP,RUNNING,NOARP> mtu 16 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC) RX packets 361 bytes 2527 (2.4 KiB) RX errors 0 dropped 361 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

No, Tx packets received is it normal?

If i run the command ; $ python3 -m can.viewer -c can0 -i socketcan:

Count Time dt ID DLC Data 12 4.088397 0.009194 0x300 7 20 0A FA 01 1A 00 00 4 3.994816 0.009091 0x600 7 20 0A 57 00 00 00 00 17 2.099257 1.965096 0x10A 7 31 00 FA C0 B4 00 00 44 2.306634 0.065849 0x180 7 22 0A FA C0 B4 00 22 7 2.297788 0.009091 0x500 7 20 0A 61 00 00 00 00 5 5.011898 0.009041 0x780 7 B0 79 FA 01 22 19 00

This should be the data received from the daikin altherma. In theory it means that the can bus interface is working, otherwise it wouldn't receive any data, right? I'm thinking there is some problem with pyHPSU, that it can't access the interface, what do you think? Did you enabled SPI in the raspi-config? What's your configuration in /etc/network ?

Vortecsz avatar Jul 25 '23 13:07 Vortecsz

@svde Hello, can you please explain me what did i asked you. Thank you so much

Vortecsz avatar Jul 27 '23 02:07 Vortecsz

/etc/network/interfaces.d/can0

auto can0
iface can0 inet manual
     pre-up /sbin/ip link set $IFACE type can bitrate 20000 triple-sampling on
     up /sbin/ifconfig $IFACE up
     down /sbin/ifconfig $IFACE down

/etc/systemd/system/hpsu.service

[Unit]
Description=HPSU in auto mode
#Requires=influxd.service

[Service]
Type=simple
Environment=PYTHONUNBUFFERED=1
ExecStartPre=
ExecStart=/usr/bin/pyHPSU.py -a --mqtt_daemon -o MQTT --log /var/log/pyHPSU.log --log_level DEBUG
ExecReload=
ExecStop=

[Install]
WantedBy=multi-user.target
Alias=hpsu.service

svde avatar Aug 19 '23 13:08 svde

Hi, I am running Debian (instead of raspberry pi OS) on my raspberry pi. The problem is that the Debian kernels do not support device tree overlays, and so even if the CAN kernel module is loaded, it cannot find the PiCan 2 hat.

Does anyone have a CAN hardware (e.g. via USB) that works with Debian (bookworm)?

m-reuter avatar Nov 25 '23 22:11 m-reuter

Hi @m-reuter , I'm using the following Adapter which you can get relatively cheap from Aliexpress (~13€) on my Debian (bookworm) Server. There's also a pretty nice looking 3D printable Case available. The main reason for me was getting rid of the additional Raspberry PI and have everything together containerized on my Home Server.

evildad avatar Nov 26 '23 08:11 evildad

Thanks @evildad . I also bought that device, and can see the can0 interface directly. I brought it up with

sudo ip link set can0 type can bitrate  20000 
sudo ip link set up can0

and can see it with ip a:

can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP group default qlen 10
    link/can

But pyhpsu does not seem to be able to send or receive anything. With errors like:

2023-12-09 13:19:48,349 - ERROR - CanPI t_dhw, msg not sync, timeout
2023-12-09 13:19:50,177 - ERROR - Error sending msg
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/can/interfaces/socketcan/socketcan.py", line 778, in _send_once
    sent = self.socket.send(data)
OSError: [Errno 105] No buffer space available

How did you set it up? What bitrate did you use?

m-reuter avatar Dec 09 '23 12:12 m-reuter

Hey @m-reuter please try it again with the pyHPSU devel branch commit 34d6afba6b85c1085fc88d0454b9c7a3b646bc5c and I have also pinned python-can==3.3.4 in my Dockerfile (FROM python:3.9-alpine). I had problems with everything newer (pyHPSU) even with my old Raspberry Pi setup but haven't digged deeper into the Problem. As for the bitrate I am using 20.000 as well because everything else doesn't work.

evildad avatar Dec 09 '23 12:12 evildad

Hey @m-reuter , did it work? Or did you get the same errors?

evildad avatar Jan 12 '24 15:01 evildad

Thanks for asking, I could not get it running yet. Can you send your dockerfile and the command to run it? In mine, many dependencies are newer and not compatible with the old commit that you list. Thanks

m-reuter avatar Jan 13 '24 15:01 m-reuter