Short answer. No. He cannot cancel out his duty to return your equipment against a money debt you owe him. Article 1287 says compensation is not proper when one of the debts arises from a commodatum — a free loan of a thing. He must return the equipment; any money claim is pursued separately.
What the law says
Compensation shall not be proper when one of the debts arises from a depositum or from the obligations of a depositary or of a bailee in commodatum.
Civil Code, Article 1287 — Debts Excluded From Compensation (Deposit, Support). Read the full provision →
What a free loan of a thing is
Lending equipment for nothing, to be returned in kind, is a commodatum — a gratuitous loan of a specific thing for the borrower's use. The borrower does not become the owner; he holds your property on trust to give it back. That is the crucial feature here. His obligation is not to pay you a sum of money but to return your particular equipment. Because he owes you a thing, not cash, his position is that of a borrower duty-bound to restore what he was lent, whatever separate financial dealings may exist between the two of you.
The law forbids offsetting it
Compensation, or set-off, is the cancelling of two debts against each other so that neither is separately paid. Article 1287 shuts that door for this kind of obligation: compensation shall not be proper when one of the debts arises from a depositum or from the obligations of a depositary or of a bailee in commodatum. Your friend is a bailee in commodatum. So he cannot say the equipment is his to keep because you owe him money; the law refuses to let a duty to return a borrowed thing be swallowed by a money claim. He must hand the equipment back and press his money claim on its own footing.
Why the law draws this line
The rule protects the special trust behind loans and deposits. When you hand your property to someone for safekeeping or for free use, you are relying on his honesty to return it, not lending him value to trade against his own debts. Allowing set-off would let a borrower or depositary convert that trust into a bargaining chip, keeping your property whenever he could point to some claim against you. The same article extends comparable protection to a creditor claiming support given by gratuitous title, reflecting a common thread: certain obligations are too personal or fiduciary to be extinguished by mere accounting.
What this does not erase
The bar on compensation does not wipe out any genuine debt you owe your friend. It changes how it must be collected, not whether it exists. If you truly owe him money from another matter, he keeps his right to demand and, if necessary, sue for that money — separately, and without holding your equipment hostage. The article prevents the shortcut of self-help by offset; it does not decide the merits of his money claim or your defenses to it. Return of the thing and settlement of the money are two distinct questions, each handled on its own.