IR receiver/transmitter for ESP8266?

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
pythoncoder
Posts: 1381
Joined: Fri Jul 18, 2014 8:01 am

Re: IR receiver/transmitter for ESP8266?

Postby pythoncoder » Wed Mar 15, 2017 1:34 pm

@mmh As I suspected there is a hardware issue. The decoder chip sometimes emits a 200µs pulse with no obvious cause. The signal and power look clean on my scope. This pulse happens much more frequently with the ESP8266 than with the Pyboard. The test program art.py now produces an 'Invalid start pulse' message when this occurs.

I've done an update on aremote.py. It is now cross-platform, running on ESP8266 and Pyboard. Rather than opaque integers it produces data and address values as args to the callback, which also supports user arguments. Bugs fixed and legacy cruft removed. Validation now implemented, with support for 16-bit extended address mode.

aremote.py and the two test programs art.py and art1.py. are here https://github.com/peterhinch/micropython-async.

This code has the following issues when run on ESP8266 with my hardware:
  • Occasional 'Invalid start pulse' events in response to the 200µs pulses from the decoder.
  • Occasional error events when an IR code is sent.

Note that the measured maximum interrupt latency of 643µs at 160MHz exceeds the pulse width of 562.5µs. This results in missed edges and consequent bad blocks. Evidently an interrupt driven solution on the ESP8266 is pushing things a bit: the chip is redolent of a leisured era when the Red Flag Act was in force...

The test program art1.py controls an on-board LED from the remote. Running this has led me to conclude that the ESP8266 port is usable provided the user gets feedback that the button has been recognised. Such errors can always occur (remote nearly out of range, low on battery or pointed in the wrong direction). But on the ESP8266 they are, alas, a `feature`. I'd be interested to hear your results/views.

[Heavily edited]
Peter Hinch

mmh
Posts: 13
Joined: Fri Jan 20, 2017 3:35 pm

Re: IR receiver/transmitter for ESP8266?

Postby mmh » Mon Mar 20, 2017 12:04 am

I'm still unsuccessful getting your codes to work on my setup seems like I'm missing some of the async capabilities and haven't been able to circle back here yet. So this is still work in progress and at this time I have nothing to report other than the import uasyncio doesn;'t go well for me. I went searching for it and came up with an empty file. I struggled for a couple of hours and haven't been able to return, I really want to compare your async stuff which looks amazing.

User avatar
pythoncoder
Posts: 1381
Joined: Fri Jul 18, 2014 8:01 am

Re: IR receiver/transmitter for ESP8266?

Postby pythoncoder » Mon Mar 20, 2017 1:16 pm

[EDIT]Reflecting a recent firmware fix.

I'm assuming your problem is that

Code: Select all

import uasyncio
is failing.

Get the most recent version of the source.

Unfortunately the asyncio library is large and needs to be installed as frozen bytecode. This is further complicated by the fact that the ESP8266 firmware is arranged to run, and provide a VFAT filesystem, on devices with only 1MB of flash. This leaves insufficient space so you need to make more space for firmware at the expense of a little VFAT space. Assuming you have more than 1MB you need to do the following.

Implement the changes I describe in my last message here https://github.com/micropython/micropython/issues/2700. This makes room for the frozen files.

Using the Unix build install the uasyncio library using upip (https://github.com/micropython/micropython-lib). Verify that in the Unix build you can issue

Code: Select all

import uasyncio


Go to ~/.micropython/lib and recursively copy the contents to esp8266/modules
Build and deploy. You should now be able to import uasyncio.

It is a bit technical; it's absurdly easy on the Pyboard (no need for frozen bytecode), but that's the resource constrained ESP8266 for you ;)
Peter Hinch


Return to “Drivers for External Components”

Who is online

Users browsing this forum: No registered users and 1 guest