Pages: 1 [2] 3   Go Down
Author Topic: Arduino Uno ds18b20 and sure 2416 dor matrix display  (Read 1490 times)
0 Members and 1 Guest are viewing this topic.
East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 90
Posts: 3523
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

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

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


* foto.JPG (110.86 KB, 640x480 - viewed 13 times.)

* foto22.JPG (113.97 KB, 640x480 - viewed 13 times.)
Logged

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

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
Logged

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 354
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Quote
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
« Last Edit: January 22, 2013, 09:09:58 am by johncc » Logged

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

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 !!
Logged

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

hi guys
don't rell me how but now it WORKS !!!

this is the correct code

 
sensors.requestTemperatures();

int temp = sensors.getTempCByIndex(0);

Serial.println(temp,DEC);
      char buffer[4];
      itoa(temp,buffer,10);
      ht1632_putchar(6 , 8, buffer[0]);
      ht1632_putchar(12 , 8, buffer[1]);
 //     ht1632_putchar(12 , 8, buffer[2]);
 //     ht1632_putchar(18 , 8, buffer[3]);
      ht1632_puttinychar(19 , 8, 'o');
      ht1632_putchar(24 , 8, 'C');
      delay(150); 


only one question ( easy i think )

now it show the temperature in this format XX °C

and if I would like to show decimal ?

ie   XX,X °C ?

how I should change it ?

Many thanks

Daniel
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46255
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how I should change it ?
Based on snippets? Who knows? Post ALL of your code. Right now, we can only guess what sensors is.

Code:
int temp = sensors.getTempCByIndex(0);
Does that method return an int? Or a float?
Logged

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

Pauls Thank you for your answer
the kind of sensor il write on the topic and on the top post... SENSOR IS DALLAS DS18B20

the entire code was just posted so I repost

Thank you so much

Daniele

* dallas 18B20.txt (15.04 KB - downloaded 12 times.)
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46255
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  // returns temperature in degrees C
  float getTempC(uint8_t*);

  // returns temperature in degrees F
  float getTempF(uint8_t*);

  // Get temperature for device index (slow)
  float getTempCByIndex(uint8_t);
 
  // Get temperature for device index (slow)
  float getTempFByIndex(uint8_t);
So, yes all the methods to get the temperature return a float, not an int.

Your buffer will need to be larger, and you'll need to use ftoa(), instead of itoa(). After that, you'll need to put more characters to the display.
Logged

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

thanks
so what i change ?

int temp = sensors.getTempCByIndex(0);
 
to

float temp = sensors.getTempCByIndex(0);  ???

then ?
( I think I must change sometingh here but how ? )

char buffer[4];
      itoa(temp,buffer,10);


Many thanks

Daniel
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46255
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
( I think I must change sometingh here but how ? )
Quote
Your buffer will need to be larger, and you'll need to use ftoa(), instead of itoa(). After that, you'll need to put more characters to the display.
Logged

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

if i change

itoa(temp,buffer,10);

to

ftoa(temp,buffer,10);

I receive this error

lcd24x16_base___temperatura.cpp: In function 'void loop()':
lcd24x16_base___temperatura:112: error: 'ftoa' was not declared in this scope

where is the problem ?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46255
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try dtostrf().
Logged

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

lcd24x16_base___temperatura.cpp: In function 'void loop()':
lcd24x16_base___temperatura:112: error: invalid conversion from 'char*' to 'signed char'
c:/users/daniele/desktop/varie2/arduino-0023/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:581: error: too few arguments to function 'char* dtostrf(double, signed char, unsigned char, char*)'
lcd24x16_base___temperatura:112: error: at this point in file
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11197
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

error: too few arguments to function 'char* dtostrf(double, signed char, unsigned char, char*)'

You aren't passing the correct number and type of arguments to dtostrf(). The documentation tells you what it expects. Only you know what you're actually providing, since we can't see your code, but it's obviously not correct. Change your code so it passes the arguments that the function expects.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: 1 [2] 3   Go Up
Jump to: