float Gesamtverbrauch = 4304.676; float Tarif1 = Gesamtverbrauch; float Einspeisung = 19.720; int32_t Leistung = 660; int code0[312] = {0x1B, 0x1B, 0x1B, 0x1B, 0x01, 0x01, 0x01, 0x01, 0x76, 0x05, 0x01, 0x02, 0x03, 0x04, 0x62, 0x00, 0x62, 0x00, 0x72, 0x65, 0x00, 0x00, 0x01, 0x01, 0x76, 0x01, 0x0B, 0x0A, 0x01, 0x4C, 0x4F, 0x47, 0x00, 0x04, 0x01, 0x02, 0x03, 0x05, 0x01, 0x02, 0x03, 0x04, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x62, 0x01, 0x65, 0x01, 0xA7, 0x06, 0x80, 0x01, 0x63, 0x2D, 0x35, 0x00, 0x76, 0x05, 0x01, 0x02, 0x03, 0x04, 0x62, 0x00, 0x62, 0x00, 0x72, 0x65, 0x00, 0x00, 0x07, 0x01, 0x77, 0x01, 0x0B, 0x0A, 0x01, 0x4C, 0x4F, 0x47, 0x00, 0x04, 0x01, 0x02, 0x03, 0x07, 0x01, 0x00, 0x62, 0x0A, 0xFF, 0xFF, 0x72, 0x62, 0x01, 0x65, 0x01, 0xA7, 0x06, 0x7F, 0x77, 0x77, 0x07, 0x01, 0x00, 0x60, 0x32, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x4C, 0x4F, 0x47, 0x01, 0x77, 0x07, 0x01, 0x00, 0x60, 0x01, 0x00, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x0B, 0x0A, 0x01, 0x4C, 0x4F, 0x47, 0x00, 0x04, 0x01, 0x02, 0x03, 0x01, 0x77, 0x07, 0x01, 0x00, 0x01, 0x08, 0x00, 0xFF, 0x65, 0x00, 0x1C, 0x01, 0x04, 0x01, 0x62, 0x1E, 0x52, 0xFF, 0x69, 0x00, 0x00, 0x00, 0x00, 0x02, 0x90, 0xD7, 0x66, 0x01, 0x77, 0x07, 0x01, 0x00, 0x01, 0x08, 0x01, 0xFF, 0x01, 0x01, 0x62, 0x1E, 0x52, 0xFF, 0x69, 0x00, 0x00, 0x00, 0x00, 0x02, 0x90, 0xD7, 0x66, 0x01, 0x77, 0x07, 0x01, 0x00, 0x01, 0x08, 0x02, 0xFF, 0x01, 0x01, 0x62, 0x1E, 0x52, 0xFF, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x77, 0x07, 0x01, 0x00, 0x02, 0x08, 0x00, 0xFF, 0x01, 0x01, 0x62, 0x1E, 0x52, 0xFF, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xF0, 0xBA, 0x01, 0x77, 0x07, 0x01, 0x00, 0x10, 0x07, 0x00, 0xFF, 0x01, 0x01, 0x62, 0x1B, 0x52, 0x00, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x94, 0x01, 0x01, 0x01, 0x63, 0xFE, 0xC6, 0x00, 0x76, 0x05, 0x01, 0x02, 0x03, 0x04, 0x62, 0x00, 0x62, 0x00, 0x72, 0x65, 0x00, 0x00, 0x02, 0x01, 0x71, 0x01, 0x63, 0xBB, 0xB5, 0x00, 0x1B, 0x1B, 0x1B, 0x1B, 0x1A, 0x00, 0x8E, 0xA8 }; void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial2.begin(9600); } void loop() { // put your main code here, to run repeatedly: uint32_t Gesamt = Gesamtverbrauch * 1000; // 1.8.0 code0[175] = Gesamt >> 24; code0[176] = Gesamt >> 16; code0[177] = Gesamt >> 8; code0[178] = Gesamt >> 0; uint32_t Tarif = Tarif1 * 1000; // 1.8.1 code0[199] = Tarif >> 24; code0[200] = Tarif >> 16; code0[201] = Tarif >> 8; code0[202] = Tarif >> 0; uint32_t Einsp = Einspeisung * 1000; // 2.8.0 code0[247] = Einsp >> 24; code0[248] = Einsp >> 16; code0[249] = Einsp >> 8; code0[250] = Einsp >> 0; // uint32_t Leist = Leistung ; // Leistung //code0[271] = (Leist >> 24) & 0xFF; //code0[272] = (Leist >> 16) & 0xFF; // code0[273] = (Leist >> 8) & 0xFF; // code0[274] = (Leist >> 0) & 0xFF; for (int i = 0 ; i < 312; i++) { Serial2.write(code0[i]); //Serial.write(code0[i]); } Serial2.println(); //Serial.println(); for (int i = 267; i <=274; i++) { code0[i] = 0x00; } long plus = random(0,2); Serial.println(plus); if (plus == 1) { Leistung = Leistung + random(50, 2000); if (Leistung >= 10000) Leistung = 10000; } else { Leistung = Leistung - random(50, 2000); } Serial.println(Leistung); if (Leistung < 0) { Leistung = Leistung * -1; code0[267] = 0xFF; code0[268] = 0xFF; code0[269] = 0xFF; code0[270] = 0xFF; code0[271] = (Leistung >> 24); code0[272] = (Leistung >> 16); code0[273] = (Leistung >> 8); code0[274] = (Leistung >> 0); if (code0[271] <= 9) { if (code0[271] == 0) { code0[271] = 0xFF; if (code0[272] <= 9) { if (code0[272] == 0) { code0[272] = 0xFF; if (code0[273] <= 9) { if (code0[273] == 0) { code0[273] = 0xFF; if (code0[274] <= 9) { code0[274] = code0[274] + 0xF0; } } else code0[273] = code0[273] + 0xF0; } } else code0[272] = code0[272] + 0xF0; } } else code0[271] = code0[271] + 0xF0; } Einspeisung += Leistung / 100; } else { code0[271] = (Leistung >> 24); code0[272] = (Leistung >> 16); code0[273] = (Leistung >> 8); code0[274] = (Leistung >> 0); Gesamtverbrauch += Leistung / 100; } Tarif1 = Gesamtverbrauch; delay(2000); }