48

Anyone with kids knows they never help with the toilet paper. Anyone know how to track when it's low or out and sound an audible alarm? I just don't know what sensor to use that may help.

Some that came to mind are: by weight, by reflection (the color of the paper) or some laser tripwire - all right on the spool. I don't mind building it, it's just I don't know which sensor. Anyone know which to use?

12
  • 5
    Perhaps you should also think about rigging a sensor on the toilet seat, so it will sound the alarm if someone sits down when there's no paper. :) Mar 2, 2014 at 20:38
  • 1
    Well, what follows may be a discussion better located on the meta.arduino, but I think that this question is typically one that deceives the point of having an arduino SE. It's not directly bound to arduinos as for every project one shall not design his solution against a tool, but choose the tools that are best for the solution (what if using a RPi is better, or a CC2540?). It's indeed a mechanical+electronical+software engineering solution. And there's no best SE place I know of to ask that kind of questions.
    – zmo
    Mar 3, 2014 at 12:05
  • 1
    You could just ignore it and wait for your wife to yell at you.
    – Jason C
    Mar 5, 2014 at 13:22
  • 1
    Mysteriously, this question managed to get more than 600 more views than the next most viewed questions...
    – TheDoctor
    Mar 16, 2014 at 23:59
  • 1
    Or buy one of those industrial-sized toilet roll dispensers, the paper will run out much less often.
    – MichaelT
    Nov 3, 2018 at 12:59

17 Answers 17

47

Bring up several rolls at a time and hang one for use. Put the other two on a short vertical pole within reach of the sitter. Sitter can take another roll when needed.

Mechanically sense lack of weight on the shelf at the bottom of the pole. Alarm triggers when the last roll is removed. No one has to get caught short.

To sense the weight use a force sensitive resistor such as the FSR 400 (see datasheet). Alternatively, you could use a lightweight coil spring to rest the toilet paper on with a micro switch that is released when both rolls are removed. Another option would be an IR beam break detector where the circuit is completed when the last roll is removed.

8
  • @AnnonomusPerson He is talking about measuring the weight of several full rolls of toilet paper, not individual sheets or empty rolls. Mar 3, 2014 at 2:42
  • 1
    This is a great idea: instead of having to deal with measuring the amount of paper left on the roll, measure the number of rolls left to tell you when you need to get more rolls. Mar 3, 2014 at 2:57
  • What sensor would you use to detect the lack of weight?
    – jfpoilpret
    Mar 3, 2014 at 6:45
  • 3
    A fabric pressure sensor is one option, or a light sensor on the base that is covered if a roll is present.
    – Rob Hoare
    Mar 3, 2014 at 9:31
  • Could you provide an example of a specific sensor that could do the job?
    – asheeshr
    Mar 3, 2014 at 15:12
22

I believe the reed sensor concept put forth by jfpoilpret and jmathew is the easiest to accomplish. I have drawn a diagram of how I think it would look.

You could adjust sensitivity by adjusting the height of the lower contact.

This really only gets you to a "low" condition and not necessarily out. Unless you want to change rolls while there are still a few sheets left this doesn't seem to me to be a satisfactory solution. I'd rather have an "out" indicator and have an audible buzzer to prompt/shame the user into replacing the roll.

This design could be accomplished using standalone electronics (no arduino needed). However it you wanted to gamify the changing of the roll you could use an arduino for that.

Note also for color based optics sensors, while the vast majority of cardboard tubes used for this purpose are brown, I have seen white ones in use as well.

Reed Sensor Diagram

