toggio / PhpEpsolarTracer

Library for communicating with Epsolar/Epever Tracer BN MPPT Solar Charger Controller
65 stars 23 forks source link

getInfoData() function not returning info for Tracer Model A, here's the fix. #4

Open aaronrryan opened 8 years ago

aaronrryan commented 8 years ago

I was able to fix it by editing the getInfoData() function in PhpEpsolarTracer.php and changing line number 263: from: $string = preg_replace('/[\f\r]/u', ' - ', $result); to: $string = preg_replace('/[\f\r\v]/', ' - ', $result);

And now it'll work with Tracer Model A, specifically Tracer2210A.

-= Tracer Info =- Manufacturer EPsolar Tech co., Ltd Model Tracer2210A Version V01.12+V02.11C

jimlynnjulian commented 8 years ago

Hello,

Working with a 3210A and get "Timeout on reading from serial port" from the getInfoData function. Made your modifications to no avail. Also changed '/dev/ttyUSB0' to '/dev/ttyACM0' , in 'example_cli.php, after doing an 'ls /dev/tty* ' listing'. Am using with a Raspberry Pi 3B and Debian/Raspbian/Jessie. Any ideas?

aaronrryan commented 8 years ago

Yes, I had to compile the xr_usb_serial_common-1a kernel module in order to enable the RS-485 protocol, I got it from https://github.com/kasbert/epsolar-tracer.git

I had to get the kernel-header files installed before it would compile. https://www.niksula.hut.fi/~mhiienka/Rpi/linux-headers-rpi/

I also has to remove the cdc_acm module before adding the kernel module, I just added the folowing to /etc/rc.local, so it works after reboot. rmmod cdc_acm insmod /root/xr_usb_serial_common-1a/xr_usb_serial_common.ko

Good luck -Aaron

jimlynnjulian commented 8 years ago

Hello,

Took your advice. Had a problem with the header part and found the cause and solution ini a program called rpi-source. After running the program, I, compiled and installed the driver easily. The header error problem was due to a 'quirk' in the production method used by RPi. Thanks again

aaronrryan commented 8 years ago

I edited using "sudo vi /etc/rc.local" and added the rm/insmod. There is probably a way to add to the /etc/modprobe.d/ dir or /etc/modules file, I just didnt look into it, since the rc.local was working for me.

On Wed, Aug 24, 2016 at 8:49 AM, jimlynnjulian notifications@github.com wrote:

Hello, A minor problem with your instructions, probably due to my newness to the Raspberry Pi and Linux. I have to do the remove/insert every time I turn the RPi off. Is there a way to make the change permanent? I'm already using 'sudo'. Thank you

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/toggio/PhpEpsolarTracer/issues/4#issuecomment-242114611, or mute the thread https://github.com/notifications/unsubscribe-auth/AKEReH1HmdYFCmqKE7kR1ZiBvLlR6vzSks5qjGgSgaJpZM4Jl-Lx .

pufferbatterie commented 8 years ago

Hello,

let me thank you for your simple library at first. I have a connection Problem with my serial adapter. I use the EPIPC-COM Charge controller which is the same and even comes with a maual for EPIPDB-COM, EPIC-COM and EPSolar Chargers. The charger has 15V from a power supply. I use the provided RJ45->USB-Serial Adapter with the Exar chip. Rasperry Pi 3 4.4.13-v7+ I tried the included /dev/ttyACM0 and compiled the x_usb_serial module to use /dev/ttyXRUSB0. I can open the port and write to it but i get a read timeout. Any ideas?

jimlynnjulian commented 8 years ago

To puffbatterie: http://raspberrypi.stackexchange.com/questions/19622/how-to-get-kernel-source-corresponding-with-the-kernel-installed-by-rpi-update

brynnneilson commented 7 years ago

I have a 3210A as well and when I run example_cli.php I get this:

Info Data
----------------------------------
00 Manufacturer: - ++
01 Model: p

Cannot get Rated Data
Cannot get RealTime Data
Cannot get Statistical Data
Cannot get Settings Data
Cannot get Coil Data
Cannot get Discrete Data

