Hacking Out Of Necessity — Fixing Your Own CPAP Machine

Fixing a CPAP machine

One of our avid readers named [Felix] suffers from sleep apnea, and needs a CPAP machine in order to not suffocate while he sleeps — After a recent power-outage, his machine broke, so he decided to try his hand at fixing it.

A CPAP (Continuous Positive Airway Pressure) machine ensures people suffering from sleep apnea breath throughout the night, by preventing their throats from closing. As a medical device, they tend to be super expensive, which is why [Felix] wanted to try fixing his (at least until he gets a new machine covered by insurance).

Upon opening up the machine, it was easy to see the problem: the circuit board was completely fried. Luckily, the machine is pretty simple. It has a brushless DC motor (12V), and two chambers with air filters, along with an air pressure sensor. Since the motor is brushless, it’s not quite as simple as just hooking it up to a power supply. It had a whopping 8 separate leads.

To figure out which was which he shorted the various leads together. If the motor still spun by hand it meant he was shorting a hall effect sensor cable — if he found the two wires going to the motors coils (which he did) shorting them would cause the motor to resist being spun (known as “plug braking” a motor).

Once he identified the various wires, he grabbed an 15A turnigy motor, an Arduino, and quickly found a sketch online to program it. It doesn’t have pressure control, or ramp up times, but it does the trick and allows [Felix] to sleep again.

