#include #include #include #include "DHT.h" #define TOPIC "data/here/temperature" #define DHTPIN 2 #define DHTTYPE DHT22 DHT dht(DHTPIN, DHTTYPE); byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; byte server[] = { 192, 168, 1, 33 }; byte ip[] = { 192, 168, 1, 72 }; EthernetClient ethClient; PubSubClient client(server, 1883, 0, ethClient); void setup() { Ethernet.begin(mac, ip); dht.begin(); Serial.begin(9600); } void loop() { //client.loop(); float t = dht.readTemperature(); float h = dht.readHumidity(); //String temp = String(t); Serial.println(t); char temp[6]; dtostrf(t, 5, 2, temp); Serial.print(temp); if (client.connect("arduinoClient")) { client.publish(TOPIC,temp); } delay(5000); }