Be notified when a sensor is plugged on a VoltageInput

C, C++, and Visual C++
natvaugien
Fresh meat
Posts: 2
Joined: Fri Mar 23, 2018 3:46 am
Contact:

Be notified when a sensor is plugged on a VoltageInput

Postby natvaugien » Wed Nov 07, 2018 4:15 am

Hello,

I was wondering if it is possible to be notified every time a sensor is plugged on a VoltageInput.
I would like to know when a sensor is being plugged or unplugged and the type of sensor I'm dealing with.
I'm working with multiple SBCs and Phidgets Interfaces so I use a PhidgetManager to open every Inputs/Outputs of the whole system.

I've already looked on the API documentation but haven't really seen anything that would work.

Thanks a lot.
Last edited by natvaugien on Wed Nov 28, 2018 3:21 am, edited 1 time in total.

User avatar
mparadis
Site Admin
Posts: 625
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Be notified when a sensor is plugged on a VoltageInput

Postby mparadis » Wed Nov 07, 2018 9:10 am

Unfortunately, since analog sensors only provide a voltage from 0 to 5V and no other information to the InterfaceKit or Hub they're connected to, you have no way of knowing what kind of sensor it is without looking at what is physically connected.

For the same reason, you can't know for sure whether there's even a sensor plugged in, since the VoltageInput is constantly measuring the voltage difference between the white and black pins regardless of whether there's a cable connected or not.

You may be able to write a part of your program that is able to make a guess as to whether a sensor is plugged in or not based on looking at the voltage values for a second or two. Typically, disconnected voltage inputs will have a value near 0 and will not fluctuate that much. If this behaviour is significantly different than a sensor you have plugged in, your program will have a good guess as to whether a sensor is connected.

Depending on what kind of sensors you're interested in using, you may be able to solve this problem by switching to a VINT Hub and using the "smart" VINT device equivalents of those sensors. For example, instead of using an 1125 temperature/humidity sensor, you could use a HUM1000. These smart devices do tell the hub what kind of device they are and you'll get events when they connect and disconnect. They can be monitored using the Phidget Manager, which is the same thing our control panel example uses to tell which Phidgets are connected.

natvaugien
Fresh meat
Posts: 2
Joined: Fri Mar 23, 2018 3:46 am
Contact:

Re: Be notified when a sensor is plugged on a VoltageInput

Postby natvaugien » Thu Nov 08, 2018 2:34 am

Thanks a lot for your answer.
I'm going to test looking at the value to detect a change and if it doesn't work I'll try the smart VINT device.

Thanks again !

elnova

Re: Be notified when a sensor is plugged on a VoltageInput

Postby elnova » Mon Nov 12, 2018 2:30 am

Thanks for the answer i am looking for similar solution in another experiment :)


Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 1 guest