This is the readme for the Youless Arduino library, it contains some usefull information on how to use the library.
This is a library for use with the Youless energy monitor, this library uses a TCP connection on port 80 to get data from the web interface. The library also does the formating of the data. For more information about the Youless energy monitor visit their website.
To use this library it's mandatory to include some other library to connect to the internet. Below you will find the apropiate instructions for each of the commonly used boards.
#include <SPI.h>
#include <Ethernet.h>
// The media acces control (MAC) adress for the ethernet shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// The IP adress for the shield:
byte ip[] = {10, 0, 0, 177};
void setup() {
Ethernet.begin(mac, ip);
}
void loop() {
// Your main code here
}
// #include <ESP8266WiFi.h> // Uncomment for use with the ESP8266
// #include <WiFi.h> // Uncomment for use with the ESP32
// Your access point SSID
const char* ssid = "Your SSID";
// Your access point password
const char* password = "Your Password";
void setup() {
Serial.print("Trying to connect to ");
Serial.println(ssid);
WiFi.begin(ssid, password); // Begin the WiFi connection
Serial.println("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Adress: ");
Serial.println(WiFi.localIP());
}
void loop() {
// Your main code here
}
- Constructor - YoulessMonitor your_name(host, conType), host is the IP address of the Youless monitor as a variable of the type IPAddress. For conType you can select
WIRED
for a wired connection with the ethernet library orWIRELESS
for a wireless connection with a WiFi library. - Destructor - This function has no implementation yet.
- getBasicStatus - your_name.getBasicStatus(), this function returns a formatted JSON document with basic gatherd data from the Youless Monitor, the type of the returned variable is a
DynamicJsonDocument
. Below is an example of the returned data, for more information on the data visit the Youless-Wiki.
{
"cnt": " 3876,188",
"pwr": 35,
"lvl": 0,
"dev": "",
"det": "■",
"con": "OK",
"sts": "(02)",
"cs0": " 0,000",
"ps0": 0,
"raw": 0
}
- readCounter - your_name.readCounter(), this function returns the count of the energy meter as floating point number.
- readPower - your_name.readPower(), this function returns the actual power usage as long variable. Note This function can also return a negative value wich means energy consumption is lower then the energy production.
- readConnectionStatus - your_name.readConnectionStatus(), this function returns
false
if the Youless monitor is not connected to the energy meter andtrue
if the Youless monitor is connected to the energy meter. - getUploadedValues - your_name.getUploadedValues(), this function returns a formatted JSON document with meter data from the Youless Monitor, the type of the returned variable is a
DynamicJsonDocument
. Below is an example of the returned data, for more information on the data visit the Youless-Wiki.
{
"tm": 1611571509,
"net": 3876.281,
"pwr": -35,
"ts0": 1605604200,
"cs0": 0.0,
"ps0": 0,
"p1": 5631.23,
"p2": 4916.995,
"n1": 2053.916,
"n2": 4618.028,
"gas": 4547.905,
"gts": 2101251140
}
- readConsumptionCounter - your_name.readConsumptionCounter(tarrif), tarrif can be left empty to return the total consumption counter or tarrif can be
LOW
to return the low tarrif consumption counter or tarrif can beHIGH
to return the high tarrif consumption counter. This function returns a value with the type of float. - readProductionCounter - your_name.readProductionCounter(tarrif), tarrif can be left empty to return the total production counter or tarrif can be
LOW
to return the low tarrif production counter or tarrif can beHIGH
to return the high tarrif production counter. This function returns a value with the type of float. - readGasCounter - your_name.readGasCounter(), this function returns the count of the gas meter as floating point number.
- Add basic functionality
- Add functions for the rest of the json data.
- Add functions to retrieve historical data.
- Add functions to get s0 data.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.