7
  • 6
    Nice diagrams. What did you use to make them?
    – jmathew
    Mar 3, 2014 at 21:16
  • 1
    Just an iportant comment: you don't even need a reed contact in this situation, but just two pieces of metal used as a simple switch. A reed contact is based on magnetic forces opening or closing a switch; that was needed in my answer where there was no real contact between both parts. But here, using a reed just seems useless, I think.
    – jfpoilpret
    Mar 3, 2014 at 21:49
  • @jfpoilpret I didn't know the term was a specific kind of switch. I was thinking the more general concept of a stiff bendable material. Thanks for the clarification!
    – jmathew
    Mar 3, 2014 at 21:56
  • @jmathew no problem, after all, we are all here to share knowledge!
    – jfpoilpret
    Mar 3, 2014 at 21:57
  • 2
    I used MS Visio 2007.
    – Arluin
    Mar 5, 2014 at 16:47
14

I think I saw this in series 1 episode 2 of James May's Manlab.

Similar to jfpoilpret, use a wide piece of material on a spring that makes contact with the roll at all times. I say 'wide' so that when the roll is empty the reed touches with a contact on one of the roll holders on the side. When it touches it completes a circuit to your alarm.

Here's a crude image describing what I mean.

In Arluin's response it was mentioned that this method would not show that the the roll was empty. Thats pretty much true. If the top contact is as thick as the TP cardboard roll and the bottom contact is positioned inside the inner part of the cardboard roll it should get close enough for practical purposes. One foot of TP roll is not enough after taco night.

Behold the image of my imagination

0
9

Use a radiation detector to detect the amount of paper left on the roll. Place some amount of radioactive material in the middle of the spool rod, and place the radiation detector somewhere else (you could mount it on the other side of the surface the roll holder is mounted to, if you want; radiation sensors are extremely flexible), and measure the radiation amounts to determine how much paper is left on the roll.

Alternately, you could have an electronically controlled toilet paper dispenser (push button to dispense a preprogrammed length of toilet paper) and have the arduino just keep track of how much has been dispensed.

Or, attach a rotary encoder to the side of the spool rod (make sure it fits without slipping inside the roll), and count the rotations of the roll to determine how much has been used.

Of course, with any of these methods, you will have to do tests and collect data depending on the exact type/brand/material/etc of toilet paper.

Especially for the second and third ideas, I would recommend taking data from the system regularly, to keep track of the typical length of a roll so you can adjust the program for any significant variation. Even within one type of toilet paper, I would imagine that there would be some variation in roll length.

For even more fun, you could instrument the detector to collect time series data, so later you can upload it to a computer and make a "toilet paper usage over time" graph or something.

7
  • 2
    I'm a huge fan of using a rotary encoder. It could even be designed the the TP holder had the encoder attached to the rod through the roll, thus causing no moving on the encoder. Also a button could be used to reset the count. Mar 3, 2014 at 8:27
  • 1
    But a common problem would be to determine the max number of rotations as this depends on the number of sheets and their thickness.
    – jfpoilpret
    Mar 3, 2014 at 10:10
  • I would change this from 'Attach radiation device to toilet roll' to attaching it to the middle roller it sits on. The same effect, but less maintennance of having to reattach the sensor for every roll
    – Robotnik
    Mar 4, 2014 at 9:30
  • 1
    You could determine the number of rotations by transferring all the TP from a new roll onto the spool in your measured roll and counting the rotations with the encoder (with a simple DYI thing like a couple of vertical dowels and just wrap one onto the other). Then when its empty, repeat. Makes the whole thing easy to use too because you can just keep reusing your same spool that you've already attached the encoder to, and keep wrapping new TP onto it.
    – Jason C
    Mar 5, 2014 at 13:25
  • 1
    @AJMansfield I wonder if some circles cut out of cardboard on the sides of the receiving roll (and some care) would give satisfactory results; if the rolls are on dowel rods for transfer you can just poke a hole in the center of the discs and slip them on. On the plus side, if you always buy the same brand of TP, you'd only have to do it once (and you can keep a list handy of the number of spins for different brands/types that you discover -- you could be the proud maintainer of the world's first opensource TP spin count database).
    – Jason C
    Mar 5, 2014 at 16:48
7

I think 'Arluin' and 'jmathew' have the right idea. Use a lever resting on the top of the roll.

