Using &quot;Sting&quot; confessions
<p>In USA, if I am not mistaken, if the police fail to warn someone that &quot;anything you say may be used against you,&quot; then whatever he says to them is inadmissible.</p>
<p>I don't understand then why a confession gotten by the subterfuge of someone else with a hidden recorder is admissible.</p>

<h2>Because a &quot;sting&quot; does not trigger the prerequisites for the warning</h2>
<p>The <a href="https://en.wikipedia.org/wiki/Miranda_warning#Circumstances_triggering_the_Miranda_requisites" rel="noreferrer">Miranda Warning</a> has triggering events:</p>
<blockquote>
<p>The circumstances triggering the Miranda safeguards, i.e. Miranda warnings, are &quot;custody&quot; and &quot;interrogation&quot;. Custody means formal arrest or the deprivation of freedom to an extent associated with formal arrest. Interrogation means explicit questioning or actions that are reasonably likely to elicit an incriminating response.</p>
</blockquote>
<blockquote>
<p>The Constitution does not require that a defendant be advised of the Miranda rights as part of the arrest procedure, or once an officer has probable cause to arrest, or if the defendant has become a suspect of the focus of an investigation.</p>
</blockquote>
<p>If you voluntarily speak to a police officer (uniformed or undercover, identified as such or not) while not being both in custody and subject to interrogation, that speech can be used in evidence.</p>

<h2>Only Admissions while in Detention Trigger <em>Miranda</em></h2>
<p>The answer by Dale M is correct, the <em>Miranda</em> warnings are required only when officers have arrested or are detaining a person, and question that person. In that case, and only in that case, nothing that the person says is admissible unless the person has been informed of the right not to make statements, the right to consult with a lawyer, and the right to have a lawyer appointed if unable to afford one, and after being so informed agrees to make statements or answer questions.</p>
<h2>History Behind <em>Miranda</em></h2>
<p>There is history behind the <em>Miranda</em> rule, more fully <a href="https://en.wikipedia.org/wiki/Miranda_v._Arizona" rel="noreferrer"><em>Miranda v. Arizona</em>, 384 U.S. 436 (1966)</a></p>
<p>In the decades prior to the <em>Miranda</em>  decision, there had been a series of US court cases over confessions and admissions by accused criminals. In <a href="https://en.wikipedia.org/wiki/Brown_v._Mississippi" rel="noreferrer"><em>Brown v. Mississippi</em>, 297 U.S. 278 (1936)</a> The US Supreme Court rules that confessions extracted by police violence were not admissible in criminal proceedings. (In that case a Deputy and others beat the accused men with leather straps until they confessed, and continued to do so until the confessions were adjusted to the dictation of the Deputy.)</p>
<p>In <a href="https://en.wikipedia.org/wiki/Chambers_v._Florida" rel="noreferrer"><em>Chambers v. Florida</em>, 309 U.S. 227 (1940)</a> the Court held that extensive police pressure, including the accused having been held in isolation for over a week with repeated questioning, resulted in confessions that were not voluntary and thus not admissible.</p>
<p>In a series of subsequent cases from 1940 to the 1960s, US courts continued to deal with when confessions were &quot;voluntary&quot; and could be admitted into criminal trials. Various police tactics were held to be coercive and thus taint confessions.</p>
<p>The <em>Miranda</em> case was the endpoint of this series, in which the court held that detention by the police was an inherently coercive  situation, and a confession could only be accepted if the accused was made aware of the rights to silence and to a lawyer. Since it is police detention that raises this coercive  situation, it is only admissions during detention that require the warnings.</p>

united-states miranda-warning