Logging to Serial¶
One of the special features of the Log4 PoE device is its ability to send and receive Serial information from an external device, for example an Arduino. In this example we will explore how to use the Log4 in conjunction with an Arduino to view the measurement readings on the Arduino Serial monitor. The measurement readings can then be used to perform protection related tasks. For example, sending commands back to Log4 to turn off power.
Send information from Log4 to Arduino via serial pins, then view the measurements on Arduino Serial Monitor.
Before we begin setting the system up, please note the below Log4 serial pin configurations (Fig. 78).
DO NOT reverse bias the VCC and Ground pins.
Fig. 79 shows an overview of the overall system set up.
- Connect Arduino to the PC via a USB cable.
- Set up the device, to be measured, by connecting the Log.4 PoE OUT port to device and Log4.PoE IN to PSE (In this case, we just used the laptop as PSE).
- Connect an Arduino 5V pin to the Log4 VCC pin.
- Connect an Arduino GND pin to the Log4 GND pin.
- Connect an Arduino Tx pin to Log4 Rx pin.
- Connect an Arduino Rx pin to Log4 Tx pin.
- The Log4 PoE device sends out measurement readings through the Tx pin. The measurements are sent out in packets (36 bytes per measurement).
Here is the Packet Structure
|Byte 0||Start byte ‘:’|
|Byte 1||Address (1 byte) (currently unused, set to 0x01)|
|Byte 2||Command (0x0B for slave data)|
|Byte 3||Data byte count|
|Byte 4-11||Uint64_t Timestamp in milliseconds since epoch (midnight 01/01/1970)|
|Byte 12-15||Int32_t Current in micro amps|
|Byte 16-19||Int32_t Bus Voltage in millivolts|
|Byte 20-23||Int32_t Power in microwatts|
|Byte 24-27||Int32_t Channel B Current in micro amps|
|Byte 28-31||Int32_t Channel B Bus Voltage in millivolts|
|Byte 32-35||Int32_t Channel B Power in microwatts|
For more information regarding command protocols, please refer to the Serial Protocol Documentation.
To view the measurement readings on the Arduino Serial port, please upload the code, provided in the Appendix, onto the Arduino.