I would do it slightly different however. Rather than rely on contacts shutting you can use a potentiometer. With this system you can measure the amount left instead of simply being notified when it gets low.

With a contact such as those suggested already, you might get paper stuck in the contact as it closes and then low paper would not be detected.

(You may need a weight, shown in blue on the diagram, to push the lever down as the roll is used)

You would need to try and get the pot as close to the roll as possible for maximum swing of the pot and therefore maximum resolution of amount remaining.

Another thing you might want is some kind of roller on the end of the lever so that the paper roll can move easily with little drag where the lever contacts the paper.

Proposed setup

5

You could just crack open one of those playing birthday cards and adapt the switch to the holder arm. Once you hear 'Happy Birthday" chiming from the toilet you know you're in trouble! (and because they are very low-power these things chime on forever ;-) ) I've shown a LED setup here but you get the idea...

happy birthday

1
  • Can you please edit your question to tell how to connect that item to an Arduino board? Thanks! Mar 12, 2014 at 1:02
3

I built a reflectance tachometer for an Arduino that'd probably solve your problem. The basic circuit is quite simple:

tachometer circuit

I had a photoransistor laying around that responded well to red light, and another from Radio Shack that was quite sensitive to the IR output of old TV remote LED's. For your purposes, green wire would be hooked up to Analog Pin 0 of Arduino, and you just have to sample periodically, not set up an interupt driven sketch. The trick to getting a reflected signal difference between white paper and grey roll is knowing that light sensitivity of a photransistor increases w increasing resistance to GND, but the dark voltage also goes up. I came by the 5 and 3 megohm values empically, by checking the AtoD values off dark and light objects at a distance of a few inches from the detector. Same procedure should work for your detection of grey vs white. Although some things that look quite different visibly have the same reflectance in IR. Here's a pic of the finished red light tachometer: enter image description here

It should be simple to make the sensor board small enough to fit into the back of your paper dispenser. IR version is even smaller, but buried too deeply in a home-built centrifuge to get a pic of it today.

3

I think another decent and cheap option to use is a proximity sensor like the ones on the phone or a fixed field infrared sensor. These sensor are pretty accurate and can easily be used to "look" at the back of the toilet roll by mounting the sensor to the holder or the wall where the toilet roll is placed. All the other ideas I saw on the post were either fairly inaccurate or felt intrusive towards the toilet roll which in the long run I feel may provide contamination. A proximity sensor is not only fairly cheap and easy to use, if calibrated well, they can allow a very good amount of accuracy and reliability. This model is already in wide usage in men urinals to auto-flush. For example on your phone: Your phone will accurately provide a distance of 2.0 inches or infinity when your hand or your face is near the screen.

4
  • For $10 you can get this adafruit.com/products/466 1cm-15cm range (perfect for TP roll) and designed to be easily integrated with a microcontroller.
    – Jason C
    Mar 5, 2014 at 13:57
  • @Jason C: First attempt was using VCNL4000, but like other reports, it would stop/halt/freeze while taking readings. I've not seen anyone resolve this, even when lowering the mA.
    – Jose Leon
    Mar 30, 2014 at 0:53
  • @Aditya Using HC-SR04 proximity sensor did not help. There was no difference between a full roll of TP and an empty one. Best I can guess is the 'echo' was going straight through the tissue and stopping at the metal bar holding the TP. So, at least for that sensor, it did not work.
    – Jose Leon
    Mar 30, 2014 at 0:55
  • @JoseLeon I see. That's quite odd indeed. I agree with your reasoning. Maybe there is another sensor out there which might work but I think your reasoning that the infrared waves should just go thru the toilet paper seems valid. Mar 30, 2014 at 12:52
2

An short-range ultrasound distance sensor might be an effective (and fairly cheap) option. You can get an emitter+sensor combination mounted on a chip. Different sensors may work in different ways (always check the datasheet). A common output though uses the length of a pulse to indicate the distance sensed. You could process that in Arduino using the pulseIn() function.

