/* Sketch was generated by motoblockly
  Website: http://www.motoblockly.com
  Author: www.motoduino.com
  Date: Mon Dec 25 2023 11:09:04 GMT+0800
*/
#include <WiFi.h>
#include <PubSubClient.h>
#include <DHT.h>

float  temp = 0;
WiFiClient client;
PubSubClient mqtt_client(client);
DHT dht(13, DHT22);

void setup()
{
  Serial.begin(115200);
  pinMode(13, INPUT);
  dht.begin();
  WiFi.mode(WIFI_STA);
  //  WiFi.begin(String("").c_str(),String("").c_str());
  WiFi.begin("Wokwi-GUEST", "", 6);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
   Serial.println("Connected  TO wifi ");
  mqtt_client.setServer("broker.MQTTGO.io", 1883);
  while (!mqtt_client.connect("3330250524")) {
    Serial.print(".");
    delay(1000);
  }
    Serial.println("Connected  TO MQTT ");
}


void loop()
{
  temp = dht.readTemperature();
  Serial.println((String("temp:") + String(temp)));
  mqtt_client.publish(String("kirk/temp").c_str(), String(temp).c_str());

}