Hello, I need help.
I need to connect the NTC10k sensor to a high seal refrigerator, which is why the ds18b20 would not work, as they have thicker cables and neither does the DHT11.
As the NTC10k has only two wires, I can place it in the fridge without disturbing its seal.
I need help because NTC is not connecting to blynk and I don’t know how to solve it, I’m using the following code:
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <WiFiManager.h>
#define BLYNK_TEMPLATE_ID "TMPLhS6Pw9a8"
#define BLYNK_TEMPLATE_NAME "NTC10k"
#define BLYNK_AUTH_TOKEN "EXZgQkXDwUtS7wagilF34jXBnslTwavk"
#define BLYNK_PRINT Serial
#define THERMISTORPIN A0
#define THERMISTORNOMINAL 10000
#define TEMPERATURENOMINAL 25
#define NUMSAMPLES 5
#define BCOEFFICIENT 3950
#define SERIESRESISTOR 10000
const char* ssid = "nit";
const char* pass = "nit@univas";
char auth[] = "EXZgQkXDwUtS7wagilF34jXBnslTwavk";
BlynkTimer timer;
int samples[NUMSAMPLES];
void myTimerEvent()
{
Blynk.virtualWrite(V1, millis() / 1000);
}
void sensorDataSend()
{
int ThermistorPin = 32;
int Vo;
float A = 10000;
float logC, C, T ;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
float c4 = 1.009249522e-03, c5 = 2.378405444e-04, c6 = 2.019202697e-07;
Vo = analogRead(ThermistorPin);
C = A * (1023.0 / (float)Vo - 1.0);
logC = log(C);
T = (1.0 / (c1 + c2*logC + c3*logC*logC*logC));
T = T - 273.15;
Blynk.virtualWrite(V1, T);
}
void setup(void) {
Blynk.begin(auth, ssid, pass);
Serial.begin(9600);
analogReference(EXTERNAL);
timer.setInterval(5000L, sensorDataSend);
}
void loop(void) {
uint8_t i;
float average;
// take N samples in a row, with a slight delay
for (i=0; i< NUMSAMPLES; i++) {
samples[i] = analogRead(THERMISTORPIN);
delay(10);
Blynk.run();
timer.run();
}
// average all the samples out
average = 0;
for (i=0; i< NUMSAMPLES; i++) {
average += samples[i];
}
average /= NUMSAMPLES;
Serial.print("Average analog reading ");
Serial.println(average);
// convert the value to resistance
average = 1023 / average - 1;
average = SERIESRESISTOR / average;
Serial.print("Thermistor resistance ");
Serial.println(average);
float steinhart;
steinhart = average / THERMISTORNOMINAL; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert absolute temp to C
Serial.print("Temperature ");
Serial.print(steinhart);
Serial.println(" *C");
delay(1000);
}