Skip to content
Ryan Pulley edited this page May 21, 2025 · 6 revisions

Configuring the Discover Lynk II gateway

Jumper Settings

On the Lynk II gateway, CAN signals (CAN H, CAN L, CAN GND) can be assigned to any PIN of the RJ-45 connector by adjusting the jumpers on the header board. To do this, disconnect the Lynk II gateway from all devices and remove the cover by removing the 4 screws on the back of the gateway.

Set the jumpers in this way:

Lynx II Jumpers - Solark

Protocol Configuration

You can configure the Discover Lynk II gateway with the Lynx Access windows application with a serial connection via a USB cable from a windows machine to the gateway. Recently, Discover has enabled the ethernet connectivity from the Lynk II gateway (Lynk Firmware release 2.1+). You can also configure the protocol from the Discover cloud app when registered and enabled.

These instructions show how to configure from the Windows Lynx Access application.

  1. Click on the "LYNK" item on the left hand side
  2. Click on the "Settings" icon in the "CAN Settings" section
Screenshot 2025-05-20 at 9 09 12 AM
  1. Choose "Discover Serial CAN" for the closed loop protocol
  2. Click the "Save" button - The Lynk Gateway will apply the protocol change and reboot
Screenshot 2025-05-20 at 9 09 58 AM

Wiring the CAN HAT to the Lynk II gateway / Inverter

I opted to use a 2 port RJ45 stick on wall adapter and attach it to my Raspberry Pi Screen. This allows you to use standard Cat 5/6 cables to wire the CAN HAT to the Inverter.

The CAN 0 port will connect to the Lynx Device and the CAN 1 port will connect to the Inverter.

IMG_5078

For the Lynx II gateway port (CAN 0), the wiring to the adapter is as follows:

  • CAN 0 CAN H - Pin 4 (BLUE)
  • CAN 0 CAN L - Pin 5 (BLUE/WHITE)
  • CAN 0 GND - Pin 6 (GREEN)

For the Inverter (CAN 1), please review the documentation for your inverter for proper pinouts. For the Midnite MN15-12KW-AIO All in One inverter, the pinout is the same as the Lynx II gateway:

  • CAN 0 CAN H - Pin 4 (BLUE)
  • CAN 0 CAN L - Pin 5 (BLUE/WHITE)
  • CAN 0 GND - Pin 6 (GREEN)

AIO Wiring

Installing the Raspberry PI

Install the CAN HAT

Note that CAN HATs do not typically fit in standard Raspberry PI cases. As I use a touchscreen display, I have no need for a case as the Raspberry PI mounts on the back of the display. If you choose to go "headless", there are some larger cases available that will accomodate the PI and the CAN HAT.

I use the Waveshare 2-Channel CAN FD HAT. I highly recommend installing the CAN adapter standoffs that come with the board to stablize and avoid putting pressure on the pins with pulling cables, etc.

Install the Service

The instructions below start from a freshly imaged SD card for a Raspberry PI 5 with the "Raspberry Pi OS (64-Bit) --- Debian Bookworm" image and basic configuration completed (network, accounts, timezone, initial software updates, etc.).

  1. From a terminal window, download the install script into your home directory

curl -s -O https://raw.githubusercontent.com/ryanpulley/DiscoverAEStoPylontech/refs/heads/main/install.sh

  1. Run the install script as the user that you wish to install the service as:

./install.sh

Note: If this is the first time the install has been run on the Raspberry PI, it will reboot after installing the Waveshare CAN FD HAT firmware configs. After the reboot, start the install script again.

  • This install script does the following:

    • Enables the Waveshare CAN FD HAT firmware configs if not already enabled and reboots
    • Installs MQTT - Mosquitto and client (mosquitto, mosquitto-client)
    • Installs the CAN Utilities (can-utils)
    • Configures Mosquitto (/etc/mosquitto/mosquitto.conf) for a listener that can talk outside of the host
    • Makes a backup of the current service to [directory.backup]
    • Clones the DiscoverBMS repository to your Raspberry PI under the users home directory (~/DiscoverBMS)
    • Creates a Python Virtual Environment
    • Installs all Python packages required by the service
    • Creates a log directory in the DiscoverBMS directory for service logs
    • Creates systemd services for initializing the CAN ports and the DiscoverBMS service
    • Reloads the systemd daemon to recognize these new services
    • Starts the systemd services

Configuring the DiscoverBMS service

With the installation of the service, a default configuration file is placed in the ~/DiscoverBMS/config directory called BMS2Inverter.yaml. You can customize this file to meet your needs. Below is a description of all configuration options:

"BMS" section

BMS:
  port: can0
  portrate: 250000
  lowVoltageWarning: 48.5
  readtimeout: 10000
  • port: which port is used on the CAN HAT for communication to the Lynk II gateway
  • portrate: What bitrate to use for communication to the Lynk II gateway. Note: the Discover Serial CAN protocol communicates at 250000 bits per second
  • lowVoltageWarning: voltage that results in a warning. I found through testing that occasionally, there was an erroneous low voltage being reported by the Lynk II gateway. This would cause the inverter to go into standby. The service now only reports this low voltage to the inverter if it's below this value for 3 consecutive messages.
  • readTimeout: # of milliseconds before the application detects that communication has been lost with the Lynk II gateway. When this occurs, a port restart will be attempted.
inverter:
  port: can1
  portrate: 500000
  • port: which port is used on the CAN HAT for communication to the Inverter
  • portrate: What bitrate to use for communication to the Inverter.
cellbalancing:
  interval-days: 2
  hold-soc: 99
  minutes: 35

A "cell balancing" charge is similar to an "absorb" charge with lead acid batteries. With the Midnite AIO inverter, when in SOC mode there is not a capability to charge beyond the Lynk II gateway reporting at 100%. At this point where the Lynx II gateway reports 100%, often not all batteries have reached 100%. In addition, the cells within individual batteries have not reached their capacity. The service supports a capability to "trick" the inverter into thinking that the battery has not yet reached 100%. It will hold the reporting to the inverter at a lower% for a time specified in the config:

  • interval-days: number of days to go between cell balancing charges
  • hold-soc: what SOC to begin the "hold"
  • minutes: number of minutes after reaching the hold-soc to continue to charge
mqtt:
  host: localhost
  port: 1883
  • host: host where mosquitto is installed. The service installs mosquitto as part of the install script, but you can specify another mqtt server.
  • port: port of the listener for the mosquitto service.
logging:
  loglevel: info
  logfile: log/BMS2Inverter.log
  • loglevel: (info, warning, debug) control's the verbosity of the log level
  • logfile: location of the logfile