├── Certification ├── ESP-WROOM-32 BQB Certification.pdf ├── ESP-WROOM-32 FCC (BT) Certification.pdf ├── ESP-WROOM-32 FCC (Wi-Fi + BT4.0) Certification.pdf ├── ESP-WROOM-32 SRRC Certification.pdf ├── ESP32-WROOM-32 & ESP-WROOM-32 MIC Certification.pdf ├── ESP32-WROOM-32 IC Certification.pdf ├── ESP32-WROOM-32 NCC Certification.pdf ├── ESP32-WROOM-32 SRRC Certification.pdf ├── ESP32-WROOM-32_Wi-Fi_Certificate.pdf ├── Espressif Systems ESP32 B2006184 RED Appendix Final.pdf ├── Espressif Systems ESP32 B2006184 RED Final.pdf ├── Microchip_REACH_Statement.pdf ├── Microchip_RoHS_Certificate.pdf └── README.md ├── Code ├── Home Assistant │ └── ipem-test.yaml ├── IPEM-1_Test_Code_DCV_IN_Voltage │ └── IPEM-1_Test_Code_DCV_IN_Voltage.ino ├── IPEM-1_Test_Code_NTC_Temperature │ └── IPEM-1_Test_Code_NTC_Temperature.ino ├── IPEM-1_Test_Code_OLED │ └── IPEM-1_Test_Code_OLED.ino ├── IPEM-1_Test_Code_RGB_LED │ └── IPEM-1_Test_Code_RGB_LED.ino ├── IPEM-1_Test_Code_User_Button │ └── IPEM-1_Test_Code_User_Button.ino ├── IPEM-1_Test_Code_Wifi │ └── IPEM-1_Test_Code_Wifi.ino ├── IPEM_1_Test_Code_ATM90E32_ATM90E36 │ ├── .gitignore │ ├── Configuration Header Examples.md │ ├── Domoticz Ouput Example.md │ ├── Firmware Configuration and Flashing.md │ ├── README.md │ ├── Terminal Output Example ATM90E32 3Phase.txt │ ├── Terminal Output Example ATM90E32 Split Phase.txt │ ├── Terminal Output Example ATM90E32.txt │ ├── Terminal Output Example ATM90E36.txt │ ├── Terminal Output Example DAC Enabled.txt │ ├── Terminal Output Example PWM Enabled.txt │ ├── Terminal Output Example with 1200W Halogen Heater.txt │ ├── Transformer Info.md │ ├── include │ │ ├── ATM90E3x.h │ │ ├── DAC.h │ │ ├── Domoticz.h │ │ ├── IPEM_EEPROM.h │ │ ├── IPEM_Hardware.h │ │ ├── MQTT.h │ │ ├── PWM.h │ │ ├── README │ │ ├── ThingSpeakIoT.h │ │ └── WiFi-OTA.h │ ├── lib │ │ └── README │ ├── platformio.ini │ ├── src │ │ ├── ATM90E3x.cpp │ │ └── main.cpp │ └── test │ │ └── README ├── IPEM_1_Test_Code_CT4_Clamp │ └── IPEM_1_Test_Code_CT4_Clamp.ino ├── IPEM_1_Test_Code_I2C_Scanner_EEPROM │ └── IPEM_1_Test_Code_I2C_Scanner_EEPROM.ino └── README.md ├── Datasheets and Information ├── AC Three Phase Sinewave Plot.jpg ├── AP63203WU-7 3v3 2A 32V Datasheet.pdf ├── AT24C32-64 EEPROM Datasheet.pdf ├── Atmel M90E32AS Datasheet (Annotated).pdf ├── Atmel M90E36A Datasheet (Annotated).pdf ├── Atmel-46003-SE-M90E32AS-Datasheet.pdf ├── Atmel-46004-SE-M90E36A-Datasheet.pdf ├── Atmel-46103-SE-M90E32AS-ApplicationNote.pdf ├── Atmel-46104-SE-M90E36A- ApplicationNote .pdf ├── CH340 USB UART Interface Datasheet.PDF ├── DitronIX Mains Calibration 3Phase R&D.jpg ├── DitronIX Mains Calibration TestBox CloseUp.jpg ├── DitronIX Mains Calibration TestBox Loads.jpg ├── DitronIX Mains Calibration TestBox Top.jpg ├── DitronIX Mains Calibration TestBox.jpg ├── DitroniX IPEM Design Processes.jpg ├── DitroniX Mains Calibration TestBox Internal.jpg ├── DitroniX Mains Test Fixture Outline IPEM 2303.jpg ├── DitroniX.net Power Energy Monitor Boards SDK Overview.jpg ├── DitroniX.net Power Energy Monitor Boards SDK Overview.pdf ├── DitroniX.net STEM Energy Monitors SDK Board Options.jpg ├── DitroniX.net STEM Energy Monitors SDK Board Options.pdf ├── DitroniX.net STEM IoT eBay.jpg ├── ESP32-WROOM-32E Datasheet.pdf ├── GreenBrook DAT01A Transformer.pdf ├── IPEM AC Input Connections.pdf ├── IPEM AC Input Connections.png ├── IPEM ArduinoISE - Serial Monitor.png ├── IPEM ESP32 ATM90E32 ATM90E36 SDK 1.2302.201P Schematic.pdf ├── IPEM ESP32 ATM90E32 ATM90E36 Variant SDK 1.2303.201PU.pdf ├── IPEM ESP32 ATM90E32 Only Variant SDK 1.2303-201PU Schematic.png ├── IPEM ESP32 ATM90E3x SDK 1.2302-202P Schematic.png ├── IPEM ESP32UE ATM90E32 Variant SDK 1.2304.203P Schematic.pdf ├── IPEM ESP32UE ATM90E36 Variant SDK 1.2306.204P Schematic.pdf ├── IPEM PlatformIO - Home.png ├── IPEM PlatformIO - MQTT Example in MQTT Explorer.png ├── IPEM PlatformIO - MQTT Example.png ├── IPEM PlatformIO - Serial Monitor.png ├── IPEM PlatformIO - WiFi Settings.png ├── IPEM Power Energy Monitor Board Overview.jpg ├── IPEM Push OTA Web Home Page.png ├── IPEM Push OTA Web Upload Page.png ├── IPEM ThingSpeak - ThingChart App.jpg ├── IPEM ThingSpeak Example.png ├── IPEM with OLED Display.jpg ├── IPEM with Transformer.jpg ├── IPEM-3 and 1 Phase Installation.mp4 ├── IPEM-ESP32E-ATM90E32 - Shipping.jpg ├── IPEM-ESP32UE-ATM90E32 - Shipping.jpg ├── Microchip Platform Energy Monitors.pdf ├── Microchip-ATM90E3x Brochure.pdf ├── README.md ├── SCT013-000-100A-50mA.pdf ├── SCT013-005-0-5A-0-1V.pdf ├── SCT013-010-0-10A-0-1V.pdf ├── SCT013-015-0-15A-0-1V.pdf ├── SCT013-020-0-20A-0-1V.pdf ├── SCT013-025-0-25A-0-1V.pdf ├── SCT013-030-0-30A-0-1V.pdf ├── SCT013-050-0-50A-0-1V.pdf ├── SCT013-060-0-60A-0-1V.pdf ├── SCT013-100-100A-1V.pdf ├── Thumbs.db ├── Transformer Info.txt ├── YHDC SCT013 CT Current Clamp Datasheet.pdf └── YHDC SCT013 CT Current Clamp Test Report.pdf ├── DitroniX.net Board Versions and Revisions.txt ├── LICENSE ├── README.md └── Transformer Info.txt /Certification/ESP-WROOM-32 BQB Certification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/ESP-WROOM-32 BQB Certification.pdf -------------------------------------------------------------------------------- /Certification/ESP-WROOM-32 FCC (BT) Certification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/ESP-WROOM-32 FCC (BT) Certification.pdf -------------------------------------------------------------------------------- /Certification/ESP-WROOM-32 FCC (Wi-Fi + BT4.0) Certification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/ESP-WROOM-32 FCC (Wi-Fi + BT4.0) Certification.pdf -------------------------------------------------------------------------------- /Certification/ESP-WROOM-32 SRRC Certification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/ESP-WROOM-32 SRRC Certification.pdf -------------------------------------------------------------------------------- /Certification/ESP32-WROOM-32 & ESP-WROOM-32 MIC Certification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/ESP32-WROOM-32 & ESP-WROOM-32 MIC Certification.pdf -------------------------------------------------------------------------------- /Certification/ESP32-WROOM-32 IC Certification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/ESP32-WROOM-32 IC Certification.pdf -------------------------------------------------------------------------------- /Certification/ESP32-WROOM-32 NCC Certification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/ESP32-WROOM-32 NCC Certification.pdf -------------------------------------------------------------------------------- /Certification/ESP32-WROOM-32 SRRC Certification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/ESP32-WROOM-32 SRRC Certification.pdf -------------------------------------------------------------------------------- /Certification/ESP32-WROOM-32_Wi-Fi_Certificate.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/ESP32-WROOM-32_Wi-Fi_Certificate.pdf -------------------------------------------------------------------------------- /Certification/Espressif Systems ESP32 B2006184 RED Appendix Final.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/Espressif Systems ESP32 B2006184 RED Appendix Final.pdf -------------------------------------------------------------------------------- /Certification/Espressif Systems ESP32 B2006184 RED Final.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/Espressif Systems ESP32 B2006184 RED Final.pdf -------------------------------------------------------------------------------- /Certification/Microchip_REACH_Statement.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/Microchip_REACH_Statement.pdf -------------------------------------------------------------------------------- /Certification/Microchip_RoHS_Certificate.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Certification/Microchip_RoHS_Certificate.pdf -------------------------------------------------------------------------------- /Certification/README.md: -------------------------------------------------------------------------------- 1 | **Certification Documentation - External** 2 | 3 | These Certification Documents pertain to the related Manufacturer MCU, covering both Wireless and Bluetooth RF Testing. 4 | 5 | 6 | ## **Further Information** 7 | 8 | Additional information, and other technical details on this project, maybe found in the related repository pages. 9 | 10 | **Repository Folders** 11 | 12 | - **Code** *(Code examples for Arduino IDE and PlatformIO)* 13 | - **Datasheets and Information** *(Component Datasheets, Schematics, Board Layouts, Photos, Technical Documentation)* 14 | - **Certification** *(Related Repository Project or Part, Certification Information)* 15 | 16 | **Repository Tabs** 17 | 18 | - **Wiki** *(Related Repository Wiki pages and Technical User Information)* 19 | - **Discussions** *(Related Repository User Discussion Forum)* 20 | - **Issues** *(Related Repository Technical Issues and Fixes)* 21 | 22 | *** 23 | 24 | We value our Customers, Users of our designs and STEM Communities, all over the World . Should you have any other questions, or feedback to share to others, please feel free to: 25 | 26 | * Visit the related [Project](https://github.com/DitroniX?tab=repositories) *plus the related* **Discussions** and **Wiki** Pages. See tab in each separate repository. 27 | * **Project Community Information** can be found at https://www.hackster.io/DitroniX 28 | * [DitroniX.net Website - Contact Us](https://ditronix.net/contact/) 29 | * **Twitter**: [https://twitter.com/DitroniX](https://twitter.com/DitroniX) 30 | * [Supporting the STEM Projects - BuyMeACoffee](https://www.buymeacoffee.com/DitroniX) 31 | * **LinkedIN**: [https://www.linkedin.com/in/g8puo/](https://www.linkedin.com/in/g8puo/) 32 | 33 | ***Dave Williams, Maidstone, UK.*** 34 | 35 | Electronics Engineer | Software Developer | R&D Support | RF Engineering | Product Certification and Testing | STEM Ambassador 36 | 37 | ## STEM 38 | 39 | **Supporting [STEM Learning](https://www.stem.org.uk/)** 40 | 41 | Life is one long exciting learning curve, help others by setting the seed to knowledge. 42 | 43 | ![DitroniX Supporting STEM](https://hackster.imgix.net/uploads/attachments/1606838/stem_ambassador_-_100_volunteer_badge_edxfxlrfbc1_bjdqharfoe1_xbqi2KUcri.png?auto=compress%2Cformat&w=540&fit=max) 44 | 45 | -------------------------------------------------------------------------------- /Code/Home Assistant/ipem-test.yaml: -------------------------------------------------------------------------------- 1 | # Working Test 2 | 3 | esphome: 4 | name: ipec-test 5 | friendly_name: IPEM Test 6 | on_boot: 7 | priority: 100 # Highest priority, ensures light turns on without delay. 8 | then: 9 | - output.turn_on: gpio_d1 10 | - output.turn_on: gpio_d2 11 | 12 | substitutions: 13 | default_gain_voltage: '38800' 14 | default_gain_ct: '38500' 15 | default_pga_gain: 4X 16 | default_interval_time: 1s 17 | 18 | esp32: 19 | board: esp32dev 20 | framework: 21 | type: arduino 22 | 23 | # Enable logging 24 | logger: 25 | 26 | # Enable Home Assistant API 27 | api: 28 | encryption: 29 | key: "##" 30 | 31 | ota: 32 | - platform: esphome 33 | password: !secret ipec_test_ota_password 34 | 35 | wifi: 36 | ssid: !secret wifi_ssid 37 | password: !secret wifi_password 38 | 39 | # Enable fallback hotspot (captive portal) in case wifi connection fails 40 | ap: 41 | ssid: "##" 42 | password: !secret ipec_test_ap_password 43 | 44 | captive_portal: 45 | 46 | output: 47 | - platform: gpio 48 | pin: GPIO04 49 | id: gpio_d1 50 | 51 | - platform: gpio 52 | pin: GPIO15 53 | id: gpio_d2 54 | 55 | status_led: 56 | pin: GPIO02 57 | 58 | font: 59 | - file: 'fonts/Arial.ttf' 60 | id: font8 61 | size: 14 62 | 63 | i2c: 64 | sda: 21 65 | scl: 22 66 | scan: true 67 | id: bus_a 68 | 69 | display: 70 | - platform: ssd1306_i2c 71 | id: i2cdisplay 72 | model: "SSD1306 128x32" 73 | #reset_pin: D0 74 | address: 0x3C 75 | pages: 76 | - id: page1 77 | lambda: |- 78 | it.printf(0, 0, id(font8), TextAlign::TOP_LEFT, "CT1 %.2fW", id(CT1CURR).state); 79 | - id: page2 80 | lambda: |- 81 | it.printf(0, 0, id(font8), TextAlign::TOP_LEFT, "CT2 %.2fW", id(CT2CURR).state); 82 | - id: page3 83 | lambda: |- 84 | it.printf(0, 0, id(font8), TextAlign::TOP_LEFT, "CT3 %.2fW", id(CT3CURR).state); 85 | 86 | interval: 87 | - interval: 5s 88 | then: 89 | - display.page.show_next: i2cdisplay 90 | - component.update: i2cdisplay 91 | 92 | spi: 93 | clk_pin: 18 94 | miso_pin: 19 95 | mosi_pin: 23 96 | 97 | sensor: 98 | - platform: atm90e32 99 | id: ctclamp 100 | cs_pin: 5 101 | phase_a: 102 | voltage: 103 | name: "IPEM Line Voltage" 104 | current: 105 | name: "IPEM CT1 Current" 106 | power: 107 | name: "IPEM Active Power CT1" 108 | id: CT1CURR 109 | reactive_power: 110 | name: "IPEM Reactive Power CT1" 111 | power_factor: 112 | name: "IPEM Power Factor CT1" 113 | gain_voltage: ${default_gain_voltage} 114 | gain_ct: ${default_gain_ct} 115 | phase_b: 116 | current: 117 | name: "IPEM CT2 Current" 118 | power: 119 | name: "IPEM Active Power CT2" 120 | id: CT2CURR 121 | reactive_power: 122 | name: "IPEM Reactive Power CT2" 123 | power_factor: 124 | name: "IPEM Power Factor CT2" 125 | gain_voltage: ${default_gain_voltage} 126 | gain_ct: ${default_gain_ct} 127 | phase_c: 128 | current: 129 | name: "IPEM CT3 Current" 130 | power: 131 | name: "IPEM Active Power CT3" 132 | id: CT3CURR 133 | reactive_power: 134 | name: "IPEM Reactive Power CT3" 135 | power_factor: 136 | name: "IPEM Power Factor CT3" 137 | gain_voltage: ${default_gain_voltage} 138 | gain_ct: ${default_gain_ct} 139 | frequency: 140 | name: "IPEM Line Frequency" 141 | chip_temperature: 142 | name: "IPEM Chip Temperature" 143 | line_frequency: 50Hz 144 | current_phases: 3 145 | gain_pga: ${default_pga_gain} 146 | update_interval: ${default_interval_time} 147 | 148 | -------------------------------------------------------------------------------- /Code/IPEM-1_Test_Code_DCV_IN_Voltage/IPEM-1_Test_Code_DCV_IN_Voltage.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | Features include ESP32 IPEM ESP32 ATM90E32 ATM90E36 16bit ADC EEPROM 3Phase 3+1 CT-Clamps Current Voltage Frequency Power Factor GPIO I2C OLED SMPS D1 USB 5 | PCA 1.2302-101 - Test Code Firmware v1 - 18th February 2023 6 | 7 | The purpose of this test code is to cycle through the various main functions of the board, as shown below, as part of board bring up testing. 8 | Simplified Board Bring Up Test - DCV_IN Voltage Sensor - PCA DC Supply (Output sent to the Serial Print) 9 | 10 | Remember! 11 | Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 12 | You may set the BAUD rate to 921600 to speed up flashing. 13 | The SDK does NOT need external power to flash. It will take Power from the USB 5V. 14 | 15 | Note: In the default state, upon first power up and during reset, the Green LED may be partially lit. Once programmed and the GPIO defined, the Green LED will go off after power up. 16 | 17 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 18 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | 20 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and github.com/DitroniX 21 | */ 22 | 23 | // Libraries 24 | #include 25 | 26 | // **************** VARIABLES / DEFINES / STATIC **************** 27 | 28 | // Constants 29 | const int LoopDelay = 1; // Loop Delay in Seconds 30 | 31 | // Variables 32 | float ADC_Voltage; 33 | float ADC_Constant; 34 | 35 | // **************** OUTPUTS **************** 36 | #define LED_Red 2 // Red LED 37 | #define LED_Green 4 // Green LED 38 | 39 | // **************** INPUTS **************** 40 | #define DCV_IN 36 //GPIO 36 (Analog VP / ADC 1 CH0) 41 | 42 | void setup() { 43 | 44 | // Stabalise 45 | delay(250); 46 | 47 | // Initialise UART: 48 | Serial.begin(115200, SERIAL_8N1); //115200 49 | while (!Serial); 50 | Serial.println(""); 51 | 52 | // LEDs 53 | pinMode(LED_Red, OUTPUT); 54 | pinMode(LED_Green, OUTPUT); 55 | 56 | // LEDs Default Off State 57 | digitalWrite(LED_Red, HIGH); 58 | digitalWrite(LED_Green, HIGH); 59 | 60 | } 61 | 62 | void loop() { 63 | 64 | // ESP32 ADC 12-Bit SAR (Successive Approximation Register) 65 | // Conversion resolution 0 - 4095 (4096) 66 | // You may need to calibrate as needed. 67 | 68 | ADC_Constant = 31.340; // Adjust as needed for calibration of VDC_IN. 69 | ADC_Voltage = (analogRead(DCV_IN) * ADC_Constant) / 4095; 70 | 71 | // Update the display 72 | Serial.print(ADC_Voltage); 73 | Serial.println(" V DCV_IN"); 74 | 75 | // Heatbeat LED 76 | digitalWrite(LED_Red, LOW); 77 | delay(50); 78 | digitalWrite(LED_Red, HIGH); 79 | 80 | // Loop Delay 81 | delay(LoopDelay * 1000); 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Code/IPEM-1_Test_Code_NTC_Temperature/IPEM-1_Test_Code_NTC_Temperature.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | Features include ESP32 IPEM ESP32 ATM90E32 ATM90E36 16bit ADC EEPROM 3Phase 3+1 CT-Clamps Current Voltage Frequency Power Factor GPIO I2C OLED SMPS D1 USB 5 | PCA 1.2302-201 - Test Code Firmware v1 - 18th February 2023 6 | 7 | The purpose of this test code is to cycle through the various main functions of the board, as shown below, as part of board bring up testing. 8 | 9 | Simplified Board Bring Up Test - NTC Temperature (Output sent to Serial Print) 10 | 11 | Remember! 12 | Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 13 | You may set the BAUD rate to 921600 to speed up flashing. 14 | The SDK does NOT need external power to flash. It will take Power from the USB 5V. 15 | 16 | Note: In the default state, upon first power up and during reset, the Green LED may be partially lit. Once programmed and the GPIO defined, the Green LED will go off after power up. 17 | 18 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 19 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | 21 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and github.com/DitroniX 22 | */ 23 | 24 | // Libraries 25 | #include 26 | 27 | // **************** VARIABLES / DEFINES / STATIC **************** 28 | 29 | // Constants 30 | const int LoopDelay = 1; // Loop Delay in Seconds 31 | 32 | // **************** OUTPUTS **************** 33 | #define LED_Red 2 // Red LED 34 | #define LED_Green 4 // Green LED 35 | 36 | // **************** INPUTS **************** 37 | #define NTC_IN 39 //GPIO 39 (Analog VN / ADC 1 CH3) 38 | 39 | void setup() { 40 | 41 | // Stabalise 42 | delay(250); 43 | 44 | // Initialise UART: 45 | Serial.begin(115200, SERIAL_8N1); //115200 46 | while (!Serial); 47 | Serial.println(""); 48 | 49 | // LEDs 50 | pinMode(LED_Red, OUTPUT); 51 | pinMode(LED_Green, OUTPUT); 52 | 53 | // LEDs Default Off State 54 | digitalWrite(LED_Red, HIGH); 55 | digitalWrite(LED_Green, HIGH); 56 | 57 | } 58 | 59 | void loop() { 60 | 61 | int Vo; 62 | float R1 = 10000; // May need calibrating 63 | float logR2, R2, T, Tc, Tf; 64 | float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07; 65 | 66 | Vo = analogRead(NTC_IN); 67 | R2 = R1 * (4095.0 / (float)Vo - 1.0); 68 | logR2 = log(R2); 69 | T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2)); 70 | Tc = T - 273.15; 71 | Tf = (Tc * 9.0) / 3.3 + 32.0; 72 | 73 | Serial.print("Temperature\t"); 74 | Serial.print(Tf); 75 | Serial.print(" ºF\t"); 76 | Serial.print(Tc); 77 | Serial.println(" ºC"); 78 | 79 | // Heatbeat LED 80 | digitalWrite(LED_Red, LOW); 81 | delay(50); 82 | digitalWrite(LED_Red, HIGH); 83 | 84 | // Loop Delay 85 | delay(LoopDelay * 1000); 86 | 87 | } -------------------------------------------------------------------------------- /Code/IPEM-1_Test_Code_OLED/IPEM-1_Test_Code_OLED.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | Features include ESP32 IPEM ESP32 ATM90E32 ATM90E36 16bit ADC EEPROM 3Phase 3+1 CT-Clamps Current Voltage Frequency Power Factor GPIO I2C OLED SMPS D1 USB 5 | PCA 1.2302-201 - Test Code Firmware v1 - 18th February 2023 6 | 7 | The purpose of this test code is to cycle through the various main functions of the board, as shown below, as part of board bring up testing. 8 | 9 | Simplified Board Bring Up Test - OLED Display via I2c (Heatbeat LED) 10 | 11 | Remember! 12 | Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 13 | You may set the BAUD rate to 921600 to speed up flashing. 14 | The SDK does NOT need external power to flash. It will take Power from the USB 5V. 15 | 16 | Note: In the default state, upon first power up and during reset, the Green LED may be partially lit. Once programmed and the GPIO defined, the Green LED will go off after power up. 17 | 18 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 19 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | 21 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and github.com/DitroniX 22 | */ 23 | 24 | // Libraries 25 | #include 26 | 27 | // **************** OUTPUTS **************** 28 | #define LED_Red 2 // Red LED 29 | #define LED_Green 4 // Green LED 30 | 31 | // Constants 32 | const int LoopDelay = 1; // Loop Delay in Seconds 33 | 34 | // Variables 35 | float TestCount = 0; 36 | 37 | // OLED Instance. You will need to select your OLED Display.  38 | // Uncomment/Comment as needed. 39 | GyverOLED oled; //0.6" 40 | //GyverOLED oled; 41 | //GyverOLED oled; 42 | //GyverOLED oled; 43 | // GyverOLED oled; //1.1" 44 | 45 | // Draw Battery 46 | void drawBattery(byte percent) { 47 | oled.drawByte(0b00111100); 48 | oled.drawByte(0b00111100); 49 | oled.drawByte(0b11111111); 50 | for (byte i = 0; i < 100 / 8; i++) { 51 | if (i < (100 - percent) / 8) oled.drawByte(0b10000001); 52 | else oled.drawByte(0b11111111); 53 | } 54 | oled.drawByte(0b11111111); 55 | } 56 | 57 | void setup() { 58 | 59 | // Stabalise 60 | delay(250); 61 | 62 | // LED 63 | pinMode(LED_Red, OUTPUT); 64 | pinMode(LED_Green, OUTPUT); 65 | 66 | // LED Default Off State 67 | digitalWrite(LED_Red, HIGH); 68 | digitalWrite(LED_Green, HIGH); 69 | 70 | // OLED 71 | oled.init(); 72 | oled.clear(); 73 | oled.setCursor(18, 0); 74 | oled.setScale(5); 75 | oled.print("IPEM"); 76 | oled.update(); 77 | delay(2000); 78 | } 79 | 80 | void loop() { 81 | 82 | // Test Counter. Any random decimal number between 0 and 99 83 | TestCount = random(0, 9999); 84 | TestCount = TestCount / 100; 85 | 86 | // Update the display 87 | oled.clear(); 88 | oled.setScale(3); 89 | oled.setCursor(0, 0); 90 | oled.print(TestCount); 91 | oled.println(" W"); 92 | drawBattery(TestCount); 93 | oled.update(); 94 | 95 | // Heatbeat LED 96 | digitalWrite(LED_Red, LOW); 97 | delay(50); 98 | digitalWrite(LED_Red, HIGH); 99 | 100 | // Loop Delay 101 | delay(LoopDelay * 1000); 102 | 103 | } 104 | -------------------------------------------------------------------------------- /Code/IPEM-1_Test_Code_RGB_LED/IPEM-1_Test_Code_RGB_LED.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | Features include ESP32 IPEM ESP32 ATM90E32 ATM90E36 16bit ADC EEPROM 3Phase 3+1 CT-Clamps Current Voltage Frequency Power Factor GPIO I2C OLED SMPS D1 USB 5 | PCA 1.2302-201 - Test Code Firmware v1 - 18th February 2023 6 | 7 | The purpose of this test code is to cycle through the various main functions of the board, as shown below, as part of board bring up testing. 8 | 9 | Simplified Board Bring Up Test - RGB LED - Cycle through the Colours 10 | 11 | Remember! 12 | Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 13 | You may set the BAUD rate to 921600 to speed up flashing. 14 | The SDK does NOT need external power to flash. It will take Power from the USB 5V. 15 | 16 | Note: In the default state, upon first power up and during reset, the Green LED may be partially lit. Once programmed and the GPIO defined, the Green LED will go off after power up. 17 | 18 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 19 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | 21 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and github.com/DitroniX 22 | */ 23 | 24 | // **************** OUTPUTS **************** 25 | #define LED_Red 2 // Red LED 26 | #define LED_Green 4 // Green LED 27 | #define LED_Blue 15 // Blue LED 28 | 29 | void setup() { 30 | 31 | // Stabalise 32 | delay(250); 33 | 34 | // Configures the specified LED GPIO as outputs 35 | pinMode(LED_Red, OUTPUT); 36 | pinMode(LED_Green, OUTPUT); 37 | pinMode(LED_Blue, OUTPUT); 38 | 39 | // LEDs Default Off State 40 | digitalWrite(LED_Red, HIGH); 41 | digitalWrite(LED_Green, HIGH); 42 | digitalWrite(LED_Blue, HIGH); 43 | } 44 | 45 | void loop() { 46 | 47 | // Test RGB LEDs 48 | 49 | // Red 50 | digitalWrite(LED_Red, LOW); 51 | delay(1000); 52 | digitalWrite(LED_Red, HIGH); 53 | delay(100); 54 | 55 | // Green 56 | digitalWrite(LED_Green, LOW); 57 | delay(1000); 58 | digitalWrite(LED_Green, HIGH); 59 | delay(100); 60 | 61 | // Blue 62 | digitalWrite(LED_Blue, LOW); 63 | delay(1000); 64 | digitalWrite(LED_Blue, HIGH); 65 | delay(100); 66 | 67 | // White 68 | digitalWrite(LED_Red, LOW); 69 | digitalWrite(LED_Green, LOW); 70 | digitalWrite(LED_Blue, LOW); 71 | delay(1000); 72 | digitalWrite(LED_Red, HIGH); 73 | digitalWrite(LED_Green, HIGH); 74 | digitalWrite(LED_Blue, HIGH); 75 | delay(100); 76 | 77 | } 78 | -------------------------------------------------------------------------------- /Code/IPEM-1_Test_Code_User_Button/IPEM-1_Test_Code_User_Button.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | Features include ESP32 IPEM ESP32 ATM90E32 ATM90E36 16bit ADC EEPROM 3Phase 3+1 CT-Clamps Current Voltage Frequency Power Factor GPIO I2C OLED SMPS D1 USB 5 | PCA 1.2302-201 - Test Code Firmware v1 - 18th February 2023 6 | 7 | The purpose of this test code is to cycle through the various main functions of the board, as shown below, as part of board bring up testing. 8 | 9 | Simplified Board Bring Up Test - GPIO - User Button Test 10 | 11 | Remember! 12 | Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 13 | You may set the BAUD rate to 921600 to speed up flashing. 14 | The SDK does NOT need external power to flash. It will take Power from the USB 5V. 15 | 16 | Note: In the default state, upon first power up and during reset, the Green LED may be partially lit. Once programmed and the GPIO defined, the Green LED will go off after power up. 17 | 18 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 19 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | 21 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and github.com/DitroniX 22 | */ 23 | 24 | // **************** VARIABLES / DEFINES / STATIC / STRUCTURES / CONSTANTS **************** 25 | 26 | // **************** INPUTS **************** 27 | #define User_Button 26 // GPIO 26 (DAC2 ADC2_CH9) 28 | 29 | // **************** OUTPUTS **************** 30 | #define LED_Red 2 // Red LED 31 | #define LED_Green 4 // Green LED 32 | #define LED_Blue 15 // Blue LED 33 | 34 | // **************** SETUP **************** 35 | void setup() { 36 | 37 | // Stabalise 38 | delay(250); 39 | 40 | // Initialise UART 41 | Serial.begin(115200, SERIAL_8N1); // 115200 42 | while (!Serial) 43 | ; 44 | Serial.println(""); 45 | 46 | // Configures the specified LED GPIO as outputs 47 | pinMode(LED_Red, OUTPUT); 48 | pinMode(LED_Green, OUTPUT); 49 | pinMode(LED_Blue, OUTPUT); 50 | 51 | // LEDs Default Off State 52 | digitalWrite(LED_Red, HIGH); 53 | digitalWrite(LED_Green, HIGH); 54 | digitalWrite(LED_Blue, HIGH); 55 | 56 | // Configure GPIO Inputs 57 | pinMode(User_Button, INPUT_PULLUP); 58 | } 59 | 60 | // **************** LOOP **************** 61 | void loop() { 62 | 63 | // Heatbeat Red 64 | digitalWrite(LED_Red, LOW); 65 | delay(1000); 66 | digitalWrite(LED_Red, HIGH); 67 | delay(100); 68 | 69 | // Check for Button Press 70 | if (digitalRead(User_Button) == LOW) { 71 | 72 | Serial.println("Button Pressed"); 73 | 74 | // Blue 75 | digitalWrite(LED_Blue, LOW); 76 | delay(1000); 77 | digitalWrite(LED_Blue, HIGH); 78 | delay(100); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Code/IPEM-1_Test_Code_Wifi/IPEM-1_Test_Code_Wifi.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | Features include ESP32 IPEM ESP32 ATM90E32 ATM90E36 16bit ADC EEPROM 3Phase 3+1 CT-Clamps Current Voltage Frequency Power Factor GPIO I2C OLED SMPS D1 USB 5 | PCA 1.2302-201 - Test Code Firmware v1 - 18th February 2023 6 | 7 | The purpose of this test code is to cycle through the various main functions of the board, as shown below, as part of board bring up testing. 8 | 9 | Simplified Board Bring Up Test - Wifi Scan (Output to Serial Print) 10 | 11 | Remember! 12 | Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 13 | You may set the BAUD rate to 921600 to speed up flashing. 14 | The SDK does NOT need external power to flash. It will take Power from the USB 5V. 15 | 16 | Note: In the default state, upon first power up and during reset, the Green LED may be partially lit. Once programmed and the GPIO defined, the Green LED will go off after power up. 17 | 18 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 19 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | 21 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and github.com/DitroniX 22 | */ 23 | 24 | // Libraries 25 | #include 26 | 27 | // **************** VARIABLES / DEFINES / STATIC **************** 28 | 29 | // Constants 30 | const int LoopDelay = 1; // Loop Delay in Seconds 31 | 32 | // **************** OUTPUTS **************** 33 | #define LED_Red 2 // Red LED 34 | #define LED_Green 4 // Green LED 35 | 36 | WiFiClient client; // Initialize the client library 37 | 38 | void setup() { 39 | 40 | // Stabalise 41 | delay(250); 42 | 43 | // Initialize UART: 44 | Serial.begin(115200, SERIAL_8N1); //115200 45 | while (!Serial); 46 | 47 | // Configures the specified LED GPIO as outputs 48 | pinMode(LED_Red, OUTPUT); 49 | pinMode(LED_Green, OUTPUT); 50 | 51 | // LED Default Off State 52 | digitalWrite(LED_Red, HIGH); 53 | digitalWrite(LED_Green, HIGH); 54 | 55 | // Set WiFi to station mode and disconnect from an AP if it was previously connected 56 | WiFi.mode(WIFI_STA); 57 | WiFi.disconnect(); 58 | delay(100); 59 | } 60 | 61 | void loop() { 62 | 63 | Serial.println("ESP32 WiFi MAC \t " + WiFi.macAddress()); 64 | Serial.println("Scanning for Access Points or Routers. Please wait...."); 65 | delay(100); 66 | 67 | // WiFi.scanNetworks will return the number of networks found 68 | int n = WiFi.scanNetworks(); 69 | Serial.print("Scan Complete. "); 70 | if (n == 0) { 71 | Serial.println("No Access Points or Routers Found."); 72 | } else { 73 | Serial.print(n); 74 | Serial.println(" Access Points or Routers Found."); 75 | Serial.println(""); 76 | 77 | for (int i = 0; i < n; ++i) { 78 | // Print SSID and RSSI for each network found 79 | Serial.print(i + 1); 80 | Serial.print(": \t"); 81 | Serial.print(WiFi.SSID(i)); 82 | Serial.print(" ("); 83 | Serial.print(WiFi.RSSI(i)); 84 | Serial.print(")"); 85 | Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " " : "*"); 86 | delay(100); 87 | } 88 | } 89 | 90 | Serial.println(""); 91 | 92 | // Heatbeat LED 93 | digitalWrite(LED_Red, LOW); 94 | delay(50); 95 | digitalWrite(LED_Red, HIGH); 96 | 97 | delay(LoopDelay * 1000); 98 | } 99 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode/.browse.c_cpp.db* 3 | .vscode/c_cpp_properties.json 4 | .vscode/launch.json 5 | .vscode/ipch 6 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Configuration Header Examples.md: -------------------------------------------------------------------------------- 1 | **Below are EXAMPLE Configuration Outputs** 2 | 3 | Hardware Configuration for ATM90E32 4 | ----------------------------------- 5 | AC Voltage Inputs: Multi Separated V1 V2 V3 - 3 Phase Configuration. 6 | Split AC Voltage: Dual Disabled 7 | CT Current Clamp: Configured for 1, 2, 3 Phase + 1 Phase (ESP32) 8 | CT4 Current Input: Configured for ESP32 ADC 9 | 10 | Hardware Configuration for ATM90E32 11 | ----------------------------------- 12 | AC Voltage Inputs: Single Input V1 will be used for all Current Phase Calculations 13 | Split AC Voltage: Dual Disabled 14 | CT Current Clamps: Configured for 1, 2, 3 Phase + 1 Phase (ESP32) 15 | CT4 Current Input: Configured for ESP32 ADC 16 | 17 | Hardware Configuration for ATM90E32 ATM_SPLITPHASE ATM_SINGLEVOLTAGE 18 | ----------------------------------- 19 | AC Voltage Inputs: Single Input V1 will be used for all Current Phase Calculations 20 | Split AC Voltage: Configuration Error (Check ATM_SINGLEVOLTAGE) 21 | CT4 Current Input: Configured for ESP32 ADC 22 | 23 | Hardware Configuration for ATM90E32 ATM_SPLITPHASE 24 | ----------------------------------- 25 | AC Voltage Inputs: Multi Dual V1 and V3 - USA Configuration 26 | Split AC Voltage: Dual Input V1 and V3 Enabled - USA Configuration 27 | CT Current Clamps: Phase Configured for 1 and 3 + 1 Phase (ESP32) 28 | CT4 Current Input: Configured for ESP32 ADC 29 | 30 | Hardware Configuration for ATM90E32 31 | ----------------------------------- 32 | * CONFIGURATION ERROR * 33 | * You cannot have an ATM90E32 and I4N Input Selected (Change CT4_CONFIG) * 34 | 35 | Hardware Configuration for ATM90E36 ATM_SPLITPHASE 36 | ----------------------------------- 37 | AC Voltage Inputs: Multi Dual V1 and V3 - USA Configuration 38 | Split AC Voltage: Dual Input V1 + V3 Enabled - USA Configuration 39 | CT Current Clamps: Phase Configured for 1 and 3 + 1 Phase (I4N) 40 | CT4 Current Input: Configured for I4N on the ATM90E36 41 | 42 | Hardware Configuration for ATM90E36 43 | ----------------------------------- 44 | AC Voltage Inputs: Multi Separated V1 V2 V3 - 3 Phase Configuration. 45 | Split AC Voltage: Dual Disabled 46 | CT Current Clamps: Configured for 1, 2, 3 Phase + 1 Phase (I4N) 47 | CT4 Current Input: Configured for I4N on the ATM90E36 48 | 49 | Hardware Configuration for ATM90E36 ATM_SINGLEVOLTAGE 50 | ----------------------------------- 51 | AC Voltage Inputs: Single Input V1 will be used for all Current Phase Calculations 52 | Split AC Voltage: Dual Disabled 53 | CT Current Clamps: Configured for 1, 2, 3 Phase + 1 Phase (I4N) 54 | CT4 Current Input: Configured for I4N on the ATM90E36 55 | 56 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Domoticz Ouput Example.md: -------------------------------------------------------------------------------- 1 | The below example Serial ouput is based on DisplayRegisters with a false argument. Refresh Values and Display. Default false = Mute Expanded Info to Serial 2 | 3 | Only some Indexes have a value, as defined in Domoticz Devices Setup. Example below 4 | 5 | 82 Dummy 00082082 1 iVoltage1 General Voltage 246.31 V - 2023-03-18 14:16:14 6 | 83 Dummy 00082083 1 iCT1 General Current 0.03 A - - 2023-03-18 14:16:14 7 | 84 Dummy 00082084 1 iCT2 General Current 0 A - - 2023-03-18 14:16:14 8 | 85 Dummy 00082085 1 iCT3 General Current 0 A - - 2023-03-18 14:16:14 9 | 86 Dummy 82086 1 iCPwr1 Usage Electric 7.39 Watt - - 2023-03-18 14:16:14 10 | 87 Dummy 82087 1 iCPwr2 Usage Electric 0 Watt - - 2023-03-18 14:16:14 11 | 88 Dummy 82088 1 iCPwr3 Usage Electric 0 Watt - - 2023-03-18 14:16:14 12 | 89 Dummy 82089 1 iAPwr1 Usage Electric 5.17 Watt - - 2023-03-18 14:16:14 13 | 90 Dummy 82090 1 iAPwr2 Usage Electric 0 Watt - - 2023-03-18 14:16:14 14 | 91 Dummy 82091 1 iAPwr3 Usage Electric 0 Watt - - 2023-03-18 14:16:14 15 | 92 Dummy 82092 1 iImpPwr1 Usage Electric 0 Watt - - 2023-03-18 13:10:35 16 | 93 Dummy 82093 1 iImpPwr2 Usage Electric 0 Watt - - 2023-03-18 13:10:40 17 | 94 Dummy 82094 1 iImpPwr3 Usage Electric 0 Watt - - 2023-03-18 13:10:45 18 | 95 Dummy 82095 1 iExpPwr1 Usage Electric 0 Watt - - 2023-03-18 13:10:54 19 | 96 Dummy 82096 1 iExpPwr2 Usage Electric 0 Watt - - 2023-03-18 13:10:59 20 | 97 Dummy 82097 1 iExpPwr3 Usage Electric 0 Watt - - 2023-03-18 13:11:04 21 | 98 Dummy 00082098 1 iPF1 General Custom Sensor 0 PF - - 2023-03-18 13:18:58 22 | 99 Dummy 00082099 1 iPF2 General Custom Sensor 0 PF - - 2023-03-18 13:19:05 23 | 100 Dummy 00082100 1 iPF3 General Custom Sensor 0 PF - - 2023-03-18 13:19:12 24 | 25 | This translated to the Index setting example within the IPEM Domoticz code. 26 | 27 | / Set these values to the Domoticz Devices Indexes (IDX). If Zero, then entry is ignored. Device needs to be created in Domoticz. 28 | int idxLineVoltage1 = 82; // LineVoltage1 - Urms - Line 1 Voltage RMS 29 | int idxLineVoltage2 = 0; // LineVoltage2 - Urms - Line 2 Voltage RMS 30 | int idxLineVoltage3 = 0; // LineVoltage3 - Urms - Line 3 Voltage RMS 31 | int idxLineVoltageAverage = 0; // LineVoltageAverage - Urms - Line Average Voltage RMS (V1+V2+V3/3) 32 | int idxLineVoltageTotal = 0; // LineVoltageTotal - Urms - Line Voltage Total RMS (V1+0+V3) 33 | 34 | int idxLineCurrentCT1 = 83; // LineCurrentCT1 - Irms - Line 1 Current RMS 35 | int idxLineCurrentCT2 = 84; // LineCurrentCT2 - Irms - Line 2 Current RMS 36 | int idxLineCurrentCT3 = 85; // LineCurrentCT3 - Irms - Line 3 Current RMS 37 | int idxLineCurrentCT4 = 0; // LineCurrentCT4 - Irms - Line 4 Current RMS (ESP) 38 | int idxLineCurrentCTN = 0; // LineCurrentCTN - Irms - Line N Current RMS 39 | int idxLineCurrentTotal = 0; // LineCurrentTotal - Irms - Line Total Current RMS (CT1+CT2+CT3+(CT4)) 40 | 41 | =============== 42 | 43 | Display Output Set to Minimised 44 | 45 | PCB Temperature Sensor (NTC_IN VN): 33.00 ºC 46 | 47 | ADC Raw: 2609 > ADC Adjusted: 2609 > Calculated: 24.85 V 48 | 49 | Sending Message to Domoticz #82 245.45 LineVoltage1 50 | Sending Message to Domoticz #83 0.03 LineCurrentCT1 51 | Sending Message to Domoticz #84 0.00 LineCurrentCT2 52 | Sending Message to Domoticz #85 0.00 LineCurrentCT3 53 | Sending Message to Domoticz #86 7.36 CalculatedPowerCT1 54 | Sending Message to Domoticz #87 0.00 CalculatedPowerCT2 55 | Sending Message to Domoticz #88 0.00 CalculatedPowerCT3 56 | Sending Message to Domoticz #89 5.02 ActivePowerCT1 57 | Sending Message to Domoticz #90 0.00 ActivePowerCT2 58 | Sending Message to Domoticz #91 0.00 ActivePowerCT3 59 | 60 | 14:16:07> Published to Domoticz -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Firmware Configuration and Flashing.md: -------------------------------------------------------------------------------- 1 | The **IPEM** Test and Development Firmware has evolved a great deal over a short period and this Wiki page will hopefully provide some insight to it's features and options. 2 | 3 | Rather than use the Arduino IDE, the IPEM firmware has been developed using Visual Studio Code (VSCode) and PlatformIO. This integrating increased flexibility, ease of use and also allows for the correct libraries to be automatically installed, so making for a better overall user experience. 4 | 5 | Originally, the purpose of '[IPEM_1_Test_Code_ATM90E32_ATM90E36](https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/tree/main/Code/IPEM_1_Test_Code_ATM90E32_ATM90E36)' was as a piece of test code / firmware, which cycled through the various main functions of the board, as part of board bring up testing. 6 | 7 | As time moved on, the single code base, expanded to include various functions, which applies to all variations of IPEM. This makes it easier to maintain and configure, irrespective of board version. 8 | 9 | You can use this firmware for both: 10 | * Testing (modify as needed to suit your integration requirements) 11 | * Final Application (just configure and flash) 12 | 13 | 14 | **IPEM Board Overview** 15 | 16 | The main purpose of the code, is to provide an array of functionality, such as: 17 | 18 | * Initial IPEM Board Bring Up and Hardware Test 19 | * Integration of functions and parameters for both ATM90E32 and ATM90E36 20 | * Configuration of CT Clamp Inputs 21 | - CT1, 2 and 3 to ATM90E32 or ATM90E32 22 | - CT4 to ATM90E36 or ESP32 ADC 23 | 24 | * Mains voltage calculations, using either: 25 | - Single AC Input for all three main Power readings 26 | - Three Phase. Separate AC Input for all three main Power readings 27 | * Split Phase. Dual AC Voltage Input for Split Voltage US Power reading 28 | 29 | * Fast Setup and Installation 30 | 31 | * Comprehensive [List of Variables](https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/IPEM-Variables-and-Functions), which ultimately translate into available readings, which can be displayed or published to Home Automation. Domoticz, MQTT etc.. 32 | * Integrated Domoticz Publishing (this will be expanded) 33 | * Web Server 34 | - Home Page (with basic information) 35 | - Push OTA (Remote flashing over HTTP) 36 | 37 | * OLED Display Driver 38 | - Directly plug in an I2C SSD1306 Display 39 | * Runtime Monitoring Information 40 | * Diagnostics 41 | 42 | 43 | **Hardware Configuration** 44 | 45 | The default hardware and firmware settings configuration is based on: 46 | 47 | * Current Clamps. Default example settings are based on the [YDHC SCT-013-000 100A/50mA](https://ditronix.net/shop/yhdc-current-transformer-sct-013-000-100a-50ma/). 48 | 49 | * AC Voltage. Inputs from a [Greenbrook DAT01A (TC TR7) Transformer](https://www.greenbrook.co.uk/dat01a), set to 12V AC. 50 | 51 | **Firmware Logic** 52 | 53 | Various software logic and switches has been included within the code, this automatically enables, and disables, various functions depending on options set. For the time being, please do not alter these, unless you understand the implications. 54 | 55 | *Please keep to the below 'Firmware Configuration' settings.* 56 | 57 | 58 | **Calibration** 59 | 60 | Based on the above hardware configuration, calibration should be absolutely minimal, to not required. All boards are tested using this configuration, with a fixed AC voltage source and fixed resistive loads, to three CT Clamp. 61 | 62 | An example Serial Monitor output, can be seen at [here](https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/IPEM-Serial-Monitor-Example). 63 | 64 | 65 | **Quick Flashing and Initial Test** 66 | 67 | From the 'box', the firmware have been thoroughly tested and should open, and compile, without any issues. 68 | 69 | *NB. All boards will have this firmware installed by default, as is is used for production testing too.* 70 | 71 | 1) Download the '[Source Code](https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/tree/main/Code/IPEM_1_Test_Code_ATM90E32_ATM90E36)' 72 | 2) Open the folder from PlatformIO 73 | 3) Connect an IPEM board to the USB Port 74 | 4) Click Upload. 75 | 76 | PlatformIO should automatically install any libraries not already installed and then connect to the IPEM board. Once compiled (Click Upload in Status Bar), it should flash the board. 77 | 78 | Once flashed, Open the 'Serial Monitor' (Click Serial Monitor in Status Bar), and you should see the default output from the IPEM board. Press RESET to refresh the Serial Monitor Info. 79 | 80 | NB. You can also press (for 1 second), the USER BUTTON to refresh the information displayed. 81 | 82 | **Firmware Configuration** 83 | 84 | Now you have proven the flashing and test concept, we can now expand to the options in the source files. 85 | 86 | * **main.cpp** {src folder} *For the most part, these can stay as defaults.* 87 | * **LoopDelay** *(Loop Delay in Seconds. Default 1)* 88 | * **EnableBasicLoop** *(Display looped readings in the Serial Monitor, or leave for displaying only once per reset cycl using default of false.)* 89 | * **EnableDisplayBoardConfiguration** *(Display board software configuration Information if DisplayFull is true.)* 90 | * **EnableOLEDLoop** *(Enables OLED Display. Over-ride via I2C Scan.)* 91 | 92 | * **ATM90E3x.cpp** {src folder} *Nothing to update.* 93 | 94 | * **IPEM_Hardware.h** {include folder} 95 | * **App USER** 96 | * Change 'LocationName', to something more descriptive, such as Home, Solar, Workshop etc. 97 | * **Constants USER** 98 | * These can be left as the defaults 99 | * **OLED Instance** 100 | * Uncomment your OLED Display. Default is the 0.6" 101 | * If no OLED connected, can be left as the defaults 102 | * **CT4 Energy Monitor Library Configuration** 103 | * These can be left as the defaults 104 | * Update at a later time, if using CT4 into ESP32 105 | 106 | * **ATM90E3x.h** {include folder} *For the most part, these can stay as defaults.* 107 | * **ATM90E3x device** 108 | * These can be left as the defaults 109 | * Only need to update, if using an ATM90E36 110 | * **DEFINE Current Clamp Input CT4** 111 | * These can be left as the defaults 112 | * Possibly, only may need to update if using an ATM90E36 113 | * **CT4 Software Configuration** 114 | * These can be left as the defaults 115 | * Possibly, only need to update if using ESP32/CT4 116 | * **DEFINE VOLTAGE REFERENCE** 117 | * Can be left as the default true 118 | * Change to False, only if using separate AC voltage Inputs. 119 | * **DEFINE PHASE TYPE** 120 | * Can be left as the default false 121 | * Change to true, only if using split phase AC Voltage. e.g. USA 122 | 123 | * **WiFi-OTA.h** {include folder} *Update with your Wi-Fi Settings* 124 | * **Wireless Information** 125 | * Enter your Router/AP SSID and Password 126 | * **Static IP** 127 | * If you are using DHCP, then leave as defaults 128 | * If wanting a Static IP, first find a suitable address and update as needed. 129 | - The board will automatically set this IP upload flashing. 130 | * **DNS** 131 | * For the most parts, leave as default. 132 | * **Domoticz.h** {include folder} *Update with your Domoticz Server Settings* 133 | * **Server IP** 134 | - Domoticz Server IP Address (Typically a Fixed Local Address) 135 | * **EnableDomoticz** 136 | - Set to true, once you have setup the Device Indexes. 137 | * **Domoticz Hardware Device Indexes** 138 | - Simply change index('s) from 0 to a 'device index number', which you want to publish. 139 | - A Variable list can be found [here](https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/Domoticz-Variables) 140 | 141 | **Web Server and Push OTA** 142 | 143 | The Web Server will assume the IP, either via DHCP or Static, which ever you setup. 144 | 145 | To find the IP address, it will be displayed on both the Serial Monitor and OLED Display, upon pressing board Reset. 146 | 147 | You have TWO pages on the Web Server. 148 | 149 | * 'Home Page' which displays basic info on the board configuration 150 | * 'update' which will display the ElegantOTA page 151 | - Simply compile your code 152 | - Choose *firmware.bin* file 153 | + Found in IPEM_1_Test_Code_ATM90E32_ATM90E36 - DW Domoticz - OTA\.pio\build\wemos_d1_mini32\ 154 | - ElegantOTA will then upload to the IPEM and auto reboot. 155 | 156 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/README.md: -------------------------------------------------------------------------------- 1 | 2 | Further details on this code options can be found in our Wiki 3 | https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/IPEM-ESP32-ATM90E32-ATM90E36-Test-Code 4 | 5 | https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki 6 | 7 | PCA 1.2302-20x - Test Code Firmware v1 - **Development Code - WORK-IN-PROGRESS** 8 | 9 | > FIRMWARE CONFIGURATION INFO WIKI > https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/Firmware-Configuration-and-Flashing 10 | 11 | This software has expanded way past it's original bring-up task and is now quite comprehensive. It can now be, as is, used for both bring-up, final use and publishing. Else, simply use the bits you like! 12 | 13 | A number of software switches are used, throughout. The defaults are listed below. You should be able to just compile this current version to an IPEM ATM90E32 and see some valid results in the serial monitor / OLED. 14 | 15 | Board Bring Up Test - ATM90E3x Test Routines (Output sent to the Serial Print - ONLY ON BOOT! Press RESET or HOLD USR Button to REFRESH) 16 | 17 | Base 90E32/36 register formulation based on the excellent ground work from Tisham Dhar, whatnick | ATM90E32 ATM90E36 Energy Monitor Core 18 | VSCode base, E32/E36 Registers/Code Merged, Updated, Software Logic/Routines, Bring Up Firmware, Comprehensive Functions, OTA and Domoticz Integration by Date Williams 19 | 20 | **CONFIGURATION** (Setup for bring-up testing of the board) 21 | 22 | This version of firmware code is by default, configured for: 23 | * ATM90E32 (ATM90DEVICE ATM90E32_DEVICE) 24 | * CT4 Configured to ESP32 ADC (CT4_CONFIG CT4_ESP) 25 | * CT4 Input - Enabled (CT4_ENABLED true) 26 | * PWM Output on Default GPIO Port GP17 (EnablePWMLocal false EnablePWMRemote false EnablePWMTestOutput false) 27 | * DAC Output. Port TBD (EnableDACLocal false EnableDACRemote false EnableDACTestOutput false) 28 | * Multi-Voltage Input (ATM_SINGLEVOLTAGE true) 29 | * Split-Phase USA - Disabled (ATM_SPLITPHASE false) 30 | * Hardware Test - Enabled (DisableHardwareTest false) 31 | * Display of Board Configuration (EnableDisplayBoardConfiguration true) 32 | * Domoticz Publishing - Disabled (EnableDomoticz false) 33 | * MQTT Publishing - Disabled (EnableMQTT false) 34 | * Loop Refreshing Terminal Output (EnableBasicLoop false) - Display Info ONCE uppon Reset. 35 | * Value Outputs are filtered through a Sofware Noise Filter / Comparator / Squelch (EnableNoiseFilterSquelch true) 36 | * When Publising to Domoticz - Mute Detailed Output to Serial (Loop) 37 | * OLED 0.6" Display SSD1306 128x32. (EnableOLEDLoop true) 38 | * Board Location and Firmware Version to OLED and Serial Monitor 39 | * IP Address Defaults to DHCP. Static IP Address Configuration in WiFi-OTA.h 40 | 41 | **AC Mains Voltage** https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/AC-Mains-Voltage-Input 42 | * The board has 3 x AC Voltage Inputs (ATM_V1P, ATM_V2P and ATM_V3P). 43 | * The AC Terminal block powering the board, also connects to ATM_V1P by default. 44 | 45 | **CALIBRATION** (This should be minimal - based on the below) 46 | 47 | This version of firmware has been setup for ATM90E32 and CT4 to ESP32 ADC. 48 | * Current Clamp default example settings are based on SCT-013-000 100A/50mA. 49 | * Voltages default example settings are based on Single/Three Phase Voltage Inputs from a Greenbrook DAT01A (TC TR7) Transformer, set to 12V AC. 50 | * Current Clamps CT1, CT2 and CT3 are connected to the ATM90E3x. Calibration requirements should be minimal and board ready to use. 51 | * AC Voltage Inputs V1, V2 and V3 are connected to the ATM90E3x. Calibration requirements should be minimal and board ready to use. 52 | * Current Clamp CT4 is connected to the ESP32 ADC1 CH7. Software EmonLib calibratrion may be required. 53 | * You can update ATM90Ex calibration (if required), in IPEM_Hardware.h 54 | * You can update board ATM Configurations in ATM90E3x.h 55 | * You can update CT4 calibration in iPEM_Hardware.h - See EmonLib 56 | 57 | **WiFi and OTA Updates** 58 | 59 | * Setup WiFi 60 | * Configure Multi-WiFi SSID/PWD 61 | * Setup Optional Static IP address and Gateway (DHCP or Static) 62 | * Setup Preferred Hostname 63 | * Setup Serial Device over IP (Used for OTA) 64 | * Display WiFI Signal Meter 65 | * Web Server Information Page and Push OTA Updater 66 | 67 | **Webserver** https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/WebServer-Commands 68 | 69 | * Web Listner 70 | * PWM Switches added: /pwm-local, /pwm-remote, /pwm-on, /pwm-off, /pwm-test 71 | * DAC Switches added: /dac-local, /dac-remote, /dac-on, /dac-off, /dac-test 72 | * Seperate switches dac-remote and pwm-remote, allow you to remotely send a fixed value to pwm / dac output. Ideal for scenes etc. Remote turns off or over-rides CT for pwm/dac. 73 | 74 | **DOMOTICZ** https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/Domoticz-Variables 75 | 76 | * Setup connection to Domoticz Home Automation 77 | * Configure Required Values to Publish to Domoticz Hardware Device Indexes 78 | 79 | **MQTT** 80 | 81 | * Setup connection to MQTT Broker / Home Automation 82 | * Configure Required Values to Publish to MQTT Broker 83 | 84 | **ThingSpeak** https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/ThingSpeak-Publishing 85 | * Example Publish (play data), can be found on https://thingspeak.com/channels/2179490 86 | * Setup easy connection to ThingSpeak Cloud Base Server / Home Automation. FREE Cloud Account. View on Phone/Web. 87 | * Configure Required Values to Publish to ThingSpeak 88 | 89 | **PWM Duty Cycle Output** https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/PWM-Output-(Tracking-Power) 90 | 91 | * PWM (On Default GPIO 17), which will track Power Usage (from Default Variable ActivePowerExportCT1) 92 | * Output Updated on Each DisplayRegisters Loop (Only if Value Changed) 93 | * WebServer /pwm-local, /pwm-remote, /pwm-on, /pwm-off, /pwm-test 94 | * Ability to Enable and Disable PWM Local Readings 95 | * Ability to Enable and Disable PWM Remote Readings 96 | * Ability to Enable and Disable PWM Test Mode 97 | * Ability to Set Fixed Power from Remote Value, or Leave to Dynamic CT Power Values (WIP) 98 | * Continuous PWM Cycle Test Mode Loop 99 | 100 | **DAC Voltage Output** https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/wiki/DAC-Output-(Tracking-Power) 101 | 102 | * Fixed Voltage Output from DAC, tracking Power Usage (from Default Variable ActivePowerExportCT1) 103 | * Output Updated on Each DisplayRegisters Loop (Only if Value Changed) 104 | * WebServer /dac-local, /dac-remote, /dac-on, /dac-off, /dac-test 105 | * Ability to Enable and Disable DAC Local Readings 106 | * Ability to Enable and Disable DAC Remote Readings 107 | * Ability to Enable and Disable DAC Test Mode 108 | * Abilty to Set Fixed DAC Output from Remote Value, or Leave to Dynamic CT Power Values (WIP) 109 | * DAC Sinewave Test Mode Loop (Default 10 Hz) 110 | * DAC Stepped Voltages Test Mode Loop (Slow Staircase) 111 | 112 | Enjoy! Dave Williams, DitroniX.net 113 | 114 | 115 | **Remember!** 116 | * Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 117 | * You may set the BAUD rate to 921600 to speed up flashing. 118 | * The SDK does NOT need external power to flash. It will take Power from the USB 5V. 119 | * You can safely connect both USB Power and PSU AC In (Makes development much easier) 120 | 121 | **Note**: In the default state, upon first power up and during reset, the Green LED may be partially lit. Once programmed and the GPIO defined, the Green LED will go off after power up. 122 | 123 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 124 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 125 | 126 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and also github.com/DitroniX 127 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Terminal Output Example ATM90E32 3Phase.txt: -------------------------------------------------------------------------------- 1 | Std Prod PCA Bring Up. Jumpers set. AC In. Resistive Load. 3 Phase Configuration - Phase 1, 2 and3 2 | ------------------------------------------------------------------------------------------------------------------------ 3 | 4 | Settings: 5 | 6 | // **************** DEFINE VOLTAGE REFERENCE **************** 7 | #define ATM_SINGLEVOLTAGE false // Set to true to use V1/ATM_V1P for VoltageGain1, VoltageGain2, VoltageGain3 and Calcfulations for CT1, CT2, CT3, CT4, CTN. (Default true) 8 | 9 | // **************** DEFINE PHASE TYPE **************** 10 | #define ATM_SPLITPHASE false // If Split Phase (i.e. USA 120+120), set to true else leave false (NB. Not fully tested). ATM_SINGLEVOLTAGE = false 11 | 12 | ------------------------------------------------------------------------------------------------------------------------ 13 | 14 | DitroniX IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor Board - Development Code 15 | 16 | Initialise OLED (If Plugged In) 17 | 18 | Register Status and Startup Report 19 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 20 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 21 | Board Location: House 22 | 23 | Software Optons 24 | ──────────────── 25 | Wi-Fi is Disabled 26 | Domoticz Publishing is Disabled 27 | MQTT Publishing is Disabled 28 | ThingSpeak Publishing is Disabled 29 | 30 | EEPROM Check: 20 (Validation OK) 31 | 32 | PWM Output is Disabled 33 | 34 | DAC Output is Disabled 35 | 36 | Peripherals Test 37 | ───────────────── 38 | Testing RGB LED 39 | Scanning I2C Bus for Devices ... 40 | * I2C device found at address Decimal 60 = Hex 0x3C OLED 41 | * I2C device found at address Decimal 80 = Hex 0x50 EEPROM 42 | * I2C Bus Scan Complete 43 | 44 | AC/DC Voltage Input Detected 45 | Connecting to the ATM90E32 46 | ATM90E32 Connected - OK 47 | IPEM Hardware Setup and Power-Up Test - Board Initialized 48 | 49 | Register Status and Diagnostic Report 50 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 51 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 Location: House 52 | 53 | Hardware Configuration for ATM90E32 54 | ──────────────────────────────────── 55 | AC Voltage Inputs: Multi Separated V1 V2 V3 - 3 Phase, or 3 x Single Phase Configuration. 56 | Split AC Voltage: Dual Split-Phase (V1-x-V3) Disabled 57 | CT Current Clamps: Configured for 1, 2, 3 Phase + 1 Phase (ESP32) 58 | CT4 Current Input: Configured for ESP32 ADC 59 | 60 | [Status Values] 61 | System Status: S0:0x37E S1:0xFFFE 62 | Meter Status: E0:0x20F E1:0xFF 63 | 64 | Mains RMS Voltage 65 | ────────────────── 66 | Voltage 1: 248.10 V 67 | Voltage 2: 247.38 V 68 | Voltage 3: 247.75 V 69 | - - - - - - - - - - - - - - - - - - - - 70 | Average Voltage: 247.74 V (V1~V2~V3) 71 | 72 | Mains RMS Current 73 | ────────────────── 74 | Current CT1: 1.31 A 75 | Current CT2: 1.30 A 76 | Current CT3: 1.30 A 77 | - - - - - - - - - - - - - - - - - - - - - - - 78 | Actual Total Current: 3.91 A (CT1~CT2~CT3) 79 | 80 | Calculated RMS Power 81 | ───────────────────── 82 | Power V1*I1: 325.01 W 83 | Power V2*I2: 321.59 W 84 | Power V3*I3: 322.07 W 85 | - - - - - - - - - - - - - - - - - - - - - - - - - 86 | Calculated Total Power: 968.68 W (CT1~CT2~CT3) 87 | 88 | Active Power (Absorbed or Used by the Load) 89 | ──────────────────────────────────────────── 90 | Active Power CT1: -322.62 W (Export) 91 | Active Power CT2: -319.25 W (Export) 92 | Active Power CT3: -320.67 W (Export) 93 | - - - - - - - - - - - - - - - - - - - - - 94 | Total Active Power: -643.35 W (Export) 95 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 96 | Calculated Total Active Power: -962.54 W (CT1~CT2~CT3) 97 | 98 | Re-Active Power 99 | ──────────────── 100 | ReActive Power CT1: -20.75 VAR 101 | ReActive Power CT2: -19.65 VAR 102 | ReActive Power CT3: -20.24 VAR 103 | - - - - - - - - - - - - - - - - - - - - - - - - - 104 | Total ReActive Power: -41.01 VAR (CT1~CT2~CT3) 105 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 106 | Calculated Total Reactive Power: -60.64 W (CT1~CT2~CT3) 107 | 108 | Apparent Power (Total Amount of Power Flowing from Source to Load) 109 | ─────────────────────────────────────────────────────────────────── 110 | Apparent Power CT1: 323.73 VA 111 | Apparent Power CT2: 320.26 VA 112 | Apparent Power CT3: 321.76 VA 113 | - - - - - - - - - - - - - - - - - - - - - - - - 114 | Total Apparent Power: 645.48 VA (CT1~CT2~CT3) 115 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 116 | Calculated Total Apparent Power: 965.75 W (CT1~CT2~CT3) 117 | 118 | Other Power Information 119 | ──────────────────────── 120 | Total Fundamental Power: -642.59 pH(t) 121 | 122 | Total Harmonic Power: -1.04 123 | 124 | Power Factor 125 | ───────────── 126 | Power Factor CT1: 0.00 PF 127 | Power Factor CT2: 0.00 PF 128 | Power Factor CT3: 0.00 PF 129 | - - - - - - - - - - - - - - - 130 | Total Power Factor: 0.00 PF 131 | 132 | Phase Angle 133 | ──────────── 134 | Phase Angle CT1: 0.00 135 | Phase Angle CT2: 0.00 136 | Phase Angle CT3: 0.00 137 | 138 | Other Information 139 | ────────────────── 140 | Chip Temperature: 33.00 °C 141 | 142 | Mains Frequency: 50.05 Hz 143 | 144 | PCB Temperature Sensor (NTC_IN VN): 32.75 ºC 145 | 146 | ADC Raw: 2763 > ADC Adjusted: 2763 > Calculated: 26.31 V -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Terminal Output Example ATM90E32 Split Phase.txt: -------------------------------------------------------------------------------- 1 | Std Prod PCA Bring Up. Jumpers set. AC In. Resistive Load. Split Phase 1+3 (Note Tested in UK with 240V per phase) 2 | ------------------------------------------------------------------------------------------------------------------------ 3 | 4 | Settings: 5 | 6 | // **************** DEFINE VOLTAGE REFERENCE **************** 7 | #define ATM_SINGLEVOLTAGE false // Set to true to use V1/ATM_V1P for VoltageGain1, VoltageGain2, VoltageGain3 and Calcfulations for CT1, CT2, CT3, CT4, CTN. (Default true) 8 | 9 | // **************** DEFINE PHASE TYPE **************** 10 | #define ATM_SPLITPHASE true // If Split Phase (i.e. USA 120+120), set to true else leave false (NB. Not fully tested). ATM_SINGLEVOLTAGE = false 11 | 12 | ------------------------------------------------------------------------------------------------------------------------ 13 | 14 | DitroniX IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor Board - Development Code 15 | 16 | Initialise OLED (If Plugged In) 17 | 18 | Register Status and Startup Report 19 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 20 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 21 | Board Location: House 22 | 23 | Software Optons 24 | ---------------- 25 | Wi-Fi is Disabled 26 | Domoticz Publishing is Disabled 27 | MQTT Publishing is Disabled 28 | ThingSpeak Publishing is Disabled 29 | 30 | EEPROM Check: 20 (Validation OK) 31 | 32 | PWM Output is Disabled 33 | 34 | DAC Output is Disabled 35 | 36 | Peripherals Test 37 | ----------------- 38 | Testing RGB LED 39 | Scanning I2C Bus for Devices ... 40 | * I2C device found at address Decimal 60 = Hex 0x3C OLED 41 | * I2C device found at address Decimal 80 = Hex 0x50 EEPROM 42 | * I2C Bus Scan Complete 43 | 44 | AC/DC Voltage Input Detected 45 | Connecting to the ATM90E32 46 | ATM90E32 Connected - OK 47 | IPEM Hardware Setup and Power-Up Test - Board Initialized 48 | 49 | Register Status and Diagnostic Report 50 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 51 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 Location: House 52 | 53 | Hardware Configuration for ATM90E32 54 | ------------------------------------ 55 | AC Voltage Inputs: Multi Dual V1 and V3 - USA Configuration 56 | Split AC Voltage: Dual Input V1 and V3 Enabled - USA Configuration 57 | CT Current Clamps: Phase Configured for 1 and 3 + 1 Phase (ESP32) 58 | CT4 Current Input: Configured for ESP32 ADC 59 | 60 | [Status Values] 61 | System Status: S0:0x37E S1:0xFFFE 62 | Meter Status: E0:0x20F E1:0xFF 63 | 64 | Mains RMS Voltage 65 | ------------------ 66 | Voltage 1: 248.38 V 67 | Voltage 3: 248.04 V 68 | - - - - - - - - - - - - - - - - - - - - - 69 | Total Split Voltage: 248.21 V (V1~X~V3) 70 | 71 | Mains RMS Current 72 | ------------------ 73 | Current CT1: 0.66 A 74 | Current CT3: 0.65 A 75 | Actual Total Current: 1.31 A (CT1~X~CT3) 76 | 77 | Calculated RMS Power 78 | --------------------- 79 | Power V1*I1: 163.93 W 80 | Power V2*I2: 0.00 W 81 | Power V3*I3: 161.23 W 82 | - - - - - - - - - - - - - - - - - - - - - - - - 83 | Calculated Total Power: 325.16 W (CT1~X~CT3) 84 | 85 | Active Power (Absorbed or Used by the Load) 86 | -------------------------------------------- 87 | Active Power CT1: -162.96 W (Export) 88 | Active Power CT2: 0.00 W 89 | Active Power CT3: -161.95 W (Export) 90 | - - - - - - - - - - - - - - - - - - - - - 91 | Total Active Power: -324.91 W (Export) 92 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 93 | Calculated Total Active Power: -324.91 W (CT1~CT2~CT3) 94 | 95 | 96 | Re-Active Power 97 | ---------------- 98 | ReActive Power CT1: -10.07 VAR 99 | ReActive Power CT2: 0.00 VAR 100 | ReActive Power CT3: -9.77 VAR 101 | - - - - - - - - - - - - - - - - - - - - - - - - - 102 | Total ReActive Power: -19.83 VAR (CT1~CT2~CT3) 103 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 104 | Calculated Total Reactive Power: -19.84 W (CT1~CT2~CT3) 105 | 106 | Apparent Power (Total Amount of Power Flowing from Source to Load) 107 | ------------------------------------------------------------------- 108 | Apparent Power CT1: 163.32 VA 109 | Apparent Power CT2: 0.45 VA 110 | Apparent Power CT3: 162.27 VA 111 | - - - - - - - - - - - - - - - - - - - - - - - - 112 | Total Apparent Power: 325.62 VA (CT1~CT2~CT3) 113 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 114 | Calculated Total Apparent Power: 326.04 W (CT1~CT2~CT3) 115 | 116 | 117 | Other Power Information 118 | ------------------------ 119 | Total Fundamental Power: -324.36 pH(t) 120 | 121 | Total Harmonic Power: -0.55 122 | 123 | Power Factor 124 | ------------- 125 | Power Factor CT1: 0.00 PF 126 | Power Factor CT2: 0.00 PF 127 | Power Factor CT3: 0.00 PF 128 | - - - - - - - - - - - - - - - 129 | Total Power Factor: 0.00 PF 130 | 131 | Phase Angle 132 | ------------ 133 | Phase Angle CT1: 0.00 134 | Phase Angle CT2: 0.00 135 | Phase Angle CT3: 0.00 136 | 137 | Other Information 138 | ------------------ 139 | Chip Temperature: 32.00 °C 140 | 141 | Mains Frequency: 50.10 Hz 142 | 143 | PCB Temperature Sensor (NTC_IN VN): 31.73 ºC 144 | 145 | ADC Raw: 2770 > ADC Adjusted: 2770 > Calculated: 26.38 V -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Terminal Output Example ATM90E32.txt: -------------------------------------------------------------------------------- 1 | Std Prod PCA Bring Up. Jumpers set. AC In. Resistive Load. 2 | ------------------------------------------------------------------------------------------------------------------------ 3 | 4 | Settings. Default 5 | 6 | // **************** DEFINE Device ATM90E32 or ATM90E36 **************** 7 | #define ATM90E32_DEVICE 32 8 | #define ATM90E36_DEVICE 36 9 | 10 | // On IPEM, Set required ATM90E3x device, ATM90E32_DEVICE or ATM90E36_DEVICE 11 | #define ATM90DEVICE ATM90E32_DEVICE 12 | 13 | // **************** DEFINE Current Clamp Input CT4 **************** 14 | #define CT4_ATM 90 // ATM90E36 (N) 15 | #define CT4_ESP 32 // ESP32 ADC. Suitable for both ATM90E32 or ATM90E36 16 | 17 | // CT4 Software Configuration. Can be used for CT INPUT to ATM90E36, ESP32 GP35. 18 | #define CT4_CONFIG CT4_ESP // On IPEM, Set CT4 ADC Configuration. CT4_ATM or CT4_ESP 19 | #define CT4_ENABLED false // CT4 ESP32 Clamp (Default false) 20 | 21 | // **************** DEFINE VOLTAGE REFERENCE **************** 22 | #define ATM_SINGLEVOLTAGE false // Set to true to use V1/ATM_V1P for VoltageGain1, VoltageGain2, VoltageGain3 and Calcfulations for CT1, CT2, CT3, CT4, CTN. (Default true) 23 | 24 | ------------------------------------------------------------------------------------------------------------------------ 25 | 26 | 27 | DitroniX IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor Board - Development Code 28 | 29 | Initialise OLED (If Plugged In) 30 | 31 | Register Status and Startup Report 32 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 33 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 34 | Board Location: House 35 | 36 | Software Optons 37 | ---------------- 38 | Wi-Fi is Disabled 39 | Domoticz Publishing is Disabled 40 | MQTT Publishing is Disabled 41 | ThingSpeak Publishing is Disabled 42 | 43 | EEPROM Check: 20 (Validation OK) 44 | 45 | PWM Output is Disabled 46 | 47 | DAC Output is Disabled 48 | 49 | Peripherals Test 50 | ----------------- 51 | Testing RGB LED 52 | Scanning I2C Bus for Devices ... 53 | * I2C device found at address Decimal 60 = Hex 0x3C OLED 54 | * I2C device found at address Decimal 80 = Hex 0x50 EEPROM 55 | * I2C Bus Scan Complete 56 | 57 | AC/DC Voltage Input Detected 58 | Connecting to the ATM90E32 59 | ATM90E32 Connected - OK 60 | IPEM Hardware Setup and Power-Up Test - Board Initialized 61 | 62 | Register Status and Diagnostic Report 63 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 64 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 Location: House 65 | 66 | Hardware Configuration for ATM90E32 67 | ------------------------------------ 68 | AC Voltage Inputs: Single Input V1 will be used for Current Phase Calculations 69 | Split AC Voltage: Dual Split-Phase (V1-x-V3) Disabled 70 | CT Current Clamps: Configured for 1, 2, 3 Phase + 1 Phase (ESP32) 71 | CT4 Current Input: Configured for ESP32 ADC 72 | 73 | [Status Values] 74 | System Status: S0:0x37E S1:0xFFFE 75 | Meter Status: E0:0x20F E1:0xFF 76 | 77 | Mains RMS Voltage 78 | ------------------ 79 | - - - - - - - - - - - - - - - - - - - - - - - - - - - 80 | Voltage 1: 249.13 V (Single Line Voltage Selected) 81 | 82 | Mains RMS Current 83 | ------------------ 84 | Current CT1: 0.66 A 85 | Current CT2: 0.66 A 86 | Current CT3: 0.66 A 87 | - - - - - - - - - - - - - - - - - - - - - - - 88 | Actual Total Current: 1.98 A (CT1~CT2~CT3) 89 | 90 | Calculated RMS Power 91 | --------------------- 92 | Power V1*I1: 164.43 W 93 | Power V1*I2: 164.43 W 94 | Power V1*I3: 164.43 W 95 | - - - - - - - - - - - - - - - - - - - - - - - - - 96 | Calculated Total Power: 492.58 W (CT1~CT2~CT3) 97 | 98 | Active Power (Absorbed or Used by the Load) 99 | -------------------------------------------- 100 | Active Power CT1: -163.87 W (Export) 101 | Active Power CT2: -162.18 W (Export) 102 | Active Power CT3: -162.85 W (Export) 103 | - - - - - - - - - - - - - - - - - - - - - 104 | Total Active Power: -326.75 W (Export) 105 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 106 | Calculated Total Active Power: -488.90 W (CT1~CT2~CT3) 107 | 108 | Re-Active Power 109 | ---------------- 110 | ReActive Power CT1: -10.33 VAR 111 | ReActive Power CT2: -9.72 VAR 112 | ReActive Power CT3: -9.88 VAR 113 | - - - - - - - - - - - - - - - - - - - - - - - - - 114 | Total ReActive Power: -20.21 VAR (CT1~CT2~CT3) 115 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 116 | Calculated Total Reactive Power: -29.93 W (CT1~CT2~CT3) 117 | 118 | Apparent Power (Total Amount of Power Flowing from Source to Load) 119 | ------------------------------------------------------------------- 120 | Apparent Power CT1: 164.44 VA 121 | Apparent Power CT2: 162.70 VA 122 | Apparent Power CT3: 163.34 VA 123 | - - - - - - - - - - - - - - - - - - - - - - - - 124 | Total Apparent Power: 327.78 VA (CT1~CT2~CT3) 125 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 126 | Calculated Total Apparent Power: 490.48 W (CT1~CT2~CT3) 127 | 128 | Other Power Information 129 | ------------------------ 130 | Total Fundamental Power: -326.40 pH(t) 131 | 132 | Total Harmonic Power: -0.50 133 | 134 | Power Factor 135 | ------------- 136 | Power Factor CT1: 0.00 PF 137 | Power Factor CT2: 0.00 PF 138 | Power Factor CT3: 0.00 PF 139 | - - - - - - - - - - - - - - - 140 | Total Power Factor: 0.00 PF 141 | 142 | Phase Angle 143 | ------------ 144 | Phase Angle CT1: 0.00 145 | Phase Angle CT2: 0.00 146 | Phase Angle CT3: 0.00 147 | 148 | Other Information 149 | ------------------ 150 | Chip Temperature: 32.00 °C 151 | 152 | Mains Frequency: 50.08 Hz 153 | 154 | PCB Temperature Sensor (NTC_IN VN): 31.42 ºC 155 | 156 | ADC Raw: 2703 > ADC Adjusted: 2703 > Calculated: 25.74 V -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Terminal Output Example ATM90E36.txt: -------------------------------------------------------------------------------- 1 | Std Prod PCA Bring Up. Jumpers set. AC In. Resistive Load. 2 | ------------------------------------------------------------------------------------------------------------------------ 3 | 4 | Settings. Default 5 | 6 | // **************** DEFINE Device ATM90E32 or ATM90E36 **************** 7 | #define ATM90E32_DEVICE 32 8 | #define ATM90E36_DEVICE 36 9 | 10 | // On IPEM, Set required ATM90E3x device, ATM90E32_DEVICE or ATM90E36_DEVICE 11 | #define ATM90DEVICE ATM90E36_DEVICE 12 | 13 | // **************** DEFINE Current Clamp Input CT4 **************** 14 | #define CT4_ATM 90 // ATM90E36 (N) 15 | #define CT4_ESP 32 // ESP32 ADC. Suitable for both ATM90E32 or ATM90E36 16 | 17 | // CT4 Software Configuration. Can be used for CT INPUT to ATM90E36, ESP32 GP35. 18 | #define CT4_CONFIG CT4_ESP // On IPEM, Set CT4 ADC Configuration. CT4_ATM or CT4_ESP 19 | #define CT4_ENABLED false // CT4 ESP32 Clamp (Default false) 20 | 21 | // **************** DEFINE VOLTAGE REFERENCE **************** 22 | #define ATM_SINGLEVOLTAGE false // Set to true to use V1/ATM_V1P for VoltageGain1, VoltageGain2, VoltageGain3 and Calcfulations for CT1, CT2, CT3, CT4, CTN. (Default true) 23 | 24 | ------------------------------------------------------------------------------------------------------------------------ 25 | 26 | 27 | DitroniX IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor Board - Development Code 28 | 29 | Initialise OLED (If Plugged In) 30 | 31 | Register Status and Startup Report 32 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 33 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 34 | Board Location: House 35 | 36 | Software Optons 37 | ---------------- 38 | Wi-Fi is Disabled 39 | Domoticz Publishing is Disabled 40 | MQTT Publishing is Disabled 41 | ThingSpeak Publishing is Disabled 42 | 43 | EEPROM Check: 20 (Validation OK) 44 | 45 | PWM Output is Disabled 46 | 47 | DAC Output is Disabled 48 | 49 | Peripherals Test 50 | ----------------- 51 | Testing RGB LED 52 | Scanning I2C Bus for Devices ... 53 | * I2C device found at address Decimal 60 = Hex 0x3C OLED 54 | * I2C device found at address Decimal 80 = Hex 0x50 EEPROM 55 | * I2C Bus Scan Complete 56 | 57 | AC/DC Voltage Input Detected 58 | Connecting to the ATM90E36 59 | ATM90E36 Connected - OK 60 | IPEM Hardware Setup and Power-Up Test - Board Initialized 61 | 62 | Register Status and Diagnostic Report 63 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 64 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 Location: House 65 | 66 | Hardware Configuration for ATM90E36 67 | ------------------------------------ 68 | AC Voltage Inputs: Single Input V1 will be used for Current Phase Calculations 69 | Split AC Voltage: Dual Split-Phase (V1-x-V3) Disabled 70 | CT Current Clamps: Configured for 1, 2, 3 Phase + 1 Phase (ESP32) 71 | CT4 Current Input: Configured for ESP32 ADC 72 | 73 | [Status Values] 74 | System Status: S0:0x210 S1:0x654 75 | Meter Status: E0:0x0 E1:0x0 76 | 77 | Mains RMS Voltage 78 | ------------------ 79 | - - - - - - - - - - - - - - - - - - - - - - - - - - - 80 | Voltage 1: 249.10 V (Single Line Voltage Selected) 81 | 82 | Mains RMS Current 83 | ------------------ 84 | Current CT1: 0.66 A 85 | Current CT2: 0.66 A 86 | Current CT3: 0.66 A 87 | - - - - - - - - - - - - - - - - - - - - - - - 88 | Actual Total Current: 1.98 A (CT1~CT2~CT3) 89 | 90 | Calculated RMS Power 91 | --------------------- 92 | Power V1*I1: 164.41 W 93 | Power V1*I2: 164.41 W 94 | Power V1*I3: 164.41 W 95 | Power V1*I4: 0.00 W 96 | - - - - - - - - - - - - - - - - - - - - - - - - - 97 | Calculated Total Power: 492.51 W (CT1~CT2~CT3) 98 | 99 | Active Power (Absorbed or Used by the Load) 100 | -------------------------------------------- 101 | Active Power CT1: -163.92 W (Export) 102 | Active Power CT2: -162.13 W (Export) 103 | Active Power CT3: -162.79 W (Export) 104 | - - - - - - - - - - - - - - - - - - - - - 105 | Total Active Power: -326.71 W (Export) 106 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 107 | Calculated Total Active Power: -488.84 W (CT1~CT2~CT3) 108 | 109 | Re-Active Power 110 | ---------------- 111 | ReActive Power CT1: -10.33 VAR 112 | ReActive Power CT2: -9.78 VAR 113 | ReActive Power CT3: -9.99 VAR 114 | - - - - - - - - - - - - - - - - - - - - - - - - - 115 | Total ReActive Power: -20.32 VAR (CT1~CT2~CT3) 116 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 117 | Calculated Total Reactive Power: -30.10 W (CT1~CT2~CT3) 118 | 119 | Apparent Power (Total Amount of Power Flowing from Source to Load) 120 | ------------------------------------------------------------------- 121 | Apparent Power CT1: 164.32 VA 122 | Apparent Power CT2: 162.57 VA 123 | Apparent Power CT3: 163.27 VA 124 | - - - - - - - - - - - - - - - - - - - - - - - - 125 | Total Apparent Power: 327.60 VA (CT1~CT2~CT3) 126 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 127 | Calculated Total Apparent Power: 490.16 W (CT1~CT2~CT3) 128 | 129 | Power Factor 130 | ------------- 131 | Power Factor CT1: 0.00 PF 132 | Power Factor CT2: 0.00 PF 133 | Power Factor CT3: 0.00 PF 134 | - - - - - - - - - - - - - - - 135 | Total Power Factor: 0.00 PF 136 | 137 | Phase Angle 138 | ------------ 139 | Phase Angle CT1: 0.00 140 | Phase Angle CT2: 0.00 141 | Phase Angle CT3: 0.00 142 | 143 | Other Information 144 | ------------------ 145 | Chip Temperature: 32.00 °C 146 | 147 | Mains Frequency: 50.00 Hz 148 | 149 | PCB Temperature Sensor (NTC_IN VN): 31.42 ºC 150 | 151 | ADC Raw: 2739 > ADC Adjusted: 2739 > Calculated: 26.09 V -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Terminal Output Example DAC Enabled.txt: -------------------------------------------------------------------------------- 1 | Std Prod PCA Bring Up. Jumpers set. AC In. Resistive Load. CT Clamp controlling DAC Output 2 | ------------------------------------------------------------------------------------------------------------------------ 3 | 4 | Settings. Default. Load with varying Powershown at end of Diagnostic Report. 5 | 6 | DAC_Power(ActivePowerExportCT1); 7 | 8 | // Variables USER and External (Power Up Default) 9 | boolean EnableDACLocal = true; // Enable/TurnOn DAC Local. Default(false) Soft Switch for Local Direct Control /DAC-On /DAC-Off 10 | boolean EnableDACRemote = false; // Enable/Allow DAC Remote Power Control. Default(false) Soft Switch for Remote Control /DAC-Remote 11 | 12 | // EnableDACTestOutput will over-ride EnableDACLocal and EnableDACRemote 13 | boolean EnableDACTestOutput = false; // Enable/TurnOn Continuous DAC Cycle Test. Will Bypass Actual Readings. Default(false) 14 | 15 | ------------------------------------------------------------------------------------------------------------------------ 16 | 17 | DitroniX IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor Board - Development Code 18 | 19 | Initialise OLED (If Plugged In) 20 | 21 | Register Status and Startup Report 22 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 23 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 24 | Board Location: House 25 | 26 | Software Optons 27 | ---------------- 28 | Wi-Fi is Disabled 29 | Domoticz Publishing is Disabled 30 | MQTT Publishing is Disabled 31 | ThingSpeak Publishing is Disabled 32 | 33 | EEPROM Check: 20 (Validation OK) 34 | 35 | PWM Output is Disabled 36 | 37 | DAC Output is Enabled from DACLocal 38 | DAC Maximum Power Limit: 4000 39 | DAC Resolution Bit: 8 40 | DAC Maximum Resolution: 255 41 | DAC Scaling Factor: 0.000825 42 | 43 | Peripherals Test 44 | ----------------- 45 | Testing RGB LED 46 | Scanning I2C Bus for Devices ... 47 | * I2C device found at address Decimal 60 = Hex 0x3C OLED 48 | * I2C device found at address Decimal 80 = Hex 0x50 EEPROM 49 | * I2C Bus Scan Complete 50 | 51 | AC/DC Voltage Input Detected 52 | Connecting to the ATM90E32 53 | ATM90E32 Connected - OK 54 | IPEM Hardware Setup and Power-Up Test - Board Initialized 55 | 56 | Register Status and Diagnostic Report 57 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 58 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 Location: House 59 | 60 | Hardware Configuration for ATM90E32 61 | ------------------------------------ 62 | AC Voltage Inputs: Single Input V1 will be used for Current Phase Calculations 63 | Split AC Voltage: Dual Split-Phase (V1-x-V3) Disabled 64 | CT Current Clamps: Configured for 1, 2, 3 Phase + 1 Phase (ESP32) 65 | CT4 Current Input: Configured for ESP32 ADC 66 | 67 | [Status Values] 68 | System Status: S0:0x37E S1:0xFFFE 69 | Meter Status: E0:0x20F E1:0xFF 70 | 71 | Mains RMS Voltage 72 | ------------------ 73 | - - - - - - - - - - - - - - - - - - - - - - - - - - - 74 | Voltage 1: 249.06 V (Single Line Voltage Selected) 75 | 76 | Mains RMS Current 77 | ------------------ 78 | Current CT1: 0.66 A 79 | Current CT2: 0.66 A 80 | Current CT3: 0.66 A 81 | - - - - - - - - - - - - - - - - - - - - - - - 82 | Actual Total Current: 1.98 A (CT1~CT2~CT3) 83 | 84 | Calculated RMS Power 85 | --------------------- 86 | Power V1*I1: 164.38 W 87 | Power V1*I2: 164.38 W 88 | Power V1*I3: 164.38 W 89 | - - - - - - - - - - - - - - - - - - - - - - - - - 90 | Calculated Total Power: 492.42 W (CT1~CT2~CT3) 91 | 92 | Active Power (Absorbed or Used by the Load) 93 | -------------------------------------------- 94 | Active Power CT1: -163.91 W (Export) 95 | Active Power CT2: -162.21 W (Export) 96 | Active Power CT3: -162.87 W (Export) 97 | - - - - - - - - - - - - - - - - - - - - - 98 | Total Active Power: -326.80 W (Export) 99 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 100 | Calculated Total Active Power: -488.99 W (CT1~CT2~CT3) 101 | 102 | Re-Active Power 103 | ---------------- 104 | ReActive Power CT1: -10.89 VAR 105 | ReActive Power CT2: -10.24 VAR 106 | ReActive Power CT3: -10.55 VAR 107 | - - - - - - - - - - - - - - - - - - - - - - - - - 108 | Total ReActive Power: -21.44 VAR (CT1~CT2~CT3) 109 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 110 | Calculated Total Reactive Power: -31.68 W (CT1~CT2~CT3) 111 | 112 | Apparent Power (Total Amount of Power Flowing from Source to Load) 113 | ------------------------------------------------------------------- 114 | Apparent Power CT1: 164.38 VA 115 | Apparent Power CT2: 162.58 VA 116 | Apparent Power CT3: 163.28 VA 117 | - - - - - - - - - - - - - - - - - - - - - - - - 118 | Total Apparent Power: 327.70 VA (CT1~CT2~CT3) 119 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 120 | Calculated Total Apparent Power: 490.24 W (CT1~CT2~CT3) 121 | 122 | Other Power Information 123 | ------------------------ 124 | Total Fundamental Power: -326.19 pH(t) 125 | 126 | Total Harmonic Power: -0.50 127 | 128 | Power Factor 129 | ------------- 130 | Power Factor CT1: 0.00 PF 131 | Power Factor CT2: 0.00 PF 132 | Power Factor CT3: 0.00 PF 133 | - - - - - - - - - - - - - - - 134 | Total Power Factor: 0.00 PF 135 | 136 | Phase Angle 137 | ------------ 138 | Phase Angle CT1: 0.00 139 | Phase Angle CT2: 0.00 140 | Phase Angle CT3: 0.00 141 | 142 | Other Information 143 | ------------------ 144 | Chip Temperature: 33.00 °C 145 | 146 | Mains Frequency: 50.11 Hz 147 | 148 | PCB Temperature Sensor (NTC_IN VN): 32.68 ºC 149 | 150 | ADC Raw: 2776 > ADC Adjusted: 2776 > Calculated: 26.44 V 151 | 152 | Updated DAC Power: 163.91 Voltage: 0.14 4 % 153 | Updated DAC Power: 163.87 Voltage: 0.14 4 % 154 | Updated DAC Power: 313.62 Voltage: 0.26 7 % 155 | Updated DAC Power: 324.07 Voltage: 0.27 8 % 156 | Updated DAC Power: 323.85 Voltage: 0.27 8 % 157 | Updated DAC Power: 726.44 Voltage: 0.60 18 % 158 | Updated DAC Power: 725.60 Voltage: 0.60 18 % 159 | Updated DAC Power: 1203.96 Voltage: 0.99 30 % 160 | Updated DAC Power: 1131.11 Voltage: 0.93 28 % 161 | Updated DAC Power: 1128.36 Voltage: 0.93 28 % 162 | Updated DAC Power: 971.49 Voltage: 0.80 24 % 163 | Updated DAC Power: 969.29 Voltage: 0.80 24 % 164 | Updated DAC Power: 863.22 Voltage: 0.71 21 % 165 | Updated DAC Power: 808.88 Voltage: 0.67 20 % 166 | Updated DAC Output DAC Off 167 | 168 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Terminal Output Example PWM Enabled.txt: -------------------------------------------------------------------------------- 1 | Std Prod PCA Bring Up. Jumpers set. AC In. Resistive Load. CT Clamp controlling PWM Output 2 | ------------------------------------------------------------------------------------------------------------------------ 3 | 4 | Settings. Default. Load with varying Powershown at end of Diagnostic Report. 5 | 6 | PWM_Power(ActivePowerExportCT1); 7 | 8 | // Variables USER and External (Power Up Default) 9 | boolean EnablePWMLocal = true; // Enable/TurnOn PWM Local. Default(false) Soft Switch for Local Direct Control /PWM-On /PWM-Off 10 | boolean EnablePWMRemote = false; // Enable/Allow PWM Remote Power Control. Default(false) Soft Switch for Remote Control /PWM-Remote 11 | 12 | // Development and testing Use. EnablePWMTestOutput will over-ride EnablePWMLocal and EnablePWMRemote 13 | boolean EnablePWMTestOutput = false; // Enable/TurnOn Continuous PWM Cycle Test. Will Bypass Actual Readings. Default(false) 14 | 15 | ------------------------------------------------------------------------------------------------------------------------ 16 | 17 | DitroniX IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor Board - Development Code 18 | 19 | Initialise OLED (If Plugged In) 20 | 21 | Register Status and Startup Report 22 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 23 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 24 | Board Location: House 25 | 26 | Software Optons 27 | ---------------- 28 | Wi-Fi is Disabled 29 | Domoticz Publishing is Disabled 30 | MQTT Publishing is Disabled 31 | ThingSpeak Publishing is Disabled 32 | 33 | EEPROM Check: 20 (Validation OK) 34 | 35 | PWM Output is Enabled from PWMLocal 36 | PWM Maximum Power Limit: 4000 37 | PWM Resolution Bit: 14 38 | PWM Maximum Resolution: 16383 39 | PWM Scaling Factor: 0.244156 40 | 41 | DAC Output is Disabled 42 | 43 | Peripherals Test 44 | ----------------- 45 | Testing RGB LED 46 | Scanning I2C Bus for Devices ... 47 | * I2C device found at address Decimal 60 = Hex 0x3C OLED 48 | * I2C device found at address Decimal 80 = Hex 0x50 EEPROM 49 | * I2C Bus Scan Complete 50 | 51 | AC/DC Voltage Input Detected 52 | Connecting to the ATM90E32 53 | ATM90E32 Connected - OK 54 | IPEM Hardware Setup and Power-Up Test - Board Initialized 55 | 56 | Register Status and Diagnostic Report 57 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 58 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 Location: House 59 | 60 | Hardware Configuration for ATM90E32 61 | ------------------------------------ 62 | AC Voltage Inputs: Single Input V1 will be used for Current Phase Calculations 63 | Split AC Voltage: Dual Split-Phase (V1-x-V3) Disabled 64 | CT Current Clamps: Configured for 1, 2, 3 Phase + 1 Phase (ESP32) 65 | CT4 Current Input: Configured for ESP32 ADC 66 | 67 | [Status Values] 68 | System Status: S0:0x37E S1:0xFFFE 69 | Meter Status: E0:0x37F E1:0xFF 70 | 71 | Mains RMS Voltage 72 | ------------------ 73 | - - - - - - - - - - - - - - - - - - - - - - - - - - - 74 | Voltage 1: 249.53 V (Single Line Voltage Selected) 75 | 76 | Mains RMS Current 77 | ------------------ 78 | Current CT1: 0.00 A 79 | Current CT2: 0.00 A 80 | Current CT3: 0.00 A 81 | - - - - - - - - - - - - - - - - - - - - - - - 82 | Actual Total Current: 0.00 A (CT1~CT2~CT3) 83 | 84 | Calculated RMS Power 85 | --------------------- 86 | Power V1*I1: 0.00 W 87 | Power V1*I2: 0.00 W 88 | Power V1*I3: 0.00 W 89 | - - - - - - - - - - - - - - - - - - - - - - - - 90 | Calculated Total Power: 0.00 W (CT1~CT2~CT3) 91 | 92 | Active Power (Absorbed or Used by the Load) 93 | -------------------------------------------- 94 | Active Power CT1: 0.00 W 95 | Active Power CT2: 0.00 W 96 | Active Power CT3: 0.00 W 97 | - - - - - - - - - - - - - - - - 98 | Total Active Power: 0.00 W 99 | - - - - - - - - - - - - - - - - - - - - - - - - - - - 100 | Calculated Total Active Power: 0.00 W (CT1~CT2~CT3) 101 | 102 | Re-Active Power 103 | ---------------- 104 | ReActive Power CT1: 0.24 VAR 105 | ReActive Power CT2: 0.22 VAR 106 | ReActive Power CT3: 0.28 VAR 107 | - - - - - - - - - - - - - - - - - - - - - - - - 108 | Total ReActive Power: 0.52 VAR (CT1~CT2~CT3) 109 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - 110 | Calculated Total Reactive Power: 0.74 W (CT1~CT2~CT3) 111 | 112 | Apparent Power (Total Amount of Power Flowing from Source to Load) 113 | ------------------------------------------------------------------- 114 | Apparent Power CT1: 0.75 VA 115 | Apparent Power CT2: 0.45 VA 116 | Apparent Power CT3: 0.79 VA 117 | - - - - - - - - - - - - - - - - - - - - - - - 118 | Total Apparent Power: 1.53 VA (CT1~CT2~CT3) 119 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - 120 | Calculated Total Apparent Power: 1.99 W (CT1~CT2~CT3) 121 | 122 | Other Power Information 123 | ------------------------ 124 | Total Fundamental Power: -0.03 pH(t) 125 | 126 | Total Harmonic Power: 0.00 127 | 128 | Power Factor 129 | ------------- 130 | Power Factor CT1: 0.00 PF 131 | Power Factor CT2: 0.02 PF 132 | Power Factor CT3: 0.00 PF 133 | - - - - - - - - - - - - - - - 134 | Total Power Factor: 0.00 PF 135 | 136 | Phase Angle 137 | ------------ 138 | Phase Angle CT1: 117.50 139 | Phase Angle CT2: 107.00 140 | Phase Angle CT3: 79.80 141 | 142 | Other Information 143 | ------------------ 144 | Chip Temperature: 33.00 °C 145 | 146 | Mains Frequency: 50.09 Hz 147 | 148 | PCB Temperature Sensor (NTC_IN VN): 32.18 ºC 149 | 150 | ADC Raw: 2694 > ADC Adjusted: 2694 > Calculated: 25.66 V 151 | 152 | Updated PWM Power: 29.55 Duty Cycle: 121 0 % 153 | Updated PWM Power: 163.47 Duty Cycle: 669 4 % 154 | Updated PWM Power: 163.45 Duty Cycle: 669 4 % 155 | Updated PWM Power: 163.33 Duty Cycle: 668 4 % 156 | Updated PWM Power: 323.11 Duty Cycle: 1323 8 % 157 | Updated PWM Power: 161.07 Duty Cycle: 659 4 % 158 | Updated PWM Power: 161.10 Duty Cycle: 659 4 % 159 | Updated PWM Power: 161.18 Duty Cycle: 660 4 % 160 | Updated PWM Power: 323.25 Duty Cycle: 1323 8 % 161 | Updated PWM Power: 163.32 Duty Cycle: 668 4 % 162 | Updated PWM Power: 1611.57 Duty Cycle: 6600 40 % 163 | Updated PWM Power: 967.14 Duty Cycle: 3961 24 % 164 | Updated PWM Power: 1395.48 Duty Cycle: 5715 34 % 165 | Updated PWM Power: 1367.65 Duty Cycle: 5601 34 % 166 | Updated PWM Power: 1364.21 Duty Cycle: 5587 34 % 167 | Updated PWM Power: 1365.37 Duty Cycle: 5592 34 % 168 | Updated PWM Power: 1359.29 Duty Cycle: 5567 33 % 169 | Updated PWM Power: 886.63 Duty Cycle: 3631 22 % 170 | Updated PWM Power: 807.48 Duty Cycle: 3307 20 % 171 | Updated PWM Power: 399.41 Duty Cycle: 1635 9 % 172 | Updated PWM Power Duty Cycle: PWM Off -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Terminal Output Example with 1200W Halogen Heater.txt: -------------------------------------------------------------------------------- 1 | Test Conditions. Test 16th June 2023 2 | DitroniX Mains CT Bench Tester, with 3 x CT clamps on single phase to a Warmlite WL42005 Halogen Heater 1200W. 3 | Mains Voltage (~245V), to Greenbrook DAT01A transformer, with single 12V AC output to three Voltage inputs on IPEM (So we see correct readings over three phases). 4 | This is a production IPEM AT90E32 board, with no calibration or corrections applied - just default firmware values. 5 | Note: AC Voltage in, is a single AC supply with common to 1, 2 and 3 input. Easy way, Short ATM to V1P (All three pads) and Link AC 1, 2 and 3. 6 | 7 | ------------------------------------------------------------------------------------------------------------------------ 8 | 9 | DitroniX IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor Board - Development Code 10 | 11 | Initialise OLED (If Plugged In) 12 | 13 | Register Status and Startup Report 14 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 15 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 16 | Board Location: House 17 | 18 | Software Optons 19 | ---------------- 20 | Wi-Fi is Disabled 21 | Domoticz Publishing is Disabled 22 | MQTT Publishing is Disabled 23 | ThingSpeak Publishing is Disabled 24 | 25 | EEPROM Check: 20 (Validation OK) 26 | 27 | PWM Output is Disabled 28 | 29 | DAC Output is Disabled 30 | 31 | Peripherals Test 32 | ----------------- 33 | Testing RGB LED 34 | Scanning I2C Bus for Devices ... 35 | * I2C device found at address Decimal 60 = Hex 0x3C OLED 36 | * I2C device found at address Decimal 80 = Hex 0x50 EEPROM 37 | * I2C Bus Scan Complete 38 | 39 | AC/DC Voltage Input Detected 40 | Connecting to the ATM90E32 41 | ATM90E32 Connected - OK 42 | IPEM Hardware Setup and Power-Up Test - Board Initialized 43 | 44 | Register Status and Diagnostic Report 45 | IPEM-1 ATM90E32 ATM90E36 IoT Power Energy Monitor 46 | ESP32 Serial ID: 5499FEEF49C0 Firmware Version: 230616 Location: House 47 | 48 | Hardware Configuration for ATM90E32 49 | ------------------------------------ 50 | AC Voltage Inputs: Single Input V1 will be used for Current Phase Calculations 51 | Split AC Voltage: Dual Split-Phase (V1-x-V3) Disabled 52 | CT Current Clamps: Configured for 1, 2, 3 Phase + 1 Phase (ESP32) 53 | CT4 Current Input: Configured for ESP32 ADC 54 | 55 | [Status Values] 56 | System Status: S0:0x37E S1:0xFFFE 57 | Meter Status: E0:0x20F E1:0xFF 58 | 59 | Mains RMS Voltage 60 | ------------------ 61 | - - - - - - - - - - - - - - - - - - - - - - - - - - - 62 | Voltage 1: 245.74 V (Single Line Voltage Selected) 63 | 64 | Calculated RMS Power 65 | --------------------- 66 | Power V1*I1: 1204.13 W 67 | Power V1*I2: 1189.38 W 68 | Power V1*I3: 1194.30 W 69 | - - - - - - - - - - - - - - - - - - - - - - - - - 70 | Calculated Total Power: 3582.81 W (CT1~CT2~CT3) 71 | 72 | Active Power (Absorbed or Used by the Load) 73 | -------------------------------------------- 74 | Active Power CT1: -1197.98 W (Export) 75 | Active Power CT2: -1180.80 W (Export) 76 | Active Power CT3: -1187.90 W (Export) 77 | - - - - - - - - - - - - - - - - - - - - - - 78 | Total Active Power: -2385.93 W (Export) 79 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 80 | Calculated Total Active Power: -3566.68 W (CT1~CT2~CT3) 81 | 82 | Re-Active Power 83 | ---------------- 84 | ReActive Power CT1: -72.75 VAR 85 | ReActive Power CT2: -68.51 VAR 86 | ReActive Power CT3: -70.68 VAR 87 | - - - - - - - - - - - - - - - - - - - - - - - - - 88 | Total ReActive Power: -143.49 VAR (CT1~CT2~CT3) 89 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 90 | Calculated Total Reactive Power: -211.94 W (CT1~CT2~CT3) 91 | 92 | Apparent Power (Total Amount of Power Flowing from Source to Load) 93 | ------------------------------------------------------------------- 94 | Apparent Power CT1: 1201.35 VA 95 | Apparent Power CT2: 1183.88 VA 96 | Apparent Power CT3: 1191.30 VA 97 | - - - - - - - - - - - - - - - - - - - - - - - - - 98 | Total Apparent Power: 2392.42 VA (CT1~CT2~CT3) 99 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 100 | Calculated Total Apparent Power: 3576.53 W (CT1~CT2~CT3) 101 | 102 | Other Power Information 103 | ------------------------ 104 | Total Fundamental Power: -2382.89 pH(t) 105 | 106 | Total Harmonic Power: -3.70 107 | 108 | Power Factor 109 | ------------- 110 | Power Factor CT1: 0.00 PF 111 | Power Factor CT2: 0.00 PF 112 | Power Factor CT3: 0.00 PF 113 | - - - - - - - - - - - - - - - 114 | Total Power Factor: 0.00 PF 115 | 116 | Phase Angle 117 | ------------ 118 | Phase Angle CT1: 0.00 119 | Phase Angle CT2: 0.00 120 | Phase Angle CT3: 0.00 121 | 122 | Other Information 123 | ------------------ 124 | Chip Temperature: 32.00 °C 125 | 126 | Mains Frequency: 50.05 Hz 127 | 128 | PCB Temperature Sensor (NTC_IN VN): 31.11 ºC -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/Transformer Info.md: -------------------------------------------------------------------------------- 1 | Example Double Insulated Bell Chime Transformer Part Number DAT01A (Greenbrook.co.uk) 2 | In-built thermal cut-out, short circuit and overload protection self re-setting. 4/8/12V AC Output @ 1A. 3 | 4 | Datasheet https://www.greenbrook.co.uk/pub/media/pdfs/DAT01AIns.pdf 5 | 6 | Available from a number of distributors, example https://www.tlc-direct.co.uk/Products/TCTR7.html 7 | 8 | Mains Input 9 | 246.2V RMS AC 10 | 11 | Secondary Output 12 | 4 = 6.4V RMS AC 13 | 8 = 12.8V RMS AC 16.43 DC 14 | 12 = 19.23V RMS AC 15 | 16 | The 12V Output setting performs the best and IPEM ATM90E26 VP Input has been designed for this. 17 | 18 | Note: IPEM AP SMPS Regulator Input Voltage, Absolute Max: 32 V DC 19 | 20 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/include/ATM90E3x.h: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | 5 | Full header information in main.cpp. 6 | 7 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 8 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | 10 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and also github.com/DitroniX 11 | */ 12 | 13 | // Libraries 14 | #ifndef ATM90E3x_h 15 | #define ATM90E3x_h 16 | #include 17 | #include 18 | 19 | // **************** SPI **************** 20 | #define WRITE 0 // WRITE SPI 21 | #define READ 1 // READ SPI 22 | 23 | // **************** VARIABLES / DEFINES / STATIC / STRUCTURES / REGISTERS **************** 24 | 25 | // **************** DEFINE Device ATM90E32 or ATM90E36 **************** 26 | #define ATM90E32_DEVICE 32 27 | #define ATM90E36_DEVICE 36 28 | 29 | // On IPEM, Set required ATM90E3x device, ATM90E32_DEVICE or ATM90E36_DEVICE 30 | #define ATM90DEVICE ATM90E32_DEVICE 31 | 32 | // **************** DEFINE Current Clamp Input CT4 **************** 33 | #define CT4_ATM 90 // ATM90E36 (N) 34 | #define CT4_ESP 32 // ESP32 ADC. Suitable for both ATM90E32 or ATM90E36 35 | 36 | // CT4 Software Configuration. Can be used for CT INPUT to ATM90E36, ESP32 GP35. 37 | #define CT4_CONFIG CT4_ESP // On IPEM, Set CT4 ADC Configuration. CT4_ATM or CT4_ESP 38 | #define CT4_ENABLED false // CT4 ESP32 Clamp (Default false) 39 | 40 | // **************** DEFINE VOLTAGE REFERENCE **************** 41 | #define ATM_SINGLEVOLTAGE true // Set to true to use V1/ATM_V1P for VoltageGain1, VoltageGain2, VoltageGain3 and Calcfulations for CT1, CT2, CT3, CT4, CTN. (Default true) 42 | 43 | // **************** DEFINE PHASE TYPE **************** 44 | #define ATM_SPLITPHASE false // If Split Phase (i.e. USA 120+120), set to true else leave false (NB. Not fully tested). ATM_SINGLEVOLTAGE = false 45 | 46 | // **************** DEFINE STATUS REGISTERS 47 | #if ATM90DEVICE == ATM90E32_DEVICE 48 | #define MeterEn 0x00 // Metering Enable 49 | #define ChannelMapI 0x01 // Current Channel Mapping Configuration 50 | #define ChannelMapU 0x02 // Voltage Channel Mapping Configuration 51 | #define SagPeakDetCfg 0x05 // Sag and Peak Detector Period Configuration 52 | #define OVth 0x06 // Over Voltage Threshold 53 | #define ZXConfig 0x07 // Zero-Crossing Config 54 | #define SagTh 0x08 // Voltage Sag Th 55 | #define PhaseLossTh 0x09 // Voltage Phase Losing Th 56 | #define INWarnTh 0x0A // Neutral Current (Calculated) Warning Threshold 57 | #define OIth 0x0B // Over Current Threshold 58 | #define FreqLoTh 0x0C // Low Threshold for Frequency Detection 59 | #define FreqHiTh 0x0D // High Threshold for Frequency Detection 60 | #define PMPwrCtrl 0x0E // Partial Measurement Mode Power Control 61 | #define IRQ0MergeCfg 0x0F // IRQ0 Merge Configuration 62 | #endif 63 | 64 | // **************** DEFINE EMM STATUS REGISTERS **************** 65 | #if ATM90DEVICE == ATM90E32_DEVICE 66 | #define SoftReset 0x70 // Software Reset 67 | #define EMMState0 0x71 // EMM State 0 68 | #define EMMState1 0x72 // EMM State 1 69 | #define EMMIntState0 0x73 // EMM Interrupt Status 0 70 | #define EMMIntState1 0x74 // EMM Interrupt Status 1 71 | #define EMMIntEn0 0x75 // EMM Interrupt Enable 0 72 | #define EMMIntEn1 0x76 // EMM Interrupt Enable 1 73 | #define LastSPIData 0x78 // Last Read/Write SPI Value 74 | #define CRCErrStatus 0x79 // CRC Error Status 75 | #define CRCDigest 0x7A // CRC Digest 76 | #define CfgRegAccEn 0x7F // Configure Register Access Enable 77 | #endif 78 | 79 | // **************** DEFINE STATUS REGISTERS **************** 80 | #if ATM90DEVICE == ATM90E36_DEVICE 81 | #define SoftReset 0x00 // Software Reset 82 | #define SysStatus0 0x01 // System Status0 83 | #define SysStatus1 0x02 // System Status1 84 | #define FuncEn0 0x03 // Function Enable0 85 | #define FuncEn1 0x04 // Function Enable1 86 | #define ZXConfig 0x07 // Zero-Crossing Config 87 | #define SagTh 0x08 // Voltage Sag Th 88 | #define PhaseLossTh 0x09 // Voltage Phase Losing Th 89 | #define INWarnTh0 0x0A // N Current Line Th 90 | #define INWarnTh1 0x0B // Voltage ADC Th 91 | #define THDNUTh 0x0C // Voltage THD Th 92 | #define THDNITh 0x0D // Current THD Th 93 | #define DMACtrl 0x0E // DMA Int. Control 94 | #define LastSPIData 0x0F // Last Read/Write SPI Value 95 | #endif 96 | 97 | // **************** LOW POWER MODE REGISTERS - NOT USED - COMMON TO BOTH ATM90E3x **************** 98 | #define DetectCtrl 0x10 99 | #define DetectTh1 0x11 100 | #define DetectTh2 0x12 101 | #define DetectTh3 0x13 102 | #define PMOffsetA 0x14 103 | #define PMOffsetB 0x15 104 | #define PMOffsetC 0x16 105 | #define PMPGA 0x17 106 | #define PMIrmsA 0x18 107 | #define PMIrmsB 0x19 108 | #define PMIrmsC 0x1A 109 | #define PMConfig 0x10B 110 | #define PMAvgSamples 0x1C 111 | #define PMIrmsLSB 0x1D 112 | 113 | // **************** CONFIGURATION REGISTERS **************** 114 | #if ATM90DEVICE == ATM90E32_DEVICE 115 | #define PLconstH 0x31 // High Word of PL_Constant 116 | #define PLconstL 0x32 // Low Word of PL_Constant 117 | #define MMode0 0x33 // Metering Mode Config 118 | #define MMode1 0x34 // PGA Gain Configuration for Current Channels 119 | #define PStartTh 0x35 // Startup Power Th (P) 120 | #define QStartTh 0x36 // Startup Power Th (Q) 121 | #define SStartTh 0x37 // Startup Power Th (S) 122 | #define PPhaseTh 0x38 // Startup Power Accum Th (P) 123 | #define QPhaseTh 0x39 // Startup Power Accum Th (Q) 124 | #define SPhaseTh 0x3A // Startup Power Accum Th (S) 125 | #endif 126 | 127 | #if ATM90DEVICE == ATM90E36_DEVICE 128 | #define ConfigStart 0x30 // Configuration Start 129 | #define PLconstH 0x31 // High Word of PL_Constant 130 | #define PLconstL 0x32 // Low Word of PL_Constant 131 | #define MMode0 0x33 // Metering Mode Config 132 | #define MMode1 0x34 // Metering Mode Config 133 | #define PStartTh 0x35 // Startup Power Th (P) 134 | #define QStartTh 0x36 // Startup Power Th (Q) 135 | #define SStartTh 0x37 // Startup Power Th (S) 136 | #define PPhaseTh 0x38 // Startup Power Accum Th (P) 137 | #define QPhaseTh 0x39 // Startup Power Accum Th (Q) 138 | #define SPhaseTh 0x3A // Startup Power Accum Th (S) 139 | #define CSZero 0x3B // Checksum 0 140 | #endif 141 | 142 | // **************** CALIBRATION REGISTERS **************** 143 | #if ATM90DEVICE == ATM90E32_DEVICE 144 | #define PoffsetA 0x41 // A Line Power Offset (P) 145 | #define QoffsetA 0x42 // A Line Power Offset (Q) 146 | #define PoffsetB 0x43 // B Line Power Offset (P) 147 | #define QoffsetB 0x44 // B Line Power Offset (Q) 148 | #define PoffsetC 0x45 // C Line Power Offset (P) 149 | #define QoffsetC 0x46 // C Line Power Offset (Q) 150 | #define PQGainA 0x47 // A Line Calibration Gain 151 | #define PhiA 0x48 // A Line Calibration Angle 152 | #define PQGainB 0x49 // B Line Calibration Gain 153 | #define PhiB 0x4A // B Line Calibration Angle 154 | #define PQGainC 0x4B // C Line Calibration Gain 155 | #define PhiC 0x4C // C Line Calibration Angle 156 | #endif 157 | 158 | #if ATM90DEVICE == ATM90E36_DEVICE 159 | #define CalStart 0x40 // Cal Start 160 | #define PoffsetA 0x41 // A Line Power Offset (P) 161 | #define QoffsetA 0x42 // A Line Power Offset (Q) 162 | #define PoffsetB 0x43 // B Line Power Offset (P) 163 | #define QoffsetB 0x44 // B Line Power Offset (Q) 164 | #define PoffsetC 0x45 // C Line Power Offset (P) 165 | #define QoffsetC 0x46 // C Line Power Offset (Q) 166 | #define GainA 0x47 // A Line Calibration Gain 167 | #define PhiA 0x48 // A Line Calibration Angle 168 | #define GainB 0x49 // B Line Calibration Gain 169 | #define PhiB 0x4A // B Line Calibration Angle 170 | #define GainC 0x4B // C Line Calibration Gain 171 | #define PhiC 0x4C // C Line Calibration Angle 172 | #define CSOne 0x4D // Checksum 1 173 | #endif 174 | 175 | // **************** FUNDAMENTAL/HARMONIC & ENERGY CALIBRATION REGISTERS **************** 176 | #if ATM90DEVICE == ATM90E32_DEVICE 177 | #define POffsetAF 0x51 // A Fund Power Offset (P) 178 | #define POffsetBF 0x52 // B Fund Power Offset (P) 179 | #define POffsetCF 0x53 // C Fund Power Offset (P) 180 | #define PGainAF 0x54 // A Fund Power Gain (P) 181 | #define PGainBF 0x55 // B Fund Power Gain (P) 182 | #define PGainCF 0x56 // C Fund Power Gain (P) 183 | #endif 184 | 185 | #if ATM90DEVICE == ATM90E36_DEVICE 186 | #define HarmStart 0x50 // Harmonic Cal Start 187 | #define POffsetAF 0x51 // A Fund Power Offset (P) 188 | #define POffsetBF 0x52 // B Fund Power Offset (P) 189 | #define POffsetCF 0x53 // C Fund Power Offset (P) 190 | #define PGainAF 0x54 // A Fund Power Gain (P) 191 | #define PGainBF 0x55 // B Fund Power Gain (P) 192 | #define PGainCF 0x56 // C Fund Power Gain (P) 193 | #define CSTwo 0x57 // Checksum 2 194 | #endif 195 | 196 | // **************** MEASUREMENT CALIBRATION REGISTERS **************** 197 | #if ATM90DEVICE == ATM90E32_DEVICE 198 | #define UgainA 0x61 // A Voltage RMS Gain 199 | #define IgainA 0x62 // A Current RMS Gain 200 | #define UoffsetA 0x63 // A Voltage Offset 201 | #define IoffsetA 0x64 // A Current Offset 202 | #define UgainB 0x65 // B Voltage RMS Gain 203 | #define IgainB 0x66 // B Current RMS Gain 204 | #define UoffsetB 0x67 // B Voltage Offset 205 | #define IoffsetB 0x68 // B Current Offset 206 | #define UgainC 0x69 // C Voltage RMS Gain 207 | #define IgainC 0x6A // C Current RMS Gain 208 | #define UoffsetC 0x6B // C Voltage Offset 209 | #define IoffsetC 0x6C // C Current Offset 210 | #define IoffsetN 0x6E // N Current Offset 211 | #endif 212 | 213 | #if ATM90DEVICE == ATM90E36_DEVICE 214 | #define AdjStart 0x60 // Measurement Cal Start 215 | #define UgainA 0x61 // A Voltage RMS Gain 216 | #define IgainA 0x62 // A Current RMS Gain 217 | #define UoffsetA 0x63 // A Voltage Offset 218 | #define IoffsetA 0x64 // A Current Offset 219 | #define UgainB 0x65 // B Voltage RMS Gain 220 | #define IgainB 0x66 // B Current RMS Gain 221 | #define UoffsetB 0x67 // B Voltage Offset 222 | #define IoffsetB 0x68 // B Current Offset 223 | #define UgainC 0x69 // C Voltage RMS Gain 224 | #define IgainC 0x6A // C Current RMS Gain 225 | #define UoffsetC 0x6B // C Voltage Offset 226 | #define IoffsetC 0x6C // C Current Offset 227 | #define IgainN 0x6D // N Current Gain 228 | #define IoffsetN 0x6E // N Current Offset 229 | #define CSThree 0x6F // Checksum 3 230 | #endif 231 | 232 | // **************** ENERGY REGISTERS - COMMON TO BOTH ATM90E3x **************** 233 | #define APenergyT 0x80 // Total Forward Active 234 | #define APenergyA 0x81 // A Forward Active 235 | #define APenergyB 0x82 // B Forward Active 236 | #define APenergyC 0x83 // C Forward Active 237 | #define ANenergyT 0x84 // Total Reverse Active 238 | #define ANenergyA 0x85 // A Reverse Active 239 | #define ANenergyB 0x86 // B Reverse Active 240 | #define ANenergyC 0x87 // C Reverse Active 241 | #define RPenergyT 0x88 // Total Forward Reactive 242 | #define RPenergyA 0x89 // A Forward Reactive 243 | #define RPenergyB 0x8A // B Forward Reactive 244 | #define RPenergyC 0x8B // C Forward Reactive 245 | #define RNenergyT 0x8C // Total Reverse Reactive 246 | #define RNenergyA 0x8D // A Reverse Reactive 247 | #define RNenergyB 0x8E // B Reverse Reactive 248 | #define RNenergyC 0x8F // C Reverse Reactive 249 | 250 | #define SAenergyT 0x90 // Total Apparent Energy 251 | #define SenergyA 0x91 // A Apparent Energy 252 | #define SenergyB 0x92 // B Apparent Energy 253 | #define SenergyC 0x93 // C Apparent Energy 254 | 255 | #if ATM90DEVICE == ATM90E36_DEVICE 256 | #define SVenergyT 0x94 // Total Apparent Energy (Arit) 257 | 258 | #define EnStatus0 0x95 // Metering Status 0 259 | #define EnStatus1 0x96 // Metering Status 1 260 | ///////////////// 0x97 // Reserved Register 261 | #define SVmeanT 0x98 // Total Apparent Energy (Vect) 262 | #define SVmeanTLSB 0x99 // LSB of Vector Sum 263 | #endif 264 | 265 | // **************** FUNDAMENTAL / HARMONIC ENERGY REGISTERS - COMMON TO BOTH ATM90E3x **************** 266 | #define APenergyTF 0xA0 // Total Forward Fund. Energy 267 | #define APenergyAF 0xA1 // A Forward Fund. Energy 268 | #define APenergyBF 0xA2 // B Forward Fund. Energy 269 | #define APenergyCF 0xA3 // C Forward Fund. Energy 270 | #define ANenergyTF 0xA4 // Total Reverse Fund Energy 271 | #define ANenergyAF 0xA5 // A Reverse Fund. Energy 272 | #define ANenergyBF 0xA6 // B Reverse Fund. Energy 273 | #define ANenergyCF 0xA7 // C Reverse Fund. Energy 274 | #define APenergyTH 0xA8 // Total Forward Harm. Energy 275 | #define APenergyAH 0xA9 // A Forward Harm. Energy 276 | #define APenergyBH 0xAA // B Forward Harm. Energy 277 | #define APenergyCH 0xAB // C Forward Harm. Energy 278 | #define ANenergyTH 0xAC // Total Reverse Harm. Energy 279 | #define ANenergyAH 0xAD // A Reverse Harm. Energy 280 | #define ANenergyBH 0xAE // B Reverse Harm. Energy 281 | #define ANenergyCH 0xAF // C Reverse Harm. Energy 282 | 283 | // **************** POWER & P.F. REGISTERS - COMMON TO BOTH ATM90E3x **************** 284 | #define PmeanT 0xB0 // Total Mean Power (P) 285 | #define PmeanA 0xB1 // A Mean Power (P) 286 | #define PmeanB 0xB2 // B Mean Power (P) 287 | #define PmeanC 0xB3 // C Mean Power (P) 288 | #define QmeanT 0xB4 // Total Mean Power (Q) 289 | #define QmeanA 0xB5 // A Mean Power (Q) 290 | #define QmeanB 0xB6 // B Mean Power (Q) 291 | #define QmeanC 0xB7 // C Mean Power (Q) 292 | #define SmeanT 0xB8 // Total Mean Power (S) 293 | #define SmeanA 0xB9 // A Mean Power (S) 294 | #define SmeanB 0xBA // B Mean Power (S) 295 | #define SmeanC 0xBB // C Mean Power (S) 296 | #define PFmeanT 0xBC // Mean Power Factor 297 | #define PFmeanA 0xBD // A Power Factor 298 | #define PFmeanB 0xBE // B Power Factor 299 | #define PFmeanC 0xBF // C Power Factor 300 | 301 | // **************** POWER & P.F. REGISTERS - COMMON TO BOTH ATM90E3x **************** 302 | #define PmeanTLSB 0xC0 // Lower Word (Tot. Act. Power) 303 | #define PmeanALSB 0xC1 // Lower Word (A Act. Power) 304 | #define PmeanBLSB 0xC2 // Lower Word (B Act. Power) 305 | #define PmeanCLSB 0xC3 // Lower Word (C Act. Power) 306 | #define QmeanTLSB 0xC4 // Lower Word (Tot. React. Power) 307 | #define QmeanALSB 0xC5 // Lower Word (A React. Power) 308 | #define QmeanBLSB 0xC6 // Lower Word (B React. Power) 309 | #define QmeanCLSB 0xC7 // Lower Word (C React. Power) 310 | #define SAmeanTLSB 0xC8 // Lower Word (Tot. App. Power) 311 | #define SmeanALSB 0xC9 // Lower Word (A App. Power) 312 | #define SmeanBLSB 0xCA // Lower Word (B App. Power) 313 | #define SmeanCLSB 0xCB // Lower Word (C App. Power) 314 | 315 | // **************** FUND/HARM POWER & V/I RMS REGISTERS - COMMON TO BOTH ATM90E3x **************** 316 | #define PmeanTF 0xD0 // Total Active Fund. Power 317 | #define PmeanAF 0xD1 // A Active Fund. Power 318 | #define PmeanBF 0xD2 // B Active Fund. Power 319 | #define PmeanCF 0xD3 // C Active Fund. Power 320 | #define PmeanTH 0xD4 // Total Active Harm. Power 321 | #define PmeanAH 0xD5 // A Active Harm. Power 322 | #define PmeanBH 0xD6 // B Active Harm. Power 323 | #define PmeanCH 0xD7 // C Active Harm. Power 324 | #define UrmsA 0xD9 // A RMS Voltage 325 | #define UrmsB 0xDA // B RMS Voltage 326 | #define UrmsC 0xDB // C RMS Voltage 327 | #define IrmsN 0xDC // Calculated N RMS Current 328 | #define IrmsA 0xDD // A RMS Current 329 | #define IrmsB 0xDE // B RMS Current 330 | #define IrmsC 0xDF // C RMS Current 331 | 332 | // **************** FUND/HARM POWER & V/I RMS REGISTERS - COMMON TO BOTH ATM90E3x **************** 333 | #define PmeanTFLSB 0xE0 // Lower Word (Tot. Act. Fund. Power) 334 | #define PmeanAFLSB 0xE1 // Lower Word (A Act. Fund. Power) 335 | #define PmeanBFLSB 0xE2 // Lower Word (B Act. Fund. Power) 336 | #define PmeanCFLSB 0xE3 // Lower Word (C Act. Fund. Power) 337 | #define PmeanTHLSB 0xE4 // Lower Word (Tot. Act. Harm. Power) 338 | #define PmeanAHLSB 0xE5 // Lower Word (A Act. Harm. Power) 339 | #define PmeanBHLSB 0xE6 // Lower Word (B Act. Harm. Power) 340 | #define PmeanCHLSB 0xE7 // Lower Word (C Act. Harm. Power) 341 | ///////////////// 0xE8 // Reserved Register 342 | #define UrmsALSB 0xE9 // Lower Word (A RMS Voltage) 343 | #define UrmsBLSB 0xEA // Lower Word (B RMS Voltage) 344 | #define UrmsCLSB 0xEB // Lower Word (C RMS Voltage) 345 | ///////////////// 0xEC // Reserved Register 346 | #define IrmsALSB 0xED // Lower Word (A RMS Current) 347 | #define IrmsBLSB 0xEE // Lower Word (B RMS Current) 348 | #define IrmsCLSB 0xEF // Lower Word (C RMS Current) 349 | 350 | // **************** PEAK, FREQUENCY, ANGLE & TEMP REGISTERS **************** 351 | #if ATM90DEVICE == ATM90E32_DEVICE 352 | #define UPeakA 0xF1 // A Voltage Peak - THD+N on ATM90E36 353 | #define UPeakB 0xF2 // B Voltage Peak 354 | #define UPeakC 0xF3 // C Voltage Peak 355 | ///////////////// 0xF4 // Reserved Register 356 | #define IPeakA 0xF5 // A Current Peak 357 | #define IPeakB 0xF6 // B Current Peak 358 | #define IPeakC 0xF7 // C Current Peak 359 | #define Freq 0xF8 // Frequency 360 | #define PAngleA 0xF9 // A Mean Phase Angle 361 | #define PAngleB 0xFA // B Mean Phase Angle 362 | #define PAngleC 0xFB // C Mean Phase Angle 363 | #define Temp 0xFC // Measured Temperature 364 | #define UangleA 0xFD // A Voltage Phase Angle 365 | #define UangleB 0xFE // B Voltage Phase Angle 366 | #define UangleC 0xFF // C Voltage Phase Angle 367 | #endif 368 | 369 | #if ATM90DEVICE == ATM90E36_DEVICE 370 | #define THDNUA 0xF1 // A Voltage THD+N 371 | #define THDNUB 0xF2 // B Voltage THD+N 372 | #define THDNUC 0xF3 // C Voltage THD+N 373 | ///////////////// 0xF4 // Reserved Register 374 | #define THDNIA 0xF5 // A Current THD+N 375 | #define THDNIB 0xF6 // B Current THD+N 376 | #define THDNIC 0xF7 // V Current THD+N 377 | #define Freq 0xF8 // Frequency 378 | #define PAngleA 0xF9 // A Mean Phase Angle 379 | #define PAngleB 0xFA // B Mean Phase Angle 380 | #define PAngleC 0xFB // C Mean Phase Angle 381 | #define Temp 0xFC // Measured Temperature 382 | #define UangleA 0xFD // A Voltage Phase Angle 383 | #define UangleB 0xFE // B Voltage Phase Angle 384 | #define UangleC 0xFF // C Voltage Phase Angle 385 | #endif 386 | 387 | // **************** CLASS **************** 388 | 389 | class ATM90E3x 390 | { 391 | private: 392 | unsigned short CommEnergyIC(unsigned char RW, unsigned short address, unsigned short val); 393 | int _cs; 394 | unsigned short _lineFreq; 395 | unsigned short _pgagain; 396 | unsigned short _ugain1; 397 | unsigned short _ugain2; 398 | unsigned short _ugain3; 399 | unsigned short _igainA; 400 | unsigned short _igainB; 401 | unsigned short _igainC; 402 | unsigned short _igainN; 403 | 404 | int Read32Register(signed short regh_addr, signed short regl_addr); 405 | 406 | public: 407 | /* Construct */ 408 | ATM90E3x(void); 409 | /* Destruct */ 410 | ~ATM90E3x(void); 411 | 412 | /* Initialization Functions */ 413 | #if ATM90DEVICE == ATM90E32_DEVICE || ATM_SPLITPHASE == true 414 | void begin(unsigned short lineFreq, unsigned short pgagain, unsigned short ugain1, unsigned short ugain2, unsigned short ugain3, unsigned short igainA, unsigned short igainB, unsigned short igainC); 415 | #endif 416 | 417 | #if ATM90DEVICE == ATM90E36_DEVICE 418 | void begin(unsigned short lineFreq, unsigned short pgagain, unsigned short ugain1, unsigned short ugain2, unsigned short ugain3, unsigned short igainA, unsigned short igainB, unsigned short igainC, unsigned short igainN); 419 | #endif 420 | 421 | double 422 | CalculateVIOffset(unsigned short regh_addr, unsigned short regl_addr /*, unsigned short offset_reg*/); 423 | double CalculatePowerOffset(unsigned short regh_addr, unsigned short regl_addr /*, unsigned short offset_reg*/); 424 | double CalibrateVI(unsigned short reg, unsigned short actualVal); 425 | 426 | /* Main Electrical Parameters (GET)*/ 427 | double GetLineVoltage1(); 428 | double GetLineVoltage2(); 429 | double GetLineVoltage3(); 430 | 431 | double GetLineCurrentCT1(); 432 | double GetLineCurrentCT2(); 433 | double GetLineCurrentCT3(); 434 | double GetLineCurrentCTN(); 435 | 436 | double GetActivePowerCT1(); 437 | double GetActivePowerCT2(); 438 | double GetActivePowerCT3(); 439 | double GetTotalActivePower(); 440 | 441 | #if ATM90DEVICE == ATM90E32_DEVICE 442 | double GetTotalActiveFundPower(); 443 | double GetTotalActiveHarPower(); 444 | #endif 445 | 446 | double GetReactivePowerCT1(); 447 | double GetReactivePowerCT2(); 448 | double GetReactivePowerCT3(); 449 | double GetTotalReactivePower(); 450 | 451 | double GetApparentPowerCT1(); 452 | double GetApparentPowerCT2(); 453 | double GetApparentPowerCT3(); 454 | double GetTotalApparentPower(); 455 | 456 | double GetFrequency(); 457 | 458 | double GetPowerFactorCT1(); 459 | double GetPowerFactorCT2(); 460 | double GetPowerFactorCT3(); 461 | double GetTotalPowerFactor(); 462 | 463 | double GetPhaseCT1(); 464 | double GetPhaseCT2(); 465 | double GetPhaseCT3(); 466 | 467 | double GetTemperature(); 468 | 469 | /* Gain Parameters (GET)*/ 470 | double GetValueRegister(unsigned short registerRead); 471 | 472 | /* Energy Consumption */ 473 | double GetImportEnergy(); 474 | 475 | #if ATM90DEVICE == ATM90E32_DEVICE 476 | double GetImportReactiveEnergy(); 477 | double GetImportApparentEnergy(); 478 | #endif 479 | 480 | double GetExportEnergy(); 481 | 482 | #if ATM90DEVICE == ATM90E32_DEVICE 483 | double GetExportReactiveEnergy(); 484 | #endif 485 | 486 | /* System Status */ 487 | unsigned short GetSysStatus0(); 488 | unsigned short GetSysStatus1(); 489 | unsigned short GetMeterStatus0(); 490 | unsigned short GetMeterStatus1(); 491 | 492 | #if ATM90DEVICE == ATM90E36_DEVICE 493 | /* Checksum Function */ 494 | bool calibrationError(); 495 | #endif 496 | }; 497 | #endif -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/include/DAC.h: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | 5 | Full header information in main.cpp. 6 | 7 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 8 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | 10 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and also github.com/DitroniX 11 | */ 12 | 13 | // NOTE: THIS CODE IS UNDER DEVELOPMENT. DAVE WILLIAMS JUNE 2023 14 | 15 | // Note: This function needs to use one of the two DAC outputs, both of which are already assigned by default. WO on GP25 is the least needed, so we will repurpose this GPIO. 16 | // To repurpose, you will need to CUT a track from GP25 to the ATM WO. Details will be provided in the Wiki once the testing is complete. 17 | // DAC Output Voltage is NOT Calibrated, although. Basic DAC Output Voltage Test @ 1.5 = 1.4979V 18 | 19 | // Libraries 20 | #include 21 | #include 22 | 23 | // **************** VARIABLES / DEFINES / STATIC / STRUCTURES / CONSTANTS **************** 24 | 25 | // Not Directly possible on IPEM 1.2304.203P without a board mod. Effectively, Cut a Track and Bypass WO Input. 26 | #define DAC_GPIO GPIO_NUM_25 // Define DAC GPIO (Default GPIO_NUM_25 = GP25) 27 | DacESP32 dacoutput(DAC_GPIO); 28 | 29 | // Variables USER and External (Power Up Default) 30 | boolean EnableDACLocal = false; // Enable/TurnOn DAC Local. Default(false) Soft Switch for Local Direct Control /DAC-On /DAC-Off 31 | boolean EnableDACRemote = false; // Enable/Allow DAC Remote Power Control. Default(false) Soft Switch for Remote Control /DAC-Remote 32 | 33 | // EnableDACTestOutput will over-ride EnableDACLocal and EnableDACRemote 34 | boolean EnableDACTestOutput = false; // Enable/TurnOn Continuous DAC Cycle Test. Will Bypass Actual Readings. Default(false) 35 | 36 | // Variables DAC Internal 37 | float DAC_ScaledVoltage; 38 | float DAC_LastValue; 39 | int DAC_WritePower; 40 | 41 | int DAC_MaximumResolution; // DAC Maximum 8-bit argument (Default 255) Note: This is the only option when using ESP32 DAC 42 | float DAC_ScalingFactor; // DAC Scaling Power Factor Based on Rounded Maximum Power (i.e. DAC_MaximumPowerLimit / Resolution of DAC_MaximumDutyCycle) 43 | 44 | // Variables DAC External 45 | float DACPowerOutput; // Last Value Used For DAC 46 | int DACPowerPercentage; // Base Power Percentage 47 | float DACLocalPower = 0; // Base Local Power Level (Power Up Default 0) 48 | float DACRemotePower = 0; // Base Remote Power Level (Power Up Default 0) 49 | 50 | // Constants Power 51 | float DAC_MaximumPowerLimit = 4000; // Maximum CT Power Range 0 to x. Upper Limit of Measured Power for Scaling (Default 4000) 52 | int DAC_MinimumPowerLimit = 0; // DAC Minimum 8-bit argument (Default 0) 53 | int DAC_MinimumPowerThreshold = 5; // Minimum Power Threshold (in Watts), Before Outputting to DAC. Also used for Noise and Jitter Control. (Default 5) 54 | int DAC_ResolutionBit = 8; // DAC Resolution bit (Default 8). Note: This is the only option when using ESP32 DAC 55 | float DAC_MinimumVoltage = 0; // (Default 0) 56 | float DAC_MaximumVoltage = 3.3; // Default is 3.3 but can be scaled if using external driver control. i.e. DAC into a transistor. 57 | 58 | // **************** FUNCTIONS AND ROUTINES **************** 59 | 60 | // Initialise DAC 61 | void InitialiseDAC() 62 | { 63 | DAC_MaximumResolution = (int)(pow(2, DAC_ResolutionBit) - 1); // 8bit = 256-1 | 10bit = 1024-1 | 12bit = 4096-1 | 14bit = 16384-1 | 16bit = 65536-1. 64 | DAC_ScalingFactor = DAC_MaximumVoltage / DAC_MaximumPowerLimit; // E.g. 3.3 / 4000 65 | 66 | // DAC Integration Status 67 | if (EnableDACLocal == false && EnableDACRemote == false && EnableDACTestOutput == false) 68 | { 69 | Serial.println("DAC Output is Disabled\n"); 70 | } 71 | else 72 | { 73 | if (EnableDACLocal == true) 74 | Serial.println("DAC Output is Enabled from DACLocal"); 75 | 76 | if (EnableDACRemote == true) 77 | Serial.println("DAC Output is Enabled from DACRemote"); 78 | 79 | if (EnableDACTestOutput == true) 80 | Serial.println("DAC Output is Enabled from DAC Test Output"); 81 | 82 | // Configuration Info 83 | Serial.printf("DAC Maximum Power Limit:\t%0f\n", DAC_MaximumPowerLimit); 84 | Serial.printf("DAC Resolution Bit:\t\t%d\n", DAC_ResolutionBit); 85 | Serial.printf("DAC Maximum Resolution:\t\t%d\n", DAC_MaximumResolution); 86 | Serial.printf("DAC Scaling Factor:\t\t%f\n\n", DAC_ScalingFactor); 87 | } 88 | } // InitialiseDAC 89 | 90 | // DAC Output Voltage Based on BasePower PreScaled to BaseValue 91 | void DAC_WriteVoltage(float InputBasePower) 92 | { 93 | if (DACPowerOutput != InputBasePower) 94 | { 95 | // Store Last Reading 96 | DACPowerOutput = InputBasePower; 97 | 98 | // Set Max and Min Limits (Top and Tail) 99 | if (DACPowerOutput >= DAC_MaximumPowerLimit) 100 | DACPowerOutput = DAC_MaximumPowerLimit; 101 | 102 | if (DACPowerOutput <= DAC_MinimumPowerLimit) 103 | DACPowerOutput = DAC_MinimumPowerLimit; 104 | 105 | // Calculate DAC Duty Cycle 106 | DAC_ScaledVoltage = (InputBasePower * DAC_ScalingFactor); 107 | 108 | // Set Max Duty Cycle limit 109 | if (DAC_ScaledVoltage >= DAC_MaximumVoltage) 110 | DAC_ScaledVoltage = DAC_MaximumVoltage; 111 | 112 | // Set Min Duty Cycle limit. If Zero then Ignore Lower Limit as this is DAC Off. 113 | if (DAC_ScaledVoltage <= DAC_MinimumVoltage) 114 | DAC_ScaledVoltage = 0; 115 | 116 | // Update DACLastValue to DAC Port. Example: Vout = 100/255 * 3.3V = ~1.3V 117 | dacoutput.outputVoltage(DAC_ScaledVoltage); 118 | 119 | // Display Value 120 | if (DACPowerOutput > 0) 121 | { 122 | Serial.print("Updated DAC Power: " + String(InputBasePower) + "\t\t"); 123 | Serial.print("Voltage: " + String(DAC_ScaledVoltage) + "\t\t"); 124 | DACPowerPercentage = map(DACPowerOutput, DAC_MinimumPowerLimit, DAC_MaximumPowerLimit, 0, 100); // Scaled example 0-4kW = 0-100% = 255 125 | Serial.println(String(DACPowerPercentage) + " %"); 126 | } 127 | else 128 | { 129 | Serial.println("Updated DAC Output \tDAC Off"); 130 | } 131 | } 132 | } // DAC_WriteVoltage 133 | 134 | // Output DAC Voltage Proportionally Based on Input Power. Approx Values: ?=1kW, ?=2kW, ?=3kW and ?=4kW 135 | void DAC_Power(float InputPower = 0) 136 | { 137 | // Check Maximum Limits. 0 to Ignore Limit. 138 | if (InputPower >= DAC_MaximumPowerLimit) 139 | InputPower = DAC_MaximumPowerLimit; 140 | 141 | // Check Valid Limits / Calculate 142 | if (InputPower > DAC_MinimumPowerThreshold && InputPower > 0) 143 | { // Local Power Control via CT 144 | DAC_WriteVoltage(InputPower); 145 | } 146 | else 147 | { // Turn DAC Off if Zero or Below DAC_MinimumPowerThreshold 148 | DAC_WriteVoltage(0); 149 | } 150 | 151 | // Configuration Conflict Issue - Turn Both Off 152 | if (EnableDACLocal == true && EnableDACRemote == true) 153 | { 154 | Serial.print("DAC Configuration Issue - Forcing Off"); 155 | DAC_WriteVoltage(0); 156 | EnableDACLocal = false; 157 | EnableDACRemote = false; 158 | } 159 | 160 | } // DAC_Power 161 | 162 | // Output DAC - Test Use Only. Modes 0 = Dynamic Output based on CT Power. 1 = SineWave. 2 =Fixed Test Voltage for Calibration etc. 163 | void DAC_Test(int Test = 0, float DAC_Value = 0) 164 | { 165 | dacoutput.outputVoltage((float)0); 166 | int DAC_StepDelayms = 500; // Inter Step Delay in milli seconds 167 | float DAC_Increment = 0.1; // Loop Step Rate 168 | 169 | if (Test == 0) 170 | { // DAC_Test Slow Stepped Voltages 171 | 172 | for (float dacv = 0; dacv <= DAC_MaximumVoltage; dacv = dacv + DAC_Increment) 173 | { 174 | Serial.printf("DAC Voltage Output Test:\t%f\t", dacv); 175 | DACPowerPercentage = map(dacv, DAC_MinimumVoltage, DAC_MaximumVoltage, 0, 100); // Scaled example 0-4kW = 0-100% = 255 176 | Serial.println(String(DACPowerPercentage) + " %"); 177 | dacoutput.outputVoltage((float)dacv); 178 | delay(DAC_StepDelayms); 179 | } 180 | 181 | for (float dacv = DAC_MaximumVoltage; dacv >= DAC_MinimumVoltage; dacv = dacv - DAC_Increment) 182 | { 183 | Serial.printf("DAC Voltage Output Test:\t%f\t", dacv); 184 | DACPowerPercentage = map(dacv, DAC_MinimumVoltage, DAC_MaximumVoltage, 0, 100); // Scaled example 0-4kW = 0-100% = 255 185 | Serial.println(String(DACPowerPercentage) + " %"); 186 | dacoutput.outputVoltage((float)dacv); 187 | delay(DAC_StepDelayms); 188 | } 189 | } 190 | 191 | if (Test == 1) 192 | { // DAC Test Sinewave 193 | Serial.printf("DAC Voltage Output Test:\tSineWave"); 194 | dacoutput.outputCW(DAC_Value); // 1, 10, 50 Hz etc 195 | } 196 | 197 | if (Test == 2) 198 | { // DAC Test Fixed Voltage 199 | Serial.printf("DAC Voltage Output Test:\t%f\t", DAC_Value); 200 | DACPowerPercentage = map(DAC_Value, DAC_MinimumVoltage, DAC_MaximumVoltage, 0, 100); // Scaled example 0-4kW = 0-100% = 255 201 | Serial.println(String(DACPowerPercentage) + " %"); 202 | dacoutput.outputVoltage((float)DAC_Value); 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/include/IPEM_EEPROM.h: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | 5 | Full header information in main.cpp. 6 | 7 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 8 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | 10 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and also github.com/DitroniX 11 | */ 12 | 13 | // Libraries 14 | #include // Reference https://github.com/argandas/serialEEPROM 15 | 16 | // EEPROM AT24C64 64K (8192 x 8) 32-byte page writes 17 | serialEEPROM extEEPROM(0x50, 8192, 32); // Address, Size, PageSize 18 | 19 | // **************** VARIABLES / DEFINES / STATIC / STRUCTURES / CONSTANTS **************** 20 | 21 | // **************** FUNCTIONS AND ROUTINES **************** 22 | 23 | // Read 8bit Value 24 | byte readEEPROM(unsigned int addEEPROM) 25 | { 26 | uint8_t valEEPROM = 0x00; 27 | valEEPROM = extEEPROM.read(addEEPROM); 28 | return valEEPROM; 29 | } 30 | 31 | // Write 8bit Value 32 | void WriteEEPROM(unsigned int addEEPROM, uint8_t valEEPROM) 33 | { 34 | extEEPROM.write(addEEPROM, valEEPROM); 35 | } 36 | 37 | // Read 16bit Value 38 | uint16_t readEEPROM16(unsigned int addEEPROM) 39 | { 40 | uint16_t valEEPROM = 0x0000; 41 | valEEPROM = (extEEPROM.read(addEEPROM + 1) << 8); 42 | valEEPROM |= extEEPROM.read(addEEPROM); 43 | return valEEPROM; 44 | } 45 | 46 | // Write 16bit Value 47 | void WriteEEPROM16(unsigned int addEEPROM, uint16_t valEEPROM) 48 | { 49 | extEEPROM.write(addEEPROM, valEEPROM); 50 | extEEPROM.write(addEEPROM + 1, valEEPROM >> 8); 51 | } 52 | 53 | // Clear EEPROM (Only if unlocked and fully clear, if Validation not correct or corruption) 54 | void ClearEEPROM() // Size 0x2000 8192 55 | { 56 | if (extEEPROM.read(1) != 0x99) // Check Locked Status - Future Use 57 | { 58 | if (extEEPROM.read(0) != 0x20 || extEEPROM.read(8192) != 0x20) // Check Validation(Future Use) and End Byte 59 | { 60 | Serial.println("\nPreparing New EEPROM. Full Formatting... Please Wait..."); 61 | 62 | for (int i = 0; i < 8192; i++) 63 | { 64 | extEEPROM.write(i, 0x00); 65 | } 66 | } 67 | else 68 | { 69 | Serial.println("\nFormatting (Smart Clearing) EEPROM. Checking, Please Wait... "); 70 | for (int i = 1; i < 8192; i++) 71 | { 72 | if (extEEPROM.read(i) != 0x00) // Only Clear Used Bytes 73 | { 74 | Serial.print(extEEPROM.read(i), HEX); 75 | extEEPROM.write(i, 0x00); 76 | Serial.print("+"); 77 | } 78 | } 79 | } 80 | 81 | WriteEEPROM(0x00, 0x20); // Write Status Byte 82 | { 83 | for (int i = 1; i < 8192; i++) 84 | { 85 | if (extEEPROM.read(i) != 0x00) // Only Clear Used Bytes 86 | { 87 | Serial.print(extEEPROM.read(i), HEX); 88 | } 89 | } 90 | } 91 | Serial.println("EEPROM Cleared and Ready"); 92 | } 93 | 94 | else 95 | Serial.println("EEPROM Locked"); 96 | } 97 | 98 | // Initialize EEPROM - Address 0x0000 = EEPROM Status 99 | void InitializeEEPROM() 100 | { 101 | /* Initialize the I2C interface and EEPROM */ 102 | Wire.begin(); 103 | 104 | // Format New EEPROM 105 | if (extEEPROM.read(0) != 0x20) 106 | ClearEEPROM(); 107 | 108 | Serial.print("\nEEPROM Check: "); 109 | Serial.print(readEEPROM16(0x00), HEX); 110 | 111 | // EEPROM Validation 112 | if (readEEPROM16(0x00) == 0x00) 113 | { 114 | Serial.print("\t(Formatted OK)"); 115 | } 116 | if (readEEPROM16(0x00) == 0xFF) 117 | { 118 | Serial.print("\t(Unformatted)"); 119 | } 120 | if (readEEPROM16(0x00) == 0x20) 121 | { 122 | Serial.print("\t(Validation OK)"); 123 | } 124 | if (readEEPROM16(0x01) == 0x99) 125 | { 126 | Serial.print("\t(Locked)"); 127 | } 128 | 129 | Serial.println("\n"); 130 | } 131 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/include/MQTT.h: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | 5 | Full header information in main.cpp. 6 | 7 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 8 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | 10 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and also github.com/DitroniX 11 | */ 12 | 13 | // Libraries 14 | #include 15 | #include // https://pubsubclient.knolleary.net/api 16 | 17 | // **************** VARIABLES / DEFINES / STATIC / STRUCTURES **************** 18 | 19 | // MQTT Server info. Setup with your MQTT Configration 20 | const char *MQTTServer = "0.0.0.0"; // MQTT Server IP Address (Typically a Fixed Local Address) 21 | int MQTTPort = 1883; // MQTT Network Port (Default 1883) 22 | const char *MQTTUser = ""; // MQTT User - if applicable 23 | const char *MQTTPassword = ""; // MQTT Password - if applicable 24 | String MQTTTopicMain = "ipem"; // MQTT Default Topic. Exclude the trailing / 25 | 26 | // Enable Publishing 27 | boolean EnableMQTT = true; // Change to true, to enable Loop reading and sending data to MQTT. Default false. 28 | boolean EnableMQTTCallBack = true; // Under Development 29 | 30 | // MQTT Object / Client Instance 31 | PubSubClient mqtt_client(wlan_client); 32 | 33 | // ######### FUNCTIONS ######### 34 | 35 | // Callback for Receiving MQTT Messages 36 | void MQTTCallback(char *topic, byte *message, unsigned int length) 37 | { 38 | Serial.print("MQTT Message arrived on topic: "); 39 | Serial.print(topic); 40 | Serial.print(". Message: "); 41 | String messageTemp; 42 | 43 | for (int i = 0; i < length; i++) 44 | { 45 | Serial.print((char)message[i]); 46 | messageTemp += (char)message[i]; 47 | } 48 | Serial.println(); 49 | } // MQTTCallback 50 | 51 | // Publish a Formatted MQTT Message 52 | void PublishMQTTMessage(String SensorName, float SensorValue, int dPlaces = 1, int dWidth = 5, int dQOS = 0) 53 | { 54 | if (mqtt_client.connect("wlan_client", MQTTUser, MQTTPassword)) 55 | // if (mqtt_client.connected) 56 | { 57 | 58 | // Green LED 59 | digitalWrite(LED_Green, LOW); 60 | 61 | // Format Sensor Message to MQTTTopic 62 | String SensorMessage = MQTTTopicMain + "/" + SensorName; 63 | int str_len = SensorMessage.length() + 1; 64 | char MQTTTopic[str_len]; 65 | SensorMessage.toCharArray(MQTTTopic, str_len); 66 | 67 | // Structure MQTT Payload 68 | char MQTTPayload[10]; 69 | dtostrf(SensorValue, dWidth, dPlaces, MQTTPayload); 70 | 71 | // Update Serial Monitor 72 | Serial.print("Sending MQTT Message: "); 73 | Serial.print(MQTTTopic); 74 | Serial.print("\t"); 75 | Serial.println(MQTTPayload); 76 | 77 | // Publish 78 | mqtt_client.publish(MQTTTopic, MQTTPayload); 79 | // mqtt_client.publish("ipem/test/1", 0); 80 | 81 | // Green LED 82 | digitalWrite(LED_Green, HIGH); 83 | } 84 | else 85 | { 86 | // Red LED 87 | digitalWrite(LED_Red, LOW); 88 | 89 | Serial.println("WiFi or MQTT Broker Not Connected"); 90 | 91 | // Update OLED 92 | oled.clear(); 93 | OLEDPrint("Error", 2, 0); 94 | OLEDPrint("MQTT", 2, 2); 95 | oled.update(); 96 | delay(1000); 97 | 98 | // Red LED 99 | digitalWrite(LED_Red, HIGH); 100 | 101 | // Stabalise for slow Access Points 102 | InitialiseWiFi(); 103 | } 104 | } // PublishMQTTMessage 105 | 106 | // Initialise MQTT 107 | void InitialiseMQTT() 108 | { 109 | if (EnableMQTT == true && WiFi.status() == WL_CONNECTED) 110 | { 111 | // Initialise MQTT Connection and Instance 112 | mqtt_client.setServer(MQTTServer, MQTTPort); 113 | 114 | // if (EnableMQTTCallBack == true) 115 | // mqtt_client.setCallback(MQTTCallback); 116 | 117 | Serial.println("Initialised MQTT"); 118 | 119 | // mqtt_client.subscribe("Light/Switch"); 120 | // mqtt_client.setCallback(MQTTCallback); 121 | } 122 | } // InitialiseMQTT 123 | 124 | // Publish MQTT Values 125 | void PublishMQTTValues() 126 | { 127 | // Test Message Example. 128 | // PublishMQTTMessage("LineVoltage1", LineVoltage1); 129 | // PublishMQTTMessage("ActivePowerCT1", ActivePowerCT1, 0); 130 | // PublishMQTTMessage("ActivePowerCT2", ActivePowerCT2, 0); 131 | // PublishMQTTMessage("ActivePowerCT3", ActivePowerCT3, 0); 132 | // PublishMQTTMessage("LineFrequency", LineFrequency, 2); 133 | 134 | /* Examples of Available Variables 135 | LineVoltage1, LineVoltage2, LineVoltage3, LineVoltageTotal, LineVoltageAverage 136 | LineCurrentCT1, LineCurrentCT2, LineCurrentCT3, LineCurrentCT4, LineCurrentCTN, LineCurrentTotal 137 | CalculatedPowerCT1, CalculatedPowerCT2, CalculatedPowerCT3, CalculatedPowerCT4, CalculatedPowerCTN, CalculatedTotalPower 138 | ActivePowerCT1, ActivePowerCT2, ActivePowerCT3, TotalActivePower, CalculatedTotalActivePower 139 | ActivePowerImportCT1, ActivePowerImportCT2, ActivePowerImportCT3, TotalActivePowerImport 140 | ActivePowerExportCT1, ActivePowerExportCT2, ActivePowerExportCT3, TotalActivePowerExport 141 | ReactivePowerCT1, ReactivePowerCT2, ReactivePowerCT3, TotalReactivePower, CalculatedTotalReactivePower 142 | ApparentPowerCT1, ApparentPowerCT2, ApparentPowerCT3, TotalApparentPower, CalculatedTotalApparentPower 143 | TotalActiveFundPower, TotalActiveHarPower 144 | PowerFactorCT1, PowerFactorCT2, PowerFactorCT3, TotalPowerFactor 145 | PhaseAngleCT1, PhaseAngleCT2, PhaseAngleCT3 146 | ChipTemperature, LineFrequency 147 | DCVoltage, PCBTemperature 148 | PWMLocalPower, PWMRemotePower, PWMPowerOutput, PWMPowerPercentage 149 | DACLocalPower, DACRemotePower, DACPowerPercentage, DACPowerOutput 150 | 151 | *Control 152 | EnablePWMLocal, EnablePWMRemote, EnablePWMTestOutput 153 | EnableDACLocal, EnableDACRemote, EnableDACTestOutput 154 | */ 155 | 156 | Serial.println(""); 157 | 158 | } // PublishMQTTValues 159 | 160 | // while (!client.connected()) 161 | // { 162 | // Serial.println("Connecting to MQTT..."); 163 | // if (client.connect("ESP32Client", mqttUser, mqttPassword)) 164 | // { 165 | // Serial.println("connected " + String(client.state())); 166 | // client.subscribe(topic, "XXXX"); 167 | // } 168 | // else 169 | // { 170 | // Serial.print("failed with state "); 171 | // Serial.print(client.state()); 172 | // delay(2000); 173 | // } 174 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/include/PWM.h: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | 5 | Full header information in main.cpp. 6 | 7 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 8 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | 10 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and also github.com/DitroniX 11 | */ 12 | 13 | // NOTE: THIS CODE IS UNDER DEVELOPMENT. DAVE WILLIAMS JUNE 2023 14 | 15 | // Libraries 16 | #include 17 | 18 | // **************** VARIABLES / DEFINES / STATIC / STRUCTURES / CONSTANTS **************** 19 | 20 | #define PWM_GPIO 17 // Define PWM GPIO (Default GPIO 17 = Existing USR_GP17_TX_PWM) 21 | 22 | // Variables USER and External (Power Up Default) 23 | boolean EnablePWMLocal = false; // Enable/TurnOn PWM Local. Default(false) Soft Switch for Local Direct Control /PWM-On /PWM-Off 24 | boolean EnablePWMRemote = false; // Enable/Allow PWM Remote Power Control. Default(false) Soft Switch for Remote Control /PWM-Remote 25 | 26 | // Development and testing Use. EnablePWMTestOutput will over-ride EnablePWMLocal and EnablePWMRemote 27 | boolean EnablePWMTestOutput = false; // Enable/TurnOn Continuous PWM Cycle Test. Will Bypass Actual Readings. Default(false) 28 | 29 | // Variables PWM Internal 30 | int PWM_DutyCycle; 31 | float PWM_LastBasePower; 32 | int PWM_MaximumResolution; // 8bit = 256-1 | 10bit = 1024-1 | 12bit = 4096-1 | 14bit = 16384-1 | 16bit = 65536-1. 33 | float PWM_ScalingFactor; // PWM Scaling Power Factor Based on Rounded Maximum Power (i.e. PWM_MaximumPowerLimit / PWM_MaximumResolution) 34 | 35 | // Variables PWM External 36 | int PWMPowerOutput; // PWM Power Output Value 37 | int PWMPowerPercentage; // PWM Power Output Percentage 38 | float PWMRemotePower = 0; // Remote Default Base Power Level (Default 0) 39 | float PWMLocalPower = 0; // Local Default Base Power Level (Default 0) 40 | 41 | // Constants Power 42 | float PWM_MaximumPowerLimit = 4000; // Maximum CT Power Range (in Watts) 0 to x (Default 4000). Upper Limit of Measured Power for Scaling 43 | float PWM_MinimumDutyCycle = 0; // PWM Minimum Duty Cycle (Default 0) 44 | int PWM_MinimumPowerThreshold = 5; // Minimum Power Threshold (in Watts), Before Outputting PWM. Also used for Noise and Jitter Control. (Default 5) 45 | int PWM_FrequencyHz = 1000; // PWM Default Frequency (Default 1000). PWM Frequency Range 10Hz to 40MHz. 46 | int PWM_ResolutionBit = 14; // PWM bit Range 1-16 bits (Default 14) 47 | int PWM_Channel = 0; // PWM Channels 0-15 (Default 0) 48 | 49 | // **************** FUNCTIONS AND ROUTINES **************** 50 | 51 | // Initialise PWM 52 | void InitialisePWM() 53 | { 54 | ledcSetup(PWM_Channel, PWM_FrequencyHz, PWM_ResolutionBit); 55 | ledcAttachPin(PWM_GPIO, PWM_Channel); 56 | PWM_MaximumResolution = (int)(pow(2, PWM_ResolutionBit) - 1); // 8bit = 256-1 | 10bit = 1024-1 | 12bit = 4096-1 | 14bit = 16384-1 | 16bit = 65536-1. 57 | PWM_ScalingFactor = PWM_MaximumPowerLimit / PWM_MaximumResolution; 58 | ledcWrite(PWM_Channel, 0); 59 | 60 | // PWM Integration Status 61 | if (EnablePWMLocal == false && EnablePWMRemote == false && EnablePWMTestOutput == false) 62 | { 63 | Serial.println("PWM Output is Disabled\n"); 64 | } 65 | else 66 | { 67 | if (EnablePWMLocal == true) 68 | Serial.println("PWM Output is Enabled from PWMLocal"); 69 | 70 | if (EnablePWMRemote == true) 71 | Serial.println("PWM Output is Enabled from PWMRemote"); 72 | 73 | if (EnablePWMTestOutput == true) 74 | Serial.println("PWM Output is Enabled from PWM Test Output"); 75 | 76 | // Configuration Info 77 | Serial.printf("PWM Maximum Power Limit:\t%0f\n", PWM_MaximumPowerLimit); 78 | Serial.printf("PWM Resolution Bit:\t\t%d\n", PWM_ResolutionBit); 79 | Serial.printf("PWM Maximum Resolution:\t\t%d\n", PWM_MaximumResolution); 80 | Serial.printf("PWM Scaling Factor:\t\t%f\n\n", PWM_ScalingFactor); 81 | } 82 | 83 | } // InitialisePWM 84 | 85 | // PWM Output Based on Input Base Power (With Defaults). 86 | void PWM_Write(float InputBasePower) 87 | { 88 | if (PWM_LastBasePower != InputBasePower) 89 | { 90 | // Store Last Reading and Calculate PWM_LastBasePower 91 | PWM_LastBasePower = InputBasePower; 92 | 93 | // Calculate PWM Duty Cycle 94 | PWM_DutyCycle = (InputBasePower / PWM_ScalingFactor); 95 | 96 | // Set Max Duty Cycle limit 97 | if (PWM_DutyCycle >= PWM_MaximumResolution) 98 | PWM_DutyCycle = PWM_MaximumResolution; 99 | 100 | // Set Min Duty Cycle limit. If Zero then Ignore Lower Limit as this is PWM Off. 101 | if (PWM_DutyCycle <= PWM_MinimumDutyCycle && PWM_DutyCycle > 0) 102 | PWM_DutyCycle = 0; 103 | 104 | // Update PWM Port 105 | ledcWrite(PWM_Channel, PWM_DutyCycle); 106 | 107 | // Display Value 108 | if (PWM_DutyCycle > 0) 109 | { 110 | Serial.print("Updated PWM Power: " + String(PWM_LastBasePower) + "\t\t"); 111 | Serial.print("Duty Cycle: " + String(PWM_DutyCycle) + "\t\t"); 112 | PWMPowerPercentage = map(PWM_DutyCycle, PWM_MinimumDutyCycle, PWM_MaximumResolution, 0, 100); // Scaled example 0-4kW = 0-100% = 1023 113 | Serial.println(String(PWMPowerPercentage) + " %"); 114 | } 115 | else 116 | { 117 | Serial.println("Updated PWM Power Duty Cycle: \tPWM Off"); 118 | } 119 | } 120 | 121 | } // PWM_Write 122 | 123 | // Output PWM Value Based on Input Power. DutyCycle Approx Values: 256=1kW, 512=2kW, 769=3kW and 1023=4kW 124 | void PWM_Power(float InputBasePower = 0) 125 | { 126 | // Check Maximum Limits. 0 to Ignore Limit. 127 | if (InputBasePower >= PWM_MaximumPowerLimit) 128 | InputBasePower = PWM_MaximumPowerLimit; 129 | 130 | // Check Valid Limits / Calculate. Also ensure no Negative Powers 131 | if (InputBasePower >= PWM_MinimumPowerThreshold) 132 | { 133 | PWM_Write(InputBasePower); 134 | } 135 | else 136 | { // Turn PWM Off if Zero or Below PWM_MinimumPowerThreshold 137 | PWM_Write(0); 138 | } 139 | 140 | // Configuration Conflict Issue - Turn Both Off 141 | if (EnablePWMLocal == true && EnablePWMRemote == true) 142 | { 143 | Serial.print("PWM Configuration Issue - Forcing Off"); 144 | PWM_Write(0); 145 | EnablePWMLocal = false; 146 | EnablePWMRemote = false; 147 | EnablePWMTestOutput = false; 148 | } 149 | 150 | } // PWM_Power 151 | 152 | // Output Full PWM Duty / Power Cycle - Test Use Only 153 | void PWM_Test() 154 | { 155 | int BasePower = 0; 156 | 157 | /* Increasing an LED brightness with PWM */ 158 | for (BasePower = 0; BasePower <= PWM_MaximumPowerLimit; BasePower++) 159 | { 160 | PWM_Write(BasePower); 161 | } 162 | /* Decreasing an LED brightness with PWM */ 163 | for (BasePower = PWM_MaximumPowerLimit; BasePower >= 0; BasePower--) 164 | { 165 | PWM_Write(BasePower); 166 | } 167 | } // PWM_Test 168 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/include/ThingSpeakIoT.h: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | 5 | Full header information in main.cpp. 6 | 7 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 8 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | 10 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and also github.com/DitroniX 11 | */ 12 | 13 | // Example Publish (play data), can be found on https://thingspeak.com/channels/2179490 14 | 15 | // Libraries 16 | #include "ThingSpeak.h" // https://github.com/mathworks/thingspeak-arduino/blob/master/README.md 17 | 18 | // **************** VARIABLES / DEFINES / STATIC / STRUCTURES **************** 19 | 20 | // ThingSpeak Server info. Setup with your ThingSpeak Configration 21 | unsigned long myChannelNumber1 = 0; // ThingSpeak Channel ID 1 22 | const char *myWriteAPIKey1 = ""; // ThingSpeak Write API Key for Channel ID 1 23 | unsigned long myChannelNumber2 = 0; // ThingSpeak Channel ID 2 24 | const char *yWriteAPIKey2 = ""; // ThingSpeak Write API Key for Channel ID 2 25 | unsigned long myChannelNumber3 = 0; // ThingSpeak Channel ID 3 26 | const char *myWriteAPIKey3 = ""; // ThingSpeak Write API Key for Channel ID 3 27 | unsigned long myChannelNumber4 = 0; // ThingSpeak Channel ID 4 28 | const char *myWriteAPIKey4 = ""; // ThingSpeak Write API Key for Channel ID 4 29 | 30 | // Enable Publishing 31 | boolean EnableThingSpeak = false; // Change to true, to enable Loop reading and sending data to ThingSpeak. Default false. 32 | 33 | // Initialise ThingSpeak 34 | void InitialiseThingSpeak() 35 | { 36 | if (EnableThingSpeak == true && WiFi.status() == WL_CONNECTED) 37 | { 38 | ThingSpeak.begin(wlan_client); // Initialize ThingSpeak ################################################################# 39 | Serial.println("Initialised ThingSpeak"); 40 | } 41 | 42 | } // void InitialiseThingSpeak() 43 | 44 | // Publish a Multi-Field Formatted ThingSpeak Message 45 | void SetThingSpeakField(unsigned long ChannelID, float SensorValue, int dPlaces = 1, int dWidth = 5) 46 | { 47 | // Green LED 48 | digitalWrite(LED_Green, LOW); 49 | 50 | // Structure ThingSpeak Payload 51 | char MQTTPayload[10]; 52 | dtostrf(SensorValue, dWidth, dPlaces, MQTTPayload); 53 | 54 | // Update Serial Monitor 55 | Serial.print("Sending ThingSpeak Message: "); 56 | Serial.print(ChannelID); 57 | Serial.print("\t"); 58 | Serial.println(MQTTPayload); 59 | 60 | ThingSpeak.setField(ChannelID, MQTTPayload); 61 | 62 | // Green LED 63 | digitalWrite(LED_Green, HIGH); 64 | 65 | } // PublishThingSpeakMessage 66 | 67 | // Publish ThingSpeak Values and Channels 68 | void PublishThingSpeakValues() 69 | { 70 | 71 | // ms publish every 5 sec 72 | 73 | // Examples to Set the Fields with Values [fields 1-8 available, variable, Decimal Places] 74 | SetThingSpeakField(1, LineVoltage1, 1); 75 | SetThingSpeakField(2, ActivePowerCT1, 1); 76 | SetThingSpeakField(3, ActivePowerCT2, 1); 77 | SetThingSpeakField(4, ActivePowerCT3), 2; 78 | SetThingSpeakField(5, CalculatedTotalPower, 1); 79 | SetThingSpeakField(6, TotalPowerFactor, 2); 80 | SetThingSpeakField(7, LineFrequency, 2); 81 | SetThingSpeakField(8, PCBTemperature), 1; 82 | 83 | /* Examples of Available Variables 84 | LineVoltage1, LineVoltage2, LineVoltage3, LineVoltageTotal, LineVoltageAverage 85 | LineCurrentCT1, LineCurrentCT2, LineCurrentCT3, LineCurrentCT4, LineCurrentCTN, LineCurrentTotal 86 | CalculatedPowerCT1, CalculatedPowerCT2, CalculatedPowerCT3, CalculatedPowerCT4, CalculatedPowerCTN, CalculatedTotalPower 87 | ActivePowerCT1, ActivePowerCT2, ActivePowerCT3, TotalActivePower, CalculatedTotalActivePower 88 | ActivePowerImportCT1, ActivePowerImportCT2, ActivePowerImportCT3, TotalActivePowerImport 89 | ActivePowerExportCT1, ActivePowerExportCT2, ActivePowerExportCT3, TotalActivePowerExport 90 | ReactivePowerCT1, ReactivePowerCT2, ReactivePowerCT3, TotalReactivePower, CalculatedTotalReactivePower 91 | ApparentPowerCT1, ApparentPowerCT2, ApparentPowerCT3, TotalApparentPower, CalculatedTotalApparentPower 92 | TotalActiveFundPower, TotalActiveHarPower 93 | PowerFactorCT1, PowerFactorCT2, PowerFactorCT3, TotalPowerFactor 94 | PhaseAngleCT1, PhaseAngleCT2, PhaseAngleCT3 95 | ChipTemperature, LineFrequency 96 | DCVoltage, PCBTemperature 97 | PWMLocalPower, PWMRemotePower, PWMPowerOutput, PWMPowerPercentage 98 | DACLocalPower, DACRemotePower, DACPowerPercentage, DACPowerOutput 99 | 100 | *Control 101 | EnablePWMLocal, EnablePWMRemote, EnablePWMTestOutput 102 | EnableDACLocal, EnableDACRemote, EnableDACTestOutput 103 | */ 104 | 105 | // NTP Time and Pre-Format Example Message for Channel Status Updates 106 | timeClient.update(); 107 | ThingSpeak.setStatus(HostName + " Last Test Publish: " + timeClient.getFormattedTime()); 108 | 109 | // Publish a Multi-Field Formatted ThingSpeak Channel. Return Codes 110 | int x = ThingSpeak.writeFields(myChannelNumber1, myWriteAPIKey1); 111 | 112 | if (x == 200) // OK / Success 113 | { 114 | Serial.println("ThingSpeak Channel " + String(myChannelNumber1) + " Successfully Updated"); 115 | } 116 | else if (x == 404) // Incorrect API key (or invalid ThingSpeak server address) 117 | { 118 | // Red LED 119 | digitalWrite(LED_Red, LOW); 120 | 121 | Serial.println("ThingSpeak Channel " + String(myChannelNumber1) + " Not Updated. Key Error (" + String(x) + ")"); 122 | 123 | // Update OLED 124 | oled.clear(); 125 | OLEDPrint("Error 404", 2, 0); 126 | OLEDPrint("ThingSpeak", 2, 2); 127 | oled.update(); 128 | delay(1000); 129 | 130 | // Red LED 131 | digitalWrite(LED_Red, HIGH); 132 | } 133 | else if (x == -401) // Point was not inserted (most probable cause is the rate limit of once every 15 seconds) 134 | { 135 | // Red LED 136 | digitalWrite(LED_Red, LOW); 137 | 138 | Serial.println("ThingSpeak Channel " + String(myChannelNumber1) + " Not Updated. Rate Error (" + String(x) + ")"); 139 | 140 | // Update OLED 141 | oled.clear(); 142 | OLEDPrint("Error 401", 2, 0); 143 | OLEDPrint("ThingSpeak", 2, 2); 144 | oled.update(); 145 | delay(1000); 146 | 147 | // Red LED 148 | digitalWrite(LED_Red, HIGH); 149 | } 150 | else 151 | { 152 | // Red LED 153 | digitalWrite(LED_Red, LOW); 154 | 155 | Serial.println("ThingSpeak Channel " + String(myChannelNumber1) + " Not Updated. Other Error (" + String(x) + ")"); 156 | 157 | // Update OLED 158 | oled.clear(); 159 | OLEDPrint("Error ?", 2, 0); 160 | OLEDPrint("ThingSpeak", 2, 2); 161 | oled.update(); 162 | delay(1000); 163 | 164 | // Red LED 165 | digitalWrite(LED_Red, HIGH); 166 | } 167 | 168 | Serial.println(""); 169 | 170 | } // PublishThingSpeakValues 171 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/include/WiFi-OTA.h: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | 5 | Full header information in main.cpp. 6 | 7 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 8 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | 10 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and also github.com/DitroniX 11 | 12 | Note: Adding an SSID will Automatically ENABLE WiFi attempt to Log-In. 13 | 14 | Preamble. This WiFi-OTA will: 15 | * Configure WiFi Parameters (e.g. ssid etc.) 16 | * Configure Optional Static IP Address (leave 0,0,0,0 for DHCP settings) 17 | * Connect to WiFi 18 | * Create a Network Port in Serial Devices 19 | * Display WiFI detail on OLED 20 | * Display Web Information Page (Put IP in Browser) 21 | * Display Push OTA Page (Remote Uploading of BIN Files) 22 | 23 | WebServer URL Commands. An example is http://ipaddress/pwm-on e.g. http:192.168.0.5/pwm-on 24 | * /pwm-local - This is Enable PWM to take use Local Power reading from specified variable and output. 25 | * /pwm-remote - This is Enable PWM to take use Remote Power reading from specified variable and output. 26 | * /pwm-on - This is Enable PWM to take use Local Power reading from specified variable and output. 27 | * /pwm-off - This is Turn Off PWM Output 28 | * /pwm-test - This will turn on a test PWM Loop and output 29 | * /dac-local - This is Enable DAC to take use Local Power reading from specified variable and output. 30 | * /dac-remote - This is Enable DAC to take use Remote Power reading from specified variable and output. 31 | * /dac-on - This is Enable DAC to take use Local Power reading from specified variable and output. 32 | * /dac-off - This is Turn Off DAC Output 33 | * /dac-test - This will turn on a test DAC Loop and output 34 | 35 | To setup the Push OTA and Reflash The Board: 36 | * Once flashed, Open Web Page using IP Address in Web Browser (PC, Tablet, Phone). 37 | * Upload a BIN file. Compiled from PlatformIO. In Folder IPEM_1_Test_Code_ATM90E32_ATM90E36\.pio\build\wemos_d1_mini32\ 38 | */ 39 | 40 | // Libraries 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | // **************** VARIABLES / DEFINES / STATIC / STRUCTURES **************** 52 | 53 | // WiFi. Setup with your Wireless Information. Add more as needed. 54 | const char *ssid1 = ""; // WiFi Network SSID - Case Sensitive 55 | const char *password1 = ""; // WiFi Network password - Case Sensitive 56 | const char *ssid2 = ""; // WiFi Network SSID - Case Sensitive 57 | const char *password2 = ""; // WiFi Network password - Case Sensitive 58 | const char *ssid3 = ""; // WiFi Network SSID - Case Sensitive 59 | const char *password3 = ""; // WiFi Network password - Case Sensitive 60 | 61 | // WiFi. Force Disable for Testing. !!!!! BEWARE Outside of Local Developmet Do NOT Disable as OTA will NOT work !!!!! 62 | const boolean DisableWiFi = false; // Force Disable WiFi for Local USB Development and Testing Only. You can leave SSID/IP etc populated. 63 | 64 | // Set your Static IP address and Gateway - Alternatively leave at (0, 0, 0, 0) 65 | IPAddress local_IP(0, 0, 0, 0); // Leave at (0, 0, 0, 0) if DHCP required 66 | IPAddress gateway(0, 0, 0, 0); // Set to your Router IP = Gateway 67 | IPAddress subnet(255, 255, 255, 0); // Should not need to change subnet from default (255, 255, 255, 0) 68 | 69 | // Optional DNS Defaults. 70 | IPAddress primaryDNS(0, 0, 0, 0); // Defaults to your above Gateway IP if left as (0, 0, 0, 0) 71 | IPAddress secondaryDNS(8, 8, 4, 4); // For Google Public DNS use for Primary or Secondary (8,8,8,8) and/or (8,8,4,4) 72 | 73 | // WiFi Other 74 | WiFiClient wlan_client; // Initialize the Client Library / Client Instance 75 | WiFiMulti wifiMulti; // Multiple WiFi Options - Auto Scanning 76 | String HostNameHeader = AppAcronym + "-"; // Hostname Prefix 77 | String HostName; // Hostname 78 | // String RSSILevel; // WiFi RSSI Level Information 79 | const uint32_t connectTimeoutMs = 10000; // WiFi connect timeout per AP. Increase when connecting takes longer. 80 | 81 | // NTP Time 82 | WiFiUDP ntpUDP; 83 | NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000); 84 | // United Kingdom (London, Belfast) 85 | // TimeChangeRule BST = {"BST", Last, Sun, Mar, 1, 60}; // British Summer Time 86 | // TimeChangeRule GMT = {"GMT", Last, Sun, Oct, 2, 0}; // Standard Time 87 | // Timezone UK(BST, GMT); 88 | 89 | // Web Server. 90 | WebServer server(80); 91 | String page_header, page_css, page_title, page_board, page_wifi, page_detail, page_updater, page_footer; 92 | 93 | // ######### FUNCTIONS ######### 94 | 95 | // Return Some Meaningful Information From RSSI 96 | String RSSI_Info(int RSSI_Value) 97 | { 98 | switch (-RSSI_Value) // Inverted dBm Level ;) 99 | { 100 | { 101 | case 0 ... 30: 102 | return "Signal Very Strong"; 103 | break; 104 | case 31 ... 50: 105 | return "Signal Excellent"; 106 | break; 107 | case 51 ... 60: 108 | return "Signal Healthy"; 109 | break; 110 | case 61 ... 70: 111 | return "Signal Very Good"; 112 | break; 113 | case 71 ... 80: 114 | return "Signal Good"; 115 | break; 116 | case 81 ... 90: 117 | return "Signal Poor - Try Moving Position"; 118 | break; 119 | case 91 ... 100: 120 | return "Signal Very Low! - Move Position"; 121 | break; 122 | default: 123 | return "No Signal :("; 124 | break; 125 | } 126 | } 127 | 128 | } // RSSI_Info 129 | 130 | // Wifi Information 131 | void DisplayWiFiConfiguration() 132 | { 133 | 134 | // RSSIInformation(); 135 | 136 | PrintUnderline("Connection Details:"); 137 | Serial.println("WiFi SSID \t " + String(WiFi.SSID()) + " (Wifi Station Mode)"); 138 | 139 | if (local_IP.toString() == WiFi.localIP().toString().c_str()) 140 | { 141 | Serial.printf("WiFi IP \t %s (Static)\n", WiFi.localIP().toString().c_str()); 142 | } 143 | else 144 | { 145 | Serial.printf("WiFi IP \t %s (DHCP)\n", WiFi.localIP().toString().c_str()); 146 | } 147 | 148 | Serial.printf("WiFi MASK \t %s\n", WiFi.subnetMask().toString().c_str()); 149 | Serial.printf("WiFi GW \t %s\n", WiFi.gatewayIP().toString().c_str()); 150 | Serial.printf("WiFi DNS 1 \t %s\n", WiFi.dnsIP().toString().c_str()); 151 | Serial.printf("WiFi DNS 2 \t %s\n", WiFi.dnsIP(1).toString().c_str()); 152 | Serial.println("WiFi MAC \t " + WiFi.macAddress()); 153 | Serial.printf("WiFi Hostname \t %s\n", WiFi.getHostname()); 154 | Serial.println("WiFi RSSI \t " + String(WiFi.RSSI()) + " dBm (" + RSSI_Info(WiFi.RSSI()) + ")"); 155 | 156 | Serial.println(""); 157 | } // DisplayWiFiConfiguration 158 | 159 | // Force Hostname 160 | void ForceHostName(void) 161 | { 162 | HostName = HostNameHeader; 163 | HostName.concat(WiFi.macAddress().substring(WiFi.macAddress().length() - 5, WiFi.macAddress().length())); 164 | HostName.replace(":", ""); 165 | WiFi.setHostname(HostName.c_str()); 166 | HostName = WiFi.getHostname(); 167 | } // ForceHostName 168 | 169 | // Configure Static IP address (if not 0.0.0.0) 170 | void InitialiseStaticIP() 171 | 172 | { 173 | if (local_IP.toString() != "0.0.0.0") 174 | { 175 | // Serial.printf("WiFI Current IP\t \t %s\n", WiFi.localIP().toString().c_str()); 176 | 177 | if (primaryDNS.toString() != "0.0.0.0") 178 | { 179 | if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) 180 | ; 181 | { 182 | 183 | Serial.println("STA Static IP Failed to configure"); 184 | } 185 | } 186 | else // Use Gateway IP for DNS 1 187 | { 188 | if (!WiFi.config(local_IP, gateway, subnet, gateway, secondaryDNS)) 189 | { 190 | Serial.println("STA Static IP Failed to configure"); 191 | } 192 | } 193 | } 194 | } // InitialiseStaticIP 195 | 196 | // Initialise WiFi 197 | void InitialiseWiFi() 198 | { 199 | 200 | // Connect or reconnect to WiFi 201 | if (WiFi.status() != WL_CONNECTED && strlen(ssid1)) 202 | { 203 | 204 | // Green LED 205 | digitalWrite(LED_Green, LOW); 206 | 207 | // App and Starting... 208 | oled.clear(); 209 | OLEDPrint(AppAcronym, 2, 0); 210 | OLEDPrint("Cnx Wi-Fi ", 2, 2); 211 | oled.update(); 212 | 213 | // Wifi Settings 214 | WiFi.mode(WIFI_STA); 215 | WiFi.setAutoReconnect(true); 216 | WiFi.persistent(true); 217 | 218 | // Multi-WiFi Connections. Add more as needed. 219 | if (strlen(ssid1)) 220 | wifiMulti.addAP(ssid1, password1); 221 | if (strlen(ssid2)) 222 | wifiMulti.addAP(ssid2, password2); 223 | if (strlen(ssid3)) 224 | wifiMulti.addAP(ssid3, password3); 225 | 226 | Serial.println("Scanning WiFi Networks... Please wait..."); 227 | int n = WiFi.scanNetworks(); 228 | 229 | if (n == 0) 230 | { 231 | Serial.println("No Wi-FI Networks Found"); 232 | } 233 | else 234 | { 235 | Serial.print(n); 236 | Serial.println(" x Wi-Fi Networks Found"); 237 | for (int i = 0; i < n; ++i) 238 | { 239 | // Print SSID and RSSI for Each Network Found 240 | Serial.print(" "); 241 | Serial.print(i + 1); 242 | Serial.print(": "); 243 | Serial.printf("%25s", WiFi.SSID(i).c_str()); 244 | Serial.print(" ("); 245 | Serial.print(WiFi.RSSI(i)); 246 | Serial.print(" dBm " + RSSI_Info(WiFi.RSSI(i)) + ")"); 247 | Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " " : "*"); 248 | delay(10); 249 | } 250 | } 251 | 252 | // Connect to Wi-Fi using wifiMulti (connects to the SSID with strongest connection) 253 | Serial.println("\nConnecting WiFi..."); 254 | 255 | while (wifiMulti.run() != WL_CONNECTED) 256 | { // Wait for the Wi-Fi to connect: scan for Wi-Fi networks, and connect to the strongest of the networks above 257 | delay(500); 258 | Serial.print('.'); 259 | } 260 | 261 | // Green LED 262 | digitalWrite(LED_Green, HIGH); 263 | 264 | // if (wifiMulti.run() == WL_CONNECTED) 265 | { 266 | // // Stabalise for Slow Access Points 267 | // while (WiFi.status() != WL_CONNECTED) 268 | // { 269 | // delay(500); 270 | // Serial.print("."); 271 | // } 272 | 273 | Serial.println("Connected to " + String(WiFi.SSID()) + "\n"); 274 | 275 | delay(500); 276 | 277 | // Force Local IP and Make Static 278 | InitialiseStaticIP(); 279 | 280 | ForceHostName(); 281 | 282 | // Wifi Information 283 | DisplayWiFiConfiguration(); 284 | 285 | // Time Server 286 | timeClient.begin(); 287 | // } 288 | } 289 | } 290 | } // InitialiseWiFi 291 | 292 | void WebServerPageContent(void) 293 | { 294 | // This section is made up of HTML/CSS Strings, which the ESP32 Web Server will hopefully deliver the page content. 295 | page_header = "" + AppAcronym + " v" + AppVersion + " ESP32 Home"; 296 | page_css = ""; 297 | page_title = "

