Creating a moisture sensor with Raspberry Pi
Utilizing a Single transistor circuit to create a moisture sensor.
In my last post, I wrote about getting to grips with using the GPIOs on a Raspberry Pi to interface hardware, and how I wanted to use this knowledge to create a moisture sensor that would monitor bed bound patients on NHS wards to improve patient health and dignity.
Currently the target on Bradford Teaching Hospitals NHS Foundation Trust wards is to check the bedsheets of bed bound patients every 4 hours. This means that a patient could be checked at 9am, wet the bed at 9:15 and in theory remain in a wet bed for the next 3 hours and 45 minutes.
This is a blow to their dignity and a poses a great risk to their health. Wet skin is more susceptible to breakage and pressure sores than dry skin and can impact the cost of care astronomically. The daily costs of treating a pressure ulcer per patient are estimated to range from £43 to £374. For ulcers without complications the daily cost ranges from between £43 to £57 (Bennett, Dealey and Posnett, 2012). The average length of stay for in inpatient across Great British health care trusts is 5.6 days (Health and Social Care Information Centre, 2013), and hospital-acquired pressure ulcers increase the length of stay by an average of 5–8 days per pressure ulcer (Bennett, Dealey and Posnett, 2012). Therefore, costing a minimum of £215(£43 x 5 days) for a simple case, to a maximum of £2992(£374 x 8 days) for those involving more complications.
Surely simple electronics can be incorporated into daily use on wards to tackle this problem?
A simple moisture sensor circuit made of a single transistor and a few resistors, and a Raspberry Pi.
I wanted to use as few components as possible. The less components I use, the less it costs to manufacture and maintain, and the more likely it is to be implemented.
The moisture sensor circuit I settled on can be seen below in the schematic and breadboard diagrams I created using Fritzing.
And brought to life the circuit can be seen below.
It’s a simple circuit that works on the basis that in air, the resistance between the electrodes is too high to conduct electricity and form a complete circuit that will turn on the LED.
When the electrodes are placed in water — or in the case of our target liquid, the presence of sodium, potassium, creatinine and other charged ions — this will allow for the completion of the circuit, a current to flow and the LED to be turned on.
This victory can be seen in the picture below.
Now I know my circuitry is sound, the next step is to ditch the LED and get the Pi involved.
My ultimate target was to have the computer display a help indicator located on a nurses station, either through lighting up an LED next to a bed number or sending a message on a screen. Since I controlled LEDs in my last post I chose to challenge myself to explore Python a little further and print a help message.
To do this I opened my text editor and imported both the GPIO and time library as I would need both. I instructed the Pi I wanted to use names of the GPIO pins rather than numbers using the line GPIO.setmode(GPIO.BCM) BCAM, and defining via a variable that Pin 23 is the is the collector using collector=23. GPIO.setup(collector, GPIO.IN, pull_up_down=GPIO.PUD_UP) facilitates an internal pull-up resistor on pin 23 to keep the input on logic level 1(True) unless it is connected to ground, which will happen if the electrodes are placed in water, and when this happens it will override this, pull the logic level to O(False) and then print out the line ‘help required’. This is defined in the last lines of the code. The time.sleep(0.2) instructs the Pi to re-evaluate the status of the circuit every 0.2 seconds. In the real world this would not be necessary, we would set it to re-evaluate and send another help indicator every 5 minutes or so, but for this test it was a good way of showing us that the circuit was staying in its loop and working correctly.
Now I’d reached the crunch point. Time to hook up my circuit to GPIO pin 23 and to the GND pin on the pie as seen below and get to testing.
I placed the electrodes in the water and crossed my fingers that the help line would be displayed.
Success!!!!! This can been seen working in the video too.
The next step.
Now I know I have a successful moisture sensor, my next challenge is to make it a bit more user friendly. Nobody wants to sit on bare wires all day. The plan is to use a conductive thread in place of my wire electrodes and sew them into a cotton square for prototype development and consider ways of programming my pie to display the help needed on a nurse’s station and keep a log of the information it is recording to be placed into tracking graphs and compiling the kind of data that will allow for target setting and save a lot of man hours in the long run. Stay tuned.
CommentsAdd a comment
I have worked with robots and sensors for education, and for non educational standards, like solar power, and have found that one often has to spend much more time in looking into what can cause sensors to accidentally activate, rather than activate. In your circuit I notice that there is no current limiting from the 6V supply to the sensor point, and nothing to protect the base input of the transistor. If there is plastic on the rails on the bed, or it has a plastic under sheet, etc, this might cause static electricity which could actually damage the circuit as is. Many people who get static shocks from cars do so because of just a slight rubbing against the seat which has no connection to earth.
Thanks for all of the feedback and information. I'll be looking into all of it. I am hopefully combining a few things, a moisture sensor(that won't electrocute anyone, i hope! no bare wires on the final project), a compression cell to weigh a patient without the nurse having to lift them or cause them pain. Some times that needs to be done a few times a day to work out medication doses etc and it's one of the things most nurses asked for. I'm looking at adding a temperature sensor and a few other bits too. I want to combine them to make a sort of monitoring system that will log everything for the nurses to make their life easier and improve the patients stay. Any help that will get me there would be greatly appreciated!
I remember ,
long time ago , my son, a baby, now 55 , during the night used to piss in bed. I was very wild so I used this scheme to advertise in the night .
We used one night only : Our son was "vexé" -in french and then used to stand by and do as a great boy...
for security all the scheme on battery
The son now work as a system engeneer in an university in THaïland
dgoadby - that's an approach that would seem to be quiet practical the bigger issue though becomes information overload for the nursing staff.
They already have an array of screens displaying vital signs, a nurscall system constantly buzzing, electronic medical records on another screen/s. With the constant grab for attention from different systems nursing staff become desensitised to alarms and information (this isn't limited to nursing many other fields suffer the same fatigue)
Sensors are also very susceptible to failure and false alarms which ends up increasing the workload as they are not self checking.
In this example (and all the commercial units Ive seen) the sensor detects only one parameter, in this case conductivity of moisture. A person on the other hand uses an array of sensors to determine the required response - Urine can be smelt(usually), a wet patch can be (often) seen and the extent of the wetness can be identified. Is it just a few drops of water or a major wee explosion. And can be felt (not the best thing to do but that's what the sensor does).
Spending less money on technology and more on real life staff IS a better solution.
As a proof of concept this is fine but, if there is a real world application then I would have gone for something like the esp8266.
The esp8266 chip has the I/O you need, wifi built-in and will run for ages on a small battery with wake-up options. Yes, you would need wifi in the ward but you could use a private in-ward network using the RPi as a base station with a simple LCD display and sounder showing which bed required attention.
With I2C you could even add other sensors such as humidity, temperature or motion.
You could make a simple package with replaceable AA cells for the power source and attach it to the side of the bed frame using a magnet. A small cable would be used for the sensor(s). Unit cost would be very low.
This is obviously a really important item for development. I'm actually a bit amazed that there isn't an off the shelf solution at a reasonable price, already - well done for identifying the product gap. A word of caution, as I remember an electronic engineer in the biomedical field telling me that using current sensors for this particular problem (bed wetting) can actually lead to electrolysis of the urine (or sweat) on the skin before the unit triggers and cause caustic burns. Better check with some bio-engineers on this issue. I'm pretty sure he said he used sensors triggering at micro-amps, not milli-amps. And keep up the research!
A very good concept to help patients and the NHS, however, I think the Raspberry Pi is a bit too overblown for such a project, and too expensive compared to some alternatives, like using a basic Arduino chip set up as a stand alone controller, it is also a very low power consumption controller, especially when set upset up to only monitor every 5 minutes or so. I am not sure from the article if it would need a Raspberry Pi for each
bed being monitored, or if it would multi-plex an array of sensors from different beds, in which case the power consumption of the Pi would not be that much of a problem, and give more alternative than an Arduino chip. set-up as a stand alone unit.