Back and Forth ESS
PHP Python HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
arduino
www
LICENSE
README.md
batt_test.php
closedloop.php
drive-pwm.py Set the PWM frequency back to 1kHz, turns out the PWM 5V rail wasn't … May 4, 2017
functions.php Update for the 8 cell configuration May 20, 2017
readshm.php
readvoltage.py
spitest.php
vars.php

README.md

baf

Back and Forth ESS Seth Mos seth.mos@dds.nl

To steer energy demand for higher self use of Solar energy using a battery, a charger and a inverter.

Instructions are not entirely complete yet, but it's a start. Basic Raspberry module things.

Features

  • Supports more then 1 Inverter/Charger.
  • Supports different size inverters/Chargers.
  • Operates remotely from the P1 reader using the arduino nano P1 reader.
  • WebUI to show current operations and P1 meter readings.
  • Has idle timers to prevent flip-flopping of AC relays (inverters/chargers).
  • Allows for diverse battery configurations, adjust voltages accordingly.
  • Charge and Discharge power taper at end of range. (adjustable)
  • Auxilary charger for balancing cells and emergency low-level charging (adjustable voltage diff trigger).

Bill of Materials (euro)

Instructions

  • Requires a Arduino Nano with Ethernetshield to connect to the P1 port of the utility smart meter. If you use something else for your power readings, that's fine, it just needs to post the data to a page of the webserver on the Raspberry. The arduino code is under arduino/ and you need to modify the IP address it POSTs too. It's currently set to 192.168.11.238.

  • It's being developed on a original RPI B with 512MB ram. Everything lives in the pi user home directory under ~/baf/ If you are the pi user you can just "git clone https://github.com/smos/baf.git" For the webpages to be reachable you need to make a link to the www directory in the webroot. "sudo ln -s /home/pi/baf/www /var/www/html/baf"

  • The ADC board is from ABElectronics UK. https://www.abelectronics.co.uk/ and uses i2c. The DAC board is also from AB Electronics and also uses i2c but on a different address. Luckily they have a nice library as well. Check out the sources from github using "cd /baf/;git clone https://github.com/abelectronicsuk/ABElectronics_Python_Libraries.git" "sudo apt-get install python-smbus php5-dev screen" "sudo adduser pi i2c" "sudo modprobe i2c-dev" "sudo modprobe i2c-bcm2708" Remove the modules from the module blacklist and add them to /etc/modules, alternatively you can use raspi-config to enable these. "sudo nano /etc/modprobe.d/raspi-blacklist.conf" After reboot they should show up "sudo i2cdetect -y 0" "sudo i2cdetect -y 1" Add the following path to the .profile of the pi user. "export PYTHONPATH=${PYTHONPATH}:/baf/ABElectronics_Python_Libraries/ADCPi/"

  • PHP SPI class "cd ~/baf/;git clone git://github.com/frak/php_spi.git ~/baf/php_spi" "cd ~/baf/php_spi/" "phpize" "./configure --enable-spi" "make test" "make install" "sudo make install"

  • It uses PiFace for 8 relay outputs using the PHP PiFace toolkit from https://github.com/peec/raspberry-piface-api Follow the instruction there and install under the ~/baf/ directory. The previous php_spi needs to work though. Make sure that you build the vendor directory and composer.json in the ~/baf/ direcory. In the future I want to move this to the AB IO board as it's better suited for the purpose.

  • Add users to the groups. Add pi to the www-data group and www-data to the pi group, you can "sudo nano /etc/group"

  • Run the controller "su -l pi -c "screen -d -m -S essloop php ~/baf/closedloop.php" Add the command to /etc/rc.local too so that it starts on boot, it logs to syslog.

Other

Log example of a battery draining (with a lightbulb) and stopping: Apr 25 22:33:16 bramenstruik php: Set pwm to 0.13, step 532 channel 0 Apr 25 22:33:18 bramenstruik php: Set pwm to 0.11, step 451 channel 0 Apr 25 22:33:20 bramenstruik php: Set pwm to 0.16, step 655 channel 0 Apr 25 22:33:22 bramenstruik php: Set pwm to 0.1, step 410 channel 0 Apr 25 22:35:37 bramenstruik php: No generation, battery empty, idle Apr 25 22:35:37 bramenstruik php: Disable inverters index 1 DC Apr 25 22:35:37 bramenstruik php: Set pwm to 0, step 0 channel 0 Apr 25 22:35:38 bramenstruik php: Disable battery relay Apr 25 22:35:40 bramenstruik php: Battery cell voltage below minimum 3.45 but above critical 3.2, continue