<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://w.electrodragon.com/w/index.php?action=history&amp;feed=atom&amp;title=HLW8032_SDK</id>
	<title>HLW8032 SDK - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://w.electrodragon.com/w/index.php?action=history&amp;feed=atom&amp;title=HLW8032_SDK"/>
	<link rel="alternate" type="text/html" href="https://w.electrodragon.com/w/index.php?title=HLW8032_SDK&amp;action=history"/>
	<updated>2026-06-05T00:00:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.2</generator>
	<entry>
		<id>https://w.electrodragon.com/w/index.php?title=HLW8032_SDK&amp;diff=32471&amp;oldid=prev</id>
		<title>Chao: /* Analyze Data */</title>
		<link rel="alternate" type="text/html" href="https://w.electrodragon.com/w/index.php?title=HLW8032_SDK&amp;diff=32471&amp;oldid=prev"/>
		<updated>2021-12-30T06:44:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Analyze Data&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
== HLW8032 ==&lt;br /&gt;
* Make sure use baud rate 4800 to read data&lt;br /&gt;
* Demo Video HLW8012 http://v.youku.com/v_show/id_XMjY3ODQ5ODMxMg==.html&lt;br /&gt;
* Demo code here, initiate version - https://github.com/Edragon/Arduino/tree/master/Sketchbook/04_sensor&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:Register_reading_of_HLW8032.png | register reading of by PL2303TA, 4800bps, each group of data is 24 bytes, please note this is reading non-load&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
Tips to use with ESP8266:&lt;br /&gt;
=== Method 1 ===&lt;br /&gt;
* Use Wemos and its softserial, wiring should be &lt;br /&gt;
# HLW8032 RX to Wemos D5&lt;br /&gt;
# HLW8032 3.3V to Wemos 5V or 3.3V&lt;br /&gt;
# HLW8032 GND pin to Wemos GND&lt;br /&gt;
* Upload [https://github.com/Edragon/Arduino/tree/master/esp8266-env/Sketchbooks/HLW8032_Softserial_read sketch this one to wemos],  Open serial monitor to check data, notice raw data in HEX ouptut&lt;br /&gt;
* Bypass on board AC-DC converter to analyze data directly, [https://twitter.com/electro_phoenix/status/1113019827713564672 see post here.]&lt;br /&gt;
=== Method 2 (obsolete) ===&lt;br /&gt;
* The wiring should be: &lt;br /&gt;
 HLW8032 RX -&amp;gt; ESP8266 RX pin&lt;br /&gt;
 HLW8032 3.3V -&amp;gt; ESP8266 3.3V, also works on 5V&lt;br /&gt;
 HLW8032 GND -&amp;gt; ESP8266 GND&lt;br /&gt;
* Better not use with wemos board, which has USB-TTL UART bridge circuits on board, could cause conflict to uart reading from hlw8032. Please use a standalone ESP8266 module or board, without this circuits, for example our esp-12f adapter board&lt;br /&gt;
* Better not use with ESP-link firmware, data can be read, but not in the raw hex data. Better write your own code to read and analyze the data by esp8266&lt;br /&gt;
* Again double check baudrate should be 4800, in case for ESP-LINK, options should set to '''&amp;quot;8E1&amp;quot;''', data could be read but incomplete&lt;br /&gt;
* The test could see here: https://twitter.com/electro_phoenix/status/1104004115422539781&lt;br /&gt;
* Not yet have demo code of this available now.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Analyze Data ===&lt;br /&gt;
&lt;br /&gt;
* total 24 bytes per transfer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Note !! state !! check !! V_para REG !! V_val REG !! I_para REG !! I_val REG !! P_para REG !! P_val REG !! Data Update REG !! PF REG !! CheckSum REG&lt;br /&gt;
|-&lt;br /&gt;
| Data read from HLW8032-ISO, NO LOAD || FA || 5A || 02 EE C8 || FE FF 01 || 00 3F 66 || 00 00 00 || 51 21 88 || FA DB 29 || 01 || 00 00 || 54&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
 FA 5A  02 EE C8  FE FF 01  00 3F 66  00 00 00  51 21 88  FA DB 29  01 00 00 54 &lt;br /&gt;
 FA 5A  02 EE C8  FE FF 01  00 3F 66  00 00 00  51 21 88  FC 75 8D  01 00 00 54 &lt;br /&gt;
 FA 5A  02 EE C8  FE FF 01  00 3F 66  00 00 00  51 21 88  FE 0E F2  01 00 00 54 &lt;br /&gt;
 FA 5A  02 EE C8  FE FF 01  00 3F 66  00 00 00  51 21 88  FE FF 01  01 00 00 54&lt;br /&gt;
* Switching Hex to DEC, for example for V_para 02 EE C8 = HEX2DEC ( 02 ) * 65536 + HEX2DEC ( G24 ) * 256 + HEX2DEC ( H24 )&lt;br /&gt;
* Voltage = (V_para / V_val) * Vk&lt;br /&gt;
 Vk = 1.88 ( by 4*470K resistors ladder)&lt;br /&gt;
* Current = (I_para / I_cal) * Ik&lt;br /&gt;
 Ik = 1 (1mR current sensing resistor)&lt;br /&gt;
* Power = ( P_para / P_val ) * Vk * Ik&lt;br /&gt;
* Data read when only power by 5V, not load, not yet connect to AC mains&lt;br /&gt;
 55 5A  02 DA 78  07 26 72  00 3D 3B  07 27 5B  4C C4 58  D0 A7 87  61 00 01 BC &lt;br /&gt;
 F2 5A  02 DA 78  07 28 BB  00 3D 3B  04 35 B5  4C C4 58  11 9F 4F  61 00 00 6C =&amp;gt;&lt;br /&gt;
 F2 / 5A / 02 DA 78 / 07 28 BB / 00 3D 3B / 04 35 B5 / 4C C4 58 / 11 9F 4F / 61 / 00 00 / 6C =&amp;gt;&lt;br /&gt;
 state: F2 / check: 5A / Voltage parameter REG: 02 DA 78 / Voltage REG: 07 28 BB / Current Parameter REG: 00 3D 3B / Current REG: 04 35 B5 / Power parameter REG: 4C C4 58 / Power REG: 11 9F 4F / Data Updata REG: 61 / PF REG: 00 00 / CheckSum REG: 6C&lt;br /&gt;
&lt;br /&gt;
== ISO Version ==&lt;br /&gt;
&lt;br /&gt;
=== ZMPT Sensors (on isolated version) ===&lt;br /&gt;
[[File:2021-04-08 142131.png|frame|right]]&lt;br /&gt;
Current-type Voltage Sensor ZMPT107&lt;br /&gt;
* Input AC voltage side: Sensor Nominate curernt 2mA = 220 / 100K (sample resistor) about 2.195mA&lt;br /&gt;
* 2mA is the typical working current of sensor, both side are equal current 2.195mA&lt;br /&gt;
* Output ACvoltage side: Output voltage for read = 2.195mA * 51R (sample resistor) = 0.112Vac&lt;br /&gt;
Current Sensor ZMCT103C&lt;br /&gt;
* output current up to 5mA&lt;br /&gt;
* 5mA * 1R = 0.005Vac&lt;br /&gt;
Any questions please read more details in datasheet&lt;br /&gt;
&lt;br /&gt;
voltage transformer&lt;br /&gt;
 Current type voltage transformer&lt;br /&gt;
 Specifications: 1000: 1000, 2mA / 2mA&lt;br /&gt;
 Voltage coefficient = 150k / (49.9 * 1000) = 3.006&lt;br /&gt;
Current Transformer&lt;br /&gt;
 Specifications: 1: 1000, 5A / 5mA&lt;br /&gt;
 Current coefficient = 1000/1000 * 1 = 1&lt;br /&gt;
&lt;br /&gt;
=== Use Isolated ZMPT Sensor Version ===&lt;br /&gt;
* [https://bitbucket.org/e_dragon/hlw/src/master/HLW8032/HLW8032%20design%20docs/2-%E8%AE%BE%E8%AE%A1%E6%96%87%E6%A1%A3/HLW8032%E5%8F%82%E8%80%83%E5%BA%94%E7%94%A8%E4%B8%80%E3%80%90%E5%85%8D%E6%A0%A1%E5%87%86%E5%8F%82%E8%80%83%E8%AE%BE%E8%AE%A1%E3%80%91.pdf Find the design documents (chinese) here]&lt;br /&gt;
* Use a already-known load to calculate the coefficience first&lt;br /&gt;
* The math for Voltage is, same for current and power, voltage value is in register bit 2~4, voltage_value is 5~7&lt;br /&gt;
 Voltage = (voltage_register / voltage_value) * voltage_coefficent. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For example for voltage 220V, you can calculate the value of voltage_coefficent&lt;br /&gt;
 22V = (voltage_register / voltage_value) * voltage_coefficent. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 * Use voltage_coefficent as a constant value for further reading.&lt;br /&gt;
* Notice voltage_register is different for every chip.&lt;br /&gt;
== Use with ESP8266 ==&lt;br /&gt;
* Data should be sent to hardware serial of ESP8266, softwareserial seems not working correctly (lose)&lt;br /&gt;
* Please refer to the ESP8266 library in documentation section&lt;br /&gt;
&lt;br /&gt;
== Calibration ==&lt;br /&gt;
* But because the error of each module is different, the scale factor is different.&lt;br /&gt;
* Therefore, each module needs to be calibrated separately, so we need to calibrate the module for a known load (known power, voltage and current parameters),&lt;br /&gt;
* And save the corresponding register data in EEPROM, this group of data can be applied to the calculation of another group of unknown load parameters (power, voltage and current).&lt;br /&gt;
&lt;br /&gt;
== Documentation ==&lt;br /&gt;
Arduino Mega&lt;br /&gt;
* https://github.com/ocrobot/HLW8032&lt;br /&gt;
ESP8266&lt;br /&gt;
* https://github.com/Khaalidi/HLW8032&lt;br /&gt;
* https://github.com/Edragon/HLW&lt;br /&gt;
&lt;br /&gt;
[[category: HLW8032]]&lt;/div&gt;</summary>
		<author><name>Chao</name></author>
	</entry>
</feed>