Code that detects if a Sensor has been removed

Hey guys how are you doing. I am new to the forum. So I am trying to make sure to do my best and follow the rules properly. Hopefully as I go I will improve. The question I have been struggling with for the past 5 months. Is feedback. The type of feedback I am trying to find is how to detect if a component has been removed from my breadboard. For example, removing a hall effect sensor from the breadboard, or a resistor for example. When the component is removed it would essentially Serial Print it on the Arduino Serial monitor. I have tried everything. I tried reading from the component set states. I am lost. Any idea?

I apologize if this wasn't clear. I guess what I am asking is for is what the code for something like this would look like. If you could attach something below bless you. I don't know how to make it happen.

In what situation would someone be removing components?

I imagine the code and supporting hardware would be different for each type of component and its usage.

Just in general, maybe it could fall out of place. It could get loose. I thought the code would be the same and it would have to do with reading the voltage levels. Maybe an analogread(); although I just don't know where to begin. I always thought there would be a universal code. That would just be able to detect component removal.

The last thing to do is write the code. Before writing the code you have to define what can be sensed.

Typically such self test capability is limited to subsystems not components.

However if you wish to give it a go you would have to look at your circuit, determine the effect of removing (or shorting) each component the figure how to communicate the result.

1 Like

Hmmmmm, I apperciate this JohnRob. So is there anyway to really give it feedback without shorting it. Is there a way to attach another sensor to the component. This would be in series. So if that sensor detects the part is removed. It would display it in the serial monitor? Does such a thing exist?

No, not as you have described.

So what happens if the processor falls out?

Yeah that would be the issue. So what if I attach a resistor to the component in series. Than I tried to analogread(); that voltage value. Than if the component got removed. it would probably lead to an open circuit. This would than display in the monitor. Do you think this would work?

It is not a good idea to remove or add components with the power applied, as that can and often does lead to the destruction of other components.

Failure analysis and detection is a very complex engineering problem, and the solutions will be unique for every different circuit. Define your circuit completely before you even start thinking about failure analysis.

A common technique - when designing your circuit is to use N/C contacts or similar to detect broken/loose wires, or missing components from the normal assembly.

It all comes down to how much effort you want to put in.

1 Like

I apperciate the feedback jremington. I know its not, but I somehow gotta get some rough idea to do it with every component. I am thinking if I find away how JohnRob mentioned. To short each component. That and if it fails the analogread do something. Although idk, I need somewhere to start. Somewhere with any sensor.

That may well destroy the voltage regulator, or if powered from the USB, overload the USB port.

Good luck with your efforts, you will need it.

Do you have any idea lastchance. How I can go about that. So would I have to violate the normally closed. So lets say I do analogread from a sensor thats 5V. Than if make the circuit open it would go to 0. So I should say if (analogread ==0) than it would display to the serial monitor like Serial.println(" Sensor was removed");

jremington, I see what your saying. What about what I commented down to lastchance. Do you think that would work?

What if the sensor actually reads 0?

shahool, you need to slow down your replies and put more thought and content into each reply, because the forum limits the number of posts for new users for the first 24 hours... I don't want to see you locked out...

1 Like

Understandable, I appreciate it aarg. I am going to try to draw a schematic and reply back later on with some code and a fritzing schematic.

You can keep the Fritzing. Nobody wants to see it. For that, post images of your actual hardware. However, given the question, it may not actually be necessary.

Gotcha, I will take this in account and keep trying and post on here a little later. Its a big oof

We would like to see your code attempts at that when you return.