NanoHub to NanoView Display Protocol

The NanoHub transmits the power consumption measurements at 1Hz intervals.

Measurements are sent in two packets:

- Live power usage (Watt)
- Cumulative energy consumption (kWh).
				


Hardware

The hardware layer is serial UART with the following settings:


- Baud Rate      : 2400bps
- Character Size : 8bits
- Stop Bits      : 1
- Parity         : None

The NanoHub uses an open collector transistor. With the following specification:

- Current sink : 10mA (max)
- Vce @ 10mA   : 0.7V (max)
			

The NanoView Display uses a 1KOhm pull up resistor with 5V source to bias the TX line.


Pin Assignment

On the Hub the pin out is as following:

 1. Ground (negative) - Black
 2. Power (5V - 6V)   - Red
 3. No Connection     - Green
 4. Transmit          - White


Packet Structure

Packets are tranmitted at 1Hz intervals all packets start with the start byte 0xAA followed by the packet ID byte. Then follows the DATA section of the packet. After the DATA section a two checksum bytes are sent. Multi-byte variables are sent in Little-Endian order. Accumlated Engergy counters reset to 0 (zero) each time mains power to the NanoHub is removed. The counters will increase indefinatly and wrapping is very unlikey.

* Start Byte (unsigned char):
  - 0xAA: Start Byte

* Packet ID (unsigned char):
  - 0x10: Live Power Packet
  - 0x11: Accumulated Energy Packet
  - 0x12: NanoHub Firmware Version Packet

* Data (array of unsigned chars):
  - Live Power Packet (34 bytes):
   -- Mains Voltage [Volts] (unsigned integer 16bits)
   -- 16x Live Power [Watt] (unsigned integer 16bits)
  - Accumulated Energy Packet (64 bytes):
   -- 16x Energy Counters [Watt hour] (unsigned integer 32bits)
  - NanoHub Firmware Version Packet (1 byte):
   -- Version Number (unsigned char)

* Checksum (2x unsigned chars):
  - CRC1 (unsigned char)
  - CRC2 (unsigned char)

Checksum Calculation

The CRC is only calculated over the Data of the packet. The pseudo code below describes the algorithm used:

crc1 = 0
crc2 = 0

for byte in data[]:
	crc1 = crc1 ADD byte
	crc2 = crc2 XOR crc1
		

Examples


Live Power Packet

0xAA, 0x10, 0xE6, 0x0, 0xE0, 0x2E, 0x64, 0x0, 0xC8, 0x0, 0x2C, 0x1, 0x90, 0x1, 0xF4, 0x1, 0x58, 0x2, 0xBC, 0x2, 0x20, 0x3, 0x84, 0x3, 0xE8, 0x3, 0x4C, 0x4, 0xB0, 0x4, 0x14, 0x5, 0x78, 0x5, 0xDC, 0x5, 0x15, 0xF5

 - Packet ID:        : 0x10
 - Voltage           : 230V
 - Channel 1 (total) : 12000W
 - Channels 2 - 16   : 100W - 1500W (incrementing by 100W for each channel)
 - CRC1, CR2         : 0x15, 0xF5

Accumulated Energy Consumption Packet

0xAA, 0x11, 0xC0, 0xD4, 0x1, 0x0,0xE8, 0x3, 0x0, 0x0,0xD0, 0x7, 0x0, 0x0,0xB8, 0xB, 0x0, 0x0,0xA0, 0xF, 0x0, 0x0,0x88, 0x13, 0x0, 0x0,0x70, 0x17, 0x0, 0x0,0x58, 0x1B, 0x0, 0x0,0x40, 0x1F, 0x0, 0x0,0x28, 0x23, 0x0, 0x0,0x10, 0x27, 0x0, 0x0,0xF8, 0x2A, 0x0, 0x0,0xE0, 0x2E, 0x0, 0x0,0xC8, 0x32, 0x0, 0x0,0xB0, 0x36, 0x0, 0x0,0x98, 0x3A, 0x0, 0x0, 0x21, 0x80

 - Packet ID:        : 0x11
 - Channel 1 (total) : 120kWh
 - Channels 2 - 16   : 1kWh - 15kWh (incrementing by 1kWh for each channel)
 - CRC1, CR2         : 0x21, 0x80

License

The NanoHub Protocol is available as open source under the terms of the MIT License.
MIT License

Copyright (c) 2019 NanoView

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.