Saturday, January 24, 2015

ESP8266 based Serial to UDP Bridge

I finally got around to building a very simple Serial to UDP bridge based on the ESP8266 board.  I tracked down the reboot issues to the fact that the LWIP stack needs to be fully initialized before wifi connection can be made.  There is a system_init_done_cb() method that allows a callback function to be registered, and putting the wifi connection and network initialization code in there fixed the reboot problem.  This is a problem that could've been solved with halfway decent documentation...  but I also appreciate the fact that I can put something together based on a board that cost $3 including shipping!

The code simply connects to the Wifi station specified in user_config.h file and sends anything received on the UART to the server specified in fixed UDP packets.  It's a completely one way data flow that suits the Battery Monitor use case just fine!  The UDP path isn't as well documented as the TCP one, but it wasn't too difficult to get it up and running once I was able to get out of the reboot loops.  What I think is more valuable, though, is just getting through the initialization and connection steps to get to a reasonable starting point for future projects.

On the ESP8266 Developer environment setup as logged before, it should just require some simple changes to the Makefile to point to the new locations for the compiler toolchain and the SDK.  I can simply run "make" afterwards to get it all built and use the "flash.sh" script to flash it onto the device (remember to ground GPIO0 pin for programming mode!)

Next weekend, I'm hoping to carve out a little time to try to get it all wired into the house - hopefully I won't run into any other issues and will finally be able to start collecting some data!  I'm also toying with the idea of trying to get Lua running on the ESP8266 boards... but we'll see if I can find a block of time to work on this...




No comments:

Post a Comment