Things used in this project

Hardware components:
Nodemcu
NodeMCU NodeMCU ESP8266 Breakout Board
Im using the 0.9 version
×1
Pi 3 02
Raspberry Pi Raspberry Pi 3 Model B
Anyone will do. as we are only using to host an instance of Node-Red and MQTT
×1
10k NTC thermistor
×1
Software apps and online services:
Ide web
Arduino Arduino IDE
node-red

Schematics

Thermistor hookup
could not find NodeMCU in Fritzing but this will work.
9bgouuwwh76u3g1nradc

Code

HLT example Arduino
Use a solid state relay to control the Heating element from the Node-Red dashboard.
/*
 Built off the Basic ESP8266 MQTT example
*/


//MQTT Items in this script. HLTTempIn=Arduino to PI & SetHLTTemp=PI to Arduino



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

// Update these with values suitable for your network.

const char* ssid = "enter you SSID";
const char* password = "Your WIFI password";
const char* mqtt_server = "MQTT server address"; // do not include the :1883
int pin = A0; // Thermistor Pin
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;
String SetTemp;
int KeepTemp;
//********************************************************
//Thermister data //From Brew Bench
// https://learn.adafruit.com/thermistor/using-a-thermistor
// resistance at 25 degrees C
#define THERMISTORNOMINAL 10200
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 3960 //3950
// the value of the 'other' resistor
#define SERIESRESISTOR 9840//9840

int samples[NUMSAMPLES];
//*******************************************************


void setup_wifi() {

  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

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

  randomSeed(micros());

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) {

    SetTemp += (char)payload[i];
    // Serial.print();
  }
  KeepTemp = SetTemp.toInt();
  Serial.print(KeepTemp);
  //KeepTemp=SetTemp;
  SetTemp = "";
  Serial.println();
  HeatControl();
  //Recieve Prefered HLT Temp
  //  SetTemp =(char)payload[i];

  // Switch on the LED if an 1 was received as first character
  // if ((char)payload[0] == '1') {
  // digitalWrite(BUILTIN_LED, LOW);   // Turn the LED on (Note that LOW is the voltage level
  // but actually the LED is on; this is because
  // it is acive low on the ESP-01)
  //} else {
  //digitalWrite(BUILTIN_LED, HIGH);  // Turn the LED off by making the voltage HIGH
  //value =0;
  //}

}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Create a random client ID
    String clientId = "ESP8266Client-";
    clientId += String(random(0xffff), HEX);
    // Attempt to connect
    if (client.connect(clientId.c_str())) {
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.publish("HLTTempIn", "0");
      // ... and resubscribe
      client.subscribe("SetHLTTemp");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  Serial.begin(115200);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}

void loop() {

  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  long now = millis();
  if (now - lastMsg > 2000) {
    lastMsg = now;
    value = Thermistor();
    value = value * 1.8 + 32;
    //++value;
    snprintf (msg, 75, "%ld", value);
    Serial.print("Publish message: ");
    Serial.println(msg);
    client.publish("HLTTempIn", msg);
  }
    HeatControl();

}

float Thermistor() { //From Brew Bench
  uint8_t i;
  float average;

  // take N samples in a row, with a slight delay
  for (i = 0; i < NUMSAMPLES; i++) {
    samples[i] = analogRead(pin);
    delay(10);
  }
  // average all the samples out
  average = 0;
  for (i = 0; i < NUMSAMPLES; i++) {
    average += samples[i];
  }
  average /= NUMSAMPLES;
  // convert the value to resistance
  average = 1023 / average - 1;
  average = SERIESRESISTOR / 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;

  return steinhart;
}

void HeatControl() { //This LED runs the SSR controling the heating element.

  if (KeepTemp > value) {
    digitalWrite(BUILTIN_LED, LOW);
  }
  else {
    digitalWrite(BUILTIN_LED, HIGH);
  }
}
node redJSON
copy this as text and "import-> clipboard" it after installing Node-Red ,MQTT, and Dashboard. Not sure if it is JSON or not? Had to pick one.
[{"id":"460f620d.2945e4","type":"mqtt out","z":"bebdff9e.bd0678","name":"Out to arduino","topic":"SetHLTTemp","qos":"","retain":"","broker":"90df1d9a.a10478","x":401,"y":336,"wires":[]},{"id":"cbca4eab.19913","type":"mqtt in","z":"bebdff9e.bd0678","name":"From arduino","topic":"HLTTempIn","qos":"2","broker":"90df1d9a.a10478","x":191,"y":214,"wires":[["9459158d.79239"]]},{"id":"9459158d.79239","type":"ui_gauge","z":"bebdff9e.bd0678","name":"Current HLT","group":"b08d087a.f65578","order":0,"width":0,"height":0,"gtype":"gage","title":"HLT Temp","label":"•F","format":"{{value}}","min":0,"max":"200","colors":["#00B500","#E6E600","#CA3838"],"x":394,"y":219,"wires":[]},{"id":"cc20567d.3d31f8","type":"ui_slider","z":"bebdff9e.bd0678","name":"SetHLT","label":"SetHLTTemp","group":"b08d087a.f65578","order":0,"width":0,"height":0,"passthru":true,"topic":"SetHLTTemp","min":"50","max":"200","step":1,"x":133,"y":393,"wires":[["460f620d.2945e4","697479bd.6967c8"]]},{"id":"697479bd.6967c8","type":"ui_text","z":"bebdff9e.bd0678","group":"b08d087a.f65578","order":0,"width":0,"height":0,"name":"Current Value","label":"","format":"{{msg.payload}}","layout":"col-center","x":341,"y":460,"wires":[]},{"id":"90df1d9a.a10478","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""},{"id":"b08d087a.f65578","type":"ui_group","z":"","name":"HLT","tab":"7d29e78f.ffcc5","order":1,"disp":true,"width":"5"},{"id":"7d29e78f.ffcc5","type":"ui_tab","z":"","name":"Brew Controller","icon":"dashboard","order":1}]

Credits

13728918 10209684861589126 4521940337226099485 n
Chris-topher Slater

Technology Teacher Chesapeake VA. Play with Home automation.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

From BT to WiFi: Creating WiFi Controlled Arduino Robot Car
Intermediate
  • 328
  • 5

Protip

NodeMCU ESP8266 in access point mode: the simplest way to make Wi-Fi controlled Robot Car from Bluetooth Arduino Robot Car + Android App.

Magic VR Hat
Intermediate
  • 616
  • 8

Wear the hat, get transported to different 360 VR experience.

LoRaWAN for Raspberry Pi with Worldwide Frequency Support
Intermediate
  • 3,878
  • 18

Full instructions

LoRaWAN LMIC 1.6 for Raspberry Pi with Dragino LoRA/GPS HAT or standalone RFM95W LoRa Module.

Human-Following Robot with Kinect
Intermediate
  • 2,571
  • 24

Full instructions

Instead of using single camera and complicated image recognition algorithms we can take advantage of Kinect libraries.

Wireless Programming and Debugging with STM32 and RPi
Intermediate
  • 99
  • 2

Full instructions

Are you tired of connecting programmer every time you want to change some functionality of your robot? Why not to try wireless programming?

Thunderboard Sense and RPi
Intermediate
  • 135
  • 2

Collecting rich sensor data over BLE and uploading it to the cloud for analysis.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog