Go Down

Topic: Displaying temperature and pressure at the same time using java  (Read 580 times) previous topic - next topic

neiklot

note to self: must check what an Arduino actually does with a runtime error like that.


brunopeniche

This:
Code: [Select]
Serial.println(sensor2);
Needs to change now to:
Code: [Select]

 Serial.print(sensor2);

wow thanks!!! It worked!! So what is the difference of putting Serial.println instead of Serial.print? the "ln" kind of finishes the line where the data is displayed, with the next values being displayed in the next paragraph?

brunopeniche

Code: [Select]
long a =1023 - analogRead(analogPin);
If analogRead returns 1013.
So if the analog read of the thermistor gives 1013 the code will have some kind of error, right? Do you guys then think that I should change the code? Because that equation was really the best that I found to display the temperature in degrees celsius

neiklot

the "ln" kind of finishes the line where the data is displayed, with the next values being displayed in the next paragraph?
Yes, and more "technically" it inserts a CR carriage return (to go back to the left) and a LF line feed (to click one line ahead) into the stream sent to the monitor.

Have a Google for the ascii table, and you will see character hex 0D, or decimal 13 is the CR and 0A or 10 is the LF.


brunopeniche

Yes, and more "technically" it inserts a CR carriage return (to go back to the left) and a LF line feed (to click one line ahead) into the stream sent to the monitor.

Have a Google for the ascii table, and you will see character hex 0D, or decimal 13 is the CR and 0A or 10 is the LF.


Thanks!!

PaulS

Can you explain, please? ahah
I was seeing parentheses where I would have put them, not where you didn't put them.

You are dividing by a. If a is ever 0, you are doing A BAD THING.

You SHOULD be using parentheses to make it clear how that equation is to be evaluated.
The art of getting good answers lies in asking good questions.

brunopeniche

I was seeing parentheses where I would have put them, not where you didn't put them.

You are dividing by a. If a is ever 0, you are doing A BAD THING.

You SHOULD be using parentheses to make it clear how that equation is to be evaluated.
Ok, I have put the equation like this now:

Code: [Select]
float sensor1 = beta /(log(((1025.0 * 10 / a) - 10) / 10) + beta / 298.0) - 273.0;

instead of:

Code: [Select]
float sensor1 = beta /(log((1025.0 * 10 / a - 10) / 10) + beta / 298.0) - 273.0;

And it seems fine. Do you agree with that?


PaulS

Quote
Do you agree with that?
No. You are still dividing by a, even if a is 0.
The art of getting good answers lies in asking good questions.

brunopeniche

No. You are still dividing by a, even if a is 0.
Oh yeah. So how you suggest me to change it? I would have to change to another equation?

PaulS

Quote
So how you suggest me to change it?
Code: [Select]
if(a != 0)
{
   sensor1 = beta /(log(((1025.0 * 10 / a) - 10) / 10) + beta / 298.0) - 273.0;
}
else
{
   sensor1 = someOtherValue;
}

I have no idea what you want to use as someOtherValue, when a is 0.
The art of getting good answers lies in asking good questions.

brunopeniche

Code: [Select]
if(a != 0)
{
   sensor1 = beta /(log(((1025.0 * 10 / a) - 10) / 10) + beta / 298.0) - 273.0;
}
else
{
   sensor1 = someOtherValue;
}

I have no idea what you want to use as someOtherValue, when a is 0.
I dont know, maybe the result of the equation when a=0.00001? Is it correct?

PaulS

I dont know, maybe the result of the equation when a=0.00001? Is it correct?
Since you have declared a to be an integral type, setting it to 0.000001 seems unlikely.
The art of getting good answers lies in asking good questions.

brunopeniche

Since you have declared a to be an integral type, setting it to 0.000001 seems unlikely.
sorry for not answering sooner but I was out of this project for 2 days. So what value do you recommend? I sincerely dont know ahah

Go Up