Any ideas?

I compiled the driver on an Asustor AS1002T Arm based NAS

brynn :-)

toggio commented 7 years ago

Hi brynn, the other parts are working?

2016-11-07 3:04 GMT+01:00 Brynn Neilson notifications@github.com:

I have a 3210A as well and when I run example_cli.php I get this:

Info Data

00 Manufacturer: - ++ 01 Model: p

Cannot get Rated Data Cannot get RealTime Data Cannot get Statistical Data Cannot get Settings Data Cannot get Coil Data Cannot get Discrete Data

Any ideas?

I compiled the driver on an Asustor AS1002T Arm based NAS

brynn :-)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/toggio/PhpEpsolarTracer/issues/4#issuecomment-258731574, or mute the thread https://github.com/notifications/unsubscribe-auth/ADkXmGUJN1klVZIRCAb_dINGoGNfdwbSks5q7odHgaJpZM4Jl-Lx .

jimlynnjulian commented 7 years ago

Brynn, I compiled on a Raspberry Pi 3B running Raspbian Jessie Linux. The action I outlined in an earlier post should work for any Debian based Linux. If you're not using a variant of Linux, I can't help you. I got the same errors. The driver was not compiled correctly. The driver may not be loading, too. I had to right a script to replace the existing driver with the newer one. Additionally, I never did get the driver to compile with Windows. I didn't know how to change from Linux USB port protocol to Windows COM port protocol.

brynnneilson commented 7 years ago

Thanks guys. I found my issue. I thought the device was at /dev/ttyS1 but it was at /dev/ttyXRUSB0 - doh! Here's the output:

`Info Data

00 Manufacturer: EPsolar Tech co., Ltd 01 Model: Tracer3210A 02 Version: V01.12+V02.11V

Rated Data

00 PV array rated voltage: 100V 01 PV array rated current: 30A 02 PV array rated power: 780W 03 Battery rated voltage: 24V 04 Rated charging current: 30A 05 Rated charging power: 780W 06 Charging Mode: 2 07 Rated load current: 30A

RealTime Data

00 PV array voltage: 13.88V 01 PV array current: 0.16A 02 PV array power: 2.31W 03 Battery voltage: 12.87V 04 Battery charging current: 0.18A 05 Battery charging power: 2.31W 06 Load voltage: 12.87V 07 Load current: 0.09A 08 Load power: 1.15W 09 Battery temperature: 17.44°C 10 Charger temperature: 18.89°C 11 Heat sink temperature: 18.89°C 12 Battery SOC: 31% 13 Remote battery temperature: 17.44°C 14 System rated voltage: 12V 15 Battery status: 0 16 Equipment status: 11

Statistical Data

00 Max input voltage today: 14.79V 01 Min input voltage today: 0V 02 Max battery voltage today: 12.9V 03 Min battery voltage today: 12.75V 04 Consumed energy today: 0.01KWH 05 Consumed energy this month: 0.21KWH 06 Consumed energy this year: 0.26KWH 07 Total consumed energy: 0.26KWH 08 Generated energy today: 0KWH 09 Generated energy this moth: 0.48KWH 10 Generated energy this year: 0.72KWH 11 Total generated energy: 4.7KWH 12 Carbon dioxide reduction: 0T 13 Net battery current: 0.09A 14 Battery temperature: 17.44°C 15 Ambient temperature: 17.44°C

Settings Data

00 Battery type: 1 01 Battery capacity: 200Ah 02 Temperature compensation coeff.: 3mV/°C/2V 03 High voltage disconnect: 16V 04 Charging limit voltage: 15V 05 Over voltage reconnect: 15V 06 Equalization voltage: 14.6V 07 Boost voltage: 14.4V 08 Float voltage: 13.8V 09 Boost reconnect voltage: 13.2V 10 Low voltage reconnect: 12.6V 11 Under voltage recover: 12.2V 12 Under voltage warning: 12V 13 Low voltage disconnect: 11.1V 14 Discharging limit voltage: 10.6V 15 Realtime clock (sec): 17 16 Realtime clock (min): 11 17 Realtime clock (hour): 8 18 Realtime clock (day): 8 19 Realtime clock (month): 11 20 Realtime clock (year): 16 21 Equalization charging cycle: 30 day 22 Battery temp. warning hi limit: 65°C 23 Battery temp. warning low limit: -39.99°C 24 Controller temp. hi limit: 85°C 25 Controller temp. hi limit rec.: 75°C 26 Components temp. hi limit: 85°C 27 Components temp. hi limit rec.: 75°C 28 Line impedance: 0mOhm 29 Night Time Threshold Volt: 5V 30 Light signal on delay time: 10 min. 31 Day Time Threshold Volt: 6V 32 Light signal off delay time: 10 min. 33 Load controlling mode: 0 34 Working time length1 min.: 0 35 Working time length1 hour: 15 36 Working time length2 min.: 0 37 Working time length2 hour: 0 38 Turn on timing1 sec: 0 39 Turn on timing1 min: 0 40 Turn on timing1 hour: 19 41 Turn off timing1 sec: 0 42 Turn off timing1 min: 0 43 Turn off timing1 hour: 6 44 Turn on timing2 sec: 0 45 Turn on timing2 min: 0 46 Turn on timing2 hour: 19 47 Turn off timing2 sec: 0 48 Turn off timing2 min: 0 49 Turn off timing2 hour: 6 50 Length of night min.: 16 51 Length of night hour: 12 52 Battery rated voltage code: 0 53 Load timing control selection: 0 54 Default Load On/Off: 1 55 Equalize duration: 120 min. 56 Boost duration: 120 min. 57 Dischargning percentage: 80% 58 Charging percentage: 100% 59 Management mode: 0

Coils Data

00 Manual control the load: 1 01 Enable load test mode: 0 02 Force the load on/off: 0

Discrete Data

00 Over temperature inside device: 0 01 Day/Night: 0 `

