Jazeker! Maar dan in de provinciePaul schreef:Maar klopt het dat jij idd ook in het plaatsje Zeeland woont!?
Ik fabriceer zelf wel wat denk ik...
Moderator: Moderators
Jazeker! Maar dan in de provinciePaul schreef:Maar klopt het dat jij idd ook in het plaatsje Zeeland woont!?
Code: Selecteer alles
procedure GradVertical(Canvas:TCanvas; Rect:TRect; FromColor, ToColor:TColor) ;
var
Y:integer;
dr,dg,db:Extended;
C1,C2:TColor;
r1,r2,g1,g2,b1,b2:Byte;
R,G,B:Byte;
cnt:Integer;
begin
C1 := FromColor;
R1 := GetRValue(C1) ;
G1 := GetGValue(C1) ;
B1 := GetBValue(C1) ;
C2 := ToColor;
R2 := GetRValue(C2) ;
G2 := GetGValue(C2) ;
B2 := GetBValue(C2) ;
dr := (R2-R1) / Rect.Bottom-Rect.Top;
dg := (G2-G1) / Rect.Bottom-Rect.Top;
db := (B2-B1) / Rect.Bottom-Rect.Top;
cnt := 0;
for Y := Rect.Top to Rect.Bottom-1 do
begin
R := R1+Ceil(dr*cnt) ;
G := G1+Ceil(dg*cnt) ;
B := B1+Ceil(db*cnt) ;
Canvas.Pen.Color := RGB(R,G,B) ;
Canvas.MoveTo(Rect.Left,Y) ;
Canvas.LineTo(Rect.Right,Y) ;
Inc(cnt) ;
end;
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
GradVertical(PaintBox1.Canvas, PaintBox1.ClientRect, Color1, Color2) ;
end;
procedure TForm1.PaintBox2Paint(Sender: TObject);
begin
GradVertical(PaintBox2.Canvas, PaintBox1.ClientRect, Color2, Color3) ;
end;
procedure TForm1.PaintBox3Paint(Sender: TObject);
begin
GradVertical(PaintBox3.Canvas, PaintBox1.ClientRect, Color3, Color4) ;
end;
Code: Selecteer alles
// Grenswaarden temperatuur naar kleur
if SensorTemp1 >= 70 then Color1:= clRed;
if SensorTemp2 >= 70 then Color2:= clRed;
if SensorTemp3 >= 70 then Color3:= clRed;
if SensorTemp4 >= 70 then Color4:= clRed;
if SensorTemp1 < 70 then Color1:= clPurple;
if SensorTemp2 < 70 then Color2:= clPurple;
if SensorTemp3 < 70 then Color3:= clPurple;
if SensorTemp4 < 70 then Color4:= clPurple;
if SensorTemp1 < 50 then Color1:= clNavy;
if SensorTemp2 < 50 then Color2:= clNavy;
if SensorTemp3 < 50 then Color3:= clNavy;
if SensorTemp4 < 50 then Color4:= clNavy;
if SensorTemp1 < 30 then Color1:= clBlue;
if SensorTemp2 < 30 then Color2:= clBlue;
if SensorTemp3 < 30 then Color3:= clBlue;
if SensorTemp4 < 30 then Color4:= clBlue;
// Paint
GradVertical(PaintBox1.Canvas, PaintBox1.ClientRect, Color1, Color2);
GradVertical(PaintBox2.Canvas, PaintBox1.ClientRect, Color2, Color3);
GradVertical(PaintBox3.Canvas, PaintBox1.ClientRect, Color3, Color4);
Image1.Repaint; //Bring Image (Buffertank) on top
Of zo (pseudo code, delphi is me te lang geleden)William schreef:Mijn bufferafbeelding bestaat namelijk uit 3 Paintboxes. De kleuren Color1 t/m 4 heb ik gedefineerd afhankelijk van de temperatuur:Je mag ook de gehele source hoor, maar hij is nog erg slecht geoptimaliseerd en erg onleesbaar. (zoals bovenstaande code niet erg netjes is... )Code: Selecteer alles
// Grenswaarden temperatuur naar kleur if SensorTemp1 >= 70 then Color1:= clRed; if SensorTemp2 >= 70 then Color2:= clRed; if SensorTemp3 >= 70 then Color3:= clRed; if SensorTemp4 >= 70 then Color4:= clRed; if SensorTemp1 < 70 then Color1:= clPurple; if SensorTemp2 < 70 then Color2:= clPurple; if SensorTemp3 < 70 then Color3:= clPurple; if SensorTemp4 < 70 then Color4:= clPurple; if SensorTemp1 < 50 then Color1:= clNavy; if SensorTemp2 < 50 then Color2:= clNavy; if SensorTemp3 < 50 then Color3:= clNavy; if SensorTemp4 < 50 then Color4:= clNavy; if SensorTemp1 < 30 then Color1:= clBlue; if SensorTemp2 < 30 then Color2:= clBlue; if SensorTemp3 < 30 then Color3:= clBlue; if SensorTemp4 < 30 then Color4:= clBlue; // Paint GradVertical(PaintBox1.Canvas, PaintBox1.ClientRect, Color1, Color2); GradVertical(PaintBox2.Canvas, PaintBox1.ClientRect, Color2, Color3); GradVertical(PaintBox3.Canvas, PaintBox1.ClientRect, Color3, Color4); Image1.Repaint; //Bring Image (Buffertank) on top
Code: Selecteer alles
functie temperatuurKleuren(temp) {
kleurenLijst = array(0 => clBlue, 1=>clNavy, 2=>clPurple, 3=> clRed);
return kleurenLijst[floor((temp-30)/20)];
}
// Paint
GradVertical(PaintBox1.Canvas, PaintBox1.ClientRect, temperatuurKleuren(SensorTemp1), temperatuurKleuren(SensorTemp2));
GradVertical(PaintBox2.Canvas, PaintBox1.ClientRect, temperatuurKleuren(SensorTemp2), temperatuurKleuren(SensorTemp3));
GradVertical(PaintBox3.Canvas, PaintBox1.ClientRect, temperatuurKleuren(SensorTemp3), temperatuurKleuren(SensorTemp4));
Image1.Repaint; //Bring Image (Buffertank) on top
Dat vind ook ook supertip voor mezelfhanskraayeveld schreef: ↑23 jul 2018, 22:19 Ik zou dan een "wärmezähler" kopen.
Op eBay.de een paar tientjes gebruikt.
Werken volgens hetzelfde principe. Je ziet de aanvoer temp, afvoertemp, flow in liters, en vermogen in kW, opbrengst in kWh of mWh.
Veel completer.
Code: Selecteer alles
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
//ESP AP Mode configuration
const char *ssid = "........"; //plaats hier je wifi netwerk naam
const char *password = "......."; // plaats hier je wifi netwerk password
#define NTP_OFFSET 60 * 60 // In seconds
#define NTP_INTERVAL 60 * 1000 // In miliseconds
#define NTP_ADDRESS "europe.pool.ntp.org"
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, NTP_ADDRESS, NTP_OFFSET, NTP_INTERVAL);
String graphic = "";
int interruptPin = D3; // pin van de watermeter
byte klaar, burn = 0;
int b, x = 0;
int a = 700;
int uur0, uur3, uur6, uur9, uur12, uur15, uur18, uur21 = 0;
int kwarray[700];
int temp1array[700];
int temp2array[700];
int temp3array[700];
int temp4array[700];
int temp5array[700];
unsigned long resettime, connectiontime, pulsintime1, pulsintime2, pulsintime3, pulsintime4, pulsintime5, pulsintimehit, looptimepulses = 0;
unsigned long plot = 0;
unsigned long kw = 0;
unsigned long whloop, whtotal, whburn, allesopnul = 0;
float rendement, whstart, whroomoutput, whroomoutputtotal, kgwood, lm, temp1, temp2, temp3, temp4, temp5, tempdif = 0;
float temp1min = 100;
int debounce = 10;
#define ONE_WIRE_BUS D4 //pin van de 5 data ds18b20 tempsensoren (de gele kabel)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
ESP8266WebServer server(80);
IPAddress ip(192, 168, 178, 40);
IPAddress gateway(192, 168, 178, 1);
IPAddress subnet(255, 255, 255, 0);
void handleRoot() {
connectiontime = millis();
Serial.println("Client connected. ");
timeClient.update();
int tijd = ((timeClient.getHours() * 60) + timeClient.getMinutes()) / 2;
Serial.println(tijd);
uur0 = 700 - (tijd - 0);
if (uur0 > 720){uur0 -= 720;}
uur3 = 700 - (tijd - 90);
if (uur3 > 720){uur3 -= 720;}
uur6 = 700 - (tijd - 180);
if (uur6 > 720){uur6 -= 720;}
uur9 = 700 - (tijd - 270);
if (uur9 > 720){uur9 -= 720;}
uur12 = 700 - (tijd - 360);
if (uur12 > 720){uur12 -= 720;}
uur15 = 700 - (tijd - 450);
if (uur15 > 720){uur15 -= 720;}
uur18 = 700 - (tijd - 540);
if (uur18 > 720){uur18 -= 720;}
uur21 = 700 - (tijd - 630);
if (uur21 > 720){uur21 -= 720;}
resettime = (21600000 - (millis() - pulsintime1));
if (resettime > 21600000){resettime = 0;}
int seconds = (int) (resettime / 1000) % 60 ;
int minutes = (int) ((resettime / (1000*60)) % 60);
int hours = (int) ((resettime / (1000*60*60)) % 24);
graphic = "";
graphic += "HTTP/1.1 200 OK\r\n";
graphic += "Content-Type: text/html\r\n";
graphic += "\r\n";
graphic += "<!DOCTYPE html><html><meta name='viewport' content='width=720px' meta charset='UTF-8'><body>";
graphic += "<canvas id='myCanvas' width='700' height='750' style='border:1px solid black;'>Your browser does not support the HTML5 canvas tag.</canvas><script>var c = document.getElementById('myCanvas');var ctx = c.getContext('2d');";
graphic += "ctx.fillStyle='black';ctx.fillRect(0, 0, 700, 531);ctx.fillStyle='lightgrey';ctx.fillRect(0, 531, 700, 219);";
graphic += "ctx.fillStyle = 'grey'; ctx.fillRect(5, 5, 300, 100); ctx.fillRect(5, 110, 300, 100); ctx.fillRect(5, 215, 300, 100); ctx.fillRect(5, 320, 300, 100); ctx.fillRect(5, 425, 300, 100);";
graphic += "ctx.fillRect(310, 5, 190, 100); ctx.fillStyle = 'red'; ctx.fillRect(310, 110, 190, 100); ctx.fillStyle = 'blue'; ctx.fillRect(310, 215, 190, 100); ctx.fillStyle = 'grey'; ctx.fillRect(310, 320, 190, 100); ctx.fillRect(310, 425, 190, 100);";
graphic += "ctx.fillStyle = 'yellow'; ctx.fillRect(505, 5, 190, 100); ctx.fillStyle = 'orange'; ctx.fillRect(505, 110, 190, 100); ctx.fillStyle = 'brown'; ctx.fillRect(505, 215, 190, 100);";
graphic += "ctx.fillStyle = 'grey'; ctx.fillRect(505, 320, 190, 100); ctx.fillRect(505, 425, 190, 100);";
graphic += "ctx.fillStyle = 'black'; ctx.font = '30px Arial'; ctx.textAlign = 'center';";
graphic += "ctx.fillText('Attack SLX 20',150,65);";
graphic += String() + "ctx.fillText('" + String((float)whtotal/1000, 3) + " kWh',150,170);";
graphic += String() + "ctx.fillText('€ " + String((float)whtotal/1000/8.8*0.65, 2) + "',150,275);";
graphic += String() + "ctx.fillText('" + String((float)whburn/1000, 3) + " kWh',150,380);";
graphic += String() + "ctx.fillText('€ " + String((float)whburn/1000/8.8*0.65, 2) + "',150,485);";
graphic += String() + "ctx.fillText('" + String((float)kw/100, 1) + " kW',400,65);";
graphic += String() + "ctx.fillText('" + String(temp1, 1) + " ºC',400,170);";
graphic += String() + "ctx.fillText('" + String(temp2, 1) + " ºC',400,275);";
graphic += String() + "ctx.fillText('" + String(kgwood, 1) + " kg',400,380);";
graphic += String() + "ctx.fillText('" + String(rendement, 1) + "%',400,485);";
graphic += String() + "ctx.fillText('" + String(temp3, 1) + " ºC',595,65);";
graphic += String() + "ctx.fillText('" + String(temp4, 1) + " ºC',595,170);";
graphic += String() + "ctx.fillText('" + String(temp5, 1) + " ºC',595,275);";
graphic += String() + "ctx.fillText('0.0 ºC',595,380);";
graphic += String() + "ctx.fillText('" + String(lm, 1) + " l/m',595,485);";
server.sendContent(graphic);
graphic = "";
graphic += "ctx.fillStyle='grey';";
for (int i = 0; i < 700; i++){
b = i + a;
if (b > 699){b -= 700;}
graphic += "ctx.fillRect(" + String(b) + ", 750, 1, -" + String(kwarray[i]) + ");";
}
server.sendContent(graphic);
graphic = "";
graphic += "ctx.fillStyle='red';";
for (int i = 0; i < 700; i++){
b = i + a;
if (b > 699){b -= 700;}
graphic += "ctx.fillRect(" + String(b) + "," + String(750 - temp1array[i]) + ",1,2);";
}
server.sendContent(graphic);
graphic = "";
graphic += "ctx.fillStyle='blue';";
for (int i = 0; i < 700; i++){
b = i + a;
if (b > 699){b -= 700;}
graphic += "ctx.fillRect(" + String(b) + "," + String(750 - temp2array[i]) + ",1,2);";
}
server.sendContent(graphic);
graphic = "";
graphic += "ctx.fillStyle='yellow';";
for (int i = 0; i < 700; i++){
b = i + a;
if (b > 699){b -= 700;}
graphic += "ctx.fillRect(" + String(b) + "," + String(750 - temp3array[i]) + ",1,2);";
}
server.sendContent(graphic);
graphic = "";
graphic += "ctx.fillStyle='orange';";
for (int i = 0; i < 700; i++){
b = i + a;
if (b > 699){b -= 700;}
graphic += "ctx.fillRect(" + String(b) + "," + String(750 - temp4array[i]) + ",1,2);";
}
server.sendContent(graphic);
graphic = "";
graphic += "ctx.fillStyle='brown';";
for (int i = 0; i < 700; i++){
b = i + a;
if (b > 699){b -= 700;}
graphic += "ctx.fillRect(" + String(b) + "," + String(750 - temp5array[i]) + ",1,2);";
}
server.sendContent(graphic);
graphic = "";
graphic += "ctx.fillStyle='black';";
graphic += "ctx.fillRect(0, 550, 700, 1);ctx.fillRect(0, 600, 700, 1);ctx.fillRect(0, 650, 700, 1);ctx.fillRect(0, 700, 700, 1);";
graphic += "ctx.font = '10px Arial';ctx.fillStyle = 'black';ctx.fillText('30 kW',17,598);ctx.fillText('20 kW',17,648);ctx.fillText('10 kW',17,698);ctx.fillText('80 C',685,598);ctx.fillText('60 C',685,648);ctx.fillText('40 C',685,698);";
graphic += "ctx.fillRect(" + String(uur0) + ", 550, 1, 200); ctx.fillRect(" + String(uur3) + ", 550, 1, 200); ctx.fillRect(" + String(uur6) + ", 550, 1, 200); ctx.fillRect(" + String(uur9) + ", 550, 1, 200); ctx.fillRect(" + String(uur12) + ", 550, 1, 200); ctx.fillRect(" + String(uur15) + ", 550, 1, 200); ctx.fillRect(" + String(uur18) + ", 550, 1, 200); ctx.fillRect(" + String(uur21) + ", 550, 1, 200);";
graphic += "ctx.textAlign = 'center'; ctx.fillText('0'," + String(uur0) + ",545); ctx.fillText('3'," + String(uur3) + ",545); ctx.fillText('6'," + String(uur6) + ",545); ctx.fillText('9'," + String(uur9) + ",545); ctx.fillText('12'," + String(uur12) + ",545); ctx.fillText('15'," + String(uur15) + ",545); ctx.fillText('18'," + String(uur18) + ",545); ctx.fillText('21'," + String(uur21) + ",545);";
graphic += "</script>";
graphic += "<p><font size='1'>Time to reset: " + String(hours) + ":" + String(minutes) + ":" + String(seconds) + " Loading page time: " + String(millis() - connectiontime) + " ms</p>";
graphic += "</body></html>";
graphic += "\r\n\r\n";
server.sendContent(graphic);
graphic = "";
server.sendContent(graphic);
server.client().stop();
Serial.print("Client disconnected. ");// Stop is needed because we sent no content length
Serial.println(millis() - connectiontime);
}
void setup() {
Serial.begin(115200);
millis();
DS18B20.begin();
DS18B20.setResolution(10);
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, CHANGE);
//Initialize AP Mode
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
WiFi.config(ip, gateway, subnet);
Serial.println("");
Serial.println("WiFi connected");
// Print the IP address
Serial.print("Use this URL : ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
plotmenu();
//Initialize Webserver
server.on("/",handleRoot);
server.begin();
}
void handleInterrupt() {
if (digitalRead (interruptPin) == HIGH && klaar == 0 && millis() - pulsintimehit > 10){
pulsintimehit = millis();
pulsintime2 = pulsintime1;
pulsintime1 = millis();
looptimepulses = (pulsintime1 - pulsintime2);
tempdif = (temp1*10 - temp2*10);
if (tempdif < 0){tempdif = 0;}
whloop = tempdif * 1163;
kw = (((float)whloop * 36)/looptimepulses);
whloop = whloop / 10000;
whtotal += whloop;
whburn += whloop;
lm = (float)60000 / looptimepulses;
allesopnul = 1;
burn = 1;
klaar = 1;
Serial.println( String() + "Pulstime: " + pulsintime1 + " Pulslaptime: " + looptimepulses + " TempHot: " + temp1 + " TempCold: " + temp2 + " Lit/min: " + lm + " Watthour: " + whburn + " Watt: " + kw*10);
}
if (digitalRead (interruptPin) == LOW && klaar == 1 && millis() - pulsintimehit > 10){klaar = 0; pulsintimehit = millis(); Serial.print("Pulse LOW: "); Serial.println(millis());}
}
void loop() {
server.handleClient();
if (kw > 0 && millis() - pulsintime1 > (looptimepulses * 1.1)){looptimepulses = looptimepulses * 1.1; kw = kw / 1.1;lm = lm / 1.1; Serial.println("10% pulsuitstel");}
if (millis() - pulsintime1 > 600000 && allesopnul == 1){Serial. println("kW en l/m op nul"); kw = 0; lm = 0; burn = 0; allesopnul = 2;}
if (millis() - pulsintime1 > 21600000 && allesopnul == 2){Serial.println("Alle tellers gaan op nul..."); whburn = 0; whroomoutputtotal = 0; kgwood = 0; rendement = 0; temp1min = 100; allesopnul = 0;}
if (millis() > plot){plotmenu();}
}
void plotmenu(){
plot += 120000;
Serial.print(String() + "Plotting: " + millis());
temperatuurmenu();
kwarray[x] = ((float)kw/100) * 5;
temp1array[x] = (temp1 - 20) * 2.5;
temp2array[x] = (temp2 - 20) * 2.5;
temp3array[x] = (temp3 - 20) * 2.5;
temp4array[x] = (temp4 - 20) * 2.5;
temp5array[x] = (temp5 - 20) * 2.5;
x += 1;
if (x > 700){x = 0;}
a -= 1;
if (a < 0){a = 700;}
if (burn == 1){
whstart = (temp1 - temp1min) * ((120 * 0.001163) + (450 * 0.0001244)) * 1000;
whroomoutput = (temp1 - 15) * 40 / 30;
whroomoutputtotal += whroomoutput;
kgwood = ((whburn + whroomoutputtotal) / 1000 / (4.22 * 0.918)) + (whstart / 1000 / (4.22 * 0.5));
rendement = whburn / (whburn + whstart + whroomoutputtotal) * 100;
Serial.println(String() + "Burning... whstart: " + whstart + " whroomoutputtotal: " + whroomoutputtotal + " whburn: " + whburn + " kgwood: " + kgwood + " rendement: " + rendement);
}
}
void temperatuurmenu(){
DS18B20.requestTemperatures();
temp1 = DS18B20.getTempCByIndex(0);
temp2 = DS18B20.getTempCByIndex(1);
temp3 = DS18B20.getTempCByIndex(2);
temp4 = DS18B20.getTempCByIndex(3);
temp5 = DS18B20.getTempCByIndex(4);
//temp1 = 100 - (float(0.25)* x);
//temp2 = 95 - (float(0.25)* x);
//temp3 = 70 - (float(0.25)* x);
//temp4 = 55 - (float(0.25)* x);
//temp5 = 45 - (float(0.25)* x);
if (temp1 < -100){temp1 = 0.0;}
if (temp2 < -100){temp2 = 0.0;}
if (temp3 < -100){temp3 = 0.0;}
if (temp4 < -100){temp4 = 0.0;}
if (temp5 < -100){temp5 = 0.0;}
if (temp1 < temp1min){temp1min = temp1;}
if (temp1 > temp1min + 5 && allesopnul == 0){burn = 1;}
Serial.println(String() + " Temp1: " + temp1 + " Temp2: " + temp2 + " Temp3: " + temp3 + " Temp4: " + temp4 + " Temp5: " + temp5 + " Temp1min: " + temp1min);
}