system
January 21, 2013, 1:01pm
1
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
system
January 21, 2013, 1:22pm
2
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.
system
January 21, 2013, 2:04pm
3
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 ?
system
January 21, 2013, 2:10pm
4
this is the full code
I use pin 13 of atmel ( input 7 of arduino )
2416 temperature.txt (15.1 KB)
system
January 21, 2013, 4:17pm
5
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?
system
January 21, 2013, 4:50pm
6
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
system
January 21, 2013, 4:51pm
7
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);
system
January 21, 2013, 5:00pm
8
That does look much closer to being right.
getTempCByIndex() does not return a char though, it returns float.
system
January 21, 2013, 5:41pm
9
ahhhh so what i should change ??
float temperature = 0 ??
thanks in advance
system
January 21, 2013, 5:54pm
10
Actually no, sorry, you were better off with the char, you just won't be getting fractional degrees.
system
January 21, 2013, 6:04pm
11
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 ?
system
January 21, 2013, 6:08pm
12
I think at this point you should just try it and see.
system
January 21, 2013, 6:21pm
13
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
system
January 22, 2013, 1:31am
14
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?
system
January 22, 2013, 8:18am
15
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
Some questions :
What do you get on the screen if you just output buffer[0] ?
Does the same problem occur if you output the temperature to somewhere else on the screen ?
What happens if you output the temperature twice ? Output it once then output it again without clearing the screen ?
What does your code do to the screen immediately before showing the temperature ?
What happens if you print some text before the temperature ?
What happens if you put a specific value in the buffer without reading the temperature then output it ?
system
January 22, 2013, 11:13am
17
this is with the code posted
( fot.jpg)
i tryed to give a value and it put on display it and it show the value
( exaple 22.50 )
sensors.requestTemperatures();
float TempC = 22.50 ;//sensors.getTempCByIndex (0);
Serial.println(TempC,DEC);
char buffer[4];
itoa(TempC,buffer,10);
ht1632_putchar(0 , 8, buffer[0]);
ht1632_putchar(6 , 8, buffer[1]);
ht1632_putchar(12 , 8, buffer[2]);
ht1632_putchar(18 , 8, buffer[3]);
ht1632_putchar(24 , 8, buffer[3]);
ht1632_puttinychar(32 , 8, 'o');
ht1632_putchar(39 , 8, 'C');
delay(150);
this is the result ( foto22.jpg )
thanks in advance
system
January 22, 2013, 1:21pm
18
if i write float TempC = 2250;
show 22500 °C
in serial monitor
show the temperature in this way : 19.4375000000
I think the problem is the decimal
I must divide 19 from 43 without the dot ( or comma )
put 19 into a buffer and the 43 into another buffer
then show it
Right ???
thanks
system
January 22, 2013, 1:48pm
19
danielb:
if i write float TempC = 2250;
show 22500 °C
in serial monitor
show the temperature in this way : 19.4375000000
That's strange, I would expect to see: 2250 , wouldn't you?
I think the problem is the decimal
I must divide 19 from 43 without the dot ( or comma )
put 19 into a buffer and the 43 into another buffer
then show it
Right ???
thanks
Pretty much. You will need to adjust your buffer size to 5 and/or adjust your placement on the screen if you want to be able to show "19.43", since that is five characters and your existing code uses four. Or, you could show it as "19.4" and leave it where it is on the screen.
John
system
January 22, 2013, 3:19pm
20
yes of course
but i can resolve 22500 problem display but not my BIG problem
If I write
float TempC = sensors.getTempCByIndex(0);
I should see something !!! not e127 that is the error when someting goes wrong !!
I need help for this
resolve 22550 end not 22 50 will be able to resolve !!