|
| 1 | +# Smart Meter |
| 2 | + |
| 3 | +This application is a prototype of **Smart Meter** designed on ARC IoT DK. It can measure household electricity consumption information, and then use **non-intrusive load identification technology** to identify electrical switch status. It uploads message to the **cloud platform**. The analog signal of current and Voltage is collected by **ATT7053AU** (*a power acquisition chip*). |
| 4 | + |
| 5 | +- [Smart Meter](#smart-meter) |
| 6 | + - [Introduction](#introduction) |
| 7 | + - [Function](#function) |
| 8 | + - [Appearance](#appearance) |
| 9 | + - [Video](#video) |
| 10 | + - [Hardware and Software Setup](#hardware-and-software-setup) |
| 11 | + - [Required Hardware](#required-hardware) |
| 12 | + - [Required Software](#required-software) |
| 13 | + - [Hardware Connection](#hardware-connection) |
| 14 | + - [User Manual](#user-manual) |
| 15 | + - [Before Running This Application](#before-running-this-application) |
| 16 | + - [Run This Application](#run-this-application) |
| 17 | + |
| 18 | +## Introduction |
| 19 | +The traditional meter can only measure the user's power consumption, but in today's more and more intelligent, concepts such as smart grid and smart home are gradually popularized and realized. Non-intrusive load identification uses meter data, combined with machine learning algorithms to analyze the power consumption status of all electrical equipment in the home. It is one of the key technologies for the refined management of power energy and the realization of the intelligentization of the whole house. This application embeds non-intrusive load identification technology into the end of the electric energy measurement equipment, and performs calculations on the end side to avoid waste of resources caused by a large amount of data upload, and at the same time, it can perform real-time load pattern recognition. This application is developed based on the Synopsys IoTDK platform, uses the Tensorflow Lite for Microcontroller neural network model for inference, and realizes the connection of device networking and the mobile phone and web pages of the cloud platform. |
| 20 | + |
| 21 | +### Function |
| 22 | +* Measure the electrical power. |
| 23 | +* Real-time non-intrusive load identification. |
| 24 | +* upload the message to the cloud platform. |
| 25 | + |
| 26 | + |
| 27 | +### Appearance |
| 28 | +* **System View** |
| 29 | +<img src="./doc/pic/system architecture.png" alt="System Architecture" style="zoom:60%;" /> |
| 30 | + |
| 31 | +### Video |
| 32 | + |
| 33 | +[Smart Meter with NILD][1] |
| 34 | + |
| 35 | +## Hardware and Software Setup |
| 36 | + |
| 37 | +### Required Hardware |
| 38 | +* Necessary Hardware: |
| 39 | + - ARC IoT Development Kit(IoT DK) *1 |
| 40 | + - ATT7053AU *1 |
| 41 | + - ESP8266 *1 |
| 42 | + - OLED *1 |
| 43 | + |
| 44 | +### Required Software |
| 45 | +* DesignWare ARC MetaWare Development Toolkit 2021.03 |
| 46 | +* [embARC open software platform][2] |
| 47 | +* [Tensorflow lite for microcontrollar][3] (the files have been all added into the projects) |
| 48 | +* Ali Cloud Platform |
| 49 | +* Serial port terminal, such as SecureCRT or Xshell |
| 50 | +* Python3.8 |
| 51 | +* Tensorflow 2.5 |
| 52 | + |
| 53 | +### Hardware Connection |
| 54 | +1. Connect ATT7053AU module to IoT DK 2x18 Pin Extension Header (Using SPI0 interface and SPI0_CS1 Pin). |
| 55 | +2. Connect OLED module to IoT DK 2x18 Pin Extension Header (Using IIC0 interface). |
| 56 | +3. Connect ESP8266 module to IoT DK 12 Pin Pmod connector Pmod_C (Using UART0 interface). |
| 57 | +4. Make sure your power regulator connect is correct,including the voltage and polarity. |
| 58 | + |
| 59 | +## User Manual |
| 60 | + |
| 61 | +### Before Running This Application |
| 62 | +* Download source code of **Smart Meter** from github. |
| 63 | +* Make sure all connection is correct again. |
| 64 | +* Passing Zero or Fire Wire of Socket Wire through Current Transformer on ATT7053AU. |
| 65 | +* Connect the zero line and live line to the Potential Transformer on ATT7053AU. |
| 66 | +* If you want to use the cloud platform, set up your own hotspot SSID and password. |
| 67 | + |
| 68 | + |
| 69 | +### Run This Application |
| 70 | +1. To build this applicaiton, select the proper board version, core configuration and build with selected toolchain using this command `make BOARD=iotdk BD_VER=10 CUR_CORE=arcem9d TOOLCHAIN=mw run`. |
| 71 | +2. Open your serial terminal such as Tera-Term on PC, and configure it to right COM port and 115200bps. |
| 72 | +3. Interact using IoT DK , serial port terminal and cloud platform. |
| 73 | + |
| 74 | +#### Makefile |
| 75 | + |
| 76 | +- Add the path of libmli.a to application library |
| 77 | + |
| 78 | + ``` |
| 79 | + # application library |
| 80 | + APPL_LIBS ?= third_party/arc_mli_iotdk_arcem9d/bin/libmli.a |
| 81 | + ``` |
| 82 | + |
| 83 | +- Selected u8glib here, then you can use [u8glib API][4] in your application: |
| 84 | + |
| 85 | + ``` |
| 86 | + MID_SEL = common u8glib |
| 87 | + ``` |
| 88 | + |
| 89 | + |
| 90 | +- Target options about IoT DK and toolchain: |
| 91 | + |
| 92 | + ``` |
| 93 | + TOOLCHAIN=mw |
| 94 | + BOARD=iotdk |
| 95 | + BD_VER=10 |
| 96 | + CUR_CORE=arcem9d |
| 97 | + ``` |
| 98 | + |
| 99 | +- The relative series of the root directory, here the path of the Makefile is `./embarc_osp/application/smart_meter/src/makefile`: |
| 100 | + |
| 101 | + ``` |
| 102 | + # root dir of embARC |
| 103 | + EMBARC_ROOT = ../../.. |
| 104 | + ``` |
| 105 | + |
| 106 | +- Directories of source files and header files, notice that it **is not recursive**: |
| 107 | + |
| 108 | + ``` |
| 109 | + # application source dirs |
| 110 | + |
| 111 | + APPL_CSRC_DIR = . \ |
| 112 | + tensorflow/lite/c \ |
| 113 | + tensorflow/lite/experimental/microfrontend/lib \ |
| 114 | + ./models |
| 115 | + |
| 116 | + APPL_CXXSRC_DIR = . \ |
| 117 | + ./models \ |
| 118 | + tensorflow/lite/core/api \ |
| 119 | + tensorflow/lite/experimental/microfrontend/lib \ |
| 120 | + tensorflow/lite/kernels \ |
| 121 | + tensorflow/lite/kernels/internal \ |
| 122 | + tensorflow/lite/micro \ |
| 123 | + tensorflow/lite/micro/arc_iotdk \ |
| 124 | + tensorflow/lite/micro/kernels \ |
| 125 | + tensorflow/lite/micro/kernels/arc_mli \ |
| 126 | + tensorflow/lite/micro/memory_planner \ |
| 127 | + tensorflow/lite/micro/testing \ |
| 128 | + |
| 129 | + # application include dirs |
| 130 | + APPL_INC_DIR = . \ |
| 131 | + ./models \ |
| 132 | + tensorflow/lite \ |
| 133 | + tensorflow/lite/c \ |
| 134 | + tensorflow/lite/core/api \ |
| 135 | + tensorflow/lite/experimental/microfrontend/lib \ |
| 136 | + tensorflow/lite/kernels \ |
| 137 | + tensorflow/lite/kernels/internal \ |
| 138 | + tensorflow/lite/micro \ |
| 139 | + tensorflow/lite/micro/kernels \ |
| 140 | + tensorflow/lite/micro/kernels/arc_mli \ |
| 141 | + tensorflow/lite/micro/memory_planner \ |
| 142 | + tensorflow/lite/micro/testing \ |
| 143 | + tensorflow/lite/schema \ |
| 144 | + third_party/arc_mli_iotdk_arcem9d/include \ |
| 145 | + third_party/arc_mli_iotdk_arcem9d/include/api \ |
| 146 | + third_party/flatbuffers/include \ |
| 147 | + third_party/flatbuffers/include/flatbuffers \ |
| 148 | + third_party/gemmlowp \ |
| 149 | + third_party/gemmlowp/fixedpoint \ |
| 150 | + third_party/gemmlowp/internal \ |
| 151 | + third_party/kissfft \ |
| 152 | + third_party/ruy |
| 153 | + ``` |
| 154 | + |
| 155 | +#### Program flow chart |
| 156 | +<img src="./doc/pic/program flow chat.png" alt="Program flow chart" style="zoom:30%;" /> |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | +#### Tensorflow Lite for Microcontrollor |
| 161 | + |
| 162 | +Placing the tflite model source code in `./models` folder. |
| 163 | + |
| 164 | +| folder/file | Function | |
| 165 | +| ------------- | -------------------------------------------------------- | |
| 166 | +| models | include tflite models source code and header file | |
| 167 | +| recongnize.cc | use Tensorflow Lite for Microcontrollor to run inference | |
| 168 | +| recongnize.h | the header of recongnize.cc | |
| 169 | + |
| 170 | +#### Driver |
| 171 | + |
| 172 | +| folder/file | Function | |
| 173 | +| -------------- | ----------------------------------------------- | |
| 174 | +| spi_att7053.cc | att7053 spi drivers,include read,write,init API | |
| 175 | +| spi_att7053.h | the header of att7053 drivers | |
| 176 | +| my_uart.cc | uart drivers | |
| 177 | +| my_uart.h | the head of uart driver | |
| 178 | + |
| 179 | +#### Network and Cloud Platform |
| 180 | + |
| 181 | +| folder/file | Function | |
| 182 | +| ------------------ | ---------------------------------------------------- | |
| 183 | +| esp8266_network.cc | connect to the hotspot by esp8266 | |
| 184 | +| esp8266_network.h | the head of esp8266_network | |
| 185 | +| self_mqtt.cc | the functions of Message Queuing Telemetry Transport | |
| 186 | +| self_mqtt.h | the head of mqtt | |
| 187 | + |
| 188 | +#### OLED Display |
| 189 | + |
| 190 | +| folder/file | Function | |
| 191 | +| -------------------- | -------------------------------------------------------- | |
| 192 | +| display.cc | interface function for using OLED to display information | |
| 193 | +| display.h | the hearder of display | |
| 194 | +| ssd1306_app_config.h | Definition of OLED Interface | |
| 195 | + |
| 196 | +[1]: https://v.youku.com/v_show/id_XNTE5MTkzMjQwNA==.html |
| 197 | +[2]: https://github.com/foss-for-synopsys-dwc-arc-processors/embarc_osp |
| 198 | +[3]: https://github.com/tensorflow/tflite-micro |
| 199 | +[4]: https://github.com/olikraus/u8glib/wiki |
0 commit comments