Microcontroller NodeMCU (ESP8266) Projects

Simple Temperature Monitor ESP2866

This is a simple temperature sensor i am working on based on the ESP2866

For some reason i can’t get the ° Degree Symbol to work. i assume i have the wrong ASCII character

////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  
//  Node MCU Simple Temperature Monitor 
//
//  Author Ketan Desai
///////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////
//  Include library //
//////////////////////
#include <OneWire.h>
#include <ESP8266WiFi.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Wire.h>

////////////////////////
//  Define Data Pins  //
////////////////////////
#define ONE_WIRE_BUS D3
#define OLED_RESET LED_BUILTIN  //4

///////////////////////////
//  variable definition  //
///////////////////////////
String temperatureString;

//Wifi Details
const char* ssid = "Wifi_SSID";
const char* pass = "PASSWORD";
 
///////////////////////
//  Declare Objects  //
///////////////////////
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);

/////////////
//  Setup  //
/////////////
void setup(void){
  Serial.begin(115200);
  Serial.println("");
  
  WiFi.begin(ssid, pass);
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(100);
    Serial.print(".");
  }
  
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  DS18B20.begin();

}
////////////////
//  Functions //
////////////////
void RequestTemperature() 
  {
    DS18B20.requestTemperatures();
    temperatureString = String (DS18B20.getTempCByIndex(0));
  }

void DisplayTemp ()
  {
   Serial.println("");
   Serial.print(temperatureString);
   Serial.print((char)248);
   Serial.print("C");
  }

////////////////////////
//  Main Program Loop //
////////////////////////
void loop()
  {
  RequestTemperature();
  DisplayTemp();
  //delay(300000);
  delay(10000);
  }

Leave a Reply

Your email address will not be published. Required fields are marked *