Help writing in a register using WiFi Connection

Hello,

I’ve recently purchased a Tstat10E and I find it a very powerful product, specially with its customization capabilities. The only issue I’m having is by writing on one of the registers to use as a variable. My plan is the following:

I want to remotely control the temperature setpoint on a thermostat through a RPi based device in the same WiFi network. My plan is the following:

  1. I can send a message to the RPi device with the temperature value I want
  2. The RPi device recives the value and writes a Variable-type register in the Tstat10E.
  3. The variable register has the temperature value, and its used by a program as a setpoint.
  4. The internal program on the Tstat10E does the corresponding control in the fan-coil, and reaches the temperature.

I imagine this workflow is viable for the device? Are there any limitations I’m not considering?

I am trying to test this using a python script, and while I can connect to the Tstat10E and read its registers, I am not able to write in these. The code I’m using is the following:

import time
from pymodbus.client import ModbusTcpClient

client = ModbusTcpClient('192.168.100.70')
client.connect()

time.sleep(1)

# Function code 0x06 - Write Single Register
write = client.write_register(address=8111, value=12000)
print(write)
time.sleep(1)

# Function code 0x03 - Read Holding Registers
result = client.read_holding_registers(address=8100, count=15)
print(result.registers)

I’m trying to write the value 12°C in address 8110, which corresponds to MODBUS_VAR_VALUE_10 in the register tables (I may be off by one register due to how they are written, but I have tested with 8110, 8111 and 8099 and neither have worked). I’ve manually written another value in this register and determined the unit (Celsius), in case it needed to be set up first. I can also read the 15 registers starting from 8100 with the second reading block.

I have the feeling that maybe the function/library I’m using isn’t writing correctly due to the Tstat10E registers being different from usual standards I’ve seen in other adress tables (40000 for holding registers)?

Anyways, thank you for your time reading this, any help will be greatly appreciated. I’ve searched for other topics and solutions in the forum but only one case could come close. If there’s already a solution or guide, I’d be thankful if someone could provide a link, please. Cheers!!

In our typical default setups we have been using VAR1, VAR2, and VAR3 to store the Setpoint, Mode, and Fan settings which the user can adjust from the keypad. The vars are linked to the up/down keypad behind the scenes through the firmware.

Watch the vars1, 2, and 3 from our T3000 application while you adjust the parameters on the Tstat10 keypad. They should go up & down as you press the thermostat keypad buttons.

So your python script running on the Pi will need to operate on these three vars, as if a person pressed the up & down buttons on the thermostat itself.

  • Addressing: The Variable values start at register 8101 (1-based). Since pymodbus is 0-based, try using address 8100 for VAR1, 8101 for VAR2, and so on. Address 8111 is actually VAR12.

  • Scaling: Most temperature registers use a factor of 10. For 12°C, try writing 120 instead of 12000.

  • Local Logic: Double-check that you don’t have a program running on the Tstat10 that uses these variables. If a local program line says VAR1 = 220, it will immediately overwrite any value you send via WiFi.

Try writing to 8100 and see if VAR1 updates in the T3000 software!

For Extra Points:
Integrating with BACnet is simpler since it handles decimals automatically and the Bacnet objects make life easier in general. For Python on a Pi, the [BAC0 Library] is excellent. VAR1–3 map to Analog Values AV1 thru AV3.

import BAC0
//Initialize with the Pi’s IP address
*bacnet = BAC0.lite(ip=‘192.168.100.50/24’) *
//Write 22.5 to VAR1 (Analog Value 1) on the Tstat
bacnet.write(‘192.168.100.70 analogValue 1 presentValue 22.5’)

1 Like

Thank you for your response @maurice, I appreciate the time taken to see this issue.

Particularly, I attempted what you told me and it didn’t fix the issue, but looking deeper into pymodbus the error was quite simple. As the register is a pair, the written value must be included as a list, and the function must use the plural “values” for it to work. It ends up looking like this:

write = client.write_register(address=8111, values=[0, 12000])

The usage of a factor of 1000 is correct, as it is how it shows when I read a register and now as I’m writing, it uses that factor (if I write 23456, the thermostat shows 23.5°C). I can also write on other registers, not only the first three shown in screen, for internal variable changes for my programs.

I hope this helps out anyone who is also having issues like this.

1 Like

Great feedback. Do consider the Bacnet option there, integrations can go a lot quicker when you dont have to mess with data types and scaling of modbus registers.

Yes, I imagine Bacnet could provide a good alternative to integrate the thermostat. I did some quick attempts with the code you previously provided but had issues working with it (which I imagine would be fixed with some brief troubleshooting time for later). When I get some extra time in my development I’ll test the Bacnet capabilities of the device over WiFi !!