Le voici… C’est un arduino en Ethernet. Il faut adapter le code à la puce ethernet que tu as.
Il faut bien entendu mettre à jour les infos d’@IP. Etc.
Ca doit donner une base correcte 
#include <SPI.h>
#include <Ethernet.h>
#include <Wiegand.h>
#define LUMIERE 9
String wgPINCODE ="";
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x0E, 0xBE, 0xAA, 0xBB, 0xBA, 0x19 };
#include <PubSubClient.h>
long stayon = 1500;
void callback(char* topic, byte* payload, unsigned int length);
const char* mqtt_server = "192.168.1.224";
const char* mqtt_input = "garage/input";
const char* mqtt_output = "garage/output";
IPAddress ipEth(192, 168, 1, 223);
IPAddress ipDNS(192, 168, 1, 254);
IPAddress subnet(255, 255, 255, 0);
void callback(char* topic, byte* payload, unsigned int length);
WIEGAND wg;
EthernetClient ethClient;
PubSubClient client(mqtt_server, 1883, callback, ethClient);
long lastMsg = 0;
char message_buff[100];
void setup() {
Serial.begin(115200);
setup_eth();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
wg.begin(2,3);
pinMode(LUMIERE, OUTPUT);
digitalWrite(LUMIERE, HIGH);
}
void setup_eth() {
delay(10);
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
Ethernet.begin(mac, ipEth, ipDNS);
Serial.println(Ethernet.localIP());
}
void callback(char* topic, byte* payload, unsigned int length) {
payload[length] = '\0';
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}
Serial.println();
String message((char*)payload);
if (message == "open") {
digitalWrite(LUMIERE, LOW);
delay(stayon);
digitalWrite(LUMIERE, HIGH);
}
if (message == "confirm") {
digitalWrite(LUMIERE, LOW);
delay(stayon);
digitalWrite(LUMIERE, HIGH);
}
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("GarageWiegand")) {
Serial.println("connected");
// Once connected, publish an announcement...
client.subscribe(mqtt_input);
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
void loop() {
if (!client.connected()) {
reconnect();
}
if(wg.available()) {
if ( wg.getWiegandType() == 8 || wg.getWiegandType() == 4 )
{
unsigned long wgCODE = wg.getCode();
if (wgCODE == 13 )
{
char wgCodeChar[16];
// sprintf(wgCodeChar, "%s", wgPINCODE);
wgPINCODE.toCharArray(wgCodeChar, 16);
client.publish(mqtt_output,wgCodeChar);
Serial.println(wgPINCODE);
Serial.println(wgCodeChar);
wgPINCODE = "";
}
else if ( wgCODE == 27 )
{
wgPINCODE = "";
}
else
{
wgPINCODE+= String(wgCODE);
if (wgPINCODE.length() > 15 )
wgPINCODE = "";
}
}
else
{
unsigned long wgCode = wg.getCode();
char wgCodeChar[16];
sprintf(wgCodeChar,"%lu",wgCode);
Serial.println(wgCodeChar);
Serial.println(wg.getCode());
client.publish(mqtt_output,wgCodeChar);
}
}
client.loop();
}