DS18B20(solar heating) display through webserver - need help(now with LCD)

Hi guys, as a total newbie to Arduino I am working on my first project. I have two DS18B20 temperature sensors and Ethernet shield ENC28J60 hooked up to an Arduino UNO R3. I believe that there are no problems with physical connection. However, I am struggling with the coding.

I just need to set up a simple webserver which will display the temperature from these two sensors and probably refresh itself somehow.

All I could produce so far is this “webserver example” mixed up with “DS18B20 temperatures to Serial monitor example”(maybe these are completely useless, I dont know :~). I will really really appreciate any help. :slight_smile:

I am using OneWire library and the EtherCard library, which is the only one working with ENC28J60.

Here’s the code. It compiles with no errors but it’s not working the way I want.

#include <OneWire.h>
#include <DallasTemperature.h>
#include <EtherCard.h>

#define ONE_WIRE_BUS 6

#define STATIC 1  // set to 1 to disable DHCP (adjust myip/gwip values below)

#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,2,200 };
// gateway ip address
static byte gwip[] = { 192,168,2,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "Temperature Webserver"
  "</title></head>"
  "<body>"
    "TEMPERATURE TEMPERATURE"
  "</body>"
"</html>"
;

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0x96, 0xC2, 0xBC, 0x04, 0x00, 0x00, 0xA1 };
DeviceAddress outsideThermometer = { 0x28, 0xA5, 0x0E, 0xBD, 0x04, 0x00, 0x00, 0x99 };

void setup(void)
{
  // temperature will show in serial monitor
  Serial.begin(57600);
  Serial.println("\n[Webserver]");
  // start of library
  sensors.begin();
  // resolution set to 10 bit
  sensors.setResolution(insideThermometer, 10);
  sensors.setResolution(outsideThermometer, 10);
  
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) 
    Serial.println( "Failed to access Ethernet controller");
#if STATIC
  ether.staticSetup(myip, gwip);
#else
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
#endif

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);

}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error, sensor is not responding");
  } else {
    Serial.print("C: ");
    Serial.print(tempC);
  }
}

void loop(void)
{
\
// wait for an incoming TCP packet, but ignore its contents
  if (ether.packetLoop(ether.packetReceive())) {
    memcpy_P(ether.tcpOffset(), page, sizeof page);
    ether.httpServerReply(sizeof page - 1);

delay(2000);
  Serial.print("Requesting temperature...\n\r");
  sensors.requestTemperatures();

  Serial.print("Temperature sensor 1: ");
  printTemperature(insideThermometer);
  Serial.print("\n\r");
  Serial.print("Temperature sensor 2: ");
  printTemperature(outsideThermometer);
  Serial.print("\n\r");
  
  
  
  }
}

For a first project, you better use the Ethernet Shield with the W5100. The ENC28J60 is not officially supported by Arduino.

You have a few problems. Let's do this step by step. First of all, can you explain what is going wrong, and what is your goal ?

Are your DS18B20 sensors working, and never fail ?

I used the rbbb_server file as a start for a webserver. https://github.com/jcw/ethercard/blob/master/examples/rbbb_server/rbbb_server.ino Which one did you use ? If you try that example without the temperature sensors, it that working okay ?

You have to create a webpage. In that rbbb_server example, you can see how a webpage is created. The webpage you have is not a webpage, it is a 503 error. You don't want that.

To get the temperature in the webpage, there are a few ways. The easiest one is to split the webpage into parts. And write the temperature between the rest.

To react fast when the webpage is requested, you don't want a delay in the sketch. Getting the temperature from a DS18B20 takes a long time, perhaps you have to make a schedular that gets the temperature in two steps (start conversion and get temperature).

Well, my goal is to have a functional website showing temperatures from my sensors. And the wrong thing is that I can't figure out how to reach it yet.

I think my DS18B20 are working fine.

For webserver I used some really simple example found in EtherCard library called backsoon.ino.

And yes, when I tried this "backsoon" example just as it was, I was able to get the website, so it was functional.

I'm gonna try to set up that rbbb_server you posted. However, I still don't very understand how should I get temperatures to display on that website. Could you maybe give me some exact example? I'd prefer the easiest way.

I want to thank you for your input. :)

The backSoon.ino example is about sending error code 503, it is not for a webpage.

The rbbb_server.ino example sends a webpage, and that example has already parameters.
https://github.com/jcw/ethercard/blob/master/examples/rbbb_server/rbbb_server.ino
The “HTTP/1.0 200 OK” means: here comes a valid webpage.
The “%D” is used for data and the bfill.emit_p uses the parameters after the comma.

%D = unsigned integer
%T = Floating point
%L = long
%H = hexadecimal
%S = string
%F = PROGMEM string
%E = EEPROM string

You can view the source of the webpage in the browser and compare that with the data in the sketch. You would see how the integers are filled in.

Well, my goal is to have a functional website showing temperatures from my sensors. And the wrong thing is that I can't figure out how to reach it yet.

I'd invest $10 below to save time and hassle.

http://www.ebay.com/itm/New-Ethernet-Module-Shield-W5100-For-Arduino-2009-UNO-Mega-1280-2560-/300919106157?pt=LH_DefaultDomain_0&hash=item46102d2a6d

Erdin: Thank you, looks like we moved somewhere. It’s showing the temperatures now but I have to use Long for “tempC”. There is problem with Long that it rounds down the numbers, 39.75 is 39 and so on. I dont know why float isn’t working, on the website it shows only “T”. Where’s the problem?

zoomkat: Yes, maybe I would do that if I would be totaly desperate. But it looks like I am getting closer now. :smiley:

// This is a demo of the RBBB running as webserver with the Ether Card
// 2010-05-28 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <iostream.h>

#define ONE_WIRE_BUS 6

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,2,200 };

byte Ethernet::buffer[500];
BufferFiller bfill;

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0x96, 0xC2, 0xBC, 0x04, 0x00, 0x00, 0xA1 };
DeviceAddress outsideThermometer = { 0x28, 0xA5, 0x0E, 0xBD, 0x04, 0x00, 0x00, 0x99 };

void setup () {
  
  // teplota sa bude zobrazovat na seriovej konzole
  Serial.begin(57600);
  Serial.println("\n[Webserver]");
  // Start kniznice
  sensors.begin();
  // Nastavenie rozlisenia na 10 bitov
  sensors.setResolution(insideThermometer, 10);
  sensors.setResolution(outsideThermometer, 10);
  
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  ether.staticSetup(myip);
}

float printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Chyba, senzor neodpoveda");
  } else {
    Serial.print("C: ");
    Serial.print(tempC);
  return(tempC);

}
}
static word homePage() {
  long t = millis() / 1000;
  word h = t / 3600;
  byte m = (t / 60) % 60;
  byte s = t % 60;
  sensors.requestTemperatures(); 
  bfill = ether.tcpOffset();
  bfill.emit_p(PSTR(
    "HTTP/1.0 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Pragma: no-cache\r\n"
    "\r\n"
    "<meta http-equiv='refresh' content='2'/>"
    "<title>RBBB server</title>" 
   // "<h1>$D$D:$D$D:$D$D$L $L</h1>"),h/10, h%10, m/10, m%10, s/10, s%10, printTemperature(outsideThermometer), printTemperature(insideThermometer));
  "<h1>$T $T</h1>"),printTemperature(outsideThermometer), printTemperature(insideThermometer));
  return bfill.position();
}



void loop () {
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);
  
  
  if (pos)  // check if valid tcp data is received
    ether.httpServerReply(homePage()); // send web page data
}

Neolog: I dont know why float isn't working,

zoomkat: Yes, maybe I would do that if I would be totaly desperate. But it looks like I am getting closer now. :D

Zoomkat's advice is likely the best you will get, but you might find something useful if you trawl through here.

http://stanchlessly16.joguetudo.com/chan-9341337/all_p1.html

You are getting close, but it is still a good idea to buy an Ethernet Shield.

The floating point seems to be disabled with a define in the source of the Ethercard library. In the file EtherCard.cpp, look for "FLOATEMIT" and uncomment that.

A 'long' is a 'long integer', it will only print numbers 1,2,3,4.... and so on.

You can add DHCP to your sketch. The example file testDHCP.ino shows how to do that. https://github.com/jcw/ethercard/blob/master/examples/testDHCP/testDHCP.ino

Thank you sir, that was the problem, working fine now :slight_smile: Only thing is that the temperature is now displayed with 3 decimal places, I would like to have only two. Is there any way how to round a floating point to two decimal places? But this is just the small issue. :slight_smile: I don’t really need DHCP so I am not adding it unnecessarily.

Currently it looks like this:

float printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error, sensor not responding");
  } else {
    Serial.print("C: ");
    Serial.print(tempC);
  
  return(tempC);

}
}
static word homePage() {
  long t = millis() / 1000;
  word h = t / 3600;
  byte m = (t / 60) % 60;
  byte s = t % 60;
  sensors.requestTemperatures(); 
  bfill = ether.tcpOffset();
  bfill.emit_p(PSTR(
    "HTTP/1.0 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Pragma: no-cache\r\n"
    "\r\n"
    "<meta http-equiv='refresh' content='2'/>"
    "<title>Temperature server</title>" 
  "<h1>Solar temp out: $TC
 Solar temp in: $TC</h1>

<h3>Time since restart: $D$D:$D$D:$D$D</h3>"),printTemperature(outsideThermometer), printTemperature(insideThermometer),h/10, h%10, m/10, m%10, s/10, s%10);
 
  return bfill.position();
}

Entire code(excuse the use of non-english language): http://pastebin.com/R8u5XXuM

I think now it’s time to consider implementing the pool lights control through this webserver. No idea where to start.

In that file EtherCard.cpp, the function "dtostrf()" is used to convert a float to a string. https://github.com/jcw/ethercard/blob/master/EtherCard.cpp In that file, 10 is used for the width and 3 for the precision after the decimal sign. http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#ga060c998e77fb5fc0d3168b3ce8771d42

Perhaps you can create you own buffer, and use "dtostrf()" in your sketch and use a string to get it into the webpage.

Worked like a charm, again :slight_smile: Thanks.

I also updated the code with a button for LED control(there will be relay for controlling pool lighting instead of LED). However, I find the code very “messy” but working. How should I tidy it up a bit?

Here’s the current code(sorry, i am too lazy to translate it from my language to english, I think you’ll get the point):

// This is a demo of the RBBB running as webserver with the Ether Card
// 2010-05-28 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 3

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,2,200 };


byte Ethernet::buffer[500];
BufferFiller bfill;

const int ledPin = 2;
boolean ledStatus;

char* on = "ON";
char* off = "OFF";
char* statusLabel;
char* buttonLabel;

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0x96, 0xC2, 0xBC, 0x04, 0x00, 0x00, 0xA1 };
DeviceAddress outsideThermometer = { 0x28, 0xA5, 0x0E, 0xBD, 0x04, 0x00, 0x00, 0x99 };

void setup () {
  
  // teplota sa bude zobrazovat na seriovej konzole
  Serial.begin(57600);
  Serial.println("\n[Webserver]");
  // Start kniznice
  sensors.begin();
  // Nastavenie rozlisenia na 10 bitov
  sensors.setResolution(insideThermometer, 10);
  sensors.setResolution(outsideThermometer, 10);
  
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  ledStatus = false;
  
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  ether.staticSetup(myip);
}

float printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Chyba, senzor neodpoveda");
  } else {
    Serial.print("C: ");
    Serial.print(tempC);
  
  return(tempC);

}
}
static word homePage() {
  long t = millis() / 1000;
  word h = t / 3600;
  byte m = (t / 60) % 60;
  byte s = t % 60;
  sensors.requestTemperatures(); 
  /*bfill = ether.tcpOffset();
  bfill.emit_p(PSTR(
    "HTTP/1.0 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Pragma: no-cache\r\n"
    "\r\n"
    "<meta http-equiv='refresh' content='2'/>"
    "<title>Teplotny server</title>"
   "<body align= 'center' bgcolor='#FFF8DC'>" 
  "<h1>Teplota zo solara: $TC
 Teplota do solara: $TC</h1>

<h3>Cas od restartu: $D$D:$D$D:$D$D</h3>"
 "</body>"),printTemperature(outsideThermometer), printTemperature(insideThermometer),h/10, h%10, m/10, m%10, s/10, s%10);
  return bfill.position();
*/
}



