sensor selection for tank cap opening

In OPs other (now removed) post there was a mention of an NRF24 transmitter. Maybe OP cares to explain their project a bit more here?

Actually I have no idea how that transmitter plus sensor plus MCU plus the batteries to power it for longer than a couple hours would ever fit on/in a fuel cap.

The OPs original post is here sensor selection for tank cap opening - #14 by DaveEvans - Sensors - Arduino Forum

So, you didn't get anything useful from the previous incarnation of this thread?

sensor selection for tank cap opening

bmg1234:
Hello,

I am using tilt sensor for my project. project is when the fuel tank of the truck is open sensor will activate and when the tank cap is closed sensor will deactivate. for this i am using simple two wire sensor. but the problem is when vehicle is moving the sensor is getting activated.

Can someone please suggest me some good tilt or angle sensor which does not work when vehicle is in motion it should work only when the cap is open.

Thank you

If you know the vehicle is moving, why not include that in your program logic.

Paul

What kind of fuel? Hopefully, you don't have an electrical switch in the vicinity of gasoline (petrol) vapors. :o

DaveEvans:
You may have to write code to ignore short triggers caused by road vibration. Only set off your alarm when the trigger is longer than "x" ms, when it is obvious that it is due to someone opening the cap. Find "x" by trial and error, or log the duration of every trigger over some number of days and figure it out from that data. That may allow you to use your existing 15 degree sensor. Or maybe not.

Also, damping would help control erroneous triggering, and Google says that tilt sensors with damping are available. Or you could build your own: e.g., a pendulum with some friction would be one way. A pendulum hanging from a small rotary damper with viscous (i.e., velocity-dependent) damping would be better.

How this can be done? could you please help me with the changes what i have make with the code.

Paul_KD7HB:
If you know the vehicle is moving, why not include that in your program logic.

Paul

I a trying but i couldn't. i tried to put some delay but still the same. could you please help me with other solutions. i can post the code if you need.

Yes, do so. Post code, complete schematics of what you tried, images of the actual setup, description of what worked and what not - in short, the works.

Here Tilt sensor makes the interrupt, when there is interrupt transmitter device wake up suddenly and sends data to receiver. now i need change the code when tilt interrupt is more than 5 seconds only the transmitter should wakeup and send data to receiver. if interruption is less than 5 seconds device should be in sleep mode and should not send any data.

Hope you understood clearly now. please help me to make this changes in the code.

I have attached the code

testtrans.ino (9.03 KB)

Record the time (value of millis()) of the latest activation of the sensor, compare that to the current time (value of millis()), checking constantly during that time whether there's any change in the sensor status.

wvmarle:
Record the time (value of millis()) of the latest activation of the sensor, compare that to the current time (value of millis()), checking constantly during that time whether there's any change in the sensor status.

I am not understanding how to do that. could you please help me by making changes in the code

No code to make changes to in this thread.

Also if you didn't write your code from the ground up with this kind of timing in mind (especially as it appears you're using sleep modes) it may require a serious overhaul.

wvmarle:
No code to make changes to in this thread.

Also if you didn't write your code from the ground up with this kind of timing in mind (especially as it appears you're using sleep modes) it may require a serious overhaul.

So, what will be the solution now to solve the issue?

Post your current code.

Please find attachment for the code

testtrans.ino (9.04 KB)