Close

ESP8266 I2C Problems

A project log for NASA Wind Decoder

This is a small project to decode the LCD Repeater output from a NASA Marine Wind indicator and to upload the data to a NMEA0183 Server

neilneil 08/19/2016 at 12:590 Comments

Having had the initial pyboard system fail due to my naivety with the length of I2C lines I decided to switch to WiFi transfer of data based on Wemos D1 Mini ESP8266 based units. This was partially due to my just receiving a batch of these units that I had ordered to play with without having a project specifically in mind for them. A booster for the I2C wiring to allow for the long transfer lengths would probably have been more straightforward, cheaper and more reliable. But I guess part of the point of hobby electronics is not necessarily to use the most efficient system, but to play and learn and achieve the goals however we can.

Had I realised when I made the decision to go with the ESP8266 units that they had no I2C Slave support then perhaps I would have made a different choice. However, having made the choice to go with the ESP8266 the lack of I2C slave support became a new technical challenge to focus on and overcome.

My challenge was slightly simplified in that the NASA repeater is not a standard compliant I2C Master as it does not require any acknowledgement and just sends its I2C stream at set intervals to provide updates to the connected repeater.

My initial attempts to implement an I2C slave in python failed miserably, I tried both an interrupt based approach and a blocking read approach and found that neither was anywhere near fast enough to capture the I2C data. This forced me down the road of C code and a custom build of the micropython source.

Using the existing bit banging I2C master code as inspiration of the structure of C code and the program logic that I had used in my python attempts I was able to implement a very rudimentary routine which provided sufficient functionality for this project.

Having got this far it is a long term aspiration to develop this code further to provide full I2C Slave functionality and ultimately to pull a full bit banged I2C Driver back to the mainline micropython esp8266 codebase. However, that is a job for another time and another project.

My micropython fork is at https://github.com/coylen/micropython and the I2C slave code is located in the drivers folder with corresponding changes to the makefile and modesp.c to build and expose the commands to the micropython user.

Discussions