In terms of installation, you'd probably fit it directly behind the toilet paper, pointing at the centre of the spool. The readings are often quite erratic, so you want to take several measurements and average them (or use a simple moving average). With a bit of calibration, you could determine what distance represents an empty spool.

When you detect that distance repeatedly for a significant period (e.g. a minute or more), you'd sound the alarm.

A reflectance-based sensor might be another possibility, although I wonder if you might struggle to find one which will work properly on toilet paper (depending on how soft your preferred brand is!).

6
  • I am not sure you would get enough accuracy with an ultrasound sensor; IIRC, most of them have about 3-4 mm accuracy; in general that's good enough, but considering the diameter of a toilet paper roll, that may be too inaccurate.
    – jfpoilpret
    Mar 2, 2014 at 20:53
  • Yes, that's often true for an individual reading. The fluctuations are quite uniform though, so you can average out several consecutive readings to counteract it. That can potentially give you a precision of ~1mm. Mar 2, 2014 at 21:01
  • What happens when the toilet paper wiggles one mm while spinning away from the sensor with a little bit of paper left? Mar 2, 2014 at 21:56
  • 1
    @AnnonomusPerson You'll always get spurious readings when there's movement. That's why you wait until the reading is steady for a significant period before acting on it. Mar 2, 2014 at 22:37
  • @Peter R: Using HC-SR04 proximity sensor did not help. There was no difference between a full roll of TP and an empty one. Best I can guess is the 'echo' was going straight through the tissue and stopping at the metal bar holding the TP. So, at least for that sensor, it did not work.
    – Jose Leon
    Mar 30, 2014 at 0:57
2

One idea that comes to mind would be something like that:

  • stick a small magnet inside the paper roll, i.e. inside the cardboard part (this has to be done every time you change it; though)
  • use a reed contact (electro-magnetic switch) at the tip of a stick mounted with a spring to be always in contact with the paper roll
  • one pin of the reed contact can be directly connected to an input logical pin (set it up as a pullup resistor input)
  • the other pin of the reed contact is to be connected to the ground

Thus, as soon as the distance between the magnet and the reed contact is under some limit, the switch will close the circuit. That distance will decrease while the paper roll gets drawn.

Note that, instead of a reed contact, you may also use a Hall Effect sensor, the principles remain the same, only technology and characteristics change.

The difficulty here will be to find the right sensitivity of the reed contact (or the force of the magnet) so that the reed contact gets closed when the distance between it and the magnet is small enough to avoid an alarm that would be activated too soon).

4
  • That won't work, same reason as an ultrasonic sensor. It'll still go off with at least 10 feet still on it. The color sensor is a better idea. Mar 2, 2014 at 22:55
  • I don't see the relation with ultrasonic sensor. Could you develop further WHY it won't work? There are large quantities of reed contact and hall effect sensors, let alone different kinds of magnets.
    – jfpoilpret
    Mar 2, 2014 at 23:08
  • A layer of TP is so thin that it might activate with a little left. It theoretically could be tweaked, but it's really inefficient to take out the microscope or whatever to change a roll of toilet paper. Mar 2, 2014 at 23:40
  • Activating with a little left is not so bad, since the OP question is "... toilet paper is low"; low does not necessarily mean empty.
    – jfpoilpret
    Mar 3, 2014 at 6:44
2

Sounds like a cool project, here are my 2 ct:

Point a camera to take photos of the roll from sideways, that is probably the only way to really find out how much paper is left. (edit: You could use a raspberry pi with the csi camera and create an output signal corresponding to the number of sheets and feed that signal to the arduino?!)

For an estimate it might also be enough to count rotations of the roll, but you need to fiix the roll better so it doesn't slip. Or you can use magnets like you do on bicycles, but they need to be attached to the roll directly then.

(edit: one more idea, mesure the thickness of the roll by measuring the angle of the lid)

