Slimme meter telegram weergeven in een webpagina
2 berichten
• Pagina 1 van 1
Slimme meter telegram weergeven in een webpagina
Hallo iedereen,
Ik zoek een mogelijkheid om een slimme meter telegram weer te geven in een webpagina zodat je bijv. ziet:
verbruik = .....
meterstand hoog = .... enz.
Heeft iemand een idee hoe je zoiets zou kunnen maken. Mijn programmeerkennis is helaas niet toereikend maar aan de hand van een voorbeeld weet ik het meestal wel naar mijn hand te zetten. Ik heb een Arduino Mega met Ethernetshield.
Bij voorbaat dank voor de hulp,
doppie
Ik zoek een mogelijkheid om een slimme meter telegram weer te geven in een webpagina zodat je bijv. ziet:
verbruik = .....
meterstand hoog = .... enz.
Heeft iemand een idee hoe je zoiets zou kunnen maken. Mijn programmeerkennis is helaas niet toereikend maar aan de hand van een voorbeeld weet ik het meestal wel naar mijn hand te zetten. Ik heb een Arduino Mega met Ethernetshield.
Bij voorbaat dank voor de hulp,
doppie
Advertisement
Re: Slimme meter telegram weergeven in een webpagina
Hallo,
Ik heb de volgende sketch gevonden:
#include <SPI.h>
#include <Ethernet.h>
// assign a MAC address for the Ethernet controller.
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEE};
// assign an IP address for the controller:
IPAddress ip(192, 168, 178, 175);
EthernetServer server(80);
char inputString[900];// a string to hold incoming data
int x = 0;//counter for incoming data
boolean lastline = false; //lastline of incoming data
boolean Update = false; // Flag when a full message is received
void setup() {
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
// initialize serial:
Serial.begin(115200);
// give the sensor and Ethernet shield time to set up:
delay(1000);
}
void loop() {
EthernetClient client = server.available(); // gets client object if available and put it in the var
client.flush(); //flush input buffer if there is any data
//looks like domoticz is not sending data only setting up the connection. Therefore you need to start
//sending data to all connected clients every set interval.Not wait for a request.
//only send data if P1 message is fully updated. Every 10 seconds
if (Update == true){
server.write(inputString);
Serial.write(inputString);
Update = false;
}
// }
}
void serialEvent() {
while (Serial.available()) {
// get the new byte
char inChar = (char)Serial.read();
// add it to the inputString:
inputString[x]= inChar;
x += 1;
//When ! is received continue until end of line and start over filling the var, the ! is followed by an CRC. Used by Domoticz.
if (inChar == '!') {
lastline = true;
}
if (inChar == '\n' && lastline == true){
lastline = false;
x = 0;
Update = true;
}
}
}
Na eniige tijd wachten werkt deze maar in plaats van telkens op de zelfde plek af te drukken wordt iedere telegram onder de oude afgedrukt. Heeft iemand een idee om dat telkens gewoon bovenaan de pagina afgedrukt te hebben?
Ik heb de volgende sketch gevonden:
#include <SPI.h>
#include <Ethernet.h>
// assign a MAC address for the Ethernet controller.
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEE};
// assign an IP address for the controller:
IPAddress ip(192, 168, 178, 175);
EthernetServer server(80);
char inputString[900];// a string to hold incoming data
int x = 0;//counter for incoming data
boolean lastline = false; //lastline of incoming data
boolean Update = false; // Flag when a full message is received
void setup() {
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
// initialize serial:
Serial.begin(115200);
// give the sensor and Ethernet shield time to set up:
delay(1000);
}
void loop() {
EthernetClient client = server.available(); // gets client object if available and put it in the var
client.flush(); //flush input buffer if there is any data
//looks like domoticz is not sending data only setting up the connection. Therefore you need to start
//sending data to all connected clients every set interval.Not wait for a request.
//only send data if P1 message is fully updated. Every 10 seconds
if (Update == true){
server.write(inputString);
Serial.write(inputString);
Update = false;
}
// }
}
void serialEvent() {
while (Serial.available()) {
// get the new byte
char inChar = (char)Serial.read();
// add it to the inputString:
inputString[x]= inChar;
x += 1;
//When ! is received continue until end of line and start over filling the var, the ! is followed by an CRC. Used by Domoticz.
if (inChar == '!') {
lastline = true;
}
if (inChar == '\n' && lastline == true){
lastline = false;
x = 0;
Update = true;
}
}
}
Na eniige tijd wachten werkt deze maar in plaats van telkens op de zelfde plek af te drukken wordt iedere telegram onder de oude afgedrukt. Heeft iemand een idee om dat telkens gewoon bovenaan de pagina afgedrukt te hebben?
2 berichten
• Pagina 1 van 1
Wie is er online?
Gebruikers in dit forum: Geen geregistreerde gebruikers en 18 gasten