Arduino + Ethernet w5100 + MQTT MOSQUITTO doesn't work

Can anyone help?
This is my Arduino code, somehow the ethernet network doesn’t connect, and then mqtt doesn’t connect. I’m using mosquitto in windows, locally. I created a firewall rule for tcp port, 1883.

#include <SPI.h>
#include <Ethernet.h> 
#include <PubSubClient.h>

#define pinBotao1 12  //D6

// Update these with values suitable for your network.
//Needed for Ethernet
byte MAC_ADDRESS[] = {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
byte MQTT_SERVER[] = { 192, 168, 0, 11 };
byte IP_ADDRESS[] = {192, 168, 0, 100};

#define ID_MQTT  "BCI01"            //Informe um ID unico e seu. Caso sejam usados IDs repetidos a ultima conexão irá sobrepor a anterior. 
#define TOPIC_PUBLISH "BCIBotao1"    //Informe um Tópico único. Caso sejam usados tópicos em duplicidade, o último irá eliminar o anterior.
EthernetClient ethClient;
PubSubClient MQTT(ethClient);

//Declaração das Funções
void mantemConexoes();  //Garante que as conexoes com WiFi e MQTT Broker se mantenham ativas
void abrirConexao();     //Faz conexão com WiFi
void conectaMQTT();     //Faz conexão com Broker MQTT
void enviaPacote();     //

void setup() {
  pinMode(pinBotao1, INPUT);         

  Ethernet.begin(MAC_ADDRESS, IP_ADDRESS);
  MQTT.setServer(MQTT_SERVER, 1883);

void loop() {
  enviaValores();//SENDS DATA

    if (!MQTT.connected()) {
    abrirConexao(); //se não há conexão com o WiFI, a conexão é refeita

void abrirConexao() {//OPENS CONNECTION TO MQTT

  Serial.print("Conectando-se na rede!");

  Serial.println("  Aguarde!");

  if (MQTT.connect(ID_MQTT)) {
    Serial.print("Conectado com sucesso!");




  while (!MQTT.connected()) {
        Serial.print("Conectando ao Broker MQTT: ");
        if (MQTT.connect(ID_MQTT)) {
            Serial.println("Conectado ao Broker com sucesso!");
        else {
            Serial.println("Noo foi possivel se conectar ao broker.");
            Serial.println("Nova tentatica de conexao em 10s");



void enviaValores() {
static bool estadoBotao1 = HIGH;
static bool estadoBotao1Ant = HIGH;
static unsigned long debounceBotao1;

  estadoBotao1 = digitalRead(pinBotao1);
  if (  (millis() - debounceBotao1) > 30 ) {  //Elimina efeito Bouncing
     if (!estadoBotao1 && estadoBotao1Ant) {

        //Botao Apertado     
        MQTT.publish(TOPIC_PUBLISH, "1");
        Serial.println("Botao1 APERTADO. Payload enviado.");
        debounceBotao1 = millis();
     } else if (estadoBotao1 && !estadoBotao1Ant) {

        //Botao Solto
        MQTT.publish(TOPIC_PUBLISH, "0");
        Serial.println("Botao1 SOLTO. Payload enviado.");
        debounceBotao1 = millis();

did you connect the Ethernet shield to router/switch or to computer?

I did connect the Arduino(With W5100) to a router, then connected the router to the computer. It created a "Network 2" on my computer.(Without access to internet)

try to use IPAddress class for IP address. use the latest Ethernet library and look at setup() in examples.

I changed for IPAddress and still doesn’t work. My ethernet library is version 2.0.0. My setup is really close to the source where I got the sketch. I just changed for ethernet connection(it was wifi). Do i need to change some configuration at my computer that might be causing this?

My arduino only works like web server, I’ve been trying to make it work like client(send data). I opened the door 1883(didn’t work), I tried ICS( internet connection sharing- didn’t work), used this shield to connect to cayenne(and worked, that means the problem is something else).