PaulS:
Using what code?
webpage= "<p><center><strong>CURRENT TEMP</p><p><form><input type=number value=sensors.getTempFByIndex(0) readonly>";
You don't really expect that assignment statement to call the getTempFByIndex() function, do you?
Paul
that is where i am getting stuck not sure how to figure it out hence my posting a question to you guys
here is the code auto formatted the first one is the temperature controller the second the webserver
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27(Cooperate with 3 short circuit caps) for a 16 chars and 2 line display
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS_PIN 4
OneWire oneWire(ONE_WIRE_BUS_PIN);
DallasTemperature sensors(&oneWire);
int backlightState = LOW;
long previousMillis = 0;
long interval = 1000;
int Relay1 = 5;
int Relay2 = 6;
int Temp01SetPoint = 68;
int Temp01SetDiff = .5;
const int buttonPin = 7;
int buttonState = 0;
const int button1Pin = 8;
int button1State = 0;
void setup() {
//
connect();
//
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.home();
lcd.begin(16, 2);
fill();
delay(5000);
lcd.clear();
sensors.begin();
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
//turn off the relays to start
digitalWrite(Relay1, HIGH);
digitalWrite(Relay2, HIGH);
pinMode(buttonPin, INPUT);
pinMode(button1Pin, INPUT);
}
void fill()
{ lcd.setCursor(3, 0);
lcd.print("Irons Gate");
lcd.setCursor(4, 1);
lcd.print("Brewery");
}
void loop()
{
control();
sensors.requestTemperatures();
lcd.setCursor(0, 0);
lcd.print("FV1 SET= F");
lcd.setCursor(10, 0);
lcd.print(Temp01SetPoint);
lcd.setCursor(0, 1);
lcd.print("FV1= F");
lcd.setCursor(5, 1);
lcd.print(sensors.getTempFByIndex(0));
Serial.println(sensors.getTempFByIndex(0));
buttonState = digitalRead(buttonPin);
Serial.println(buttonState);
button1State = digitalRead(button1Pin);
Serial.println(button1State);
//COOLING
if (sensors.getTempFByIndex(0) > (Temp01SetPoint + Temp01SetDiff))
digitalWrite(Relay1, LOW);
else if (sensors.getTempFByIndex(0) == Temp01SetPoint)
digitalWrite(Relay1, HIGH);
//HEATING
if (sensors.getTempFByIndex(0) < (Temp01SetPoint - Temp01SetDiff))
digitalWrite(Relay2, LOW);
else if (sensors.getTempFByIndex(0) == Temp01SetPoint)
digitalWrite(Relay2, HIGH);
if (sensors.getTempFByIndex(0) < (Temp01SetPoint - Temp01SetDiff))
digitalWrite(Relay1, LOW);
else if (sensors.getTempFByIndex(0) == Temp01SetPoint)
digitalWrite(Relay1, HIGH);
//PUSH BUTTONS
if (buttonState == HIGH)
{ Serial.println("Button is ON ");
++Temp01SetPoint;
Serial.println(Temp01SetPoint);
}
else
{
Serial.println("Button is OFF");
};
if (button1State == HIGH)
{ Serial.println("Button is ON ");
--Temp01SetPoint;
Serial.println(Temp01SetPoint);
}
else
{
Serial.println("Button is OFF");
};
delay(100);
//
//
}
#include <SoftwareSerial.h>
#define DEBUG true
SoftwareSerial esp8266(2, 3);
void connect() {
Serial.begin(9600);
esp8266.begin(9600); // your esp's baud rate might be different
sendData("AT+RST\r\n", 2000, DEBUG); // reset module
sendData("AT+CWMODE=1\r\n", 1000, DEBUG); // configure as access point
sendData("AT+CWJAP=\"Johnston\",\"4017380838\"\r\n", 3000, DEBUG);
delay(3000);
sendData("AT+CIFSR\r\n", 1000, DEBUG); // get ip address
sendData("AT+CIPMUX=1\r\n", 1000, DEBUG); // configure for multiple connections
sendData("AT+CIPSERVER=1,80\r\n", 1000, DEBUG); // turn on server on port 80
}
void control()
{ if (esp8266.available()) // check if the esp is sending a message
{
if (esp8266.find("+IPD,"))
{
delay(1000);
int connectionId = esp8266.read() - 48; // subtract 48 because the read() function returns
// the ASCII decimal value and 0 (the first decimal number) starts at 48
float tempf = sensors.getTempFByIndex(0);
String webpage = "<body background=https://scontent-iad3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/1462848_572151666199012_864666124_n.jpg?oh=52378bc2ac8912fab163de0d70fef52b&oe=57B46108>" ;
String cipSend = "AT+CIPSEND=";
cipSend += connectionId;
cipSend += ",";
cipSend += webpage.length();
cipSend += "\r\n";
sendData(cipSend, 100, DEBUG);
sendData(webpage, 1000, DEBUG);
webpage = "<font color=#66ff00><h1><center>IRONS GATE BREWERY</h1>";
cipSend = "AT+CIPSEND=";
cipSend += connectionId;
cipSend += ",";
cipSend += webpage.length();
cipSend += "\r\n";
sendData(cipSend, 100, DEBUG);
sendData(webpage, 1000, DEBUG);
webpage = "<center><strong>SET TEMP<form><input type=number value=Temp01SetPoint readonly>" ;
cipSend = "AT+CIPSEND=";
cipSend += connectionId;
cipSend += ",";
cipSend += webpage.length();
cipSend += "\r\n";
sendData(cipSend, 1000, DEBUG);
sendData(webpage, 1000, DEBUG);
webpage = "<p><center><strong>CURRENT TEMP</p><p><form><input type=number value=sensors.getTempFByIndex(0) readonly>";
cipSend = "AT+CIPSEND=";
cipSend += connectionId;
cipSend += ",";
cipSend += webpage.length();
cipSend += "\r\n";
sendData(cipSend, 1000, DEBUG);
sendData(webpage, 1000, DEBUG);
String closeCommand = "AT+CIPCLOSE=";
closeCommand += connectionId; // append connection id
closeCommand += "\r\n";
sendData(closeCommand, 3000, DEBUG);
}
}
}
String sendData(String command, const int timeout, boolean debug)
{
String response = "";
esp8266.print(command); // send the read character to the esp8266
long int time = millis();
while ( (time + timeout) > millis())
{
while (esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
response += c;
}
}
if (debug)
{
Serial.print(response);
}
return response;
}