Pages: [1]   Go Down
Author Topic: Print data from temp sernsors on web page  (Read 933 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Im using ethernet shield with ENC28J60. Im trying to print data from temp sensor to web page.

To print data to web in example:

Code:
uint16_t print_webpage(uint8_t *buf)
{
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("HTML HERE"));
}

Now i want to print there sensors.getTemperature() from OneWire Dallas library.

this:
Code:
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR(sensors.getTemperature()));
is not workinc becouse getTemperature() return float...
How to make it work?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26638
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
len=es.ES_fill_tcp_data_p(buf,plen,PSTR(sensors.getTemperature()));
That doesn't make any kind of sense - "getTemperature" presumably is a function returning a value, so it's result cannot be found in PROGMEM.
You could use sprintf to make an ASCII string out of the float, then
Code:
len=es.ES_fill_tcp_data(buf,plen, yourStringHere);
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Thank You! i just read about PROGMEM and PSTR. Now i know why it's not working smiley
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its not working smiley-sad

Code:
  dtostrf(tempSensor.getTemperature(),3,2,vstr);
  Serial.println(vstr); 
  plen=es.ES_fill_tcp_data_p(buf,plen,vstr);

On serial i can see '16.87', but last line hang up board... when i remove it, its working ok... smiley-neutral
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26638
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
plen=es.ES_fill_tcp_data_p(buf,plen,vstr);
The _p at the end of the name of that method suggests to me it expects a PROGMEM parameter for vstr
Is there a "ES_fill_tcp_data" method?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes! And its working now smiley
Thank You!
Logged

Forum Administrator
Offline Offline
God Member
*****
Karma: 52
Posts: 646
I find plain exciting
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks AWOL, he's now banned smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

DreamCatch, what solution for your problem?
A have a similar problem (show temperature from ds18b20 on webserver via ethernet shield)
Logged

Pages: [1]   Go Up
Jump to: