friedpenguin

EPSolar Tracer python3 script

Jan 31st, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # I could NOT have done this without a few different sources on the web but this is a simple working script to pull data off an EPSolar Tracer BN series charge controller. The EPSolar USB RS485 adapter is a lot of work so skip it and and get a cheap $3.50 USB to RS485 off Ebay and snip an end off an Ethernet cable.
  3.  
  4. from pymodbus.client.sync import ModbusSerialClient as ModbusClient
  5. import serial
  6. from pymodbus.pdu import ModbusRequest
  7. from pymodbus.transaction import ModbusRtuFramer
  8. from pymodbus.register_read_message import ReadHoldingRegistersResponse
  9.  
  10. client = ModbusClient(method='rtu', port='/dev/ttyUSB0', baudrate=115200, stopbits=1, bytesize=8, timeout=2)
  11. client.connect()
  12. print(client)
  13.  
  14. result = client.read_input_registers(0x3100,20, unit=1)
  15.  
  16. solarVoltage = float(result.registers[0] / 100.0)
  17. solarCurrent = float(result.registers[1] / 100.0)
  18. solarWatt = float(result.registers[2] / 100.0)
  19. batteryVoltage = float(result.registers[4] / 100.0)
  20. chargeCurrent = float(result.registers[5] / 100.0)
  21. loadCurrent = float(result.registers[19] / 100.0)
  22. # Do something with the data
  23.  
  24.  
  25. print ("Solar Voltage", str (solarVoltage) + 'V')
  26. print ("Solar Current", str (solarCurrent) + 'A')
  27. print ("Current Watts", str (solarWatt) + 'W')
  28. print ("Battery Voltage", str (batteryVoltage) +'V')
  29. print ("Charge Current", str (chargeCurrent) + 'A')
  30. print ("Load Power", str (loadCurrent) + 'W')
  31. #print (result)
  32. client.close()
Advertisement
Add Comment
Please, Sign In to add comment