bonkas commented 7 years ago

I am having trouble getting the cable supplied by EPSolar to be recognised. After following all these instructions and also giving this alternative a go: http://indilib.org/forum/general/1085-baader-diamond-steeldrive-not-working.html?start=12

The only device I have is /dev/ttyAMA0

I can see the USB device being detected when plugged in as "Exar Device"

Not sure where to go from here...

jimlynnjulian commented 7 years ago

What are you plugging into, a Raspberry Pi? If so, you should have '/dev/ttyXRUSB0'.

jimlynnjulian commented 7 years ago

For the RPi, the linux headers have to be re-compiled before the driver can be compiled. If you're not using a RPi, then I can't help you. If the Exar UART is being recognized, the cable is probably fine unless there is a reason why you think not.

bonkas commented 7 years ago

Yeah I am using RPi, The driver compiled fine. Cable being recognised but not showing as '/dev/ttyXRUSB0' which is also what I was expecting. I must be doing something wrong but cant figure out what...

jimlynnjulian commented 7 years ago

Hello,

If the driver was not compiled with new headers, it will not work. Did you run the rpi-source program to re-compile the system headers?

Cogito ergo sum. - René DesCarte ~1665 ("I think, therefore I am") Sum ergo cogito. - Google ~2014 ("So I'm thinking...")

On Jan 18, 2017, at 4:32 PM, bonkas notifications@github.com wrote:

Yeah I am using RPi, The driver compiled fine. Cable being recognised but not showing as '/dev/ttyXRUSB0' which is also what I was expecting. I must be doing something wrong but cant figure out what...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

jimlynnjulian commented 7 years ago

hello,

If the driver is good, all you have to do is remove the default driver module and insert the Exar driver module. The you should see '/dev/ttyXRUSB0' in your list.

Cogito ergo sum. - René DesCarte ~1665 ("I think, therefore I am") Sum ergo cogito. - Google ~2014 ("So I'm thinking...")

On Jan 18, 2017, at 4:32 PM, bonkas notifications@github.com wrote:

Yeah I am using RPi, The driver compiled fine. Cable being recognised but not showing as '/dev/ttyXRUSB0' which is also what I was expecting. I must be doing something wrong but cant figure out what...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

bonkas commented 7 years ago