void loop () {
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);
  
  
  if(pos) {
    
    if(strstr((char *)Ethernet::buffer + pos, "GET /?status=ON") != 0) {
      Serial.println("Received ON command");
      ledStatus = true;
    }

    if(strstr((char *)Ethernet::buffer + pos, "GET /?status=OFF") != 0) {
      Serial.println("Received OFF command");
      ledStatus = false;
    }
    
    if(ledStatus) {
      digitalWrite(ledPin, HIGH);
      statusLabel = on;
      buttonLabel = off;
    } else {
      digitalWrite(ledPin, LOW);
      statusLabel = off;
      buttonLabel = on;
    }
    long t = millis() / 1000;
  word h = t / 3600;
  byte m = (t / 60) % 60;
  byte s = t % 60;  
    sensors.requestTemperatures();
    BufferFiller bfill = ether.tcpOffset();
    bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\n"
      "Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
      "<meta http-equiv='refresh' content='2';url=192.168.2.200/>"
      "<html><head><title>Teplotny server</title></head>"
      "<body align= 'center' bgcolor='#FFF8DC'>"
      "<h1>Teplota zo solara: $TC
 Teplota do solara: $TC</h1>"
      "

"
      "<h3>Osvetlenie bazena: $S"
      "<a href=\"/?status=$S\"><input type=\"button\" value=\"$S\"></a></h3>
"
      "Cas od restartu: $D$D:$D$D:$D$D"
      "</body></html>"      
      ), printTemperature(outsideThermometer), printTemperature(insideThermometer), statusLabel, buttonLabel, buttonLabel, h/10, h%10, m/10, m%10, s/10, s%10);
    ether.httpServerReply(bfill.position());
  }
}

photo.PNG

There is not much you can do to tidy it up.
You could create a new file (use the drop-down menu in the upper-right corner of the Arduino IDE) to place the temperature sensor code in its own file. But that part of the code is not big, so I would not do that.

You could add comment to create ‘blocks’ of code.

// ----------------------------
// 
// Check if button is pressed for led status
//
// ----------------------------

I have placed the webpage code seperately as PROGMEM. The three dots mean: and so on.

prog_char webPage[] PROGMEM  = {
  "HTTP/1.0 200 OK\r\n"
  "Content-Type: text/html\r\n"
  "Pragma: no-cache\r\n"
  "\r\n"
  "<html>\r\n"
  "<header>\r\n"
  "<meta http-equiv='refresh' content='1'/>\r\n"
  "<title>Arduino</title>\r\n" 
  "</header>\r\n"
  "<body>\r\n"
  "<center>
\r\n"
  "<h3>Arduino</h3>
\r\n"
  ...
  "</body>\r\n"
  "</html>" };

void setup()
{
  ...
}

void loop()
{
  ...
  bfill.emit_p( webPage, h/10, h%10, m/10, m%10, s/10, s%10, ...
  ...
}

Hello guys, I was “upgrading” my project recently so I am seeking some advice again.

I added an LCD to my project for displaying temperatures from 3 sensors. LCD is working perfectly, however I have a problem with “webserver” part of the project. As long as I am displaying temperatures on LCD, the webserver is not working, there is no reply from webserver. As soon as I disable lcd.print part of the code, webserver is working again.

I think that the mistake is in the lcdprint() function. I think there is something wrong with two “delays” but I need them because I want to display two screens on my LCD, both of them should be displayed for 3 seconds.

I would be thankful if someone could take a look at the code and tell me what is wrong.

Here’s the current code:

#include <EtherCard.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

#define ONE_WIRE_BUS 3

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,2,200 };

LiquidCrystal lcd(10, 9, 5, 4, 6, 7);

byte Ethernet::buffer[500];
BufferFiller bfill;

const int ledPin = 2;
boolean ledStatus;

