Skip to content

Latest commit

 

History

History
184 lines (121 loc) · 7.78 KB

Software_Manual.md

File metadata and controls

184 lines (121 loc) · 7.78 KB

Manual Raspbian Installation

Operating System Installation

The recommended installation for this project is on a Raspberry Pi machine using Raspbian. The Raspbian OS can be downloaded from the following location:

You can flash the Raspbian OS using the tools listed on the following page:

Install Required Packages (Debian/Ubuntu/Raspbian)

The following packages are required to fetch and install the TWCManager project. These are the minimal required packages to start the installation process, during which any other required dependencies will be fetched automatically.

sudo apt-get update
sudo apt-get install -y git python3 python3-pip python3-setuptools python3-dev libatlas-base-dev lsb-release

Default to Python3

TWCManager requires a minimum of python 3.4 to work correctly. To attempt to support Raspberry Pi OS versions going back to 2019, TWCManager is regularly tested against Python 3.4 and above to ensure that support is retained. As of TWCManager v1.2.2, a number of features are beginning to diverge based on minimum Python versions being higher than those required by TWCManager, so the following features may be unavailable if your Python version is below the minimum:

  • Support for OCPP control module requires a minimum Python 3.6.1 version

Raspberry Pi OS version 9 (stretch) from 2019 ships with Python 3.5.3. If you are running Raspberry Pi OS version 9 or earlier, you may not have access to a Python interpreter which supports the above features. You may want to consider the use of pyenv to support installation of a newer Python interpreter.

Python versions below 3.6 may show the following error when running setup.py:

Traceback (most recent call last):
  File "setup.py", line 3, in <module>
    from setuptools import setup, find_namespace_packages
ImportError: cannot import name find_namespace_packages

This indicates an older version of setuptools is installed. To resolve this issue, run the following command:

pip3 install --upgrade setuptools

Raspberry Pi OS / Raspbian Bullseye (11)

There is no need to change the python intepreter to python3 in Bullseye, this is the default.

Raspberry Pi OS / Raspbian Buster

You may need to set python3 as your default python interpreter version on Raspberry Pi OS / Debian Buster. The following command will set python 3.7 as your default interpreter.

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2

You can check that this command has been successful by running python --version and checking that the version is python3.

Raspbian Stretch

Please note that Raspbian Stretch will no longer be supported as of v1.2.4 of TWCManager. The following instructions are relevant for versions earlier than this.

You may need to set python3 as your default python interpreter version on Debian/Ubuntu. The following command will set python 3.5 as your default interpreter.

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2

You can check that this command has been successful by running python --version and checking that the version is python3.

Clone GIT Repository and copy files

During this step, the source code and all related files will be cloned from the GitHub repository and installed into the appropriate location on your system.

We have two versions of the codebase that you may want to check out. The stable version is v1.3.2, which will only change for stability or urgent fixes. To check out v1.3.2, follow these steps:

git clone https://github.com/ngardiner/TWCManager
cd TWCManager
git checkout v1.3.2
sudo make install

Alternatively, the main branch is the development branch, where all of the new ideas and features are tested prior to becoming the stable branch. This version has more features, but we can't guarantee stability.

git clone https://github.com/ngardiner/TWCManager
cd TWCManager
git checkout main
make install

Configure TWCManager

After performing the installation tasks above, edit the /etc/twcmanager/config.json file and customize to suit your environment.

The following documents provide detail on specific areas of configuration:

Running TWCManager

Once the above steps are complete, start the TWCManager script with the following command:

sudo -u twcmanager python3 -m TWCManager

Monitoring the script operation

After starting TWCManager, the script will run in the foreground and will regularly update with the current status. An example output is as follows:

11:57:49: SHA 1234: 00 00.00/00.00A 0000 0000  M: 09 00.
00/17.00A 0000 0000
11:57:49: Green energy generates 4956W, Consumption 726W, Charger Load 0W
          Limiting car charging to 20.65A - 3.03A = 17.62A.
          Charge when above 6A (minAmpsPerTWC).
  • SHA 1234 is the reported TWC code for each of the Slave TWCs that the Master is connected to.

  • The 00.00/00.00A next to the Slave TWC code is the current number of amps being utilised and the total number of amps available to that slave. The master divides the total amperage available for use between the connected slaves.

  • M is the same values for the Master device (our script). It shows current utilization and total available amps (in this case, 17A) available for all connected slaves.

  • The second line shows the green energy values detected. In this case, the attached green energy device (solar inverter) is reporting 4956W being generated from solar, 726W being used by other household appliances, and no load being generated by the charger. As we charge a vehicle, that value will increase and maybe subtracted from the consumption value if configured to do so.

  • The line below this reports the same values but in amps instead of watts.

  • The final line shows the minAmpsPerTWC value, which is the minimum number of amps that the master must offer each slave before we tell the attached vehicle to charge (via the Tesla API).

Running TWCManager as a Service

The following commands make TWCManager run automatically (as a service) when the Raspberry Pi boots up.

Enable the service. The --now flag also makes it start immediately. This will persist after rebooting.

sudo cp contrib/twcmanager.service /etc/systemd/system/twcmanager.service
sudo systemctl enable twcmanager.service --now
  • Note: The systemd service file assumes that your TWCManager installation is in /home/pi/TWCManager. If this is not the case, edit /etc/systemd/system/twcmanager.service and update the WorkingDirectory parameter to suit.

To check the output of the TWCManager service as it runs in the background, use the following command:

journalctl -f

To disable the TWCManager service permanently use the following command. This will persist after rebooting.

sudo systemctl disable twcmanager

Upgrading TWCManager

Stable Release

From version v1.2.4 of TWCManager and beyond, you can use pip to upgrade TWCManager to the latest stable version.

To upgrade TWCManager to the latest version:

sudo pip3 install --upgrade twcmanager

Development Version

If you would prefer to upgrade to the latest Development release, you should do the following:

  • Enter the directory in which the TWCManager sources are downloaded
cd /home/pi/TWCManager
  • Download the latest updates using git
git pull
  • Build the latest TWCManager package
make install