Hello,
I am extremely new to arduino so I am sorry for any noob questions, I have been googling a few weeks now so I hope it is ok to ask a question
My starting project is getting some temperature's from my boiler with a very low power/cost device and send it over ethernet (not wifi) to my Rasberry pi for further use.
I have a arduino nano with ENC28J60 ethernet shield and some DS18B20 sensors and Mosquito MQTT running on my Rasberry pi.
I am able to get my DS18B20 sensor's working and can read the temperature with the serial monitor
Working code for this part :
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Addresses of 2 DS18B20s
uint8_t sensor1[8] = { 0x28, 0x17, 0x56, 0x79, 0x97, 0x10, 0x03, 0xAE };
uint8_t sensor2[8] = { 0x28, 0xF6, 0x5B, 0x79, 0x97, 0x11, 0x03, 0x98 };
void setup(void)
{
 Serial.begin(9600);
 sensors.begin();
}
void loop(void)
{
 sensors.requestTemperatures();
Â
 Serial.print("Sensor 1: ");
 printTemperature(sensor1);
Â
 Serial.print("Sensor 2: ");
 printTemperature(sensor2);
Â
 Â
 Serial.println();
 delay(1000);
}
void printTemperature(DeviceAddress deviceAddress)
{
 float tempC = sensors.getTempC(deviceAddress);
 Serial.print(tempC);
 Serial.print((char)176);
 Serial.print("C | ");
 Serial.print(DallasTemperature::toFahrenheit(tempC));
 Serial.print((char)176);
 Serial.println("F");
}
I am also able to get a network connection to show the "Hello World" webpage, so the LAN is working also on the nano with the ENC28J60
my code (copy pasted afcourse )
#include <UIPEthernet.h> // Voor Ethernet
// **** ETHERNET INSTELLINGEN ****
byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
IPAddress ip(192, 168, 15, 111);Â Â Â Â Â Â Â Â Â Â Â Â
EthernetServer server(80);
void setup() {
 Serial.begin(9600);
 // start de Ethernet verbinding en de server:
 Ethernet.begin(mac, ip);
 server.begin();
 Serial.print("IP Adres: ");
 Serial.println(Ethernet.localIP());
}
void loop() {
 // listen for incoming clients
 EthernetClient client = server.available();
 if (client)
 {Â
  Serial.println("-> Nieuwe Verbinding");
  // een http request eindigt met een lege regel
  boolean currentLineIsBlank = true;
  while (client.connected())
  {
   if (client.available())
   {
    char c = client.read();
    // als je aan het einde van een regel bent (newline karakter ontvangen)
    // en de regel is leeg, dan zijn we aan het einde van een HTTP request gekomen,
    // en kunnen we een antwoord sturen
    if (c == '\n' && currentLineIsBlank)
    {
     client.println("<html><title>Hello World!</title><body><h3>Hello World!</h3></body>");
     break;
    }
    if (c == '\n') {
     // We beginnen met een nieuwe regel
     currentLineIsBlank = true;
    }
    else if (c != '\r')
    {
     // we ontvingen een karakter (niet einde regel)
     currentLineIsBlank = false;
    }
   }
  }
  // geef de browser tijd om de data te ontvangen
  delay(10);
  // sluit de verbinding:
  client.stop();
  Serial.println(" Einde verbinding\n");
 }
}
I however am not been able to combine these to send temperature readings to my MQTT server,
I can fine alot of examples for this but they are all for other sensors (DHT11 or BME280)
Like these examples ;
So it looks defenatly possible to use the enc28j60 to use pubsub (also confirmed by pubsub maintainer that it should work with the new UIPethernet.h
but for the life of my I can not find a way or an example to send the temperature data from my DS18B20 to a MQTT broker, I do find examples like these :
but they all work with Wifi modules and not an ethernet shield and my very limited knowlidge makes it impossible to convert them to my ethernet shield
If anyone could point me in the right direction or knows of a project/example with the ENC28J60-DS18B20-MQTT combo that would be awesome.
thank you in advance,
Hans