Welcome to the " + AppAcronym + " - Local Web Portal

" + AppName + "
(Firmware Version " + AppVersion + ")

"; 298 | page_board = "

Board Location: " + LocationName + "     Device: ATM90E" + ATM90DEVICE + "     MAC Address: " + String(WiFi.macAddress()) + "

"; 299 | page_wifi = "

Board Hostname: " + HostName + "     Wi-Fi SSID: " + String(WiFi.SSID()) + "     Wi-Fi RSSI: " + String(WiFi.RSSI()) + " dBm (" + RSSI_Info(WiFi.RSSI()) + ")" + "


"; 300 | page_detail = ""; 301 | page_updater = "

To Update the " + AppAcronym + " Firmware via Push OTA - Click Here

(Load compiled firmware.bin file - located in 'IPEM_1_Test_Code_ATM90E32_ATM90E36 > .pio > build > wemos_d1_mini32')


"; 302 | page_footer = "

Dave Williams   |   DitroniX  |  DitroniX.net  |  github.com/DitroniX  |  hackster.io/DitroniX

Buy Me A Coffee

"; 303 | } // WebServerPageContent 304 | 305 | // WebServer Pages 200 (and 400). 306 | void WebServerRoot() 307 | { 308 | page_updater.replace("localhost", WiFi.localIP().toString().c_str()); 309 | server.send(200, "text/html", page_header + page_css + page_title + page_board + page_wifi + page_detail + page_updater + page_footer); 310 | } // WebServerRoot 311 | 312 | // Initialise WebServer 313 | void InitialiseWebServer() 314 | { 315 | if (WiFi.status() == WL_CONNECTED) 316 | { 317 | Serial.println("Initialise WebServer"); 318 | 319 | WebServerPageContent(); 320 | 321 | // Web Server Listener 322 | server.on("/pwm-local", []() // Use Local CT Clamp to Derive PWM 323 | { 324 | Serial.println("Receiving Message: PWM Turn On\n"); 325 | PWM_Write(0); // Turn Output Off 326 | EnablePWMLocal = true; 327 | EnablePWMRemote = false; 328 | EnablePWMTestOutput = false; 329 | delay(100); WebServerRoot(); }); 330 | 331 | server.on("/pwm-on", []() // Use Local CT Clamp to Derive PWM 332 | { 333 | Serial.println("Receiving Message: PWM Turn On\n"); 334 | PWM_Write(0); // Turn Output Off 335 | EnablePWMLocal = true; 336 | EnablePWMRemote = false; 337 | EnablePWMTestOutput = false; 338 | delay(100); WebServerRoot(); }); 339 | 340 | server.on("/pwm-remote", []() // Use Remote Value to Derive PWM 341 | { 342 | Serial.println("Receiving Message: PWM Turn On Remote Power\n"); 343 | PWM_Write(0); // Turn Output Off 344 | EnablePWMLocal = false; 345 | EnablePWMRemote = true; 346 | EnablePWMTestOutput = false; 347 | delay(100); WebServerRoot(); }); 348 | 349 | server.on("/pwm-off", []() // Zero and then Disable PWM Output 350 | { 351 | Serial.println("Receiving Message: PWM Turn Off\n"); 352 | PWM_Write(0); // Turn Output Off 353 | EnablePWMLocal = false; 354 | EnablePWMRemote = false; 355 | EnablePWMTestOutput = false; 356 | delay(100); WebServerRoot(); }); 357 | 358 | server.on("/pwm-test", []() // Use to Enable PWM Test Output 359 | { 360 | Serial.println("Receiving Message: PWM Turn Off\n"); 361 | PWM_Write(0); // Turn Output Off 362 | EnablePWMLocal = false; 363 | EnablePWMRemote = false; 364 | EnablePWMTestOutput = true; 365 | delay(100); WebServerRoot(); }); 366 | 367 | server.on("/dac-local", []() // Use Local CT Clamp to Derive DAC Output Voltage 368 | { 369 | Serial.println("Receiving Message: DAC Turn On\n"); 370 | DAC_WriteVoltage(0); // Turn Output Off 371 | EnableDACLocal = true; 372 | EnableDACRemote = false; 373 | EnableDACTestOutput = false; 374 | delay(100); WebServerRoot(); }); 375 | 376 | server.on("/dac-on", []() // Use Local CT Clamp to Derive DAC Output Voltage 377 | { 378 | Serial.println("Receiving Message: DAC Turn On\n"); 379 | DAC_WriteVoltage(0); // Turn Output Off 380 | EnableDACLocal = true; 381 | EnableDACRemote = false; 382 | EnableDACTestOutput = false; 383 | delay(100); WebServerRoot(); }); 384 | 385 | server.on("/dac-remote", []() // Use Remote Value to Derive DAC Output Voltage 386 | { 387 | Serial.println("Receiving Message: DAC Turn On Remote Power\n"); 388 | DAC_WriteVoltage(0); // Turn Output Off 389 | EnableDACLocal = false; 390 | EnableDACRemote = true; 391 | EnableDACTestOutput = false; 392 | delay(100); WebServerRoot(); }); 393 | 394 | server.on("/dac-test", []() // Use to Enable DAC Test Output 395 | { 396 | Serial.println("Receiving Message: DAC Turn On Remote Power\n"); 397 | DAC_WriteVoltage(0); // Turn Output Off 398 | EnableDACLocal = false; 399 | EnableDACRemote = false; 400 | EnableDACTestOutput = true; 401 | delay(100); WebServerRoot(); }); 402 | 403 | server.on("/dac-off", []() // Zero and then Disable DAC Output Voltage 404 | { 405 | Serial.println("Receiving Message: DAC Turn Off\n"); 406 | DAC_WriteVoltage(0); // Turn Output Off 407 | EnableDACLocal = false; 408 | EnableDACRemote = false; 409 | EnableDACTestOutput = false; 410 | delay(100); WebServerRoot(); }); 411 | 412 | // Display Web Page Upon Client Request 413 | server.on("", WebServerRoot); 414 | 415 | // Display Web Page Upon Invalid URL Client Request. Faster than redirecting a 404 error. 416 | server.onNotFound(WebServerRoot); 417 | 418 | // Ignore SerialMonitor _handleRequest(). Future Options. 419 | 420 | ElegantOTA.begin(&server); // Start ElegantOTA 421 | server.begin(); 422 | Serial.println("HTTP Web Server Started"); 423 | Serial.println("Webpage can be found http://" + WiFi.localIP().toString() + "\n"); 424 | } 425 | } // InitialiseWebServer 426 | 427 | // Display Web Server Page for Information and OTA 428 | void CheckOTA() 429 | { 430 | if (WiFi.status() == WL_CONNECTED) 431 | { 432 | WebServerPageContent(); // Refresh Content. NB.Temporary Solution. 433 | server.handleClient(); 434 | } 435 | 436 | } // CheckOTA 437 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:wemos_d1_mini32] 12 | platform = espressif32 13 | board = wemos_d1_mini32 14 | framework = arduino 15 | upload_speed = 921600 16 | monitor_speed = 115200 17 | 18 | lib_deps = 19 | argandas/serialEEPROM@^2.0.1 20 | openenergymonitor/EmonLib@^1.1.0 21 | arduino-libraries/NTPClient@^3.2.1 22 | gyverlibs/GyverOLED@^1.6.1 23 | ayushsharma82/ElegantOTA @ ^2.2.9 24 | me-no-dev/ESP Async WebServer @ ^1.2.3 25 | knolleary/PubSubClient @ ^2.8 26 | mathworks/ThingSpeak @ ^2.0.0 27 | yellobyte/DacESP32 @ ^1.0.11 28 | 29 | 30 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_ATM90E32_ATM90E36/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Test Runner and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PlatformIO Unit Testing: 11 | - https://docs.platformio.org/en/latest/advanced/unit-testing/index.html 12 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_CT4_Clamp/IPEM_1_Test_Code_CT4_Clamp.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | Features include ESP32 IPEM ESP32 ATM90E32 ATM90E36 16bit ADC EEPROM 3Phase 3+1 CT-Clamps Current Voltage Frequency Power Factor GPIO I2C OLED SMPS D1 USB 5 | PCA 1.2302-201 - Test Code Firmware v1 - 17th March 2023 6 | 7 | The purpose of this test code is to cycle through the various main functions of the board, as shown below, as part of board bring up testing. 8 | 9 | Simplified Board Bring Up Test - CT4 Clamp into ESP32 (Output sent to Serial Print) 10 | 11 | Remember! 12 | Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 13 | You may set the BAUD rate to 921600 to speed up flashing. 14 | The SDK does NOT need external power to flash. It will take Power from the USB 5V. 15 | 16 | Note: In the default state, upon first power up and during reset, the Green LED may be partially lit. Once programmed and the GPIO defined, the Green LED will go off after power up. 17 | 18 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 19 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | 21 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and github.com/DitroniX 22 | */ 23 | 24 | // Libraries 25 | #include 26 | #include 27 | 28 | // **************** VARIABLES / DEFINES / STATIC **************** 29 | 30 | // Constants 31 | const int LoopDelay = 1; // Loop Delay in Seconds 32 | 33 | // Variables 34 | double Irms; 35 | 36 | // **************** OUTPUTS **************** 37 | #define LED_Red 2 // Red LED 38 | #define LED_Green 4 // Green LED 39 | 40 | // **************** INPUTS **************** 41 | #define CT_IN 35 //GPIO 35 (Analog ADC 1 CH7) 42 | 43 | // Force EmonLib to use 1bit ADC resolution 44 | #define ADC_BITS 12 45 | #define ADC_COUNTS (1 << ADC_BITS) 46 | #define HOME_VOLTAGE 230.0 47 | //#define emonTxV3 //Force the library to use 3v3 as supply voltage 48 | 49 | // EnergyMonitor Instance. 50 | EnergyMonitor emon1; 51 | 52 | void setup() { 53 | 54 | // Stabalise 55 | delay(250); 56 | 57 | // Initialise UART: 58 | Serial.begin(115200, SERIAL_8N1); //115200 59 | while (!Serial) 60 | ; 61 | Serial.println(""); 62 | 63 | // LEDs 64 | pinMode(LED_Red, OUTPUT); 65 | pinMode(LED_Green, OUTPUT); 66 | 67 | // LEDs Default Off State 68 | digitalWrite(LED_Red, HIGH); 69 | digitalWrite(LED_Green, HIGH); 70 | 71 | // adc1_config_channel_atten(ADC1_CHANNEL_5, ADC_ATTEN_DB_11); 72 | // analogReadResolution(ADC_BITS); 73 | 74 | // Initialize emon library (30 = calibration number, adjust as needed) 75 | // Set to 260 for low current test < 1.5A. Update Value as required. 76 | emon1.current(CT_IN, 260); 77 | } 78 | 79 | void loop() { 80 | 81 | double amps = emon1.calcIrms(7400); // Calculate Irms only. Update Value as required. 82 | amps = amps / 1000; 83 | double watt = amps * HOME_VOLTAGE; 84 | 85 | //if (amps > 0.15) { // Filter out any noise 86 | 87 | // Update the display 88 | Serial.print((int)watt); 89 | Serial.print(" W \t"); 90 | Serial.print(amps); 91 | Serial.println(" A"); 92 | 93 | Serial.println("\n- - - - - - - - - - - - - - - - - - - -"); 94 | //} 95 | 96 | // Heatbeat LED 97 | digitalWrite(LED_Red, LOW); 98 | delay(50); 99 | digitalWrite(LED_Red, HIGH); 100 | 101 | // Loop Delay 102 | delay(LoopDelay * 1000); 103 | } 104 | -------------------------------------------------------------------------------- /Code/IPEM_1_Test_Code_I2C_Scanner_EEPROM/IPEM_1_Test_Code_I2C_Scanner_EEPROM.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Dave Williams, DitroniX 2019-2023 (ditronix.net) 3 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor v1.0 4 | Features include ESP32 IPEM ESP32 ATM90E32 ATM90E36 16bit ADC EEPROM 3Phase 3+1 CT-Clamps Current Voltage Frequency Power Factor GPIO I2C OLED SMPS D1 USB 5 | PCA 1.2302-201 - Test Code Firmware v1 - 18th February 2023 6 | 7 | The purpose of this test code is to cycle through the various main functions of the board, as shown below, as part of board bring up testing. 8 | 9 | Simplified Board Bring Up Test - I2C Bus Scanner and EEPROM Basic Test (Output sent to the Serial Print - ONLY ON BOOT! Press RESET to REFRESH) 10 | 11 | Remember! 12 | Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 13 | You may set the BAUD rate to 921600 to speed up flashing. 14 | The SDK does NOT need external power to flash. It will take Power from the USB 5V. 15 | 16 | Note: In the default state, upon first power up and during reset, the Green LED may be partially lit. Once programmed and the GPIO defined, the Green LED will go off after power up. 17 | 18 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 19 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | 21 | Further information, details and examples can be found on our website wiki pages ditronix.net/wiki and github.com/DitroniX 22 | */ 23 | 24 | // Libraries 25 | #include 26 | #include 27 | 28 | // **************** VARIABLES / DEFINES / STATIC **************** 29 | 30 | // Constants 31 | const int LoopDelay = 1; // Loop Delay in Seconds 32 | 33 | // Variables 34 | unsigned short ReadValue; 35 | 36 | // **************** OUTPUTS **************** 37 | #define LED_Red 2 // Red LED 38 | #define LED_Green 4 // Green LED 39 | 40 | // Define I2C (Expansion Port) 41 | #define I2C_SDA 21 42 | #define I2C_SCL 22 43 | 44 | // EEPROM 45 | #define EEPROM_SIZE 1 46 | 47 | // **************** FUNCTIONS AND ROUTINES **************** 48 | 49 | void ScanI2CBus() { // I2C Bus Scanner 50 | 51 | byte error, address; 52 | int nDevices; 53 | 54 | Serial.println("Scanning I2C Bus for Devices ..."); 55 | 56 | nDevices = 0; 57 | for (address = 1; address < 127; address++) { 58 | Wire.beginTransmission(address); 59 | error = Wire.endTransmission(); 60 | if (error == 0) { 61 | Serial.print("I2C device found at address Decimal "); 62 | if (address < 16) { 63 | Serial.print("0"); 64 | } 65 | Serial.print(address); 66 | Serial.print(" = Hex 0x"); 67 | Serial.print(address, HEX); 68 | if (address == 80) Serial.print(" EEPROM"); 69 | Serial.println(); 70 | 71 | nDevices++; 72 | } else if (error == 4) { 73 | Serial.print("Unknown error at address Decimal "); 74 | if (address < 16) { 75 | Serial.print("0"); 76 | } 77 | Serial.print(address); 78 | Serial.print(" = Hex 0x"); 79 | Serial.println(address, HEX); 80 | } 81 | } 82 | if (nDevices == 0) { 83 | Serial.println("No I2C devices found. Possible Hardware Issue?"); 84 | } else { 85 | Serial.println("I2C Bus Scan Complete"); 86 | } 87 | } 88 | 89 | void ReadEEPROM() { // Read EEPROM Test 90 | Serial.print("EEPROM Test Read Value = 0x"); 91 | ReadValue = EEPROM.read(0); 92 | Serial.print(ReadValue, HEX); 93 | if (ReadValue == 0x00) Serial.print(" Possible EEPROM Issue?"); // Blank New EEPROM should normally return 0xFF 94 | if (ReadValue == 0xFF) Serial.print(" Read OK. Possible Blank EEPROM"); 95 | Serial.println(); 96 | } 97 | 98 | // **************** SETUP **************** 99 | void setup() { 100 | 101 | // Stabalise 102 | delay(250); 103 | 104 | // Initialise UART 105 | Serial.begin(115200, SERIAL_8N1); //115200 106 | while (!Serial) 107 | ; 108 | Serial.println(""); 109 | 110 | // Initialize I2C 111 | Wire.begin(I2C_SDA, I2C_SCL); 112 | 113 | // LEDs 114 | pinMode(LED_Red, OUTPUT); 115 | pinMode(LED_Green, OUTPUT); 116 | 117 | // LEDs Default Off State 118 | digitalWrite(LED_Red, HIGH); 119 | digitalWrite(LED_Green, HIGH); 120 | 121 | // Initialize EEPROM 122 | EEPROM.begin(EEPROM_SIZE); 123 | 124 | // Hardware Tests 125 | ScanI2CBus(); 126 | ReadEEPROM(); 127 | } 128 | 129 | // **************** LOOP **************** 130 | void loop() { 131 | 132 | // Heatbeat LED 133 | digitalWrite(LED_Red, LOW); 134 | delay(50); 135 | digitalWrite(LED_Red, HIGH); 136 | 137 | // Loop Delay 138 | delay(LoopDelay * 1000); 139 | } -------------------------------------------------------------------------------- /Code/README.md: -------------------------------------------------------------------------------- 1 | **IPEM ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitor** 2 | 3 | ------------ 4 | 5 | **NEW FIRMWARE**: [**FliX**](https://github.com/DitroniX/FLIX-DitroniX-Power-Energy-Monitors-Firmware) is an Integrated Firmware for DitroniX Power Energy Monitor SDK Boards 6 | 7 | This folder contains IPEM Example Source Code. 8 | 9 | The main develpment code is https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/tree/main/Code/IPEM_1_Test_Code_ATM90E32_ATM90E36 10 | 11 | Remember! 12 | - Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 13 | - You may set the BAUD rate to 921600 to speed up flashing. 14 | - The SDK does NOT need external power to flash. It will take Power from the USB 5V. 15 | 16 | Note: In the default state, upon first power up and during reset, the Green LED may be partially lit. Once programmed and the GPIO defined, the Green LED will go off after power up. 17 | 18 | This test code is OPEN SOURCE and formatted for easier viewing. Although is is not intended for real world use, it may be freely used, or modified as needed. 19 | It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | 21 | 22 | ## **Further Information** 23 | 24 | Additional information, and other technical details on this project, maybe found in the related repository pages. 25 | 26 | **Repository Folders** 27 | 28 | - **Code** *(Code examples for Arduino IDE and PlatformIO)* 29 | - **Datasheets and Information** *(Component Datasheets, Schematics, Board Layouts, Photos, Technical Documentation)* 30 | - **Certification** *(Related Repository Project or Part, Certification Information)* 31 | 32 | **Repository Tabs** 33 | 34 | - **Wiki** *(Related Repository Wiki pages and Technical User Information)* 35 | - **Discussions** *(Related Repository User Discussion Forum)* 36 | - **Issues** *(Related Repository Technical Issues and Fixes)* 37 | 38 | *** 39 | 40 | We value our Customers, Users of our designs and STEM Communities, all over the World . Should you have any other questions, or feedback to share to others, please feel free to: 41 | 42 | * Visit the related [Project](https://github.com/DitroniX?tab=repositories) *plus the related* **Discussions** and **Wiki** Pages. See tab in each separate repository. 43 | * **Project Community Information** can be found at https://www.hackster.io/DitroniX 44 | * [DitroniX.net Website - Contact Us](https://ditronix.net/contact/) 45 | * **Twitter**: [https://twitter.com/DitroniX](https://twitter.com/DitroniX) 46 | * [Supporting the STEM Projects - BuyMeACoffee](https://www.buymeacoffee.com/DitroniX) 47 | * **LinkedIN**: [https://www.linkedin.com/in/g8puo/](https://www.linkedin.com/in/g8puo/) 48 | 49 | ***Dave Williams, Maidstone, UK.*** 50 | 51 | Electronics Engineer | Software Developer | R&D Support | RF Engineering | Product Certification and Testing | STEM Ambassador 52 | 53 | ## STEM 54 | 55 | **Supporting [STEM Learning](https://www.stem.org.uk/)** 56 | 57 | Life is one long exciting learning curve, help others by setting the seed to knowledge. 58 | 59 | ![DitroniX Supporting STEM](https://hackster.imgix.net/uploads/attachments/1606838/stem_ambassador_-_100_volunteer_badge_edxfxlrfbc1_bjdqharfoe1_xbqi2KUcri.png?auto=compress%2Cformat&w=540&fit=max) 60 | 61 | -------------------------------------------------------------------------------- /Datasheets and Information/AC Three Phase Sinewave Plot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/AC Three Phase Sinewave Plot.jpg -------------------------------------------------------------------------------- /Datasheets and Information/AP63203WU-7 3v3 2A 32V Datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/AP63203WU-7 3v3 2A 32V Datasheet.pdf -------------------------------------------------------------------------------- /Datasheets and Information/AT24C32-64 EEPROM Datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/AT24C32-64 EEPROM Datasheet.pdf -------------------------------------------------------------------------------- /Datasheets and Information/Atmel M90E32AS Datasheet (Annotated).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/Atmel M90E32AS Datasheet (Annotated).pdf -------------------------------------------------------------------------------- /Datasheets and Information/Atmel M90E36A Datasheet (Annotated).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/Atmel M90E36A Datasheet (Annotated).pdf -------------------------------------------------------------------------------- /Datasheets and Information/Atmel-46003-SE-M90E32AS-Datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/Atmel-46003-SE-M90E32AS-Datasheet.pdf -------------------------------------------------------------------------------- /Datasheets and Information/Atmel-46004-SE-M90E36A-Datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/Atmel-46004-SE-M90E36A-Datasheet.pdf -------------------------------------------------------------------------------- /Datasheets and Information/Atmel-46103-SE-M90E32AS-ApplicationNote.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/Atmel-46103-SE-M90E32AS-ApplicationNote.pdf -------------------------------------------------------------------------------- /Datasheets and Information/Atmel-46104-SE-M90E36A- ApplicationNote .pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/Atmel-46104-SE-M90E36A- ApplicationNote .pdf -------------------------------------------------------------------------------- /Datasheets and Information/CH340 USB UART Interface Datasheet.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/CH340 USB UART Interface Datasheet.PDF -------------------------------------------------------------------------------- /Datasheets and Information/DitronIX Mains Calibration 3Phase R&D.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitronIX Mains Calibration 3Phase R&D.jpg -------------------------------------------------------------------------------- /Datasheets and Information/DitronIX Mains Calibration TestBox CloseUp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitronIX Mains Calibration TestBox CloseUp.jpg -------------------------------------------------------------------------------- /Datasheets and Information/DitronIX Mains Calibration TestBox Loads.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitronIX Mains Calibration TestBox Loads.jpg -------------------------------------------------------------------------------- /Datasheets and Information/DitronIX Mains Calibration TestBox Top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitronIX Mains Calibration TestBox Top.jpg -------------------------------------------------------------------------------- /Datasheets and Information/DitronIX Mains Calibration TestBox.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitronIX Mains Calibration TestBox.jpg -------------------------------------------------------------------------------- /Datasheets and Information/DitroniX IPEM Design Processes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitroniX IPEM Design Processes.jpg -------------------------------------------------------------------------------- /Datasheets and Information/DitroniX Mains Calibration TestBox Internal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitroniX Mains Calibration TestBox Internal.jpg -------------------------------------------------------------------------------- /Datasheets and Information/DitroniX Mains Test Fixture Outline IPEM 2303.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitroniX Mains Test Fixture Outline IPEM 2303.jpg -------------------------------------------------------------------------------- /Datasheets and Information/DitroniX.net Power Energy Monitor Boards SDK Overview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitroniX.net Power Energy Monitor Boards SDK Overview.jpg -------------------------------------------------------------------------------- /Datasheets and Information/DitroniX.net Power Energy Monitor Boards SDK Overview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitroniX.net Power Energy Monitor Boards SDK Overview.pdf -------------------------------------------------------------------------------- /Datasheets and Information/DitroniX.net STEM Energy Monitors SDK Board Options.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitroniX.net STEM Energy Monitors SDK Board Options.jpg -------------------------------------------------------------------------------- /Datasheets and Information/DitroniX.net STEM Energy Monitors SDK Board Options.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitroniX.net STEM Energy Monitors SDK Board Options.pdf -------------------------------------------------------------------------------- /Datasheets and Information/DitroniX.net STEM IoT eBay.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/DitroniX.net STEM IoT eBay.jpg -------------------------------------------------------------------------------- /Datasheets and Information/ESP32-WROOM-32E Datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/ESP32-WROOM-32E Datasheet.pdf -------------------------------------------------------------------------------- /Datasheets and Information/GreenBrook DAT01A Transformer.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/GreenBrook DAT01A Transformer.pdf -------------------------------------------------------------------------------- /Datasheets and Information/IPEM AC Input Connections.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM AC Input Connections.pdf -------------------------------------------------------------------------------- /Datasheets and Information/IPEM AC Input Connections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM AC Input Connections.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM ArduinoISE - Serial Monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM ArduinoISE - Serial Monitor.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM ESP32 ATM90E32 ATM90E36 SDK 1.2302.201P Schematic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM ESP32 ATM90E32 ATM90E36 SDK 1.2302.201P Schematic.pdf -------------------------------------------------------------------------------- /Datasheets and Information/IPEM ESP32 ATM90E32 ATM90E36 Variant SDK 1.2303.201PU.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM ESP32 ATM90E32 ATM90E36 Variant SDK 1.2303.201PU.pdf -------------------------------------------------------------------------------- /Datasheets and Information/IPEM ESP32 ATM90E32 Only Variant SDK 1.2303-201PU Schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM ESP32 ATM90E32 Only Variant SDK 1.2303-201PU Schematic.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM ESP32 ATM90E3x SDK 1.2302-202P Schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM ESP32 ATM90E3x SDK 1.2302-202P Schematic.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM ESP32UE ATM90E32 Variant SDK 1.2304.203P Schematic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM ESP32UE ATM90E32 Variant SDK 1.2304.203P Schematic.pdf -------------------------------------------------------------------------------- /Datasheets and Information/IPEM ESP32UE ATM90E36 Variant SDK 1.2306.204P Schematic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM ESP32UE ATM90E36 Variant SDK 1.2306.204P Schematic.pdf -------------------------------------------------------------------------------- /Datasheets and Information/IPEM PlatformIO - Home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM PlatformIO - Home.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM PlatformIO - MQTT Example in MQTT Explorer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM PlatformIO - MQTT Example in MQTT Explorer.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM PlatformIO - MQTT Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM PlatformIO - MQTT Example.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM PlatformIO - Serial Monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM PlatformIO - Serial Monitor.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM PlatformIO - WiFi Settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM PlatformIO - WiFi Settings.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM Power Energy Monitor Board Overview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM Power Energy Monitor Board Overview.jpg -------------------------------------------------------------------------------- /Datasheets and Information/IPEM Push OTA Web Home Page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM Push OTA Web Home Page.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM Push OTA Web Upload Page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM Push OTA Web Upload Page.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM ThingSpeak - ThingChart App.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM ThingSpeak - ThingChart App.jpg -------------------------------------------------------------------------------- /Datasheets and Information/IPEM ThingSpeak Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM ThingSpeak Example.png -------------------------------------------------------------------------------- /Datasheets and Information/IPEM with OLED Display.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM with OLED Display.jpg -------------------------------------------------------------------------------- /Datasheets and Information/IPEM with Transformer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM with Transformer.jpg -------------------------------------------------------------------------------- /Datasheets and Information/IPEM-3 and 1 Phase Installation.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM-3 and 1 Phase Installation.mp4 -------------------------------------------------------------------------------- /Datasheets and Information/IPEM-ESP32E-ATM90E32 - Shipping.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM-ESP32E-ATM90E32 - Shipping.jpg -------------------------------------------------------------------------------- /Datasheets and Information/IPEM-ESP32UE-ATM90E32 - Shipping.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/IPEM-ESP32UE-ATM90E32 - Shipping.jpg -------------------------------------------------------------------------------- /Datasheets and Information/Microchip Platform Energy Monitors.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/Microchip Platform Energy Monitors.pdf -------------------------------------------------------------------------------- /Datasheets and Information/Microchip-ATM90E3x Brochure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/Microchip-ATM90E3x Brochure.pdf -------------------------------------------------------------------------------- /Datasheets and Information/README.md: -------------------------------------------------------------------------------- 1 | **IPEM ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitor SDK** 2 | 3 | ------------ 4 | 5 | This folder contains applicable datasheets and IPEM design information. 6 | 7 | 8 | 9 | 10 | ## **Further Information** 11 | 12 | Additional information, and other technical details on this project, maybe found in the related repository pages. 13 | 14 | **Repository Folders** 15 | 16 | - **Code** *(Code examples for Arduino IDE and PlatformIO)* 17 | - **Datasheets and Information** *(Component Datasheets, Schematics, Board Layouts, Photos, Technical Documentation)* 18 | - **Certification** *(Related Repository Project or Part, Certification Information)* 19 | 20 | **Repository Tabs** 21 | 22 | - **Wiki** *(Related Repository Wiki pages and Technical User Information)* 23 | - **Discussions** *(Related Repository User Discussion Forum)* 24 | - **Issues** *(Related Repository Technical Issues and Fixes)* 25 | 26 | *** 27 | 28 | We value our Customers, Users of our designs and STEM Communities, all over the World . Should you have any other questions, or feedback to share to others, please feel free to: 29 | 30 | * Visit the related [Project](https://github.com/DitroniX?tab=repositories) *plus the related* **Discussions** and **Wiki** Pages. See tab in each separate repository. 31 | * **Project Community Information** can be found at https://www.hackster.io/DitroniX 32 | * [DitroniX.net Website - Contact Us](https://ditronix.net/contact/) 33 | * **Twitter**: [https://twitter.com/DitroniX](https://twitter.com/DitroniX) 34 | * [Supporting the STEM Projects - BuyMeACoffee](https://www.buymeacoffee.com/DitroniX) 35 | * **LinkedIN**: [https://www.linkedin.com/in/g8puo/](https://www.linkedin.com/in/g8puo/) 36 | 37 | ***Dave Williams, Maidstone, UK.*** 38 | 39 | Electronics Engineer | Software Developer | R&D Support | RF Engineering | Product Certification and Testing | STEM Ambassador 40 | 41 | ## STEM 42 | 43 | **Supporting [STEM Learning](https://www.stem.org.uk/)** 44 | 45 | Life is one long exciting learning curve, help others by setting the seed to knowledge. 46 | 47 | ![DitroniX Supporting STEM](https://hackster.imgix.net/uploads/attachments/1606838/stem_ambassador_-_100_volunteer_badge_edxfxlrfbc1_bjdqharfoe1_xbqi2KUcri.png?auto=compress%2Cformat&w=540&fit=max) 48 | 49 | -------------------------------------------------------------------------------- /Datasheets and Information/SCT013-000-100A-50mA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/SCT013-000-100A-50mA.pdf -------------------------------------------------------------------------------- /Datasheets and Information/SCT013-005-0-5A-0-1V.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/SCT013-005-0-5A-0-1V.pdf -------------------------------------------------------------------------------- /Datasheets and Information/SCT013-010-0-10A-0-1V.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/SCT013-010-0-10A-0-1V.pdf -------------------------------------------------------------------------------- /Datasheets and Information/SCT013-015-0-15A-0-1V.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/SCT013-015-0-15A-0-1V.pdf -------------------------------------------------------------------------------- /Datasheets and Information/SCT013-020-0-20A-0-1V.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/SCT013-020-0-20A-0-1V.pdf -------------------------------------------------------------------------------- /Datasheets and Information/SCT013-025-0-25A-0-1V.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/SCT013-025-0-25A-0-1V.pdf -------------------------------------------------------------------------------- /Datasheets and Information/SCT013-030-0-30A-0-1V.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/SCT013-030-0-30A-0-1V.pdf -------------------------------------------------------------------------------- /Datasheets and Information/SCT013-050-0-50A-0-1V.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/SCT013-050-0-50A-0-1V.pdf -------------------------------------------------------------------------------- /Datasheets and Information/SCT013-060-0-60A-0-1V.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/SCT013-060-0-60A-0-1V.pdf -------------------------------------------------------------------------------- /Datasheets and Information/SCT013-100-100A-1V.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/SCT013-100-100A-1V.pdf -------------------------------------------------------------------------------- /Datasheets and Information/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/Thumbs.db -------------------------------------------------------------------------------- /Datasheets and Information/Transformer Info.txt: -------------------------------------------------------------------------------- 1 | Example Double Insulated Bell Chime Transformer Part Number DAT01A (Greenbrook.co.uk) 2 | In-built thermal cut-out, short circuit and overload protection self re-setting. 4/8/12V AC Output @ 1A. 3 | 4 | Datasheet https://www.greenbrook.co.uk/mpattachment/file/download/id/46/ 5 | 6 | Available from a number of distributors, example https://www.tlc-direct.co.uk/Products/TCTR7.html 7 | 8 | Mains Input 9 | 246.2V RMS AC 10 | 11 | Secondary Output 12 | 4 = 6.4V RMS AC 13 | 8 = 12.8V RMS AC 16.43 DC 14 | 12 = 19.23V RMS AC 15 | 16 | The 12V Output setting performs the best and IPEM ATM90E32 and ATM90E36 VP Input has been designed for this. 17 | 18 | Note: IPEM AP SMPS Regulator Input Voltage, Absolute Max: 32 V DC 19 | 20 | -------------------------------------------------------------------------------- /Datasheets and Information/YHDC SCT013 CT Current Clamp Datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/YHDC SCT013 CT Current Clamp Datasheet.pdf -------------------------------------------------------------------------------- /Datasheets and Information/YHDC SCT013 CT Current Clamp Test Report.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/c4fb51aee4397cf0483cb704d0d76eccd40a180e/Datasheets and Information/YHDC SCT013 CT Current Clamp Test Report.pdf -------------------------------------------------------------------------------- /DitroniX.net Board Versions and Revisions.txt: -------------------------------------------------------------------------------- 1 | 2 | For various production reasons and component availability, our boards may require update. The below list contains any revision information summary. 3 | 4 | IPEM-1 ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitoring Energy Monitor Board SDK 5 | Features include ESP32 IPEM ESP32 ATM90E32 ATM90E36 16bit ADC EEPROM 3Phase 3+N 3+1 CT-Clamps Current Voltage Frequency 6 | 7 | *Production* 8 | 1.2304-203 Exactly the same as 1.2303-202 but has BOM specific updates for the ESP32E ATM90E32 AP63203 Variant for production. 9 | 1.2303-202 Final Production Release, same as 1.2302-201 but has reverted back to a CH340C and has an additional GP0/GP26 Link. 10 | 11 | *Pre-Production* 12 | 1.2303-201 Pre-Production Release, same as 1.2302-201 but has schematic text changes so both variants option CT4 with ESP32 ADC 13 | 1.2302-201 Pre-Production Release. Last minuted change from CH340C to CH340E due to supply issues. 14 | 1.2302-101 Beta Release 15 | 16 | 17 | 18 | ## **Further Information** 19 | 20 | Additional information, and other technical details on this project, maybe found in the related repository pages. 21 | 22 | **Repository Folders** 23 | 24 | - **Code** *(Code examples for Arduino IDE and PlatformIO)* 25 | - **Datasheets and Information** *(Component Datasheets, Schematics, Board Layouts, Photos, Technical Documentation)* 26 | - **Certification** *(Related Repository Project or Part, Certification Information)* 27 | 28 | **Repository Tabs** 29 | 30 | - **Wiki** *(Related Repository Wiki pages and Technical User Information)* 31 | - **Discussions** *(Related Repository User Discussion Forum)* 32 | - **Issues** *(Related Repository Technical Issues and Fixes)* 33 | 34 | *** 35 | 36 | We value our Customers, Users of our designs and STEM Communities, all over the World . Should you have any other questions, or feedback to share to others, please feel free to: 37 | 38 | * Visit the related [Project](https://github.com/DitroniX?tab=repositories) *plus the related* **Discussions** and **Wiki** Pages. See tab in each separate repository. 39 | * **Project Community Information** can be found at https://www.hackster.io/DitroniX 40 | * [DitroniX.net Website - Contact Us](https://ditronix.net/contact/) 41 | * **Twitter**: [https://twitter.com/DitroniX](https://twitter.com/DitroniX) 42 | * [Supporting the STEM Projects - BuyMeACoffee](https://www.buymeacoffee.com/DitroniX) 43 | * **LinkedIN**: [https://www.linkedin.com/in/g8puo/](https://www.linkedin.com/in/g8puo/) 44 | 45 | ***Dave Williams, Maidstone, UK.*** 46 | 47 | Electronics Engineer | Software Developer | R&D Support | RF Engineering | Product Certification and Testing | STEM Ambassador 48 | 49 | ## STEM 50 | 51 | **Supporting [STEM Learning](https://www.stem.org.uk/)** 52 | 53 | Life is one long exciting learning curve, help others by setting the seed to knowledge. 54 | 55 | ![DitroniX Supporting STEM](https://hackster.imgix.net/uploads/attachments/1606838/stem_ambassador_-_100_volunteer_badge_edxfxlrfbc1_bjdqharfoe1_xbqi2KUcri.png?auto=compress%2Cformat&w=540&fit=max) 56 | 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## IPEM ESP32 ATM90E32 ATM90E36 IoT Power Energy Monitor SDK 2 | 3 | **250112 UPDATED FIRMWARE**: [**FliX**](https://github.com/DitroniX/FLIX-DitroniX-Power-Energy-Monitors-Firmware) is an Integrated Firmware for DitroniX Power Energy Monitor SDK Boards 4 | 5 | IPEM Overview 6 | ![Display-Type-B](https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/blob/main/Datasheets%20and%20Information/IPEM%20Power%20Energy%20Monitor%20Board%20Overview.jpg?raw=true) 7 | 8 | The IPEM Kit 9 | ![Display-Type-B](https://ditronix.net/wp-content/uploads/2023/07/IPEM-ESP32-ATM90E32-ATM90E36-Variant-SDK-1.2303.202P-Kit-scaled.jpg?raw=true) 10 | 11 | IPEM with OLED 12 | ![Display-Type-B](https://ditronix.net/wp-content/uploads/2023/08/IPEM-with-OLED-Display.jpg?raw=true) 13 | 14 | **DitroniX.net Power Energy Monitor Boards SDK Overview** 15 | ![Display-Type-B](https://ditronix.net/wp-content/uploads/2023/08/DitroniX.net-Power-Energy-Monitor-Boards-SDK-Overview-scaled.jpg?raw=true) 16 | ------------ 17 | 18 | **IPEM Production - 3D Render** 19 | ![Display-Type-B](https://ditronix.net/wp-content/uploads/2023/07/IPEM-ESP32-ATM90E32-ATM90E36-SDK-1.2302.201P-3D-Model-v2.png?raw=true) 20 | 21 | **IPEM with Integrated Push OTA Example** 22 | ![Display-Type-B](https://ditronix.net/wp-content/uploads/2023/05/IPEM-Push-OTA-Web-Home-Page.png?raw=true) 23 | ![Display-Type-B](https://ditronix.net/wp-content/uploads/2023/05/IPEM-Push-OTA-Web-Upload-Page.png?raw=true) 24 | 25 | **IPEM Example Real-Time Output to ThingSpeak** 26 | ![Display-Type-B](https://ditronix.net/wp-content/uploads/2023/06/IPEM-ThingSpeak-Example.png?raw=true) 27 | 28 | **IPEM Example Real-Time Output to ThingSpeak into ThingChart on Mobile Phone App** 29 | ![Display-Type-B](https://hackster.imgix.net/uploads/attachments/1602282/ipem_thingspeak_-_thingchart_app_WLh2JVkBZ2.jpg?raw=true) 30 | 31 | Four fully tested versions of this board are available. Thye most popular being ESP32E (PCB Ant), plus ATM90E32. 32 | 33 | The board layout is designed to be a flexible dual purpose. 34 | - ESP32 WROOM, with Internal Antenna, or UF.L connector for external antenna 35 | - ATM90E32 or ATM90E36 36 | 37 | **CT Clamp Inputs** 38 | 39 | The forth CT input on the ATM90E32 board, which is included for the ATM90E36, now remains on the board and goes to the ESP32 ADC. So both 40 | board variants will have FOUR CT inputs. 41 | 42 | - **ATM90E32** 43 | - 3 x CT Line inputs to the ATM chip. 44 | - 1 x CT input to the ESP32 ADC. 45 | 46 | - **ATM90E36** 47 | - 3 x CT Line inputs to the ATM chip. 48 | - 1 x CT N input to the ATM chip or CT to ESP32 ADC 49 | - Alternative 1 x CT input to the ESP32 ADC. 50 | 51 | ------------ 52 | 53 | **IPEM with Transformer** 54 | 55 | ![Display-Type-B](https://github.com/DitroniX/IPEM-IoT-Power-Energy-Monitor/blob/main/Datasheets%20and%20Information/IPEM%20with%20Transformer.jpg?raw=true) 56 | 57 | 58 | The **IPEM IoT Power Energy Monitor** board main features: 59 | - **Compact** and **Flexible Design** SDK Board 60 | - All connections are **low voltage**, for **safe operation** 61 | - **Easy to interface** 62 | - *Optional* **Espressif** **ESP32** **WROOM** 63 | - **ESP32-WROOM-32E-N4** 64 | - Integral Antenna Wireless and Bluetooth 65 | - **ESP32-WROOM-32UE-N4** 66 | - Ext Antenna - U.FL Socket 67 | - Wireless and Bluetooth 68 | - *Optional* **ATM90E** Series 69 | - **ATM90E32** Energy Monitor 70 | - 3 x Phases Line CT Clamp Input 71 | - Example YHDC SCT013000 72 | - 3 x Voltage Inputs (AC RMS) 73 | - Power Modes Settings 74 | - **ATM90E36** Energy Monitor 75 | - 3 x Phases Line CT Clamp Input 76 | - Example YHDC SCT013000 77 | - 3 x Voltage Inputs (AC RMS) 78 | - 1 x Phase Neutral CT Clamp 79 | - DMA Mode (Logging via SPI) 80 | - Power Modes Settings 81 | - Auto DMA selection opton via GP12 82 | - **24C64** EEPROM 83 | - Parameter Settings 84 | - Logging 85 | - **OLED I2C** 86 | - I2C Interface 87 | - OLED I2C Connector 88 | - Configurable Power Pins 89 | - **AC Low Voltage** Input (for Safety) 90 | - Power safely derived from a SELV / Wall AC/AC Power Supply 91 | - 8 to 12V AC RMS 92 | - Examples GreenBrook DAT01A or TLC TC TR7 93 | - Onboard **3V3 DC SMPS** Power Supply 94 | - Power taken from AC Input 95 | - Arduino **Wemos D1 Compatible** USB Interface 96 | - On-board Micro USB Socket 97 | - Flashing and Programming 98 | - Example wemos_d1_mini32 99 | - Can also used to power the board 100 | - Debugging 101 | - On Board **NTC** (Temperature) 102 | - **USER GPIO/UART** 103 | - 2 GPIO for User (GP16 and GP17) 104 | - UART Interfacing (UART 2) 105 | - **Reset Button** 106 | - User **Programmable Button** 107 | - **RGB Status LED** 108 | - User Configurable 109 | - **Power LED** 110 | - On 3V3 111 | - **ATM CT LEDs** 112 | - CF1 - Active 113 | - CF2 - ReActive 114 | - CF3 - Fundamental 115 | - CF4 - Harmonic 116 | - PCB designed to fit into an BMC enclosure 117 | - Also allows for the display to be included, or not. 118 | - **Size** 70 mm x 53 mm 119 | 120 | 121 | 122 | ------------ 123 | 124 | **In The Box** 125 | 126 | ![Display-Type-B](https://ditronix.net/wp-content/uploads/2023/07/IPEM-ESP32-ATM90E32-ATM90E36-Variant-SDK-1.2303.202P-Kit-scaled.jpg?raw=true) 127 | 128 | External Antenna Version 129 | ![Display-Type-B](https://ditronix.net/wp-content/uploads/2023/07/IPEM-ESP32UE-ATM90E32-IoT-Power-Energy-Monitor-In-the-Box-scaled.jpg?raw=true) 130 | 131 | 132 | 133 | Our SDKs are WeMos D1 Mini flashing compatible 134 | Set the BOARD to ESP32, 'WEMOS D1 MINI ESP32' DEV Module (or similar). 135 | You can also set the BAUD rate to 921600 to speed up flashing. 136 | The SDK does NOT need external power to flash. It will take Power from the USB 5V. 137 | You will need to provide external 12V AC for power up of the Energy Monitor functions. You will need to provide a CT Current Clamp. Ideally YHDC SCT-013-000 138 | 139 | All test code is OPEN SOURCE and although is is not intended for real world use, it may be freely used, or modified as needed. It is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 140 | 141 | ## **Purchase** 142 | [![Display-Type-B](https://raw.githubusercontent.com/DitroniX/DitroniX/main/Files/DitroniX.net%20STEM%20IoT%20eBay.jpg?raw=true)](https://www.ebay.co.uk/usr/ditronixuk) 143 | 144 | Our STEM SDK boards and accessories are available from our online shops on [eBay](https://www.ebay.co.uk/usr/ditronixuk) 145 | ## **Further Information** 146 | 147 | Additional information, and other technical details on this project, maybe found in the related repository pages. 148 | 149 | **Repository Folders** 150 | 151 | - **Code** *(Code examples for Arduino IDE and PlatformIO)* 152 | - **Datasheets and Information** *(Component Datasheets, Schematics, Board Layouts, Photos, Technical Documentation)* 153 | - **Certification** *(Related Repository Project or Part, Certification Information)* 154 | 155 | **Repository Tabs** 156 | 157 | - **Wiki** *(Related Repository Wiki pages and Technical User Information)* 158 | - **Discussions** *(Related Repository User Discussion Forum)* 159 | - **Issues** *(Related Repository Technical Issues and Fixes)* 160 | 161 | *** 162 | 163 | We value our Customers, Users of our designs and STEM Communities, all over the World . Should you have any other questions, or feedback to share to others, please feel free to: 164 | 165 | * Visit the related [Project](https://github.com/DitroniX?tab=repositories) *plus the related* **Discussions** and **Wiki** Pages. See tab in each separate repository. 166 | * **Project Community Information** can be found at https://www.hackster.io/DitroniX 167 | * [DitroniX.net Website - Contact Us](https://ditronix.net/contact/) 168 | * **Twitter**: [https://twitter.com/DitroniX](https://twitter.com/DitroniX) 169 | * [Supporting the STEM Projects - BuyMeACoffee](https://www.buymeacoffee.com/DitroniX) 170 | * **LinkedIN**: [https://www.linkedin.com/in/g8puo/](https://www.linkedin.com/in/g8puo/) 171 | 172 | ***Dave Williams, Maidstone, UK.*** 173 | 174 | Electronics Engineer | Software Developer | R&D Support | RF Engineering | Product Certification and Testing | STEM Ambassador 175 | 176 | ## STEM 177 | 178 | **Supporting [STEM Learning](https://www.stem.org.uk/)** 179 | 180 | Life is one long exciting learning curve, help others by setting the seed to knowledge. 181 | 182 | ![DitroniX Supporting STEM](https://hackster.imgix.net/uploads/attachments/1606838/stem_ambassador_-_100_volunteer_badge_edxfxlrfbc1_bjdqharfoe1_xbqi2KUcri.png?auto=compress%2Cformat&w=540&fit=max) 183 | -------------------------------------------------------------------------------- /Transformer Info.txt: -------------------------------------------------------------------------------- 1 | Example Double Insulated Bell Chime Transformer Part Number DAT01A (Greenbrook.co.uk) 2 | In-built thermal cut-out, short circuit and overload protection self re-setting. 4/8/12V AC Output @ 1A. 3 | 4 | Datasheet https://www.greenbrook.co.uk/pub/media/pdfs/DAT01AIns.pdf 5 | 6 | Available from a number of distributors, example https://www.tlc-direct.co.uk/Products/TCTR7.html 7 | 8 | Mains Input 9 | 246.2V RMS AC 10 | 11 | Secondary Output 12 | 4 = 6.4V RMS AC 13 | 8 = 12.8V RMS AC 16.43 DC 14 | 12 = 19.23V RMS AC 15 | 16 | The 12V Output setting performs the best and IPEM ATM90E32 VP Input has been designed for this. 17 | 18 | Note: IPEM AP SMPS Regulator Input Voltage, Absolute Max: 32 V DC 19 | 20 | ## **Further Information** 21 | 22 | Additional information, and other technical details on this project, maybe found in the related repository pages. 23 | 24 | **Repository Folders** 25 | 26 | - **Code** *(Code examples for Arduino IDE and PlatformIO)* 27 | - **Datasheets and Information** *(Component Datasheets, Schematics, Board Layouts, Photos, Technical Documentation)* 28 | - **Certification** *(Related Repository Project or Part, Certification Information)* 29 | 30 | **Repository Tabs** 31 | 32 | - **Wiki** *(Related Repository Wiki pages and Technical User Information)* 33 | - **Discussions** *(Related Repository User Discussion Forum)* 34 | - **Issues** *(Related Repository Technical Issues and Fixes)* 35 | 36 | *** 37 | 38 | We value our Customers, Users of our designs and STEM Communities, all over the World . Should you have any other questions, or feedback to share to others, please feel free to: 39 | 40 | * Visit the related [Project](https://github.com/DitroniX?tab=repositories) *plus the related* **Discussions** and **Wiki** Pages. See tab in each separate repository. 41 | * **Project Community Information** can be found at https://www.hackster.io/DitroniX 42 | * [DitroniX.net Website - Contact Us](https://ditronix.net/contact/) 43 | * **Twitter**: [https://twitter.com/DitroniX](https://twitter.com/DitroniX) 44 | * [Supporting the STEM Projects - BuyMeACoffee](https://www.buymeacoffee.com/DitroniX) 45 | * **LinkedIN**: [https://www.linkedin.com/in/g8puo/](https://www.linkedin.com/in/g8puo/) 46 | 47 | ***Dave Williams, Maidstone, UK.*** 48 | 49 | Electronics Engineer | Software Developer | R&D Support | RF Engineering | Product Certification and Testing | STEM Ambassador 50 | 51 | ## STEM 52 | 53 | **Supporting [STEM Learning](https://www.stem.org.uk/)** 54 | 55 | Life is one long exciting learning curve, help others by setting the seed to knowledge. 56 | 57 | ![DitroniX Supporting STEM](https://hackster.imgix.net/uploads/attachments/1606838/stem_ambassador_-_100_volunteer_badge_edxfxlrfbc1_bjdqharfoe1_xbqi2KUcri.png?auto=compress%2Cformat&w=540&fit=max) 58 | 59 | 60 | --------------------------------------------------------------------------------