Go Down

Topic: MQTT Publish funkt nicht (Read 579 times) previous topic - next topic


ich verwende einen Uno R3 mit einem ENC28J60 Modul und diesem Code
Code: [Select]

#include <SPI.h>
#include <UIPEthernet.h>
#include "PubSubClient.h"
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte server[] = { 192, 168, 1, 6 };
byte mac[] = {  0x00, 0x01, 0x02, 0x03, 0x04, 0x05};

void callback(char* topic, byte* payload, unsigned int length) {
  // handle message arrived

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient ethClient;
PubSubClient client(server, 1883, callback, ethClient);

void setup() {
  // Open serial communications and wait for port to open:
  // this check is only needed on the Leonardo:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for (;;)
  // print your local IP address:
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
  if (client.connect("arduinoClient")) {
    client.publish("thisis/atest","hello world");

void loop() {

Der Mosquitto Server läuft einwandfrei da ich an localhost topics publishen kann, aber mit Arduino bekomm ich es nicht hin. Habe hier gelesen dass jemand mit der UIPEthernet Lib MQTT auf dem ENC Modul zum Laufen bekommen hat. Hab CS auf Arduino Pin 10, IP Adresse bekomme ich zugewiesen nur der Publish will nicht funken.
Was mache ich falsch?

Go Up