45 thoughts on “Hacking Out Of Necessity — Fixing Your Own CPAP Machine

  1. Why does a several thousand dollar medical device NOT come with basic voltage protection circuitry? Poly resettable fuses, AC voltage limiters, a quality AC/DC converter, etc? One would think the FIRST thing the machine should do is filter the inputs being sent to it and the only real input from the mains is going to be expected to be no more than 120/240 volts, depending on the country you are living in.

    1. Because that would improve longevity and life of the device. Big companies want the products to experience more frequent failure rates and a short product life span. This forces the people to continue consuming… if you catch my drift.

    2. You mean we should build things to last, and so ordinary humans can fix them. That is the way Ford built his first cars (one 9/16″ wrench fit almost every nut and bolt on the vehicle) and it was the way Mercedes built theirs a few decades ago (Head lights and Tail lights could be uncovered and removed with your fingers.. they used wing nuts, duhh). But now “planned obsolescence” has taken over society (this was predicted 90 years ago: remember the old SciFi book called Brave NEW World? 1932 by Huxley) It is the Economy, Stupid… Or is it our “Stupid Economy”, designed by geniuses but run by money grubbing idiots.

    1. I find that low a price surprising – are you sure they’re not renting them for $50/month? But still, a reasonably good CPAP costs about $1000 new on cpap.com.

      My CPAP hacking so far has mainly been dealing with the problem that my cat likes to chew on the hoses. They look like snakes, and they’re nice chewy plastic, and if they get left out without covers on them they start to leak like sieves :-)

      But I do have the kind where the data gets recorded on an SD flash card, and there’s software available for download that can read it. The medical equipment companies feel excessively proprietary about their data formats, so you can officially only download it if you’re in the medical business (but conveniently I have “Bill’s Medical Research Company and Bait Shop” right here in my PC.) It was interesting to look at a couple of times, but my CPAP doesn’t have automatic pressure settings, so I can basically only track the AHI, usage times, and leakage rates (see previous discussion of cat tooth holes.)

        1. CPAP tubes usually have two parts – a short hose that’s part of the mask, and a long hose to connect it to the machine. For the long hoses, there are insulated covers available to prevent condensation problems, and I use one of the heavier versions to keep the cat from biting it (I don’t need it for condensation, since I’ve got the heated hose, and the lengths aren’t always a good match, so they slide around a bit, but they’re pretty close.) The shorter hose is more trouble, because there’s less choice for attaching a cover, and velcro’s annoying if it scratches your face, but usually the cat doesn’t try to bite that part when I’m wearing it.

  2. Part of the price in medical equipment goes into being able to sue someone else if you suffer grievous bodily harm. Simple as it is, I don’t think I’d trust not suffocating to hobby grade equipment.

    1. First, nice build. Think the arduno will do nice. I work in a hospital repairing med equip en find atmel chips in all sorts of devices (also lost of pic’s) Only thing i woud build a little more protective case aroud it to protect the electronics. It saves not only repairing time but coud save your life someday.

    2. Keep on rationalizing with the excuses. The reason the units cost $800 to 1,000 and do not last long before failing is simply gouging people and lining their pockets. I don’t know if you realize it but we used to be able to buy a used CPAP at Goodwill or anywhere, now look underneath the CPAP where it states that is a federal crime to sell one without a physician’s prescription. Just follow the money and wise up, that is not to help poor people or people that cannot afford it, it is only to help protect doctors and manufacturers to make more money. Our corrupt politicians were bought off I guarantee you, just follow the money. A blower in an automobile will last 20, 30, 40, 50 years under much more stressful conditions at much higher speeds. You can buy a replacement blower for 40 bucks sometimes 30. Do you think that this plastic CPAP device really should cost $800-$1000 and last three or four years? That’s been my experience with my Respironics. Keep on rationalizing. Perhaps you are in the medical field and are trying to protect your wallet rather than help others in need as most doctors and medical personnel seem to practice today.

  3. I thought you can’t suffocate from a failed CPAP machine? The patient will just wake up every time his throat closes ruining sleep. So I don’t think this hack is really risky.

    1. There is a slight risk in sleep apnea that when you stop breathing, you don’t start back up again. Apart from comfort and sleeping more soundly, this is why using the machine is recomended.

  4. i can add sensors and functions too, should be reasonably easy to add a simple pressure sensor for the airflow to be less when breathing out, some kind of data storage to log and some kind of alarm for prolonged episodes of apnea, but most of the time its the continuous pressure that does the job

      1. Hey zenzed! Could you please message me, I would like to pick your brain about programming equipment like this and if there is an open source community that exists or just a select few people.

        I am a respiratory therapist who works exclusively in non invasive ventilation and I run a DME company. I am about “the cause(lol)” in regards to open source medical equipment. What you described about the solenoid valve and lung volume is exactly what I would like to see programmed – an ASV (auto servo ventilation) or a BiPap s/t.

        Please send me an email at nivtherapist@gmail.com

      2. Seems easiest way would be modifying a scuba regulator. Instead of air coming from tanks, would be coming from CPAP blower, and instead of output being in your mouth, it would go to CPAP mask.
        However, a very important thing to know/remember is:
        1) Lungs under pressure, more readily gives up the CO2. This is why CPAP is prescribed to COPD patients. Only when prescribed to them, it is called “NIV”. (Non Invasive Ventilation) but with apnea, you still get the benefits of lowered CO2.
        2) after a few breaths under pressure, you adjust, and don’t notice the pressure at all. Without pressure during exhalation, you won’t acclimate. Every breath will hit like blowing down your throat.
        3) without your CPAP machine being able to sense exhalation, it’s going to totally screw up its algorithms and self adjusting ability. Will probably make data worthless to your doctor.

  5. I work as a biomedical technician servicing and repairing this sort of equipment, and whenever I see something like this I cringe. As Leithoa stated above, part of it is the ability of you to sue the manufacturer if something goes wrong with the equipment. More than that is just how much design, testing, and certification has to go into equipment like this.

    The manufacturers have to ensure that it will reliably work when you turn it on each time, that it will pass all government testing (both the FDA as well as the rest of the world ) as well as that when you plug it in should something go wrong (such as the fried board stated above) that it doesn’t complete the circuit through the attached patient. Considering that completing the circuit could route the flow of electricity past or through the heart this could be a Very Bad Thing…..

    I know a number of you are going to probably state that all this is a bit extreme with respect to something like a CPAP, but consider what could happen if something were to go wrong. The manufacturer would not only be sued, but the publicity from a product killing the patients that use it would destroy that company, not to mention the cry for more ‘government regulation’ which may (or more likely wouldn’t) be justified from something like this (Anyone want a drone with a video camera? Also please note I said MORE regulation….)

    for those who are going TL;DR, a good part of this cost is in making sure the product keeps the patient alive, not killing them. Of course, the other part IS profit….

    1. i did some research before trying this though, first of all there is no way in hell im gonna get electrocuted by this, since the tube and the mask is plastic, also this is not a respirator its just a machine supposed to give positive pressure, if the machine breaks like it did last time, i wake up instantly, the machine just lets me breathe normally it does not breathe for me so i think most of the issues concerning my health would be coming from the filtering of the air

      also i did specify that i am awaiting a new machine, and this is just a way to sleep a few days.

      for me it’s a risk worth taking

      1. My apologies, I did not intend to imply you did not think this through or do your research. You are also correct that it is extremely unlikely (I can’t say no way in hell as I’ve been in this job for 15 years and seen stranger things…) with these devices to be electrocuted. My comments were intended for those who either complain or don’t understand why these are so expensive.

        I will agree with others your approach is impressive in figuring out how to rebuild and get the unit working again until your replacement arrives, and my negative approach and view comes more from the fact I do work in this industry, and it I did this I would 1) be out of a job and 2) end up in court or jail.

        Of course, I envy you for being able to redesign something like this, your approach could give it a lot more flexibility and options. Unfortunately the approval process for any medical device is almost unbelievable (we still get brand-new monitoring systems where the computers STILL run Windows XP…. Yes the FDA approval process takes that long…)

    2. With the supposed high amount of design and testing that goes into this kind of device, I’m a bit surprised that it would be destroyed due to a simple power fluctuation. It’s not a very rare thing to happen, and not that difficult to protect against in the circuit design.

      Probably the manufacturer considered that a failed CPAP will not kill the patient. In which case, this hack is quite safe. If, on the other hand, a failed CPAP could kill a patient, this would mean already a reason to sue the manufacturer simply because it broke.

  6. Good hack. I’ve poked around inside several of the old CPAP machines that I’ve worn out, and there’s nothing in there of higher quality than any other well-built consumer device. I think the price comes with the expensive words “medical equipment” and the even more expensive words “lawyer” and “malpractice”.

  7. As someone who works at a company that makes this sort of product, I can say that most of the cost comes from engineering time, as well as product assurance. For every hour spent writing code, expect 20 hours of documented testing. Device malfunctions are a huge deal, and we need to prove to the regulatory authorities that due diligence has been given to ensuring that our product (and every subsequent software release) is safe and complies with published specifications, Furthermore, for every device failure that is reported to us, we need to do a full investigation—for every device. There is an entire department here just to handle that shit.

    And with regards to the failure mode seen here: of fucking course it failed after a high-voltage power surge.Without putting a surge protector inside the device, there is no way to prevent this—and no electronic devices do this, because if you want to say your device is protected from power surges, you gotta prove it (through yet more testing). Besides, most surge protectors will be destroyed (or at least damaged to the point of uselessness) when they absorb the energy from an actual power surge. When this happens, you swap them out for a new one. Putting one inside the device doesn’t help at all, since the device has still been destroyed by the surge.

    1. During a visit to my mother in the hospital the staff dropped of a warmer/chiller device, like a heating pad, but connected with tubes so that water could be pumped through from an external box that sits on the floor. I guess peltier cooling.

      Anyway, my mother wanted it, but after a she while complained that it didn’t seem to do much. My Dad is a big reader so he looks at the fine print on the external box where it says how to bleed the system, which is not what the staff did. The pump inside was strong enough to push liquid, as long as there was a siphon path back. Maybe that is to prevent it from pumping its contents out if the tube is cut. Once properly burped, it ran well and was useful.

      He mentioned the startup procedure to the nurse who replied, that that explained why so many patients weren’t as happy as would be expected.

      I guess from that they had never really read the directions.

  8. A surge suppressor is important to have on any expensive equipment, but for something like a CPAP you also need a power out alarm. I don’t know about most CPAP machines, but the one I have at home does not alert me if the power goes out. I would just keep rebreathing my CO2 until I died. Needless to say I bought one and the CPAP is plugged into it.

  9. Awesome job/idea. Though, maybe for only temporary or emergency times for when your real machine stops working as mentioned. Don’t believe I would trust it permanently, but still very cool

  10. If your machine has this weakness, invest in a spike protector. They used to be common among computer users and are now often found as part of that expensive plug strip you have your system plugged into.

  11. My ResMed S10 Autoset has a bad power recept (female). Tried to undo it to fix it. Can’t figure out how to open up machine…. tried unscrewing bottom, but something still keeps plastic cover over the “guts” …. I don’t want to “force it” …. any ideas ???

  12. Guys my CPAP is doing some sort of a weird power reset shutdown. As long as it stays plugged in it works. When someone unplugs it and goes to plug it back up it won’t power up. Has to sit unplugged for hours sometimes before it works again

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.