{"id":19892303,"url":"https://github.com/peff74/sonoff-dual-r3","last_synced_at":"2025-05-02T18:31:43.610Z","repository":{"id":216713669,"uuid":"560888727","full_name":"peff74/Sonoff-Dual-R3","owner":"peff74","description":"Arduino Code for Sonoff Dual R3 v2 with bl0939","archived":false,"fork":false,"pushed_at":"2025-04-24T23:09:26.000Z","size":20465,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-25T00:24:39.232Z","etag":null,"topics":["arduino","bl0939","dualr3","esp32","sonoff","sonoffdualr3"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peff74.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-02T13:47:15.000Z","updated_at":"2024-07-31T17:59:05.000Z","dependencies_parsed_at":"2024-01-12T07:06:46.808Z","dependency_job_id":"95230f99-5745-43b5-8c66-bfd11e5bb6d2","html_url":"https://github.com/peff74/Sonoff-Dual-R3","commit_stats":null,"previous_names":["peff74/sonoff-dual-r3"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peff74%2FSonoff-Dual-R3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peff74%2FSonoff-Dual-R3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peff74%2FSonoff-Dual-R3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peff74%2FSonoff-Dual-R3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peff74","download_url":"https://codeload.github.com/peff74/Sonoff-Dual-R3/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252088555,"owners_count":21692815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","bl0939","dualr3","esp32","sonoff","sonoffdualr3"],"created_at":"2024-11-12T18:22:59.027Z","updated_at":"2025-05-02T18:31:39.863Z","avatar_url":"https://github.com/peff74.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  Sonoff Dual R3 v2\n\nAn **Arduino** program for obtaining data from a **Sonoff Dual R3 v2**  with a **bl0939** chip inside.\n\n# ⚠️️Special Attention ⚠️️\n\n**Do not connect AC power and the serial connection at the same time**\nThe GND connection of the Dual R3 is connected to the live AC wire.\nConnecting serial with your PC will fry your PC and will electrocute you.\nSafety and fire danger.\n\n**DO NOT CONNECT ANY SENSORS TO THESE DEVICES!!! The GPIOs on the Dual R3 are connected to AC power!**\n\n\n\n#  Features\n\n - Initializes the bl0939\n - requests data\n - reads the data \n - does a CRC check\n - decodes the data string\n - converts the data to real values\n - Telnet for monitoring\n\n\n\n\n# How to calculate Voltage, Current , Active Power\n   \n   More information\n  - BL0939 Notes_V1.1_cn.pdf\n  - BL0939_V1.2_cn.pdf\n  \n   Needed values\n  - Vref=1.218V\n   - R1=0.51kOhm\n   - R2=5*390kOhm\n  - RL=1mOhm\n   \n| Value | Calculation |\n| ------ | ------ |\n|  Current(A)|  = I_RMS_Reg*Vref/324004*RL|\n|        |      = I_RMS_Reg / ((324004*RL)/Vref)\n|   |              = I_RMS_Reg / ((324004*1)/1,218)\n||              = I_RMS_Reg / 266013,14\n |  Voltage(V)|  = V_RMS_Reg*Vref*(R2+R1)/79931*R1*1000\n | |= V_RMS_Reg / ((79931*R1*1000)/(1,218*(R2+R1)))\n | |= V_RMS_Reg / ((79931*0,51*1000)/(1,218*(5*390)+0,51))\n |  |= V_RMS_Reg / 17158,92\n | Power (W)|   = WATT_Reg*Vref²*(R2+R1)/4046*RL*R1*1000\n||  = WATT_Reg / ((4046*RL*R1*1000)/(Vref²*(R2+R1))\n||   = WATT_Reg / ((4046*1*0,51*1000)/((1,218*1,218)*((5*390)+0,51)\n||       = WATT_Reg / 713,105\n| Engergy(kWh)|= CF*((1638,4*256*Vref²*(R2+R1))/(3600000*4046*RL*R1*1000))\n||       = CF*((1638,4*256*(1,218*1,218)*((5*390)+0,51))/(3600000*4046*1*R0,51*1000))\n||       = CF * 0,0001633819620262585\n| TEMP (°C) |  = (170/448)*(TPS1/2-32)-45\n|   | = ((85TSP1-5440)/448)-45\n               \n # One full measurement frame from bl0939\n55 3a 12 0  f0 2f 0  0  0  0  8c 61 3c bb 3  0  fc 10 0  0  0  0  b6 0  0  0  0  0  e2 1  0  7d 2  0  df\n|  Byte: | 00| 01| 02| 03| 04| 05| 06| 07| 08| 09| 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29| 30| 31| 32| 33| 34|\n| - |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- |- | \n|  Data:|  55| 3a| 12| 0 | f0| 2f| 0 | 0 | 0 | 0 | 8c| 61| 3c| bb| 3 | 0 | fc| 10| 0 | 0 | 0 | 0 | b6| 0 | 0 | 0 | 0 | 0 | e2| 1 | 0 | 7d| 2 | 0 | df|\n  \n  \n | Byte | Data |          Function |     How to calculate|\n | -----|---      |--------------      |----------|\n | 00|    0x55|           HEADER\n  |01-03| 0x3a 0x12 0x00| I_FAST_RMS[A]\n  |04-06| 0xf0 0x2f 0x00 |I_RMS[A] |     002ff0 --\u003e 12272   --\u003e /266013                --\u003e 0,046A\n  |07-09 |0x00 0x00 0x00| I_RMS[B]\n  |10-12 |0x8c 0x61 0x3c| V_RMS     |    3C618C --\u003e 3957132 --\u003e /17159                 --\u003e 231V\n  |13-15 |0xbb 0x03 0x00 |I_FAST_RMS[B]\n  |16-18 |0xfc 0x10 0x00 |WATT[A] |      0010fc --\u003e 4348    --\u003e /713                   --\u003e 6,1W\n  |19-21| 0x00 0x00 0x00| WATT[B]\n  |22-24| 0xb6 0x00 0x00| CF_CNT[A] |    0000b6 --\u003e 182     --\u003e *0.000163              --\u003e 0,0296kWh\n  |25-27| 0x00 0x00 0x00| CF_CNT[B]\n  |28-29| 0xe2 0x01     | TPS1[internal] | 01e2 --\u003e 482     --\u003e ((85*482-5440)/448)-45 --\u003e 34,31°C\n  |30|    0x00      |     Free\n | 31-32| 0x7d 0x02    |  TPS2[external]\n  |33   | 0x00 |          Free\n|  34    |0xdf    |       CHECKSUM\n\n\n[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fpeff74%2FSonoff-Dual-R3\u0026count_bg=%2379C83D\u0026title_bg=%23555555\u0026icon=\u0026icon_color=%23E7E7E7\u0026title=hits\u0026edge_flat=false)](https://hits.seeyoufarm.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeff74%2Fsonoff-dual-r3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeff74%2Fsonoff-dual-r3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeff74%2Fsonoff-dual-r3/lists"}