Skip to content

Commit a0c356b

Browse files
author
Unal,Volkan
committed
initial commit
0 parents  commit a0c356b

File tree

11 files changed

+867
-0
lines changed

11 files changed

+867
-0
lines changed

Diff for: .gitignore

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Object files
5+
*.o
6+
*.ko
7+
*.obj
8+
*.elf
9+
10+
# Linker output
11+
*.ilk
12+
*.map
13+
*.exp
14+
15+
# Precompiled Headers
16+
*.gch
17+
*.pch
18+
19+
# Libraries
20+
*.lib
21+
*.a
22+
*.la
23+
*.lo
24+
25+
# Shared objects (inc. Windows DLLs)
26+
*.dll
27+
*.so
28+
*.so.*
29+
*.dylib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app
35+
*.i*86
36+
*.x86_64
37+
*.hex
38+
39+
# Debug files
40+
*.dSYM/
41+
*.su
42+
*.idb
43+
*.pdb
44+
45+
# Kernel Module Compile Results
46+
*.mod*
47+
*.cmd
48+
.tmp_versions/
49+
modules.order
50+
Module.symvers
51+
Mkfile.old
52+
dkms.conf
53+
54+
# Eclipse
55+
.metadata/
56+
RemoteSystemsTempFiles/.project
57+
.settings/
58+
*.a
59+
*.o
60+
*.d
61+
.cproject
62+
.project
63+
sdkconfig
64+
sdkconfig.old
65+
**/build/
66+
**/esp_idf_components/
67+
#doxygen
68+
Doxyfile
69+
.project
70+
.cproject
71+
72+
# Visual Studio Code
73+
.vscode/

Diff for: CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# For more information about build system see
2+
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
3+
# The following five lines of boilerplate have to be in your project's
4+
# CMakeLists in this exact order for cmake to work correctly
5+
cmake_minimum_required(VERSION 3.5)
6+
7+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
8+
get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
9+
string(REPLACE " " "_" ProjectId ${ProjectId})
10+
project(${ProjectId})

Diff for: Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
3+
# project subdirectory.
4+
#
5+
6+
PROJECT_NAME := sample_project
7+
8+
include $(IDF_PATH)/make/project.mk

Diff for: README.md

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# What is esp32-iec62056-component
2+
3+
esp32-iec62056-component is a pure C esp-idf component for ESP32 that allows reading electricity meters with optical eye.
4+
5+
## Example
6+
7+
The project **example** contains one source file in C language [main.c](main/main.c). The file is located in folder [main](main).
8+
9+
## List of events
10+
* IEC1107_PROTOCOL_ERROR
11+
* IEC1107_START_MESSAGE_NOT_SENDED
12+
* IEC1107_START_MESSAGE_SENDED
13+
* IEC1107_START_MESSAGE_NOT_RECIEVED
14+
* IEC1107_START_MESSAGE_RECEIVED
15+
* IEC1107_READOUT_MESSAGE_SENDED
16+
* IEC1107_READOUT_MESSAGE_NOT_RECEIVED
17+
* IEC1107_READOUT_MESSAGE_RECEIVED
18+
* IEC1107_FIELDS_UPDATED
19+
20+
## When you adding esp32-iec62056-component to your code
21+
```
22+
#include "iec1107.h"
23+
```
24+
25+
Add this two line
26+
```
27+
extern export_values_t* export_hdl;
28+
extern const int export_params_size;
29+
```
30+
31+
Event handler function
32+
```
33+
static void iec1107_event_handler(void* event_handler_arg, esp_event_base_t event_base, int32_t event_id, void* event_data)
34+
{
35+
switch(event_id)
36+
{
37+
case IEC1107_PROTOCOL_ERROR:
38+
ESP_LOGI("Event Handler", "IEC1107_PROTOCOL_ERROR");
39+
break;
40+
case IEC1107_START_MESSAGE_NOT_RECIEVED:
41+
ESP_LOGI("Event Handler", "IEC1107_START_MESSAGE_NOT_RECIEVED");
42+
break;
43+
case IEC1107_START_MESSAGE_NOT_SENDED:
44+
ESP_LOGI("Event Handler", "IEC1107_START_MESSAGE_NOT_SENDED");
45+
break;
46+
case IEC1107_START_MESSAGE_SENDED:
47+
ESP_LOGI("Event Handler", "IEC1107_START_MESSAGE_SENDED");
48+
break;
49+
case IEC1107_START_MESSAGE_RECEIVED:
50+
ESP_LOGI("Event Handler", "SIEC1107_START_MESSAGE_RECEIVED");
51+
break;
52+
case IEC1107_READOUT_MESSAGE_SENDED:
53+
ESP_LOGI("Event Handler", "IEC1107_READOUT_MESSAGE_SENDED");
54+
break;
55+
case IEC1107_READOUT_MESSAGE_NOT_RECEIVED:
56+
ESP_LOGI("Event Handler", "IEC1107_READOUT_MESSAGE_NOT_RECEIVED");
57+
break;
58+
case IEC1107_READOUT_MESSAGE_RECEIVED:
59+
ESP_LOGI("Event Handler", "IEC1107_READOUT_MESSAGE_RECEIVED");
60+
break;
61+
case IEC1107_FIELDS_UPDATED:
62+
print_exported_fields();
63+
ESP_LOGI("Event Handler", "IEC1107_FIELDS_UPDATED");
64+
break;
65+
66+
default:
67+
break;
68+
}
69+
}
70+
```
71+
72+
73+
Our main
74+
```
75+
void app_main()
76+
{
77+
iec1107_parser_handle_t iec1107 = iec1107_parser_init(LOOP, 1000);
78+
79+
iec1107_parser_add_handler(iec1107, iec1107_event_handler, NULL);
80+
81+
iec1107_start(iec1107);
82+
}
83+
```
84+
85+
## Adding obis code
86+
87+
You can edit `export_obis_code` [config.h](components/iec1107/include/config.h)
88+
Example :
89+
```
90+
const char* export_obis_code[] =
91+
{
92+
"32.7.0",
93+
"1.8.0",
94+
"34.7.0",
95+
"96.77.2*1",
96+
};
97+
```
98+
99+
I will calculate the values using the order found above. You can access these values through this struct. `export_hdl` We have already defined it in [main.c](main/main.c).
100+
101+
For examle above `export_obis_code`
102+
103+
When the reading from the meter is finished. All values are placed in the export_hdl variable. If you want to access the value of 32.7.0.
104+
`export_hdl -> export_holder[0]` It holds this value.

Diff for: components/iec1107/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
idf_component_register(SRCS "iec1107.c"
2+
INCLUDE_DIRS "include")
3+

0 commit comments

Comments
 (0)