Digital Temperature Probe

Why? First the background, the other weekend my daughter and I made a home made pizza's including the base. The recipe book called for activating the yeast in tepid water. Well what temperature is tepid water supposed to be? Warm was the answer I got so having a rough guess and using my finger probe the yeast was added to the water and the 15-minute wait began. The yeast didn't react as fast as I would have hoped and being brand new yeast, it was time to over engineer a solution!

Googling best temperature to activate yeast turns up 38C.  As luck would have it I had a spare ESP8266 micro controller, a water proof DS18B20 temperature sensor and a OLED LCD

Parts:

  • ESP8266 ESP-12E

  • DS1820 Stainless steel package Waterproof DS18b20 temperature probe

  • 0.96 inch oled IIC Serial White OLED Display Module 128X64 I2C SSD1306 12864 LCD

ESP8266 Digital Temperature Probe

Testing it out the following weekend making another pizza base for lunch.

Water close enough to the optimal temperature of 38C for activating yeast.

Water Temp

The Yeast began very fast and by the end had overflowed the top of the measuring cup.

The result was outstanding compared to the week before when I just guessed what temperature Tepid water was. The doe rose faster because of activating the yeast correctly.

What would I improve, I left the webserver code in the sketch so you can read the temperature remotely

Web Temperature Display

This implementation requires a refresh of the web page to retrieve the temperature, If you didn't have a LCD handy I would recommend using the aysn web server example here that creates a dynamic web page the automatically updates.

Random Nert Tutorials Example

Using Rui Santos example for a temperature webserver I've added in the LCD screen for convenience to instantly see the temperature rather then refreshing the web page on your phone. 

ESP8266 DS18B20 Temperature Sensor

Code:

/*********
  Rui Santos
  Complete project details at http://randomnerdtutorials.com  
*********/

 

// Including the ESP8266 WiFi library
#include
#include
#include
#include
#include
#include
#include

 

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

 

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

 

// Replace with your network details
const char* ssid = "wifiname";
const char* password = "wifipass";

 

// Data wire is plugged into pin D4 on the ESP8266 12-E - GPIO 2
#define ONE_WIRE_BUS 2

 

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

 

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature DS18B20(&oneWire);
char temperatureCString[6];
char temperatureFString[6];

 

// Web Server on port 80
WiFiServer server(80);

 

// only runs once on boot
void setup() {
  // Initializing serial port for debugging purposes
  Serial.begin(115200);
  delay(10);
  pinMode(ONE_WIRE_BUS, INPUT);
  Serial.println("Set D2 pull high");
  pinMode(ONE_WIRE_BUS,INPUT_PULLUP);

 

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { 
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  display.clearDisplay();
  display.setCursor(0,0);
  display.setTextSize(1);             // Draw 1X-scale text
  display.setTextColor(WHITE);
  display.println(F("Display Initialized"));
  display.display();
  
  DS18B20.begin(); // IC Default 9 bit. If you have troubles consider upping it 12. Ups the delay giving the IC more time to process the temperature measurement
  
  // Connecting to WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  display.println(F("Connecting to "));
  display.display();
  Serial.println(ssid);
  display.println(ssid);
  display.display();
  
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    display.print(F("."));
    display.display();
  }
  Serial.println("");
  display.println(F(""));
  display.display();
  Serial.println("WiFi connected");
  display.println(F("WiFi connected"));
  display.display();
  
  // Starting the web server
  server.begin();
  Serial.println("Web server running. Waiting for the ESP IP...");
  display.clearDisplay();
  display.setCursor(0,0);
  display.println(F("Web server running. Waiting for the ESP IP..."));
  display.display();
  delay(10000);
  
  // Printing the ESP IP address
  Serial.println(WiFi.localIP());
  display.println(WiFi.localIP());
  display.display();
  delay(1000);
}

 

void getTemperature() {
  delay(100);
  float tempC;
  float tempF;
  do {
    DS18B20.requestTemperatures(); 
    tempC = DS18B20.getTempCByIndex(0);
    dtostrf(tempC, 2, 2, temperatureCString);
    tempF = DS18B20.getTempFByIndex(0);
    dtostrf(tempF, 3, 2, temperatureFString);
    delay(100);
  } while (tempC == 85.0 || tempC == (-127.0));
  displaytemp(tempC);
}

 

// runs over and over again
void loop() {
  getTemperature();
  // Listenning for new clients
  WiFiClient client = server.available();
  
  if (client) {
    Serial.println("New client");
    // bolean to locate when the http request ends
    boolean blank_line = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        
        if (c == '\n' && blank_line) {
            getTemperature();
            client.println("HTTP/1.1 200 OK");
            client.println("Content-Type: text/html");
            client.println("Connection: close");
            client.println();
            // your actual web page that displays temperature
            client.println("");
            client.println("");
            client.println("ESP8266 - Temperature

Temperature in Celsius: ");

            client.println(temperatureCString);
            client.println("*C

Temperature in Fahrenheit: ");

          client.println(temperatureFString);
            client.println("*F");  
            break;
        }
        if (c == '\n') {
          // when starts reading a new line
          blank_line = true;
        }
        else if (c != '\r') {
          // when finds a character on the current line
          blank_line = false;
        }
      }
    }  
    // closing the client connection
    delay(1);
    client.stop();
    Serial.println("Client disconnected.");
  }
}

 

void displaytemp(float tempC) {
  display.clearDisplay();
  display.setCursor(1,2);
  display.setTextSize(2);             // Draw 2X-scale text
  display.setTextColor(WHITE);
  display.println(F("Temp"));
  display.print(tempC);
  display.print((char)247);
  display.print("C");
  display.display();
  delay(500);
}