<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>remote &#8211; Matthew Petroff</title>
	<atom:link href="https://mpetroff.net/tag/remote/feed/" rel="self" type="application/rss+xml" />
	<link>https://mpetroff.net</link>
	<description>mpetroff.net</description>
	<lastBuildDate>Wed, 17 Aug 2016 18:19:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Decoding a Midea Air Conditioner Remote</title>
		<link>https://mpetroff.net/2015/07/decoding-a-midea-air-conditioner-remote/</link>
					<comments>https://mpetroff.net/2015/07/decoding-a-midea-air-conditioner-remote/#comments</comments>
		
		<dc:creator><![CDATA[Matthew Petroff]]></dc:creator>
		<pubDate>Sun, 26 Jul 2015 21:15:36 +0000</pubDate>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[air conditioner]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[IR]]></category>
		<category><![CDATA[Midea]]></category>
		<category><![CDATA[R09B/BGCE]]></category>
		<category><![CDATA[remote]]></category>
		<guid isPermaLink="false">http://mpetroff.net/?p=1914</guid>

					<description><![CDATA[Last month, I purchased a 6000 BTU Midea window air conditioner (branded Arctic King WWK+06CR5) and thought it would be convenient if I could control it remotely. Doing so would involve decoding the remote&#8217;s IR signals; for this, I used a &#8230; <a href="https://mpetroff.net/2015/07/decoding-a-midea-air-conditioner-remote/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p><span class="dropcap">L</span>ast month, I purchased a 6000 BTU Midea window air conditioner (branded Arctic King WWK+06CR5) and thought it would be convenient if I could control it remotely. Doing so would involve decoding the remote&#8217;s IR signals; for this, I used a <a href="http://dangerousprototypes.com/docs/USB_Infrared_Toy">USB Infrared Toy</a> and the <a href="https://github.com/crleblanc/PyIrToy">PyIrToy</a> Python library. Control signals for other Midea air conditioners have previously <a href="http://veillard.com/embedded/midea.html">been</a> <a href="http://thebloughs.net/design-a-custom-ac-timer/">decoded</a>, providing a starting point. Although the signals transmitted by my air conditioner&#8217;s R09B/BGCE remote are similar to these previous remotes, they are also sufficiently different such that the actual data transmitted shares little in common. The signal is transmitted on a 38 kHz carrier, with a time base, T, of 21 carrier cycles, approximately 1.1 ms. Each bit consists of the IR transmitter off for 1T followed by it turned on for either 1T for <code>0</code> or 3T for <code>1</code>. Each frame consists of a start pulse, six bytes of data, a middle pulse, and then the inverse of the six data bytes. The start pulse consists of the transmitter off for 8T and then on for 8T; the middle pulse consists of the transmitter off for 1T, on for 9.5T, off for 8T, and then on for 8T.</p>
<p><a href="https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote0.jpg" title="R09B/BGCE Remote" data-sbox="1914"><img decoding="async" class="aligncenter wp-image-1923 size-large" title="R09B/BGCE Remote" src="https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote0-640x427.jpg" alt="R09B/BGCE Remote" width="640" height="427" srcset="https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote0-640x427.jpg 640w, https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote0-300x200.jpg 300w, https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote0-1280x853.jpg 1280w, https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote0.jpg 1500w" sizes="(max-width: 640px) 100vw, 640px" /></a><span id="more-1914"></span></p>
<p>With the exception of the commands to toggle the energy saver feature and the front panel lights, all of the commands encode a full system state instead of just a single command, ensuring the remote stays in sync with the air conditioner. This state is encoded in five bytes containing information on the power state, sleep state, system mode, fan speed, set temperature, and the remote temperature sensor reading. The final byte is some sort of checksum, which I have not been able to figure out. The remote is based around a 4-bit microcontroller with 64&thinsp;bytes of RAM, a Sino Wealth SH66P51A, so the checksum calculation must be something simple. <del>Based on its behavior to changing input, it seems to involve <code>XOR</code> operations, but it does not always behave like a simple <code>XOR</code>. As I haven&#8217;t been able to figure out the functional form of the checksum calculation, I can only send commands that I have recorded from the remote. This isn&#8217;t too much of an issue as I recorded all of the possible commands except for those involving the remote temperature sensor feature (and the timer since I didn&#8217;t care about it). Recording all temperature sensor commands would be very difficult as it only transmits once every three minutes and one needs to get the sensor to report all values. I was hoping to emulate the remote&#8217;s temperature sensor using a higher quality sensor, but, alas, I can&#8217;t without the functional form of the checksum.</del> It turns out that the bit order of the data needs to be reversed for the checksum calculation. The checksum can be calculated by reversing the bit order of the five data bytes; adding them, truncating the result to 8 bits, and subtracting the result from 2<sup>8</sup>; and reversing the bit order of the subtracted result. Below is a Python function to do the checksum calculation.</p>
<div class="highlighted-source default python">
<pre><span></span><span class="k">def</span> <span class="nf">calc_checksum</span><span class="p">(</span><span class="nb">bytes</span><span class="p">):</span>
    <span class="c1"># Reverse bits for each bytes</span>
    <span class="n">bit_reversal</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">bytes</span><span class="p">:</span>
        <span class="n">bit_reversal</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">{:08b}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">)[::</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="mi">2</span><span class="p">))</span>
    <span class="c1"># Calculate checksum</span>
    <span class="n">checksum</span> <span class="o">=</span> <span class="mi">2</span><span class="o">**</span><span class="mi">8</span> <span class="o">-</span> <span class="nb">sum</span><span class="p">(</span><span class="n">bit_reversal</span><span class="p">)</span> <span class="o">%</span> <span class="mi">2</span><span class="o">**</span><span class="mi">8</span>
    <span class="c1"># Return bits to original order</span>
    <span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">{:08b}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">checksum</span><span class="p">)[::</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="mi">2</span><span class="p">)</span>
</pre>
</div>
<p><a href="https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote1.jpg" title="Inside of Remote" data-sbox="1914"><img loading="lazy" decoding="async" class="aligncenter wp-image-1922 size-large" title="Inside of Remote" src="https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote1-640x427.jpg" alt="Inside of Remote" width="640" height="427" srcset="https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote1-640x427.jpg 640w, https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote1-300x200.jpg 300w, https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote1-1280x853.jpg 1280w, https://cdn0.mpetroff.net/wp-content/uploads/2015/07/remote1.jpg 1500w" sizes="auto, (max-width: 640px) 100vw, 640px" /></a></p>
<p>Detailed information on the individual data bytes, values recorded from the remote, and Python code for emulating the remote with a USB Infrared Toy is available <a href="https://cdn0.mpetroff.net/wp-content/uploads/2015/07/midea-remote.zip">here</a>. <del>If anyone figures out the checksum calculation, please let me know.</del></p>
<p>Edit 2016-04-23: Tim Chang figured out the checksum calculation and let me know via email. I updated the post to include the checksum calculation.</p>
<p>Edit 2016-08-17: Fixed description of middle pulse.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mpetroff.net/2015/07/decoding-a-midea-air-conditioner-remote/feed/</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Content Delivery Network via Amazon Web Services: CloudFront: cdn0.mpetroff.net
Minified using Disk

Served from: mpetroff.net @ 2026-03-31 01:31:15 by W3 Total Cache
-->