Summary: The design of genuinely waterproof containers is an arcane art but is reasonably doable if certain rules are adhered to which codify the underlying "magic".
Failures occur when the basic sealing rule discussed below is violated. I.e. pressure on all sealing surfaces exceeds differential pressure at all times. In many products the failure is inbuilt due to lack of formal design, and is just waiting for conditions where the requisite 'rule' is not met.
The easiest and usually best method is the use of a properly designed O ring.
The typical cause of any failures is that people use squashed rubber rings that look like O-rings but which are not designed and so fail to meet the basic rule in some situations.
Requirement for sealing: To be and to remain waterproof a minimum requirement is that ALL locations along the sealing surfaces must either be bonded with an impervious material or exert a pressure (force per unit area) that is in excess of the pressure difference between inner and outer.
A coating material (e.g. "grease") may be used to help meet this "rule" but the use of a coating material in an undesigned manner is no guarantee of sealing success.
O-rings - the usual easiest and best solution: The most easily designable means of providing a seal is to use an O-ring.
An O-ring typically looks like, and is, a circular rubber ring of round ring cross section. However many circular rubber rings of round ring cross section LOOK like O-rings, but aren't. I.e. to work as an O-ring certain well defined constraints need to be met and it is very likely that if a round rubber ring seal is not formally designed then it will not work in the manner that an O-ring does under all circumstances.
An O-ring uses the pressure differential in such a way that the ring moves and/or distorts in a manner that produces more pressure on the sealing surfaces than the pressure differential does. I.e. the resisting pressure is caused by the target sealing pressure and is designed to always be greater. Designing a seal that works like this from first principles is a formidable task as it depends on a number of dimensions and material properties. Designing one by using standard tables is relatively straight forward.
An analogy: A simple analogy for O-ring operation that is incomplete but useful is to imagine a panicking crowd of people trying to get through a door that must be opened towards the crowd in order to allow people through. Increasing crowd pressure on the door simply makes it harder to open.
O-ring design is most easily achieved by using parameters chosen from standard tables. These include groove width and depth, ring material diameter, ring loop diameter, groove inner diameter, ring wall angle, surface finish, ring and groove material a and a bit more. Simply follow standard 'cookbook' procedures and an O-ring will usually work extremely well indeed.
Maintaining design integrity: The Challenger 'Space Shuttle' was destroyed due to an O-ring failure in an SRB (solid rocket booster) joint. However, the ring was well designed and able to handle the task assigned to it. The failure occurred because the task changed in an uncontrolled manner. Pressure on the overall joint system allowed the mechanical separations between the joint sides to increase and to adopt an angle rather than being parallel. Hot gases were then able to escape past the O-ring, causing it to be progressively destroyed.
Similarly in a DIY case - not only do the O-ring & housing need to be designed to work together but the designed mechanical relationships of the joint parts need to be maintained within specification. If a case can flex under impact or force on the case such that the joint clearances or angles exceed design limits then leakage may occur. I.e. a vital part of the design is ensuring that worst case joint "excursions" are known and not exceeded.
There are two main types of O-ring - radial seal and face or axial seal.
- A radial seal O-ring is more common and easier to design well as sealing forces are generated by the process of sliding the two parts of the join together - any fasteners or screws etc play no part in creating the sealing force - they simply
serve to hold the pieces in correct relative proximity.
- A face or axial seal O-ring system effectively "squashes" a ring between two plates. It has advantages in the sort of surfaces that can easily be sealed BUT relies on fasteners, screws, etc. to pull the two sealing surfaces together in order to provide adequate sealing force. While this is not hard to design it does depend on correct assembly and no failure of the compression system.
Some products employ or seem to employ both types of O-ring in the one joint - two tubular parts are slid together with an O-ring between them and the outer part is screwed down onto a face seal. In designs that do this in cheap consumer equipment it seems likely that the radial O-ring does most of the work.
Real world products:
Low cost ABS housing Asian manufactured consumer products are not usually expected to have an IP66+ design sealing rating. But, it can be achieved.
I was involved with the design of the two main types of portable solar powered lights seen here - roll up from start point for large light examples, down for small light. The larger lights were built first with input from a Chinese designer who was good at making things that looked good but resistant to certain suggestions re: sealing. The sealing worked 'well enough' when assembled correctly but could have been far better. The small light uses a true O-ring front seal and an "almost O-ring" battery box seal (less critical) (and the factory manager managed a design change along the way because he 'knew better'). The all important front seal works superbly. The lights are 100% tested to 5 metre equivalent immersion depth during manufacture and can be relied on to stay dry in any use. (As they float, getting one to 5+ metres deep is usually unattractive to users :-)).
The switches use a magnet operated reed switch and are 100% waterproof and extremely reliable in operation (by design).
I can and will add table references, design links and photos to this answer if it looks like people find it useful. If it receives little interest it's not worth the time (and I must do other things at this stage).