Mqtt with arduino nano and ENC28J60

Hello,

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.

Thanks for your time.

Greathings

EthernetENC library with PubSubClient library. start with mqtt_basic example of PubSubClient, only change #include <Ethernet.h> to #include <EthernetENC.h>

Ok i have done that:

I have only change:

#include <EthernetENC.h>

and

IPAddress ip(192, 168, 0, 50);
IPAddress server(192, 168, 0, 12);

But i got

Attempting MQTT connection...failed, rc=-2 try again in 5 seconds

I think it's the wiring:
SO -> D12
SI -> D11
SCK -> D13
CS -> D8
VCC -> 3.3
GND -> GND

Add Ethernet.init(8); to set the CS pin

Nano 3 3V pin can"t supply enough current for the ENC

1 Like

How can i be so easy,

Realy thanks i'm connected to the mqtt with a dynamic ip.

Maybe spoken to soon:

i have this:

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. :frowning:

please try delay(500); after Ethernet.init(8);

sadly same error.

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

but the cable is in the jack.

i have put 5V on the VCC pin, can that destroy the board?

yes. it will destroy the ENC

:poop: will buy another one.

Ok, i have new board

i have connected the wires the same and have used 3.3v and 5V (it has run on it for multiple hours). With the new board the problem is the same.

did you bought the same module? there are modules which can be powered with 5 V. they have a voltage level conversion IC. I use this https://robotdyn.com/ethernet-module-enc28j60-power-in-3-3v-5v.html

Yes they are the same. I'm hitting the max memory size of the nano.

i think i buy a UNO R3 U with Ethernet Shield W5100-set

the EthernetENC library has settings to save flash and RAM.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.