Esp8266 temperature probe

Hi i'm new here, just wondering if anyone could help. I am doing a complex WiFi temp probe with esp8266 and my code won't work. Here is the code:

#include <OneWire.h>
#include <DallasTemperature.h>

#include <NTPClient.h>
#include <WiFiUdp.h>

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

const char* ssid = "TelstraA09B23";
const char* password = "AF151C2182";
const char* mqtt_server = "broker.mqtt-dashboard.com";

WiFiClient espClient;
PubSubClient client(espClient);

int donepin = 5;
String formattedDate;
String dayStamp;
String timeStamp;


WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);

OneWire oneWirePenetrative(4);
DallasTemperature sensor2(&oneWirePenetrative);

float ambient_temp;
float penetrative_temp;

char Buffer[100];


void setup() {
  timeClient.begin();
  pinMode(donepin, OUTPUT);
  Serial.begin(9600);
  setup_wifi();
  timeClient.setTimeOffset(34200); 
  readTemp();
  MQTT();
  delay(100);
   
}

void setup_wifi() {

  delay(10);
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
}

void readTemp(){
  
  sensor2.requestTemperatures();
  penetrative_temp = sensor2.getTempCByIndex(0);
 
  }

void MQTT(){
  client.setServer(mqtt_server, 1883);
  bool connected = client.connect("client01","","");
  if(connected){
    timeClient.update();
    Serial.println("MQTT DID connect");
    sprintf(Buffer, "The date is %s the time is %s:%s:%s and the temp is %3.0f",timeClient.getDay(), timeClient.getHours(), timeClient.getMinutes(), timeClient.getSeconds(), penetrative_temp);
    client.publish("TempTopic", Buffer);
  }
  else{
    Serial.println("MQTT did NOT connect");
  }
done();
}

void done(){
  delay(1000);
  client.publish("DebugTopic", "POWERING DOWN...");
  delay(100);
  digitalWrite(donepin, LOW);
  digitalWrite(donepin, HIGH);
  delay(10);
}

void loop()
{

}

Thanks

Hi,
Explain better.
For my license from the association of soothsayers is expired.

Does it compile without error?
What is contained in the monitor output?
To what is pin 5 connected?

Please show us the circuit schematic.

i will try to show to schematic but they do not have the right parts on fritzing. and yes it does compile without error.

I cannot even find 20% of the parts on fritzing. pin 5 is connected to a sparkfun nano power timer done pin and the 4 pin is connected to a ds18b20 onewire temp sensor. I am using a lolin d1 mini.

Forsooth, loop () is truly void, bereft of content, there's nothing there.

the code only has to run once since the chip gets turned off and on again.
every 30 minutes is gets turned on and once it is finished publishing to mqtt it sends a signal to the power timer to turn it off. btw I have about 2.5 years experience in arduino code.

the code only has to run once since the chip gets turned off and on again.
every 30 minutes is gets turned on and once it is finished publishing to mqtt it sends a signal to the power timer to turn it off. btw I have about 2.5 years experience in arduino code.

Fritzing is anyway not a schematic, a hand drawn schematic will do or use a simple drawing program or something like Kicad.

what information appears on the serial monitor? i.e.

  1. does it conect to the WiFi network?
  2. does it read the temperature OK?
  3. does it attempt to connect via MQTT?

I've noted how everybody is just dying to know what is not happening that you think should, where you note everything about this "my code won't work" complaint, details about that stuff.
How about filling in the blanks?

OK. I am pretty new to arduino forum and This is my first post. so thank you and I will try my best to show a schematic.

yes, yes and yes. it connects but gets stuck at the publishing part.
btw I am in the middle of upgrading to adafruit huzzah32 with proto featherwing because of the IoT
features. I do not have the original setup anymore but if the code works I can convert it to esp32.
Thanks

Sorry about that. I just do not know what is wrong. it worked very well before I added the

> Buffer, "The date is %s the time is %s:%s:%s and the temp is %3.0f",timeClient.getDay(), timeClient.getHours(), timeClient.getMinutes(), timeClient.getSeconds(), penetrative_temp

I Am Trash At Schematics

Which library is your source for NTPClient.h ?

int day = timeClient.getDay();
int hh = timeClient.getHours();
int mm = timeClient.getMinutes();
int ss = timeClient.getSeconds();

sprintf(Buffer, "The date is %s the time is %s:%s:%s and the temp is %3.0f",day, hh, mm, ss, penetrative_temp);
sprintf(Buffer, "The date is %d the time is %d:%d:%d and the temp is %3.0f",day, hh, mm, ss, penetrative_temp);

? ? ?

The NTPClient library. I do not know what you mean, the library IS NTPClient 3.1.

Mine got "lost".
I used/use the aentinger library on/from github.
I'm not sure if the function calls are OK with sprintf.
I've used the NTPClient.h in a clock project, but with the variables
outside the sprintf().

Any difference (see edited post No. 18)