Read values from webpage to control relay (Ethernet Shield)

Then you didn’t change the includes to the wifi shield.

#include <SPI.h>
#include <WiFi.h>

edit: You keep referring to this device as a module instead of a shield. You should post a link to the wifi hardware you are using.

I posted the English documentation on this module in another persons thread.

http://forum.arduino.cc/index.php?topic=241146.msg1852857#msg1852857

So I presume I need to change all references to "Ethernet" to "WiFi"?

This part is easy. That is not an Arduino WiFi shield. It does not use the same library as the official Wifi shield, so I can't help you with it. Maybe you can get some help from the users in the other thread you posted a link to.

Okay. Thank you for your time. :slight_smile:

Hello, I need a help, I am doing my project with arduino, I have 2 temperature sensors DS18B20 and I can print them on webserver. But the third “temperature” will be just a number that I want to set in input text field with a submit button and somehow send it from webserver to Arduino to compare with real values of temperature and according to comparison opening/closeing relays. I tried to do it from string but I need an integer or float. Can you help me please ? i´m sending the code.

#include <SPI.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <Ethernet.h>
#define ONE_WIRE_BUS_PIN 2
OneWire oneWire(ONE_WIRE_BUS_PIN);
DallasTemperature sensors(&oneWire);
DeviceAddress Probe01 = { 0x28, 0x55, 0x76, 0xA2, 0x09, 0x00, 0x00, 0x0A };
DeviceAddress Probe02 = { 0x28, 0xFD, 0x3F, 0xA2, 0x09, 0x00, 0x00, 0xED };
byte mac = {0x90, 0xA2, 0xDA, 0x00, 0x9C, 0xB7};
IPAddress ip(192, 168, 0, 177);
EthernetServer server(80);
String readString;
int rele1=4;

void setup()
{
pinMode(rele1, OUTPUT);
digitalWrite(rele1, HIGH);
Serial.begin(9600);
Serial.print("Initializing Temperature Control Library Version ");
Serial.println(DALLASTEMPLIBVERSION);

// Initialize the Temperature measurement library
sensors.begin();

sensors.setResolution(Probe01, 10);
sensors.setResolution(Probe02, 10);

Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
pinMode(rele1, OUTPUT);
digitalWrite(rele1, HIGH);
}

void loop()
{

delay(1000);
Serial.println();
Serial.print("Number of Devices found on bus = ");
Serial.println(sensors.getDeviceCount());
Serial.print("Getting temperatures… ");
Serial.println();

sensors.requestTemperatures();

Serial.print("Probe 01 temperature is: ");
printTemperature(Probe01);
Serial.println();

Serial.print("Probe 02 temperature is: ");
printTemperature(Probe02);
Serial.println();

EthernetClient client = server.available();

if (client) {
Serial.println(“new client”);

boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 100) {

//store characters to string
readString += c;
//Serial.print(c);
Serial.write(c);
}
if (c == ‘\n’ && currentLineIsBlank) {

client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“Connection: close”);
client.println(“Refresh: 5”);
client.println();
client.println("");
client.println("");
client.println("");
client.print("

 

");
client.print(“

Actual temperatures

”);
client.print("

temp 1 = ");
client.print(sensors.getTempC(Probe01));
client.print("

temp 2 = “);
client.print(sensors.getTempC(Probe02));
client.print(”
");

client.println(""); //uses IP/port of web page

client.println("Požadovaná teplota:
");

client.println("");

client.println("");

client.println("");
break;
}
if (c == ‘\n’) {

currentLineIsBlank = true;
} else if (c != ‘\r’) {

currentLineIsBlank = false;
}
}
}

delay(1);

client.stop();

Serial.println(“client disconnected”);
}

if (readString.length() >0) {
Serial.println(readString); //so you can see the captured String
int n = readString.toInt(); //convert readString into a number

Serial.print(n);
readString="";
}
if(readString.toInt()>sensors.getTempC(Probe01)){

digitalWrite(rele1, LOW);
}
else{
digitalWrite(rele1, HIGH);
}
}

void printTemperature(DeviceAddress deviceAddress)
{

float tempC = sensors.getTempC(deviceAddress);

if (tempC == -127.00)
{
Serial.print("Error getting temperature ");
}
else
{
Serial.print("C: ");
Serial.print(tempC);

}
}