RCX temperature sensor

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc.

Moderators: roger, imaqine, 99jonathan

pawelp
New User
Posts: 16
Joined: Fri Jun 01, 2007 8:34 pm

RCX temperature sensor

Postby pawelp » Sun Oct 26, 2008 10:06 pm

Hello.
I just bought RCX temperature sensor with conversion (RCX-NXT) cable.
Is there any way to read data from it using lejos?

Best regards
Pawel

mdsmitty
Novice
Posts: 78
Joined: Tue Feb 27, 2007 3:07 am
Contact:

Postby mdsmitty » Mon Oct 27, 2008 1:25 am

The best way would be to set the sensor port to passive mode and read the raw value.

pawelp
New User
Posts: 16
Joined: Fri Jun 01, 2007 8:34 pm

Postby pawelp » Tue Oct 28, 2008 2:42 am

But then I need to know an array of raw values and temperatures.
In practice, it means that I will have to calibrate using real thermometer.

Maybe someone know this data?

Best regards
Pawel.

enzomango
Novice
Posts: 30
Joined: Tue Feb 26, 2008 5:20 pm

Postby enzomango » Thu Oct 30, 2008 1:25 am

I see you haven't had much luck getting the answers you need. I can't be much help with the RCX sensor but if you don't have success with that approach you might consider building the simple temperature sensor described in the Extreme NXT book. I did, and it works great. The code in the book isn't leJOS but I wrote a small java class that you're welcome to use. It displays the data from this homemade sensor in F, C, and Kelvin. It seems to be very accurate. If you or anyone else is interested I'll post the code.

lawrie
leJOS Team Member
Posts: 955
Joined: Mon Feb 05, 2007 1:27 pm

Postby lawrie » Mon Nov 03, 2008 10:23 pm

There is a class for the RCX Temerature sensor in SVN. It will be in the 0.7 release. The source is:

Code: Select all

package lejos.nxt.addon;

import lejos.nxt.*;

/**
 *Abstraction for an RCX temperature sensor.
 *
 * @author Soren Hilmer
 */
public class RCXTemperatureSensor
 implements SensorConstants {
    LegacySensorPort port;
   
    /**
     * Create an RCX temperature sensor object attached to the specified port.
     * @param port port, e.g. Port.S1
     */
    public RCXTemperatureSensor(LegacySensorPort port)
    {
        this.port = port;
        port.setTypeAndMode(TYPE_TEMPERATURE,
                            MODE_RAW);
    }
   
    /**
     * Read the current sensor value.
     * @return raw Value.
     */
    public int readValue()
    {
        return port.readRawValue();
    }

    /**
     * Convert sensor value to Celcius, value outside [-20;70] is not accurate
     * @return sensor value converted to Celcius
     **/
    public float getCelcius() {
        return (785-readValue())/8.0f;
    }

    /**
     * Convert sensor value to Fahrenheit, value outside [-4;158] is not accurate
     * @return sensor value converted to Fahrenheit
     **/
    public float getFahrenheit() {
        return (getCelcius()*1.8f) + 32.0f;
    }

}

pawelp
New User
Posts: 16
Joined: Fri Jun 01, 2007 8:34 pm

Postby pawelp » Thu Nov 06, 2008 11:54 pm

Thank you very much for you answers.

lawrie:
In your code there is a comment: "value outside [-20;70] is not accurate"
But maybe you know, if higher temperatures are safe for sensor?
I mean, if is it possible to destroy sensor in eg 100 Celsius?

Best regards
Pawel

lawrie
leJOS Team Member
Posts: 955
Joined: Mon Feb 05, 2007 1:27 pm

Postby lawrie » Tue Nov 11, 2008 7:58 pm

Sorry, I do not have a temperature sensor, and don't know anything about them. I was sent the code by Soren and just included the code in the new version of leJOS NXJ (which is released today).

DerSani
New User
Posts: 10
Joined: Mon Nov 02, 2009 8:21 am
Location: Germany

Postby DerSani » Mon Nov 02, 2009 8:37 am

Hello,

I try to read out some values from the temperaturen sensor, but i only get a strange value. If I disconnect the sensor, the value would be the same.

I have a normal temperature sensor form LEGO for the NXT, is the RCX sensor class the right one for me?

DerSani

User avatar
gloomyandy
leJOS Team Member
Posts: 4605
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby gloomyandy » Mon Nov 02, 2009 9:30 am

Hi,
No the RCX sensor is different to the NXT temperature sensor. I'm not sure if anyone has created a driver for the NXT version...

Andy

DerSani
New User
Posts: 10
Joined: Mon Nov 02, 2009 8:21 am
Location: Germany

Postby DerSani » Tue Nov 03, 2009 11:55 pm

thanks gloomyandy!

Has anyone a hint for me to get values from the sensor?

DerSani


Return to “NXJ Hardware”

Who is online

Users browsing this forum: No registered users and 1 guest