Yeah I used the rpi-source application before I built the driver. It is being recognised... /dev/bus/usb/001/006 - Exar_Corp._XR21B1411_H7180876441 Just not showing as '/dev/ttyXRUSB0'...

I am rebuilding the file now, will check for typos in /etc/rc.local as explained above and see what happens.

jimlynnjulian commented 7 years ago

Try a manual removal and insertion of modules. If that works, the automation may be the problem. sudo rmod cdc-acm sudo insmod /path/to/xr_usb_serial_common.ko

Cogito ergo sum. - René DesCarte ~1665 ("I think, therefore I am") Sum ergo cogito. - Google ~2014 ("So I'm thinking...")

On Jan 18, 2017, at 4:50 PM, bonkas notifications@github.com wrote:

Yeah I used the rpi-source application before I built the driver. It is being recognised... /dev/bus/usb/001/006 - Exar_Corp._XR21B1411_H7180876441 Just not showing as '/dev/ttyXRUSB0'...

I am rebuilding the file now, will check for typos in /etc/rc.local as explained above and see what happens.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

bonkas commented 7 years ago

Hmmm have noticed the raspberry pi reboots upon inserting the cable after loading this driver. I have tried wiping the SD and starting over 3 times now but no luck. You seem very knowledaible in the RPi and Linux in general which is where my knowledge is sorely lacking, dont mean to hijack this thread but are you able to offer any more assistance or point me to a guide which may get this working?

bonkas commented 7 years ago

I have made progress here... The USB device is now showing correctly! Although to get this to happen I have to run these commands in sequence - admittedly I am not 100% on thier full function:

rmmod cdc-acm modprobe -r usbserial modprobe usbserial insmod ./xr_usb_serial_common.ko

Is there any way to make this changer permanent?

jimlynnjulian commented 7 years ago

Hello,

There are a couple of ways. Using rc.local is one. You mentioned that. Have you tried using the rc.local option? The most common would probably be a cronjob. Google linux cron for more. The rc.local option is considered to be obsolete or deprecated and replaced by systemd services and daemons. Systemd is not built into Raspbian and has to be downloaded.

Jim J

Cogito ergo sum. - René DesCarte ~1665 ("I think, therefore I am") Sum ergo cogito. - Google ~2014 ("So I'm thinking...")

On Jan 19, 2017, at 3:45 AM, bonkas notifications@github.com wrote:

I have made progress here... The USB device is now showing correctly! Although to get this to happen I have to run these commands in sequence - admittedly I am not 100% on thier full function:

rmmod cdc-acm modprobe -r usbserial modprobe usbserial insmod ./xr_usb_serial_common.ko

Is there any way to make this changer permanent?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

jimlynnjulian commented 7 years ago

I recently ran update and upgrade on my RPi. Afterward, the Epever service I wrote would not run. The driver would not load. I recompiled the headers and driver and the driver ran for a day. Currently, attempts to manually load the driver result in a 'file exists' message and a list of running modules includes the Exar driver. However, when I list the TTY, the Exar driver is not on the list. The upgrade is the first time since the current installation of Raspbian. I'm thinking that has something to do with the problem. Anyone have any ideas? Thanks

brynnneilson commented 7 years ago

I'm having exactly the same issue. Did you move from kernel 3.x to 4.x?

jimlynnjulian commented 7 years ago

Linux raspberrypi 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux

jimlynnjulian commented 7 years ago

If the Rpi-Source script is no longer useful, I'll use a copy of Raspbian I put on DVD a few months ago, and not make any upgrades. Hopefully, updates will have no effect. My next step will, if I don't run across another option, be to re-record my SD card and start over. I'm going to keep searching though, that seems draconian for the moment.

jimlynnjulian commented 7 years ago

But wait! I just rebooted the RPi and, while the driver was not loaded, a manual load succeeded and the data's being recorded. I ran Rpi-Source again an got a message stating the kernel was fine. One thing I did do differently was to remove all of the driver related files created in the first compile (several months ago). Then I recompiled. The reboot must have reset something because the driver is working now.

bonkas commented 7 years ago

