I have been started with trying to program API commands in python for controlling some I2C boards.
The main board is the BridgeX5, on port 1 there is attached: Relay Controller + HYT-939 sensor + PCA9531 2-Channel 8-bit PWM with 8 Outputs.
The connection to the BridgeX5 is using a Ethernet Lantronix Port
This setup is used to control a 12V DC Fan of max 1A according to the temperature of HYT-939
First question: Is this fan also a source of high inductive loads and can it be handled by the same power source as where the I2C boards are attached to? Or should i also find an other power source for the fan.
Second question: is there some kind of API command needed to flush the boards before asking new information? I experience problems when i want to turn on and off the relay with the use of the PCA9531 board. In AnyI2C it works and i can control it, but my programming seem to have some trouble. When i only asks for activate relay on and off in my program, that works. When aksing for PWM controls ( for instance a test led ) this also works. But the 2 together active in the run list, the relay will not switch on.
Third: When sending API in Decimal encoded data, i get some other type of string back.
Anybody any idea how to decode this back? ‘UTF-8’ does not seem to work.
For instance, i get a lot of this :b’\xaa\x01U\x00
in witch i suppose it means number 85 ( Output of AnyI2C command log )
I need to know how to again decode the outcomming of the HYT-939 sensor when using API commands. Can’t seem to find this on the internet.
Thank you very much.
Here is a copy of the data:
TCP_IP = '192.168.12.184' TCP_PORT = 2101 BUFFER_SIZE = 1024 FANPWROFF = bytes ((170,7,188,51,3,64,9,0,0,236)) FANPWRON = bytes ((170,7,188,51,3,64,9,1,0,237)) PWMON = bytes ((170,7,188,51,3,192,5,2,0,106)) PWM0 = bytes ((170,7,188,51,3,192,2,255,0,100)) PWM5 = bytes ((170,7,188,51,3,192,2,242,0,87)) PWM10 = bytes ((170,7,188,51,3,192,2,229,0,74)) PWM15 = bytes ((170,7,188,51,3,192,2,216,0,61)) PWM20 = bytes ((170,7,188,51,3,192,2,203,0,48)) PWM25 = bytes ((170,7,188,51,3,192,2,190,0,36)) PWM30 = bytes ((170,7,188,51,3,192,2,178,0,23)) PWM35 = bytes ((170,7,188,51,3,192,2,165,0,10)) PWM40 = bytes ((170,7,188,51,3,192,2,152,0,253)) PWM45 = bytes ((170,7,188,51,3,192,2,139,0,240)) PWM50 = bytes ((170,7,188,51,3,192,2,127,0,228)) PWM55 = bytes ((170,7,188,51,3,192,2,114,0,215)) PWM60 = bytes ((170,7,188,51,3,192,2,101,0,202)) PWM65 = bytes ((170,7,188,51,3,192,2,88,0,189)) PWM70 = bytes ((170,7,188,51,3,192,2,76,0,177)) PWM75 = bytes ((170,7,188,51,3,192,2,63,0,164)) PWM80 = bytes ((170,7,188,51,3,192,2,50,0,151)) PWM85 = bytes ((170,7,188,51,3,192,2,37,0,138)) PWM90 = bytes ((107,7,188,51,3,192,2,25,0,126)) PWM95 = bytes ((107,7,188,51,3,192,2,12,0,113)) PWM100 = bytes ((170,7,188,51,3,192,2,0,0,101)) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) s.send(PWMON) s.send(PWM100) s.send(FANPWRON) time.sleep(5) s.send(PWMON) s.send(PWM80) time.sleep(2) s.send(PWM60) time.sleep(2) s.send(PWM40) time.sleep(2) s.send(PWM20) time.sleep(2) s.send(PWM0) time.sleep(2) s.send(FANPWROFF) data = s.recv(BUFFER_SIZE) s.close() print ("received data:", data)