esp8266 XBee carrier board PCB design

esp8266_xbee1

esp8266_xbee2

I’ve been putting together a small carrier board to allow a esp8266 board to sit on an XBee connector. The design is shown above (as yet untested). The gerbers and Kicad design files are available for download below.

XBee_esp8266 Gerbers

Kicad files (and gerbers)

UPDATE: The first rev of these boards came though, I’ll be needing to update the design. The esp1 faces in the opposite direction to what I’d like. The serial TX and RX connections are connected the wrong way to the FTDI header (which doesn’t matter too much as it’s just there for debugging). The fit into the XBee header also seems poor, I’m not sure if this is just because I’ve killed the header I’m using by jamming 2.54mm pins into it. Here the a couple of pics in any case:

photo 1

photo 2(1)

UPDATE: Sent out a rev with the header flipped. Wanted to get it out before I go away to China. Here are the pics:

xbee_r2

xbee_r2_2

And the new gerbers: gerbers

UPDATE2: The new boards came back, and I’ve now tested them all looks good! Pics below:

image

image(1)

This is a continuation of my notes on the esp8266 microcontroller, you can find a complete list of my esp8266 posts here

esp8266 GPIO input configuration

The following code, when used in user_init() will enable the internal pullup on GPIO0 and read it’s value. Unfortunately GPIO0 (and GPIO2) when held low at boot put the device into a non-running mode (firmware update), I’ve also been unsuccessful in using the internal pulldowns on these pins. This means these pins can not be used for user mode selection at boot, using the internal pullup/down resistors. And unfortunately, those are the only GPIOs available on the simplest modules. It maybe possible if an external pulldown is installed.

gpio_init();
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
PIN_PULLUP_EN(PERIPHS_IO_MUX_GPIO0_U);
os_delay_us(10000);
int config = GPIO_INPUT_GET(0);//GPIO_ID_PIN(PERIPHS_IO_MUX_GPIO0_U));
char buffer[30];
os_sprintf(buffer,"config: %d",config);

This is a continuation of my notes on the esp8266 microcontroller, you can find a complete list of my esp8266 posts here

esp8266 serial (UART0) tx/rx

The esp8266 SDK manual and examples are pretty poor. There an example uart.c knocking around, but the receive code is incomplete. I built this out a bit so I could read serial data from the circular buffer. You can download my update files here: uart.c,
uart.h
, uart_register.h. Only uart.c has been changed significantly. (update, I’ve put a tarball which a complete echo example here. UART data can then be received as follows:

  int c = uart0_rx_one_char();

  if(c != -1) {
    char out[30];
    os_sprintf(out,"received %c",c);
    debug(out);
  }

Or if you just want to echo received characters:

  int c = uart0_rx_one_char();

  if(c != -1) {
   uart_tx_one_char(c);
  }

I’ve only built out reading a single character, but it should be easy to build more general functions on top of that. You can still use the old function to transmit:

uart0_tx_buffer(data,strlen(data));

As always you need to init the UART in user_init with something like:

uart_init(BIT_RATE_9600,BIT_RATE_9600);

Or the UART will be configured with 74KBPS (which is a pretty odd value).

Update: You may also want to take a look at my notes on messaging system in the esp8266 SDK, and how it can potentially be used for this application.

This is a continuation of my notes on the esp8266 microcontroller, you can find a complete list of my esp8266 posts here

esp8266 wifi doesn’t connect

*SEE UPDATE BELOW*

I spent quite some time debugging an issue where the wifi wouldn’t connect in station mode on the esp8266 today. wifi_station_get_connect_status() would return either 1 or 3 (which means CONNECTING or AP_NOT_FOUND). The issue /appears/ to be that wifi_station_set_config does not work reliably when called outside user_init (even if called from a function called from user_init. I.e.

void ICACHE_FLASH_ATTR wifi_config() {
    // Wifi configuration
    char ssid[32] = SSID;
    char password[64] = SSID_PASSWORD;
    struct station_config stationConf;

    //Set station mode
    wifi_set_opmode( 0x1 );

    //Set ap settings
    os_memcpy(&stationConf.ssid, ssid, 32);
    os_memcpy(&stationConf.password, password, 64);
    wifi_station_set_config(&stationConf);
    //wifi_station_connect(); // should not be required
    debug("init wifi");
    debug(SSID);
    debug(SSID_PASSWORD);
}

//Init function
void ICACHE_FLASH_ATTR user_init() {

    // Set UART Speed (default appears to be rather odd 77KBPS)
    uart_init(BIT_RATE_9600,BIT_RATE_9600);

    wifi_config();

    //Start os task
    system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
    system_os_post(user_procTaskPrio, 0, 0 );

    network_init();
}

Does NOT work consistantly. Whereas:

//Init function
void ICACHE_FLASH_ATTR user_init() {

    // Set UART Speed (default appears to be rather odd 77KBPS)
    uart_init(BIT_RATE_9600,BIT_RATE_9600);

    //wifi_config();
    // Wifi configuration
    char ssid[32] = SSID;
    char password[64] = SSID_PASSWORD;
    struct station_config stationConf;

    //Set station mode
    wifi_set_opmode( 0x1 );

    //Set ap settings
    os_memcpy(&stationConf.ssid, ssid, 32);
    os_memcpy(&stationConf.password, password, 64);
    wifi_station_set_config(&stationConf);
    //wifi_station_connect(); // should not be required
    debug("init wifi");
    debug(SSID);
    debug(SSID_PASSWORD);

    //Start os task
    system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
    system_os_post(user_procTaskPrio, 0, 0 );

    network_init();
}

Works as expected. The reason that wifi_config() above may sometimes work is that I would guess it occasionally gets inlined. I’ve no idea why the calls need to be in user_init directly though, there’s perhaps some funky stack related stuff going on.

UPDATE

Wow, Espressif saw my post and emailed me out of the blue. There suggestion was that stationConf.bssid_set should also be set to 0 in this case. Otherwise it will also check the AP mac address i.e it should be:

void wifi_config()
{
// Wifi configuration
char ssid[32] = SSID;
char password[64] = PASSWORD;
struct station_config stationConf;

//Set station mode
wifi_set_opmode( 0x1 );

stationConf.bssid_set = 0;

//Set ap settings
os_memcpy(&stationConf.ssid, ssid, 32);
os_memcpy(&stationConf.password, password, 64);
wifi_station_set_config(&stationConf);

}

//Init function
void user_init()
{
wifi_config();
}

This also makes sense to me in terms of random fiddling fixed this issue, I guess in some cases the uninitialized memory is 0 by chance.