ootjersb / pislave

I2C service to communicate with Itho devices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pislave

Set of tools to communicate with Itho WPU and Autotemp units. The tools are supposed to run on a Raspberry Pi, and there is some electronics involved to connect the device to the WPU or Autotemp via UTP cable.

The communication to the Itho devices works via I2C. You need both a master and a slave on the I2C bus. The Master is used to send requests to the WPU or Autotemp. The Slave is used to receive the answer. The Itho device is registered at address 0x82. The Raspberry Pi is registered at address 0x80. This project has been developed and tested with a Raspberry Pi 3B+. The Raspberry Pi Model 4 has a little different API, which has not been tested.

The toolset:

  • pimaster.cpp: Initial attempt to send commands to the Itho devices. This one has been replaced by pimaster2.c
  • pimaster2.c: Tool that can be used to send queries (hardcoded) to the Itho device.
  • emu_autotemp.c: Simulator for Autotemp which is normally at address 0x82, can be used to test the other programs without connecting to the Itho device. Does send a datalog message
  • emu_heatpump.c: Simulator for Heat Pump which is normally at address 0x82, can be used to test the other programs without connecting to the Itho device. Does send a datalog message
  • pislave.cpp: Tool to receive the data from the Itho device. Currently some hardcoded actions are possible: Insert raw data into SQLite DB, Parse a single value and upload to Domoticz
  • pislave82.cpp: Simulator for WPU/Autotemp on receival side. Other files are included with the above.

This project started from this forum thread: https://www.circuitsonline.net/forum/view/65868

Wiring

The component involved is a level shifter, because the Itho units run on 5V instead of 3.3V. I used the Adafruit BSS138 level shifter: https://www.kiwi-electronics.nl/4-channel-i2c-safe-bi-directional-logic-level-converter-BSS138?search=adafruit%20i2c%20level%20shifter&description=true Wiring like this:

  • I2C-SDA: Raspberry Pi GPIO02 (PIN03) & GPIO18 (PIN12) to Level shifter Low (A1), Level shifter high (B1) to RJ-45 pin 7 (White/Brown)
  • I2C-SCL: Raspberry Pi GPIO19 (PIN35) & GPIO03 (PIN05) to Level shifter Low (A2), Level shifter high (B2) to RJ-45 pin 2 (Orange)
  • Raspberry Pi - GRND(PIN39) - Level shifter GRND Hi and Low - RJ45 Pin 3 (White/Green)
  • Raspberry Pi - 3.3V (PIN01) to Level shifter Low (LV), Level shifter High (HV) is unattached. The reason for this is that the RJ-45 pin 5 (White/Blue) measures around 15 volt, and a level shifter cannot handle that usually. There are pull up resistors in place at WPU/Autotemp side, so they provide the pull up to the correct high level. image

Dependencies

pislave is dependent upon:

  • Curl: sudo apt-get install libcurl4-openssl-dev
  • pigpio: sudo apt-get install pigpio python-pigpio python3-pigpio
  • Sqlite3: sudo apt-get install libsqlite3-dev
  • Enabled I2C port: sudo raspi-config. Option 5 and enable I2C.

Upload and Compile

Upload to Raspberry Pi and compile with the instructions given in the source file itself. Easiest way to upload is just to clone this repository into the pi home directory.

Configuration

At the moment all of the settings and options are hardcoded. Most difficult configuration is probably bound to the model of the HeatPump itself. The parsing of the datalog message is model specific

Run

Common operations works by launching first pislave and then pimaster2

Service installation

The process can be run as system. The process reports output to console which is redirected to syslog by systemd. Copy file ithowp.service to /lib/systemd/system/ithowp.service. Reboot your Raspberry Pi.

Cron job

You can use cron to schedule running the pimaster GetDatalog command. The crontab line for this is:

* * * * * /home/pi/pislave/pimaster2 97

Todo

  • Configuration options in configuration file
  • Integrating send (pimaster2) and receive (pislave) to single service.

pislave

sudo ./pislave --debug

This will launch the receiver in debug mode and respond to data being send to I2C address 0x80 (which is 0x40 using 7 bit). Data being received is handled accoring to the setting in config.cpp. This can be logged to console, domoticz or file

Options for control:
x = Exit the program and close communication

pimaster2

After pislave has been launched you can open a second session and launch pimaster2 to execute commands: ./pimaster2

Options for control:
r = GetRegelaar. This is a quite generic message that asks the connected device for its information (make, model and such), that is usually the start when you are new.
a = Retrieve the datalog. This is the most interesting message in the sense that it asks for the sensor read outs. The data differs per device.

Another way of starting is by adding -f and a filename. This content of this file will be translated to a byte array and send. Example content:

[0x82 0x80 0xC2 0x10 0x04 0x00 0x28]

About

I2C service to communicate with Itho devices


Languages

Language:C++ 66.6%Language:C 33.4%