I try to make a 433hz mqtt gateway, so i can trigger home assistant with the 433hz buttons. I have try many online tutorials but the arduino hangs or it can not find the rj45 port.
Can someone point me into the right direction?
i have a ENC28j60, a arduino nano and a mqtt server on ip 192.168.0.12, the gateway can not have a static ip. i have test the enc28j60 as a webserver and this did work.
EthernetENC library with PubSubClient library. start with mqtt_basic example of PubSubClient, only change #include <Ethernet.h> to #include <EthernetENC.h>
void networkSetup() {
delay(1500);
client.setServer(server, 1883);
client.setCallback(callback);
Ethernet.init(8);
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
networkSetup();
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
networkSetup();
}
//Ethernet.begin(mac, ip);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
networkSetup();
}
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
and got
Ethernet shield was not found. Sorry, can't run without hardware.
the led's on the rj45 jack are blinking and i have checked the cables. yesterday it did work fine.
after changing:
Ethernet.begin(mac, ip);
/*if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
}*/
i got
Setup start
The MAC address is: DE-AD-BE-EF-FE-EDEthernet cable is not connected.
server is at 192.168.0.207
The DNS server IP address is: 192.168.0.1
The gateway IP address is: 192.168.0.1
The subnet mask is: 255.255.255.0
Setup done
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds