pump kram

This commit is contained in:
2023-07-03 17:48:20 +02:00
parent d22e0bc752
commit e7e8ecc57d
5 changed files with 44 additions and 14 deletions
+41 -11
View File
@@ -12,19 +12,25 @@
#define BUFFER_SIZE 128
byte mac[] = { 0xC3, 0xF9, 0x7C, 0xB1, 0x8C, 0xF3 };
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// IPAddress ip(192, 168, 13, 0);
// IPAddress gateway(192, 168, 0, 1);
// IPAddress subnet(255, 255, 128, 0);
IPAddress ip(192, 168, 13, 0);
IPAddress subnet(255, 255, 128, 0);
IPAddress gateway(192, 168, 0, 1);
IPAddress dns(192, 168, 0, 1);
IPAddress server(192, 168, 1, 7);
IPAddress ip(192, 168, 178, 202);
IPAddress gateway(192, 168, 178, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(192, 168, 178, 1);
IPAddress server(192, 168, 178, 35);
// IPAddress ip(192, 168, 178, 202);
// IPAddress gateway(192, 168, 178, 1);
// IPAddress subnet(255, 255, 255, 0);
// IPAddress dns(192, 168, 178, 1);
// IPAddress server(192, 168, 178, 35);
// IPAddress server(91, 121, 93, 94);
const char mqttUser[] = "kleiax";
const char mqttPass[] = "p?{$_~5%hBM7wrcFkr55KWr#";
const char mqttId[] = "bewaesserungArduino123";
ShiftRegister reg(RCLK_PIN, SRCLK_PIN, SRSER_PIN, 2);
Pump pump(SSR_PIN, PRESSURE_PIN, INT_HALL_PIN, STATUS_LED_1_PIN);
Valve valves;
@@ -41,6 +47,12 @@ void setup() {
Serial.begin(115200);
Serial.println(F("Arduino Irrigation"));
pinMode(SROE_PIN, OUTPUT);
pinMode(SRCLR_PIN, OUTPUT);
digitalWrite(SROE_PIN, LOW);
digitalWrite(SRCLR_PIN, HIGH);
reg.writeByte(0, UINT8_MAX);
reg.writeByte(1, UINT8_MAX);
valves.addShiftRegister(&reg);
for (uint8_t i = 0; i < VALVE_COUNT; i++)
valves.add(valvePins[i], true);
@@ -49,7 +61,24 @@ void setup() {
client.setServer(server, 1883);
client.setCallback(callback);
Ethernet.begin(mac, ip, dns, gateway, subnet);
Ethernet.begin(mac, ip, dns, gateway, subnet);
Serial.print("Info: ");
Serial.println(Ethernet.localIP() );
// if (Ethernet.begin(mac) == 0) {
// Serial.println("Failed to configure Ethernet using DHCP");
// } else {
// Serial.print(" DHCP assigned IP ");
// Serial.println(Ethernet.localIP());
// Serial.println(Ethernet.subnetMask());
// Serial.println(Ethernet.dnsServerIP());
// Serial.println(Ethernet.gatewayIP());
// }
// // give the Ethernet shield a second to initialize:
// delay(1000);
// Serial.print("connecting to ");
// Serial.println(server);
// Allow the hardware to sort itself out
delay(1500);
@@ -118,7 +147,7 @@ void reconnect() {
char topic[64];
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
if (client.connect("arduinoClient")) {
if (client.connect(mqttId, mqttUser, mqttPass)) {
Serial.println("connected");
sprintf(topic, "%s/info", mainTopic);
client.publish(topic,"reconnect");
@@ -175,3 +204,4 @@ void sendInfo() {
size_t n = serializeJson(doc, buffer);
client.publish(topic, buffer, n);
}