DTemperature and DGPS Sensor Question Android Java


#1

Hello,
I was needing to get more info about how I can read the Temperature and DGPS from the NXT to Android Java NXT, I would like to know the syntax of the Android Code I could use to display this value in the Android Cellphone. Thanks very much for your support. Same thing with DGPS.
The Bluetooth is communicating correctly, I already can read the Touch Sensor and the Distance Sensor but I need the temperature and DGPS values…


#2

Hey Daniel!

Just to be clear, are you talking about Lejos?

If indeed we’re talking about Lejos, we admit we don’t know too much about it. You may want to ask on their forums here: http://www.lejos.org/

Also confusing about your post: Android code? or NXT code?


#3

Please see below code, and the line bellow,
val = nxt.ReadTouchSensor( 1 );
txtTouch1.SetText( "Child Seat Status 1: " + (val?“On”:“Off”) );

I need to know which it will be the command to read the values of the DTemperature and DGPS for example, nxt.READTEMPERATURESensor (2,C), (this one does not work), which it would be the syntax that can be recognized by yhe Android Java to read the values from the Dtemp and DGPs (these values are being pulled out from the Andriod Cellphone using the code below)

Instead the color sensor I would like to have the temp sensor… your temp sensor…

Thanks so much…

function nxt_OnConnected()
{
//Start updating sensor values.
UpdateSensors();
}

//Update the sensor values.
function UpdateSensors()
{
if( nxt.IsConnected() )
{
val = nxt.ReadTouchSensor( 1 );
txtTouch1.SetText( "Child Seat Status 1: " + (val?“On”:“Off”) );

    val = nxt.ReadTouchSensor( 2 ); 
    txtTouch2.SetText( "Touch Sensor 2: " + (val?"On":"Off") ); 
 
    val = nxt.ReadColorSensor( 3 );
    txtColor.SetText( "Color: " + val ); 
     
    val = nxt.ReadDistanceSensor( 4 ); 
    txtDist.SetText( "Distance: " + val + " cm" );     
} 
 
//Set a timer to call this function again in 1/3 of a second. 
timer = setTimeout( "UpdateSensors()", 300 ); 

}