forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharge_module.cpp
More file actions
90 lines (83 loc) · 3.21 KB
/
Copy pathcharge_module.cpp
File metadata and controls
90 lines (83 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <PZEM004Tv30.h> // digitalWrite
#include <definitions.h>
unsigned long previousMillis_charge_module_timer = 0;
const long interval_charge_module_timer = 1000;
void control_Relays();
void start_Charge_Data() {
if (start_charge_data_counter == 0) {
digitalWrite(relay_4, HIGH);
start_charge_data_counter = 1;
}
}
void stop_Charge_Data() {
//Stop Charge
digitalWrite(relay_4, LOW);
}
void charge_State() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis_charge_module_timer >=
interval_charge_module_timer) {
previousMillis_charge_module_timer = currentMillis;
Serial.print("Ev Car Communication Values: ");
Serial.print(sensor_4_value);
Serial.print(" - ");
Serial.print(sensor_5_value);
Serial.print(" - ");
Serial.println(sensor_6_value);
if (sensor_4_value == 0 && sensor_5_value == 1 && sensor_6_value == 0) {
Serial.println("Connected To Charge Module Ready To Charge");
charge_state_from_module = 2;
error_code_12 = "1";
}
if (sensor_4_value == 1 && sensor_5_value == 1 && sensor_6_value == 0) {
Serial.println("Car Charging");
charge_state_from_module = 1;
error_code_13 = "1";
}
if (sensor_4_value == 0 && sensor_5_value == 1 && sensor_6_value == 1) {
Serial.println("EV Charging Ventilation Requared");
error_code_14 = "1";
}
if (sensor_4_value == 1 && sensor_5_value == 0 && sensor_6_value == 0) {
Serial.println("No Connection To Charge Module");
charge_state_from_module = 2;
error_code_15 = "1";
charge_state_from_module = 0;
relay_1_cloud_value = "0";
relay_2_cloud_value = "0";
relay_3_cloud_value = "0";
control_Relays();
}
if (sensor_4_value == 1 && sensor_5_value == 0 && sensor_6_value == 1) {
Serial.println("Error");
error_code_16 = "1";
charge_state_from_module = 2;
Serial.println("No Connection To Charge Module");
charge_state_from_module = 2;
error_code_15 = "1";
if (charge_counter > 0) {
charge_cost =
String(((sum_of_power / 3600) * (-1 * package_price_1)));
relay_1_cloud_value = "0";
relay_2_cloud_value = "0";
relay_3_cloud_value = "0";
control_Relays();
Serial.println("-------------------------Charge Ended "
"Up---------------------------");
}
}
if (sensor_4_value == 0 && sensor_5_value == 1 && sensor_6_value == 1) {
Serial.println("Unknown Error");
error_code_17 = "1";
charge_state_from_module = 2;
}
if (sensor_4_value == 0 && sensor_5_value == 0 && sensor_6_value == 0) {
Serial.println("Socket İs Out");
charge_state_from_module = 0;
relay_1_cloud_value = "0";
relay_2_cloud_value = "0";
relay_3_cloud_value = "0";
control_Relays();
}
}
}