I got mine reading the data now.. Except it is not reading the manufacturer for some reason.

This way of reading the data gives me the manufacturer but no other data... https://github.com/kasbert/epsolar-tracer

EDIT: Doh re-read the thread title and the first post...

bonkas commented 7 years ago

This is how I resolved having to manually insert the driver in each boot...

Copy my kernel module to the drivers directory.

$ sudo cp mymodule.ko /lib/modules/$(uname -r)/kernel/drivers/

Add the simple name of my module to the file /etc/modules. You can edit the file or just append to it as shown here.

$ echo 'mymodule' | sudo tee -a /etc/modules

Update the list of module dependencies.

$ sudo depmod

Reboot the computer and voila, it worked.

jimlynnjulian commented 6 years ago

Hello toggio, I've been running PHPEpsolarTracer for nine months without issue. Thanks again for the software and the help. Jim J.

phuse commented 4 years ago

Hello,

let me thank you for your simple library at first. I have a connection Problem with my serial adapter. I use the EPIPC-COM Charge controller which is the same and even comes with a maual for EPIPDB-COM, EPIC-COM and EPSolar Chargers. The charger has 15V from a power supply. I use the provided RJ45->USB-Serial Adapter with the Exar chip. Rasperry Pi 3 4.4.13-v7+ I tried the included /dev/ttyACM0 and compiled the x_usb_serial module to use /dev/ttyXRUSB0. I can open the port and write to it but i get a read timeout. Any ideas?

Hi, Did you get this to work? I'm trying to figure out if the EPIPC-COM is actually using modbus as it's MPPT Tracer-siblings

Regards, Daniel

audunbrekke commented 4 years ago

EPIPC-COM

Hi. Did You manage to communicate with the EPIPC-COM ? I am trying now, but get broken data.

jimlynnjulian commented 4 years ago

Hello,

If you pull data too fast, some data gets skipped. Try slowing down your transfer rate.

Cogito ergo sum. René Descartes circa 1685 “I think, therefore, I am.”

Sum ergo cogito. Google 2004 “So, I’m thinking...”

On Apr 6, 2020, at 12:46 PM, audunbrekke notifications@github.com wrote:

 EPIPC-COM

Hi. Did You manage to communicate with the EPIPC-COM ? I am trying now, but get broken data.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

audunbrekke commented 4 years ago

Ok. I have been trying with baud rate 9600. Is'nt it the right baud rate ? Or do you mean delay in write / read commands in the software ?

jimlynnjulian commented 4 years ago

Hello,

The software you're using to pull data may need to use a time delay loop.

Cogito ergo sum. René Descartes circa 1685 “I think, therefore, I am.”

Sum ergo cogito. Google 2004 “So, I’m thinking...”

On Apr 6, 2020, at 2:22 PM, audunbrekke notifications@github.com wrote:

 Ok. I have been trying with baud rate 9600. Is'nt it the right baud rate ? Or do you mean delay in write / read commands in the software ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

dtabone commented 3 years ago

Confirming this fix in the first post works on a raspi3b - connected via socat to an ebox-wifi-01 in STA mode to my home wifi.

Info Data

00 Manufacturer: EPsolar Tech co., Ltd 01 Model: TriRon3210 02 Version: V01.56+V01.22j

I was able to fix it by editing the getInfoData() function in PhpEpsolarTracer.php and changing line number 263: from: $string = preg_replace('/[\f\r]/u', ' - ', $result); to: $string = preg_replace('/[\f\r\v]/', ' - ', $result);

And now it'll work with Tracer Model A, specifically Tracer2210A.

-= Tracer Info =- Manufacturer EPsolar Tech co., Ltd Model Tracer2210A Version V01.12+V02.11C

isipisi89 commented 1 year ago

@aaronrryan

i have a TriRon 3210N and tracer 1210AN. Installed drivers and they are showing as /dev/ttyXRUSB0

when i enable debug php gives me this on example_web.php:

DEBUG [query sent]: \x01\x2b\x0e\x01\x00\x70\x77 DEBUG [response received]: \x DEBUG [query sent]: \x01\x43\x31\x00\x00\x76\xcb\x1f DEBUG [response received]: \x DEBUG [no response]

