Technical, Techniques, Hints, and Tips > Microprocessor control
Arduino Bilge Monitor
DJW:
Hi All
Aim is to create an Arduino (Pro Mini) based water detection solution, then to push the result via S.Port as a new telemetry sensor to an FrSky Tx. Then an Tx audio warning in the event of water detection.
I have a good idea of what the sensor will look like, just two exposed pins in the right place(s) in the bilge and monitor the resistance with some simple code.
I'm yet to understand the details of how to get the information into the telemetry...
So first question is has anyone done it already..?
Regards to all.
David.
DJW:
Evening All
I think there's an easy way to do this.
Once the Arduino detects a resistance indicating water present it sets a pin high. Thats then sent to the AIN2 pin on the FrSky S.Port, I'm using the R8 Pro Rx. That's already visible on the Tx telemetry screens as A2.
Then in OpenTX set up a detection of A2, if its greater than 0, play a suitable sound file...
Bit of a hack of the analog port, but might just work...
David.
DJW:
Half way there...
I found this on YouTube as a great start point:
https://www.youtube.com/watch?v=YkIiRbI4Plc
These are the original connections:
2 headpins for the probe with 2 wires cable (A1, +5V).
3 headpins for connections with Arduino. The 22K resistance goes from the probe A1 to the 3th pinhead creating the GND pin for Arduino. For Arduino we get +5v, A1 (or other analog pin) and GND.
Video refers to 'Sketch file in Comments', but I couldn't find it so I recreated it from what I could see on screen.
I've taken that as a start point and tweaked a shade.
I now have the Arduino detecting water. Its outputting to the Serial Monitor for testing, and setting an output pin high when water is detected.
This is the 'sensor' made from two header pins:
This is the sensor test...
And this is the Serial Monitor output. Reading of '0' is open sensor, very small reading is my fingers across the sensor, over 100 is sensor dipped in water.
This is the code so far:
--- Code: ---int probe = A1; // Bilge Probe pin
int level = 0; // Detected Water Level
int AIN2 = 12; // AIN2 Telemetry Trigger pin
int levelT = 10; // Set threshold above which triggers AIN2 (Prevent False positives)
void setup()
{
Serial.begin(9600); // Include Serial Monitor for Testing
pinMode(probe, INPUT); // Set Probe Pin as Bilge Input
pinMode(AIN2, OUTPUT); // Set AIN2 Pin to output to Rx S.Port
}
void loop(){
{
delay(1000); // Adds a 1 sec pause for easier monitor visibility
level = analogRead(probe); // Detection on probe pin
Serial.print("Reading Now = ");
Serial.println(level);
}
if (level > levelT){ // If water present voltage will increase on probe pin
Serial.println("---- > Water in the Bilge");
digitalWrite(AIN2, HIGH); // If Voltage on probe is > 0, set AIN2 pin to 5v
}
if (level <= levelT){
Serial.println("----- > No Water in the Bilge");
digitalWrite(AIN2, LOW); // If Voltage on probe is 0, set AIN2 pin to 0v
}
}
--- End code ---
I've made changes to Tx Telemetry to detect when AIN2 pin goes high so that's next step to test, there's an option to detect the 'highest' voltage on the AIN2 pin within OpenTX, I'm going to use that as if a small amount of water is in the bilge, it may not always cover the sensor, so once triggered the Tx will keep announcing til a telemetry reset. Plan is to use the Rx S.Port power supply for the Arduino mainly to avoid ground issues, I'm going to get this connected up, then test the telemetry.
Regards to all
David.
DJW:
Good News. Its working, and no blue smoke (yet...). :-))
This is the Arduino Pro Mini in its final state:
And the underside:
Its has a pass through for the S.Port to other devices.
Testing the probe:
So on detection of water by the probe the AIN2 line of the S.Port gets a 5v signal. In OpenTX I've set up monitoring of the AIN2 port using the AIN2+ telemetry signal, this (+ option) records the highest signal and keeps it til a telemetry reset. Then I play an audio track, 'Danger' was the most apt I could find in the sound pack... And it keeps playing every 3 seconds if the AIN2+ figure is more than '0'. So once triggered it basically plays til the telemetry is manually reset.
Now I'll incorporate a few sensors in the vulnerable bilge areas around the rudder tube and prop shaft seals.
I did change some of the pins in order to get the connectors in the right place on the board, so the top of the Sketch now looks like this:
--- Code: ---int probe = A2; // Bilge Probe pin
int level = 0; // Detected Water Level
int AIN2 = 3; // AIN2 Telemetry Trigger pin
int levelT = 10; // Set threshold above which triggers AIN2 (Prevent False positives)
--- End code ---
Not sure if this is a sledgehammer to crack a walnut thing... But I wanted another Arduino project so am happy with the result.
Video showing the end to end telemetry system working is here: [size=78%]https://www.youtube.com/watch?v=9S9OKOHVceM[/size]
If I've omitted any details that anyone wants to know, just ask.
Best regards to all.
David.
DJW:
Meant to add to earlier post...
This is on the Tx end to set up the monitoring (shown in OpenTX companion):
So L02 is activated if A2+ is greater than zero, i.e. if there's a detection signal from the Arduino.
And L03 is active if A2+ is zero, no detection of water.
And then if L02 is activated a sound ('Danger') is played every 3 seconds til telemetry reset.
If L03 is active, which is the usual state, a different sound ('Normal') is played, just once at startup.
Best regards
David.
Navigation
[0] Message Index
[#] Next page
Go to full version