-
Notifications
You must be signed in to change notification settings - Fork 20
/
E06_ESP_EMONLIB.ino
68 lines (55 loc) · 1.95 KB
/
E06_ESP_EMONLIB.ino
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
// Configure the framework
#include "bconf/MCU_ESP8266.h" // Load the code directly on the ESP8266
#include "conf/Gateway.h" // The main node is the Gateway, we have just one node
#include "conf/IPBroadcast.h"
// Define the WiFi name and password
#define WIFICONF_INSKETCH
#define WiFi_SSID "SSID"
#define WiFi_Password "PASSWORD"
// Include framework code and libraries
#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include "Souliss.h"
// This identify the number of the LED logic
#define CURRENT 0
#define WATTS 2
#define Debug Serial1 //Change to Serial1 if you want to use the GPIO2 to TX
void setup()
{
Initialize();
Serial.begin(9600);
Debug.begin(115200);
// Connect to the WiFi network and get an address from DHCP
GetIPAddress();
SetAsGateway(myvNet_dhcp);
// This node will serve all the others in the network providing an address
// This is the vNet address for this node, used to communicate with other
// nodes in your Souliss network
SetAddress(0xAB01, 0xFF00, 0x0000);
//Example of Peer Definition
//SetAsPeerNode(0xAB02, 1);
Set_Current(CURRENT);
Set_Power(WATTS);
}
void loop()
{
EXECUTEFAST() {
UPDATEFAST();
FAST_510ms() {
Logic_Current(CURRENT);
Logic_Power(WATTS);
}
FAST_710ms() {
float current = 0;
if(Serial.available()){
float current = Serial.parseFloat();
Debug.println(current);
Souliss_ImportAnalog(memory_map, CURRENT, ¤t);
float watt = current*230;
Souliss_ImportAnalog(memory_map, WATTS, &watt);
}
}
// Here we handle here the communication with Android
FAST_GatewayComms();
}
}