the usb device i have is Bus 001 Device 003: ID 04e2:1411 Exar Corp. XR21B1411

Both 3210N and tracer 1210AN are not working :/

Mybe someone could help me?

TerryFrench commented 1 year ago

Have you tried the Epever app to know for sure you can communicate with the devices using USB on that computer? When you get no answer, it could be anything such as wrong 485 settings. So I would advise to get some communication to work first with the devices before using the more fancy SW to use it. That will give you confidence that you have a good physical connection (proper wires connected), with the right speed settings. I think that (from memory) if you put a serial / 485 monitor running on your side, you should see some traffic on your computer coming from the device. Basically it might think it's talking to the remote display for instance, and just send some data on a regular basis. That might be a way to check that things are working. Good luck. Post your findings.

On Sun, Oct 9, 2022 at 6:49 AM Isi @.***> wrote:

@aaronrryan https://github.com/aaronrryan

i have a tracer 3210N and tracer 1210AN. Installed drivers and they are showing as /dev/ttyXRUSB0

when i enable debug php gives me this on example_web.php:

DEBUG [query sent]: \x01\x2b\x0e\x01\x00\x70\x77 DEBUG [response received]: \x DEBUG [query sent]: \x01\x43\x31\x00\x00\x76\xcb\x1f DEBUG [response received]: \x DEBUG [no response]

the usb device i have is Bus 001 Device 003: ID 04e2:1411 Exar Corp. XR21B1411

Mybe someone could help me?

— Reply to this email directly, view it on GitHub https://github.com/toggio/PhpEpsolarTracer/issues/4#issuecomment-1272546788, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABK4I2KZNGVV2F6AHOIDH33WCLENNANCNFSM4CMX4LYQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

isipisi89 commented 1 year ago

@TerryFrench

yes the cable works fine, i used the cable with windows 11 and the epever software to configure the devices, they show up properly on windows. but i cant get it work on the pi. i compiled the driver on the pi and the usb device is showing correctly /dev/ttyXRUSB0. but using the software on the pi gives me DEBUG [response received]: \x

there musst be something i am missing out, mybe it dosent work with the pi 4?

TerryFrench commented 1 year ago

Good that the cable works. You might check in case the cable shows up as two different devices. See what lsusb in a terminal window shows also dmesg | grep -i USB after you plug the cable. google the modprobe commands. There's one more command I forgot to give a regular user access to a device. But basically, your cable has a usb to serial (485 here) adapter chip in it. You want the driver for that device to be loaded. Which seems to be the case here, as you ended up with a "tty" device. But there are speed settings, possibly parity settings... for the 485 port. In your windows program, check how they are set when you connect the cable to the epever. You will want to set the same settings when running from the Pi.

I went a different way on my side, with a 485 to wifi adapter (all solar stuff is outside), and I had a windows server running, so I consume the data from there. But the Chinese 485-wifi adapter was a pain to configure right (it has its own settings) to get a connection going. A serial monitor tool (on the Pi one could pipe the output of the tty device to the console, or connect a console to the tty device. Type some commands, see if you get any answer.

On Mon, Oct 10, 2022 at 2:40 AM Isi @.***> wrote:

@TerryFrench https://github.com/TerryFrench

yes the cable works fine, i used the cable with windows 11 and the epever software to configure the devices, they show up properly on windows. but i cant get it work on the pi. i compiled the driver on the pi and the usb device is showing correctly /dev/ttyXRUSB0. but using the software gives me DEBUG [response received]: \x

there musst be something i am missing out

— Reply to this email directly, view it on GitHub https://github.com/toggio/PhpEpsolarTracer/issues/4#issuecomment-1273048599, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABK4I2N3HT2SADTW2ZHY6X3WCPQAPANCNFSM4CMX4LYQ . You are receiving this because you were mentioned.Message ID: @.***>

jimlynnjulian commented 1 year ago

Just for the record, the Epever Triron 4210 is a plugin replacement for the Tracer 3210 when using this software. (aaronrryan variant).