2
  • Hello and welcome to Arduino Stack Exchange! Can you please say how you connect it to an Arduino? Thanks! Also, I don't know how good of an idea it is to put a camera in a bathroom. :) Mar 3, 2014 at 1:24
  • I like your last edited idea; it might be simplified further by just using a switch on the lid, that would close the circuit when the lid has reached a certain angle; that seems easier than measuring the angle itself.
    – jfpoilpret
    Mar 3, 2014 at 6:48
2

The simplest, yet best solution afaict, would be to use an optocoupler made of one IR LED and an opto-transistor. You make the LED lighten towards the roll, the LED being within the roll tied to the "handle". Once you remove the cardboard roll, the opto-transistor gets the IR light from the LED and triggers a pin change interruption on the Arduino, which can then alert you through many ways (light, SMS, twitter, alarm…).

That design is really cheap, easy and fast to build. Though there's still one thing you need to do: when there's no more toilet paper, you need to actually have the cardboard roll removed ;-)

Otherwise, the same kind of solution for the spare rolls is even a better idea :-)

2
  • Arent't optocouplers single chips that include both the emitter and the receiver? See here: en.wikipedia.org/wiki/Opto-isolator
    – jfpoilpret
    Mar 5, 2014 at 7:06
  • […] is a component that transfers electrical signals between two isolated circuits by using light […] so basically that's what we do, between an IR LED (one circuit), and a phototransistor. Though you're right it's not a single component (like the MOC3020).
    – zmo
    Mar 5, 2014 at 9:57
2

A lot of the options here seem overcomplicated and intrusive.

Color Sensor

Another option, slightly complicated (but fun) to implement, but unintrusive and easy-to-install, is to build a cheap color sensor and mount it on the wall behind the roll. When you detect the color of the roll (or the absence of the color of TP), it's low.

You can also just buy one for $8.

You can adjust the threshold by taking advantage of the thinness of TP and the fact that it starts to look a little darker when there's only a few sheets left.

If necessary, calibration can be done by pressing a button after a new roll is installed with the bathroom lights on.

You would have to make a few adjustments depending on the specifics of your bathroom. If you added some extra complexity and powered it off an AC outlet that was tied to the bathroom light switch, you could only have it powered on when the bathroom lights were on, which would filter out a lot of unreliable data.

This is very easy to install and doesn't involve modification to the roll itself. You could stick the sensor to the wall with double-sided tape, or put it on a tiny shelf under the roll facing up (or on top facing down).

IR beam break

Mount a small IR LED on one side of the dispenser, just above the spool. Mount an IR photo sensor on the other side of the dispenser. When the sensor sees the LED, the roll is low. Could be done with a cheap laser too (e.g. an off the shelf laser pointer on one side and a photosensor on the other; but don't hurt your eyes!)

This is also easy to install (e.g. hot glue to dispenser) and doesn't involve modification to the roll, although the location of the sensors might make them easy to damage when you're replacing rolls.


I also really like the reed sensor and range sensor (BTW: $10 gets you a great short range distance sensor) options here.

2
  • 1
    IR beam was my first thought. Simple and easy to implement and probably more reliable than some of the other solutions, although maybe less fun :)
    – Kevin
    Mar 5, 2014 at 20:44
  • Hehe, I agree. I think a color sensor would be fun, at least from the software side; it would be a nice challenge to collect data and try and come up with an algorithm that was immune to, e.g., changes in natural lighting or other false triggers.
    – Jason C
    Mar 5, 2014 at 20:49
1

You have a few options:

Note: The links given are just the first ones that come up. Most of them are pricey compared to other sites. eBay buy it nows can be fairly cheap for most of these items. Check other places, too, including Sparkfun.

  • Ultrasonic Ping Sensor. This isn't ideal by any means, but they're easy to use. Just add one with an enclosure. It isn't ideal because it won't be accurate enough to tell when exactly it's empty. It might be a little over/under sensitive. Weight would be harder, though if it shifts at all.
  • Color sensor (preferable, but costs more). You mentioned this and this is probably the best idea. It'll give you analogue values (to read with Arduino) for red, green, and blue. [Assuming that the higher the content of that color, the higher the voltage,] white should be pretty much all of those at 100% and brown I would image that most of them would be about 30-40%. (More later, if you don't understand this, skip this part)

I'm going to go into more detail on the color sensor:

Colors are read with three values here: red, green, and blue. There are three sensors on the board. One filters out everything except red, another blue, and the other green. The sensors on the board detect the amount of incoming light and then convert that to a voltage: between 5V ("100% red/green/blue") or 0V ("0% red/green/blue"). This then can be converted into a number by the Arduino (0-1024 on an analogue pin).

A problem with lighting: This sensor, from what I can tell, has a LED that's always on. You'll want to either desolder that or cover it up, unless you want an illuminated toilet paper holder. Now wait... your sensor will think that when it's dark, it's brown. No problem... here's something for you mind to think about.

Use a color picker like I'm using and select a brown. On the left of this one, you can control the "simulated brightness." Besides that is the hexadecimal form of RGB. You'll want to convert that to standard values with this calcuator.

In brown, the color blue is almost nonexistent. We should ignore that color, unless you want a way to double check that it's brown. I'd say it should always be under 40% for pretty much any shade of brown.

From what I can tell with a sample shade of brown, the red is pretty much 2x the green. That ratio may vary, but you should verify that it is somewhat existent. For white/grey/black, all the colors are proportional 1:1:1. You can use this to detect if it's dark, or if it's brown.

int rPin = A0;      //Red Pin
int gPin = A1;      //Green Pin
int bPin = A2;      //Blue Pin
int ledPin = 13;    //I made this code with a LED, not a speaker
boolean testTwice = false;

void setup() {
  pinMode(ledPin, OUTPUT);  
}

void loop() {
  int rValue = analogRead(rPin);
  int gValue = analogRead(gPin);
  int bValue = analogRead(bPin);

  if (bPin < 256) { //If this is false, either something is in the way or it's white. Going to verify that something's not in the way...
    int minRed = rPin * 0.4; //A little under a half for padding... this values may need to be adjusted. Adjust this one and the one below farther apart for less sensitive.
    int maxRed = rPin * 0.6; //A little over a half for padding... this values may need to be adjusted.
    if (gPin < maxRed && gPin > minRed) { //Verifys that red between minRed and maxRed
      digitalWrite(ledPin, HIGH);
      delay(5000);
      digitalWrite(ledPin, LOW);
    }
  }
  delay(5000); // No need to waste power... you might want to add an actutal sleep function if on battery power
}

First, it verifies that the blue is less than 25%. Then, it verifies that the red and green are equal... give or take 20%. (i.e. red = 100 green = 80, red = 110 green = 90, etc.). If that is true, you can pretty much establish that it's brown. Then, a LED turn on for five seconds.

You can modify the LED to be a buzzer if you want. You might have to adjust the if statement with verifying that the blue is less than 256/1024 (1024 = resolution of analog pin) if it isn't working in a lot of light or is working in dark light. Since the code later verifies that the red is about 2x the green, any shade of white shouldn't pass that if statement. You may also have to adjust the minRed and maxRed to be farther (if not detecting brown) or closer (if detecting brown when it's white). I can't really test this code with no color sensor.


Note: these can be a little fidgety. I would recommend a LED instead so the whole house isn't woken up in the middle of the night just because of low toilet paper. Also, if you obstruct the sensor at all... If it wasn't in the bathroom, I would recommend a camera and have it take a shot every time it gets very low with a reed switch like @jfpolipret's answer... but... (no pun intended) :)

11
  • Shall the color sensor work the same (i.e. without having to tune the sketch) if you change the color of your toilet paper :-) ?
    – jfpoilpret
    Mar 2, 2014 at 20:56
  • @jfpoilpret I don't know if you reuse your toilet paper or not but... :) I'm adding code with mechanisms so it'll be "similar" but not exact. Mar 2, 2014 at 21:07
  • I think toilet paper is soft enough to absorb the ultrasonic burst from an ultrasonic sensor
    – TheDoctor
    Mar 2, 2014 at 21:09
  • @TheDoctor It's not a good idea really, like I pointed out. It's way to inaccurate. Mar 2, 2014 at 21:11
  • 1
    @jfpoilpret If you added a "calibrate" button and pressed it with the bathroom lights on after you install a new roll, you can measure the correct color.
    – Jason C
    Mar 5, 2014 at 14:07
