Eventprogramming - temperaturesensor does not report

Supporting Java SE version 7 and up
eg1l

Eventprogramming - temperaturesensor does not report

Postby eg1l » Sun Jul 04, 2010 12:01 pm

Hello!

Basically for test purposes i run:

Code: Select all

      interfaceKit.addSensorChangeListener(new SensorChangeListener() {
         public void sensorChanged(SensorChangeEvent se) {
            switch (se.getIndex()) {
               case (tempSensorPort):
                  System.out.println("Temperature changed: " +se.getValue()+ " C");
and so on...


The temperature comes from a 1125 (Humidity/Temperature) sensor. I have also a lightsensor, and all three are in the switch. However, only humidity and light is causing calling sensorChanged.
If i run interfaceKit.getSensorValue(temperatureSensorPort), it reads the temperature.

So the problem is only that the sensor does not call sensorChanged. Is this a hardware issue?

Robert

Re: Eventprogramming - temperaturesensor does not report

Postby Robert » Mon Jul 05, 2010 1:23 pm

What's your sensor change trigger value? It's possible the temperature isn't changing enough to trigger an event.

eg1l

Re: Eventprogramming - temperaturesensor does not report

Postby eg1l » Tue Jul 06, 2010 3:34 pm

Aha, that is probably why it not reporting. I see the default triggervalue is 10. Will test later and see :)

Robert

Re: Eventprogramming - temperaturesensor does not report

Postby Robert » Tue Jul 06, 2010 4:29 pm

Yeah, the default value is usually a little too large for the temperature sensors. I believe a change of 10 corresponds to something like a 4 degree temperature sensor change.

eg1l

Re: Eventprogramming - temperaturesensor does not report

Postby eg1l » Wed Jul 07, 2010 1:12 pm

You are correct. Set triggervalue to 1, and it works perfectly :)

kami

Re: Eventprogramming - temperaturesensor does not report

Postby kami » Fri Sep 16, 2011 7:44 am

Sorry can you show me you set the trigger value of sensor by Phidgets sensor manager or in you program?

erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: Eventprogramming - temperaturesensor does not report

Postby erik » Fri Sep 16, 2011 8:15 am

Under the Programming Link above and in the Java-->API Reference section, the InterfaceKitPhidget class has a method called setSensorChangeTrigger and would be used something like

Code: Select all

ifkit.setSensorChangeTrigger(0,1);


Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest