brelovich

How to not measure the water level with an ultrasonic sensor

Put an ultrasonic sensor at the end of a 75mm pipe, stick the pipe down a water tank and measure the distance. It seemed like such a good idea. Get an exact distance reading and calculate the water depth.

Testing on dry land gave promising results. The sensor would deliver perfect distance readings up to at least 2m when fitted to the end of a 75 mm pipe. Testing in an actual tank worked equally well. For a while.

Then, suddenly, a stray reading, totally off the scale, and then back to normal. This wouldn’t really have been a problem if it wasn’t for the GSM module, sending me a text message every time it happened, but it was an easy fix to introduce a threshold, requiring a number of readings saying the same thing to trigger the text message telling me something was wrong.

That worked, but not for long, until the messages started coming in. Again the sensor was reporting strange values, completely off the scale, but for longer periods of time than before.

Visual inspection gave no clues. Mechanically everything was all right where the sensor sitting just as it should and the water level was fine, within limits.

The sensor had to go. It was deactivated and later replaced by a differential pressure sensor that has been successfully used before and still works after several months of use. The only downside is that it varies slightly with the weather, but it does so consistently, so that readings can be trusted to stay within certain limits.

I know for a fact that ultrasonic sensors are used for exactly this application industrially, so there’s no doubt that it can be done, but I don’t recommend trying it with the kind of naked sensor that you can buy cheaply at the electronics store. If the sensor is encapsulated in some suitable material that lets the ultrasonic waves through it should be a totally workable solution. Feel free to experiement.

Changing reprap filaments in the middle of a print

You can’t do that. (Actually you may be able to pull it off, using something like this procedure.)

I didn’t intend to to it either, but then I managed to break the filament in the middle of printing a pulley and I had to try something.

First I tried to feed the new filament manually, while the printer was working. Off course it’s moving around all the time so that’s difficult and yes, I failed.

So, I paused the print and very quickly put the new filament in. Then I just let it continue.

The results weren’t so great, as you can see. I could live with the blob – it’s just a matter of filing it down. The problem is the weak layers that will not be easily fixed.

Maybe I could have got away with it if I had paused the printing at the exact moment when the filament end was released by the extruder, but I’m not so sure that would have worked either.

I should probably practice this the proper way or just not break the filament in the middle of a print.

Printing reprap pulleys

A tray of pulleys, fresh off the printer

I managed to print a set of pulleys. If anyone would have asked me before I started trying I wouldn’t have seen it as very much of an achievement, but after spending two months trying to figure out how to get decent printing results I now find cause for some celebration.

I’ve had a Mendel Orca 0.3 sitting on my workbench since Christmas. I avoided for several weeks to install the software and connect it to my computer. Something in me made me realize what would happen the day I actually tried to get it up and running and yes, that realization was true.

At some point it had to be done and yes, all other project suddenly came to a halt.

Initial connection attempts failed but after reloading the, supposedly pre-loaded, firmware I got it to print something. Then started the real nightmare that is calibration.

For two weeks I thought the printing bed wasn’t flat (it was) and tried various solutions, including a glass sheet on top. Then I realized that the y-carriage was the culprit and the problem was finally resolved.

Then there was the filament feeding problem. The filament would feed fine initially and then stop. This, of course, was due to spring tension and alignment of the extruder with the hotend. I’m sure that helped, somewhat, but what really got things moving was raising the temperature to around 250C. I’m pretty sure that the thermistor isn’t calibrated correctly and that the real temperature is lower but right now I can’t be bothered to do anything about it right now. It works, after all, and I can print stuff, so I’ll keep on running as long as I can.

For a while the hotend temperature would jump, suddenly to 900C and then be shut down. That turned out to be due to a short circuit between the leads. I had to remove the hotend, take it apart and put it back together again to get it working.

Missing a tooth

Then there was the problem with the missing tooth on the pulley. Whatever I did the pulleys would come out with one tooth missing or severely malformed. That is until I read about the Cool settings in Skeinforge. It turns out, if you activate cool, set a minimum time of 30 seconds or so per layer and set Skeinforge to slow down, all the teeth come out just fine.

The base is sagging and it's quite a bit wobbly.

The problems weren’t completely over, though. The pulleys came out with all their teeth, but they weren’t straight. They were sagging, more in some directions than in others, as if the underlying layers couldn’t cope with the weight.

The solution to this one seemed obvious. I turned the infill ratio up from 0.2 to 1.0. For a pulley that’s probably a good idea anyway, although I’m not sure that should really be necessary.

There are lots of little things left to tinker with and probably some settings to adjust but now, at last, I can leave the printer running for a few hours and have it deliver usable results.

If only I had known three months ago where to start…

The water level sensor that phones home

Arduino with psu to the right - Seeedstudio gprs module to the left

Arduino with psu to the right - Seeedstudio gprs module to the left

The Water Level Sensor has been upgraded quite a bit. I added another sensor, for the second sump pit, but the biggest addition is the GPRS-module (to the left.) So now, if the water level rises above a set trigger level, the house will send me a text message.

I don’t expect that to happen any time soon but if it happens you can be sure that I won’t be there to notice until too late. Well, not any more, at least not as long as all the electronics work and I remember to charge the SIM regularly.

I rewrote most of the software in Arduino 1.0 and added automatic logging to a Google Docs spreadsheet. That works nicely for keeping an eye on things when online. Also I’ll be able to make all sorts of (useless) statistics.

There are more details coming up with source code and detailed explanations but I’m not really there yet. Just leave a comment if you have questions and I’ll provide as many answers as I can.

Learnings from Steve

There are two things you can learn from Steve Jobs:

  1. You may have some truly amazing stuff cooking in your garage
  2. It could all end tomorrow

So, what are you waiting for?

How to lose customers

Don’t answer email.

You don’t even have to do anything.

Water Level Sensor with Arduino Ethernet

This project implements a network connected water level sensor, measuring the level in the sump pit of my house. It’s connected to the home network and reports the water level by broadcasting UDP packets so that any computer can receive it and take action, such as sending out an alert or storing statistics.

The Arduino Ethernet and the Power Supply installed and connected

Important note
Before we go any further, let me just point out that the pressure sensor, MPX2010DP, used in this project exists in another version, MPX5010DP, that has an output voltage interval much better suited for this project. If only I had checked that I wouldn’t have needed to build any circuits or use any extra components at all.

The pressure sensor MPX2010DP measures the pressure difference between two inputs, from 0 to 10 kPa and outputs between 0 and 25 mV on it’s two output pins. (The MPX5010DP gives you between 0 and 4.7 V output, ideal for direct connection to the analog inputs on Arduino.) This means that we can use it to reliably measure the water level in a tank or pit, without being troubled by changes in air pressure The only thing we need to do is connect input 1 to a hose leading to the bottom of the pit and leave input 2 hanging in the air.

The MPX2010DP operates anywhere between 0 and 16 V and draws less than 10 mA, which means we can run it directly off the 5 V pin on the Arduino. (MPX5010DP operates between 4.7 V and 5.25 V with about the same current draw, so in that case it’s even more ideal) It’s also possible to run the amplifier circuit from the Arduino, if you decide to go down that road. All this also means that you can run a long cable (I used shielded 4-wire telephone cable, but any 3-wire cable should be fine) from your Arduino to your sump pit or water tank.

Circuits and PCBs

Bottom layer of PCB with pads, as PDF

Eagle files

The schematics for the amplifier circuit. Pin assignments for SV1 are identical with those on the MPX2010DP pressure sensor

 

The amplifier circuit takes the input from the pressure sensor and amplifies the 25 mV maximum output to something more useful, like 5 V. Initially I used the circuit from Practical Arduino, and it worked fine when supplied with 12 V. When powering it with only 5 V it wouldn’t give me enough gain, so I had to rework the resistor values. I also scrapped the fourth amplifier as it didn’t really do anything for me. In the end what I had was an instrumentation amplifier.

There is one trim potentiometer. It can be used to adjust the amplification, i.e. the sensitivity of the sensor, so that you get a good high reading for when the water level is high, and a good resolution in between.

The PCB layout for the amplifier circuit. The lines and pads are a bit on the small side for manual drilling and soldering, but it's worked out well.

For the second sensor – I have two sump pits – I created a PCB. It’s the first PCB ever that I designed myself and the second ever that I made myself, so it’s not exactly perfect. Most notably I didn’t change the size of anything on the board so all lines and connectors are very small, making it a pain to drill and solder.

Arduino Sketch

Arduino sketch WaterLevelSensorUdp_110912

Simple UDP Server to receive data from the Arduino WaterTank sketch – brelovich.com

The program for the Arduino is pretty simple. I read the value from the analog input A0 and send it out as a broadcast UDP message. This allows me to receive the results on any computer in the house and do whatever I like with the results. So far I’m just monitoring the values.

Of course I couldn’t leave it at that. For one thing, I need a way to calibrate the system and I don’t feel like modifying and uploading a new sketch for that, so I decided to create a serial port command line interface, allowing me to modify and read the trigger levels. I also made sure that the values are stored to the EEPROM and read back from there whenever the program starts, so that I won’t have to redo it whenever I need to reset the Arduino.

Simple Java UDP Server displaying the output from the Arduino. If you keep it running it will remember the highest and lowest levels recorded.

Power Supply

The Arduino and the sensors don’t draw a lot of current so any 5V (or higher) power source will do. I decided to a computer power supply from a disused Pico ITX case. I’m using the standby 5V rail to power the Arduino and sensors. This leaves me an assortment of 3.3V, 5V and 12V rails that I can use for future projects. Computer power supplies are nice as you can run your Arduino from the 5V standby rail and power power it on and off  through software. (Pull one of the digital outputs high, connect the green wire to it and then pull the pin low to turn on the power supply. Pull the pin high again to turn it off.)

Putting it all together

The pressure sensor and amplifier circuit, mounted in a splash-proof box. The two green hoses are for the air pressure (upper) and water pressure (lower)

I used small and really cheap, although water resistant electrical connection boxes for the sensor and the electronics that live in the sump pit. For the Arduino I  got a slightly smaller box to hold it and the power supply. I opted for one with a transparent lid so that I can see the electronics. I also got a case with some extra height to leave room for future shield extensions.

Arduino Ethernet and Pico-PSU mounted side by side on a plexi glass shield, fastened in the connection box.

Future plans

The first thing is to get yet another level sensor, for the second sump pit, wired up and to extend the sketch for that. Then there are all kinds of ideas for further sensors, maybe checking the temperature in and outside of the house and why not monitor the fridge and freezer?

I’m also thinking of connecting it to a mobile phone and enable the system to send me a text message whenever something unusual happens, such as the water rising above a specified level.

For now, however, I’ll be quite happy to get both sensors installed and calibrated and have my web server presenting the results. That should just be a few weeks off.

Questions?

I may very well have missed something here. If you have any questions, please leave a comment and I’ll answer as soon as possible.

Does your behavior match your brand?

It’s a great idea to put your brand on the cars, jackets, t-shirts and caps you use at your company. Free advertising! Excellent!

Except now it’s not just a jerk plastering herself to the back window on my car on the highway, it’s not just any reckless guy changing lanes unexpectedly, almost causing an accident and it’s not just any random person skipping ahead in the line at the mall. It’s your brand. Not so excellent!

When you or your employees start driving and walking around dressed in your brand they aren’t just their own selves anymore. They are your brand. That should be pretty obvious to everyone.

However it seems to have been largely forgotten and right now it could be costing your business money.

Perhaps it’s time to wake up and realize that free advertising is free for a reason. It comes with a big risk. If you want it to be good advertising you need to invest in your behavior. That isn’t free but it may very well be worth it.

Don’t fight the mess! Cope with it.

Everything is a mess. Your inbox is a mess, your home directory is a mess, your
shared drives are a total mess and then there’s people.

Every day is a new fight against the mess. Hopefully you can cope with it, if you’re really lucky you may even feel on top of it but then comes tomorrow and there’s a new mess waiting for you right there.

What if you could get rid of all the mess, permanently, and get everything tucked up in an easy to manage structure? Wouldn’t that be nice? What if you could spend your days being on top of things, instead of coping with the mess?

There are lots of people willing to help you. They come in all shapes. Consultants, hardware vendors, software companies. They all have the perfect solution for you and your mess. If you would just spend 6 months and a few hundred thousand whatever on a mess-reduction project everything will be fine from then on.

The problem is it doesn’t work. In fact you’ll be worse off afterwards, having spent five years, millions of whatever and an enormous amount of prestige on mess reduction, and still unable to get rid of all the mess.

The problem is that your mess, like everything else in the world, is in constant
change. Your mess today is not anything like your mess yesterday and it won’t be anything like that of tomorrow, or next week, or six months.

As soon as you start working on your mess reduction system you start spending more time on managing yesterday’s mess and less time on coping with the mess of the day. The minute you start working on a structure for it all the mess will have started to change into something else and six months down the road, when you’re supposed to be finished, your daily mess will not be anything like what you started with.

The only thing you really can do is to realize that the world is a constant mess and find ways to cope with it. There are tools for that too. They don’t require a six month analysis phase and a multi-million something budget (well, they may cost you if you’re running a big operation.) They do, however, require you to work with them every day, to keep the mess at bay.

Messy, I know, but that’s nature. That’s why most of us have a job.

Change without change

I work in an office. Lots of people do nowadays and so lots of people don’t get any exercise and quite a few of them end up being a bit overweight. Of course, that’s not what you want, so at every office, at any time, some people trying to lose some weight.

These people often try hard. They use more or less elaborate methods and are often prepared to invest a lot of time, money and effort into losing weight.

Congratulations! You managed the hard part, losing some weight. Now comes the even harder part: Maintaining your new, lighter self.

The even harder part is the permanent change that’s required to maintain your new, wanted self. You managed to push through and reach the light at the end of the tunnel, but you’re not done. In fact, you only just started.

If you’re not prepared to exercise more, or change your eating habits permanently, what is the meaning of putting all that effort into losing weight in the first place? Is it really worth it? Is it really that fun that you’ll want to do it again in two years time?

I’m currently on my fourth round of weight loss. Yes, I did it again. I bounced back. Not to the start but far enough and no, I don’t enjoy doing it again. In fact I find it hard to motivate myself but I am at least losing, although at a slow pace.

I love eating. That’s my problem, right there. I also enjoy going for a walk or even running sometimes. But walking to the fridge is still a lot easier than getting out the door.

I know for a fact that I’ll have to make my new habits permanent to succeed. In a couple of months I’ll be able to eat a bit more without gaining but without the permanent change in my daily schedule I’m bound to be doing this again in a couple of years.

To change yourself permanently you have to actually change yourself permanently. You can’t do it as a one-off activity. Then you didn’t really change at all.

That goes for everything. Not just weigh loss. Now, if I could just have one extra sandwich…