1

Your best option is attaching a rotary encoder to the side of the roll, and count the rotations of the roll to determine how much has been used. Once you know the number of rotations per roll,you can set where you want your notification to fire. Attach it to a logging system of sorts and you'll have historical data of paper use as well as toilet use.

1
  • I agree. People seem to be overcomplicating this. Also you can keep reusing the same roll with the encoder attached to it by transferring TP from a new roll to the sensor roll when you refill it (e.g. put rolls on a couple of cheap dowel rods, and wrap it up); that also lets you count how many rotations for that roll (as you refill it).
    – Jason C
    Mar 5, 2014 at 13:30
1

I say get a weight sensor, and program it for the roll's weight. When it drops below a certain weight, start flashing an LED or make a beep.

0

Another way to do it, in case you just want to for the fun of it would be to put a metal rod inside the roll, and a metal plate on the outside, and measure the capacitance which should change with the TP remaining due to the dielectric constant of the paper.

But that would be taking the "scenic route" for sure. Still, the Arduino can measure capacitance pretty easily and it might even be sensitive enough, and it would stay out of the way because it would just be a metal plate behind the roll and a metal rod in the roll. You might even be able to retrofit an existing holder without it being noticed.

An easier way would be a stick attached to the shaft of a potentiometer held up by the top of the roll. Less TP, shaft goes lower and turns the pot. Might need a long shaft for leverage because you can't press too hard without impeding the function of pulling toilet paper.

As AJMansfield suggested, Radioactivity actually is used to measure the thickness of things in industrial settings. If you really wanted to go crazy maybe you could use an extremely low energy radioactive source like a can of that weird tasting salt substitute which is a tiny bit above background levels and average over extremely long times(toilet paper shouldn't change much from hour to hour), so this could actually be a reasonable if expensive way to do things.

Infrared beam break sensors are also good, and if you position it right you could get it to block more light the fuller the roll was instead of just giving you and on or off signal.

EDIT: Working Proof of concept of the capacitative approach. Only needs an arduino and 2 stiff wires. Precise to about an 8th of an inch, with a lot of noise. Pretty sure you could reliably get at least 1inch accuracy. Measurement time is about a minute. It's really sensitive to it's surroundings. You'd have to make sure anything metal within a foot stayed where it was or use shielding.

float difference;
unsigned long i;
unsigned long j;
unsigned int temp;
volatile unsigned char blah;

void setup()
{
  pinMode(5,OUTPUT);
  Serial.begin(9600);
}

void loop()
{
 difference =0;
 Serial.print("Measuring: ");

 for(i=0;i<100;i++)
   {
     for(j=0;j<5000;j++)
     {
       digitalWrite(5,LOW);

       temp=analogRead(A0);

       digitalWrite(5,HIGH);

       temp = analogRead(A0)-temp;
       if(temp<1024)
       {
         difference += temp;
       }

     }
     //Random delay every 5000 samples helps avoid problems with interference by staggering the samples to cancel aliasing.
     delay(random(1,50));
     Serial.print("|");

   }
   Serial.print("\n");
   Serial.print("Value: ");
   Serial.print(difference/500000);
   Serial.print("\nMeasurement Complete. Press Enter to begin another test.\n");

   while(!Serial.available())
   {
     blah = 20;
   }
   Serial.read();


}

http://pastebin.com/2W5y81AB

1
  • It's better to include code in your answer instead of an external link. If the link breaks in the future your answer will still be relevant.
    – sachleen
    Mar 11, 2014 at 19:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.