Offline
Newbie
Karma: 0
Posts: 31
|
 |
« on: January 21, 2013, 08:01:21 am » |
Hi everybody I'm Daniele from Italy and I'm happy to be here.
I'm tryng to dispaly a temperature by this display ( i've read everything ) but I've got a big problem
I see on dispaly e127 °C and if i unplug +5 volts to ds18b20 it become 0 27 °C
this is the code that I wrote
Serial.println(temperature,DEC); char buffer[4]; itoa(temperature,buffer,10); ht1632_putchar(0 , 0, buffer[0]); ht1632_putchar(6 , 0, buffer[1]); ht1632_putchar(12 , 0, buffer[2]); ht1632_putchar(18 , 0, buffer[3]); ht1632_puttinychar(26 , 0, 'o'); ht1632_putchar(33 , 0, 'C'); delay(150);
any idea ???
thank you so much
Daniele
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35519
Seattle, WA USA
|
 |
« Reply #1 on: January 21, 2013, 08:22:09 am » |
and if i unplug +5 volts to ds18b20 it become 0 27 °C Why does that surprise you? If the sensor isn't powered, it can't function. If it can't function, you really can't expect to read a temperature from it, can you? Of course, it's hard to tell much from your snippet of code.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 31
|
 |
« Reply #2 on: January 21, 2013, 09:04:01 am » |
thank you so much !
of course that if the sensor isn't powered it doesn't works !
i try it to be sure that the input pin was correct and the buffer was filled by data !
I shoult post full code ?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 31
|
 |
« Reply #3 on: January 21, 2013, 09:10:12 am » |
this is the full code
I use pin 13 of atmel ( input 7 of arduino )
|
|
|
|
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #4 on: January 21, 2013, 11:17:02 am » |
I think there needs to be a call to "sensors.requestTemperatures()" and "sensors.getTemp..." in there. Did you look at the sample code for DallasTemperature?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 31
|
 |
« Reply #5 on: January 21, 2013, 11:50:01 am » |
thanks for your answer
"sensors.requestTemperatures()" ( i forgot to write it on here but is present on sketch )
what and where else exatly ?
char temperature = 0 ;
sensors.requestTemperatures();
Serial.println(temperature,DEC);
char buffer[4]; itoa(temperature,buffer,10); ht1632_putchar(0 , 0, buffer[0]); ht1632_putchar(6 , 0, buffer[1]); ht1632_putchar(12 , 0, buffer[2]); ht1632_putchar(18 , 0, buffer[3]); ht1632_puttinychar(26 , 0, 'o'); ht1632_putchar(33 , 0, 'C'); delay(150);
thanks
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 31
|
 |
« Reply #6 on: January 21, 2013, 11:51:54 am » |
sorry for multiple post
like this ??
char temperature = 0 ; sensors.requestTemperatures();
temperature = (sensors.getTempCByIndex(0));
Serial.println(temperature,DEC); char buffer[4]; itoa(temperature,buffer,10); ht1632_putchar(0 , 0, buffer[0]); ht1632_putchar(6 , 0, buffer[1]); ht1632_putchar(12 , 0, buffer[2]); ht1632_putchar(18 , 0, buffer[3]); ht1632_puttinychar(26 , 0, 'o'); ht1632_putchar(33 , 0, 'C'); delay(150);
|
|
|
|
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #7 on: January 21, 2013, 12:00:57 pm » |
That does look much closer to being right.
getTempCByIndex() does not return a char though, it returns float.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 31
|
 |
« Reply #8 on: January 21, 2013, 12:41:35 pm » |
ahhhh so what i should change ??
float temperature = 0 ??
thanks in advance
|
|
|
|
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #9 on: January 21, 2013, 12:54:55 pm » |
Actually no, sorry, you were better off with the char, you just won't be getting fractional degrees.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 31
|
 |
« Reply #10 on: January 21, 2013, 01:04:13 pm » |
I don't understand. I' can't convert ?
What's the problem with decimal ?
ie I can't show on this dispaly 22,5 °C ?
|
|
|
|
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #11 on: January 21, 2013, 01:08:48 pm » |
I think at this point you should just try it and see.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 31
|
 |
« Reply #12 on: January 21, 2013, 01:21:57 pm » |
float temperature=0 ; sensors.requestTemperatures();
temperature = (sensors.getTempCByIndex(0));
Serial.println(temperature,DEC); char buffer[4]; itoa(temperature,buffer,10); ht1632_putchar(0 , 0, buffer[0]); ht1632_putchar(6 , 0, buffer[1]); ht1632_putchar(12 , 0, buffer[2]); ht1632_putchar(18 , 0, buffer[3]); ht1632_puttinychar(26 , 0, 'o'); ht1632_putchar(33 , 0, 'C'); delay(150);
do not works... e127 °C show
|
|
|
|
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #13 on: January 21, 2013, 08:31:31 pm » |
Which part do you suppose is not working-- the part that reads the temperature from the sensor, or the part that displays the temperature on the LCD screen?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 31
|
 |
« Reply #14 on: January 22, 2013, 03:18:54 am » |
I think that inside buffer there is nothing becouse it write 127. The ds 18b20 works perfectly becouse with lcd skecht show the correct temperature
|
|
|
|
|
Logged
|
|
|
|
|
|