This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
uphp:serial_port_programming [2017/03/18 20:51] jeff removed |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Serial Port Programming====== | ||
- | WattmonPRO comes with an RS-232 serial interface on pins 7 and 8 and an RS-485 port on an RJ45 connector. | ||
- | =====Using the RS-232 Serial Port===== | ||
- | To open the serial port, use the [[.functions: | ||
- | The serial port is treated like a file after opening and standard file functions such as [[.functions: | ||
- | |||
- | An example of using the serial port is shown below: | ||
- | <code php> | ||
- | <? | ||
- | // Open the serial port at 115200 baud in non-blocking mode | ||
- | $fp=fseropen(115200, | ||
- | if (!$fp) { | ||
- | print(" | ||
- | } else { | ||
- | $res=fwrite($fp," | ||
- | if ($res) { | ||
- | print(" | ||
- | } | ||
- | fclose($fp); | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | |||
- | ====Jumper Settings Inside Wattmon==== | ||
- | {{: | ||
- | |||
- | ====RS-232 Cable Connection==== | ||
- | In order to connect to a device you will need to procure a DB9 cable (male or female) and connect it up as shown in the following diagram: | ||
- | {{: | ||
- | |||
- | =====Using the RS-485 Serial Port===== | ||
- | |||
- | In order to use the RS-485 port, you need to disable modbus polling. | ||
- | |||
- | {{: | ||
- | |||
- | To open the RS-485 port, use the [[.functions: | ||
- | The RS-485 serial port is treated like a file after opening and standard file functions such as [[.functions: | ||
- | |||
- | An example of using the RS-485 serial port is shown below: | ||
- | <code php> | ||
- | <? | ||
- | // Open the 485 port at 115200 baud with no parity | ||
- | $fp=f485open(115200, | ||
- | if (!$fp) { | ||
- | print(" | ||
- | } else { | ||
- | $res=fwrite($fp," | ||
- | if ($res) { | ||
- | print(" | ||
- | } | ||
- | fclose($fp); | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | |||
- | ====RS-485 Cable Connection==== | ||
- | |||
- | Use a standard RJ-45 cable and cut it to connect your RS-485 device to WattmonPRO. | ||
- | ^ PIN ^ Color ^ Description | ||
- | | 1,2 | Orange | ||
- | | 4 | Blue | D+ / A | | ||
- | | 5 | White-Blue | D- / B | | ||
- | |||
- | {{: |