char* on = "ON";
char* off = "OFF";
char* statusLabel;
char* buttonLabel;

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0x96, 0xC2, 0xBC, 0x04, 0x00, 0x00, 0xA1 };
DeviceAddress outsideThermometer = { 0x28, 0xA5, 0x0E, 0xBD, 0x04, 0x00, 0x00, 0x99 };

void setup () {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  
  // teplota sa bude zobrazovat na seriovej konzole
  Serial.begin(57600);
  Serial.println("\n[Webserver]");
  // Start kniznice
  sensors.begin();
  // Nastavenie rozlisenia na 10 bitov
  sensors.setResolution(insideThermometer, 10);
  sensors.setResolution(outsideThermometer, 10);
  
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  ledStatus = false;
  
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  ether.staticSetup(myip);
}

float printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Chyba, senzor neodpoveda");
  } else {
    Serial.print("C: ");
    Serial.print(tempC);
  
  return(tempC);

}
}
static word homePage() {
  long t = millis() / 1000;
  word h = t / 3600;
  byte m = (t / 60) % 60;
  byte s = t % 60;
  
}

void lcdprint () {
  
  lcd.setCursor(0,0);
  lcd.print("Zo solara: ");
  lcd.print(printTemperature(outsideThermometer));
  lcd.setCursor(0,1);
  lcd.print("Do solara: ");
  lcd.print(printTemperature(insideThermometer));
  delay(3000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Teplota vody: ");
  //lcd.print(printTemperature(teplotaThermometer));
  lcd.setCursor(0,1);
  if (ledStatus = 0) {
                        lcd.print("ON");
  }
  else { lcd.print("OFF");
  }
  delay(3000);
}

void loop () {
 lcdprint();
  
  
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);
  
  
  if(pos) {
    
    if(strstr((char *)Ethernet::buffer + pos, "GET /?status=ON") != 0) {
      Serial.println("Received ON command");
      ledStatus = true;
    }

    if(strstr((char *)Ethernet::buffer + pos, "GET /?status=OFF") != 0) {
      Serial.println("Received OFF command");
      ledStatus = false;
    }
    
    if(ledStatus) {
      digitalWrite(ledPin, HIGH);
      statusLabel = on;
      buttonLabel = off;
    } else {
      digitalWrite(ledPin, LOW);
      statusLabel = off;
      buttonLabel = on;
    }
    long t = millis() / 1000;
  word h = t / 3600;
  byte m = (t / 60) % 60;
  byte s = t % 60;  
    sensors.requestTemperatures();
    BufferFiller bfill = ether.tcpOffset();
    bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\n"
      "Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
      "<meta http-equiv='refresh' content='2';url=192.168.2.200/>"
      "<html><head><title>Teplotny server</title></head>"
      "<body align= 'center' bgcolor='#FFF8DC'>"
      "<h1>Teplota zo solara: $TC
 Teplota do solara: $TC 
 Teplota vody: NaN</h1>"
      "

"
      "<h3>Osvetlenie bazena: $S"
      "<a href=\"/?status=$S\"><input type=\"button\" value=\"$S\"></a></h3>
"
      "Cas od restartu: $D$D:$D$D:$D$D"
      "</body></html>"      
      ), printTemperature(outsideThermometer), printTemperature(insideThermometer), statusLabel, buttonLabel, buttonLabel, h/10, h%10, m/10, m%10, s/10, s%10);
    ether.httpServerReply(bfill.position());
  }

}

You use pin 10 for the LCD. Pin 10 is the SS signal of the SPI. Even if you use a different ChipSelect, pin 10 is used by the SPI hardware somehow.

Try another pin. I think you can also use the analog pins, if you use 'A0', 'A1' and so on for the pin number.

Thank you, I'll try. But I don't think this is the issue, because when I remove the two "Delay(3000)"s, everything seems to work normally.

The lcdprint waits 6 seconds. During that time the ethernet is not working. I'm not sure what the effect will be for the Ethernet.

I have made this for my web server: When there is no ethernet request, I run a background task. That background task uses millis() to create a second 'tick'. I use counters to create other timing ticks, like a few seconds and also minutes and hours.

This examples shows how to use timing without delay: http://arduino.cc/en/Tutorial/BlinkWithoutDelay

The second part of this page shows how to prevent rollover problem: http://playground.arduino.cc/Code/TimingRollover

Is ram usage a problem ? Perhaps some array is too small or there is a ram overflow.

Now I think I’m too dumb but I can’t get it working.

I divided lcdprint() into two parts(like screen1 and screen2):

void lcdprint1 () {
  
  lcd.setCursor(0,0);
  lcd.print("Zo solara: ");
  lcd.print(printTemperature(outsideThermometer));
  lcd.setCursor(0,1);
  lcd.print("Do solara: ");
  lcd.print(printTemperature(insideThermometer));
  
}

void lcdprint2() {
 lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Voda(C): ");
  lcd.print(printTemperature(teplotaThermometer));
  lcd.setCursor(0,1);
  if (ledStatus = 0) {
                        lcd.print("ON");
  }
  else { lcd.print("OFF");
  } 
  
}

And the next thing I did is that I edited void loop(). However, I think I did it wrong. All I get is lcdprint1 for 2 seconds then just a blink of lcdprint2 and back:

void loop () {

  
  
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);
  
  
  if(pos) {
    
    if(strstr((char *)Ethernet::buffer + pos, "GET /?status=ON") != 0) {
      Serial.println("Received ON command");
      ledStatus = true;
    }

    if(strstr((char *)Ethernet::buffer + pos, "GET /?status=OFF") != 0) {
      Serial.println("Received OFF command");
      ledStatus = false;
    }
    
    if(ledStatus) {
      digitalWrite(ledPin, HIGH);
      statusLabel = on;
      buttonLabel = off;
    } else {
      digitalWrite(ledPin, LOW);
      statusLabel = off;
      buttonLabel = on;
    }
    long t = millis() / 1000;
  word h = t / 3600;
  byte m = (t / 60) % 60;
  byte s = t % 60; 
   sensors.requestTemperatures();
    BufferFiller bfill = ether.tcpOffset();
    bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\n"
      "Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
      "<meta http-equiv='refresh' content='2';url=192.168.2.200/>"
      "<html><head><title>Teplotny server</title></head>"
      "<body align= 'center' bgcolor='#FFF8DC'>"
      "<h1>Teplota zo solara: $TC
 Teplota do solara: $TC 
 Teplota vody: $TC</h1>"
      "

"
      "<h3>Osvetlenie bazena: $S"
      "<a href=\"/?status=$S\"><input type=\"button\" value=\"$S\"></a></h3>
"
      "Cas od restartu: $D$D:$D$D:$D$D"
      "</body></html>"      
      ), printTemperature(outsideThermometer), printTemperature(insideThermometer), printTemperature(teplotaThermometer), statusLabel, buttonLabel, buttonLabel, h/10, h%10, m/10, m%10, s/10, s%10);
    ether.httpServerReply(bfill.position());
  }
  
  unsigned long currentMillis = millis();
 
  lcdprint1(); 
  if(currentMillis - previousMillis > interval) {
    
    previousMillis = currentMillis;   

    lcdprint2();
  }
  
  if(currentMillis - previousMillis > interval) {
 
    previousMillis = currentMillis;
    lcdprint1();
  
}
}

You can use only one 'if' when you use the same 'previousMillis' to test against millis().

You could use an interval of 3 seconds and in that interval use another variable to alternate between the two functions. Every division of the timing requires another variable. It must keep its value, so make it global or use the 'static' keyword.

Guys, I was doing some wire tidying and I messed something up. I am trying to fix it for several hours now but I am out of ideas. I checked almost everything. The display has some unknown problem now, only first half of it is working. And that is only if I use wall adaptor for power, if I use USB power then the whole display is not working. What else should I check? I checked the wiring several times and everything looks to be connected correctly.

Edit: I found out that all temperature sensors are giving me 85C. I guess this has something to do with the first problem.

Photo with “Hello w” is when the wall adaptor is connected.

Any ideas whats wrong? :frowning:

photo-2.JPG

photo-1.JPG

That is what the displays do when they are broken. It is hard to say what else is damaged.