Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:09 11 May 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : DS18B20 Space Problem

Author Message
edu001
Regular Member

Joined: 14/07/2014
Location: United Kingdom
Posts: 82
Posted: 08:33am 22 Jul 2014
Copy link to clipboard 
Print this post

Hi

I am using a MicroMite to build a GPS Tracker with the DS18B20 Temp Sensor

The problem I have is that the temp printout has a space before the value, I cannot parse the data unless I remove it

Any Ideas?

Thanks
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 09:21am 22 Jul 2014
Copy link to clipboard 
Print this post

Not quite sure want you are trying to do
Could you post your code so we can help ?

Maybe this bit below will help

Temp = DS18B20(14)
Temp$ = Str$(Temp)
If Int(Val(Temp$)) < 10 Then Temp$ = " " + Temp$
Temp$ = Left$(Temp$,2) + "." + Str$(Int((Temp-Int(Temp))*10))

Print Temp$


Regards
Jman
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2927
Posted: 09:29am 22 Jul 2014
Copy link to clipboard 
Print this post

Assuming value is in a string called Tdata$, then one way to strip a potential leading space is with:

IF LEFT$(Tdata$,1,1)=" " THEN
Tdata$=RIGHT$(Tdata$,2,(LEN(Tdata$)-1))
ENDIF

Another way is to convert string to value with the VAL command. I don't remember MMBasic having a TRIM command (or LTRIM), and don't currently have access to a user manual to check.

Not sure if FORMAT command has a syntax that may work too.

Above should give you something to go on . . . .

WW
 
edu001
Regular Member

Joined: 14/07/2014
Location: United Kingdom
Posts: 82
Posted: 11:53pm 22 Jul 2014
Copy link to clipboard 
Print this post

Thanks I will try the suggested solutions later I will also post the code
 
edu001
Regular Member

Joined: 14/07/2014
Location: United Kingdom
Posts: 82
Posted: 07:34pm 23 Jul 2014
Copy link to clipboard 
Print this post

Fixed now B20$ = STR$(DS18B20(15))
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025