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


hi guys, total newbie arduino working on first project. have 2 ds18b20 temperature sensors , ethernet shield enc28j60 hooked arduino uno r3. believe there no problems physical connection. however, struggling coding.

i need set simple webserver display temperature these 2 sensors , refresh somehow.

all produce far "webserver example" mixed "ds18b20 temperatures serial monitor example"(maybe these useless, dont know :~). really appreciate help.  :)

i using onewire library , ethercard library, 1 working enc28j60.

here's code. compiles no errors it's not working way want.
code: [select]
#include <onewire.h>
#include <dallastemperature.h>
#include <ethercard.h>

#define one_wire_bus 6

#define static 1  // set 1 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 unique on network
static byte mymac[] = { 0x74,0x69,0x69,0x2d,0x30,0x31 };

byte ethernet::buffer[500]; // tcp/ip send , 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 show in serial monitor
 serial.begin(57600);
 serial.println("\n[webserver]");
 // start of library
 sensors.begin();
 // resolution set 10 bit
 sensors.setresolution(insidethermometer, 10);
 sensors.setresolution(outsidethermometer, 10);
 
 if (ether.begin(sizeof ethernet::buffer, mymac) == 0)
   serial.println( "failed 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 not responding");
 } else {
   serial.print("c: ");
   serial.print(tempc);
 }
}

void loop(void)
{
\
// wait incoming tcp packet, ignore 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 first project, better use ethernet shield w5100.
the enc28j60 not officially supported arduino.

you have few problems. let's step step.
first of all, can explain going wrong, , goal ?

are ds18b20 sensors working, , never fail ?

i used rbbb_server file start webserver.
https://github.com/jcw/ethercard/blob/master/examples/rbbb_server/rbbb_server.ino
which 1 did use ?
if try example without temperature sensors, working okay ?

you have create webpage.
in rbbb_server example, can see how webpage created.
the webpage have not webpage, 503 error. don't want that.

to temperature in webpage, there few ways.
the easiest 1 split webpage parts. , write temperature between rest.

to react fast when webpage requested, don't want delay in sketch. getting temperature ds18b20 takes long time, perhaps have make schedular gets temperature in 2 steps (start conversion , temperature).


Arduino Forum > Using Arduino > Project Guidance > DS18B20(solar heating) display through webserver - need help(now with LCD)


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62