Close

Production update, and testers!

A project log for wESP32: Wired ESP32 with Ethernet and PoE

A low cost ESP32 core board with Ethernet and PoE for convenient "single cable" deployments

patrick-van-oosterwijckPatrick Van Oosterwijck 12/30/2018 at 06:390 Comments

Last week it dawned on me that time keeps passing and I hadn't given much thought yet to how I was going to test the wESP32 and wESP32-Prog boards before we ship them!  A very important issue to start cranking on, especially with holidays and vacation eating up a good amount of time.

wESP32-Prog tester

The wESP32-Prog board is quite simple and because of this, the tester can be simple as well.  Building the tester only took half a day and this is what I ended up with:

The hardware consists of a little STM8S103F3 board that can be had for less than a dollar on AliExpress.  I had it laying around and all I needed for this was a simple UART capable chip, so this was perfect.  I used the Sduino project project to speed up firmware development.   It looks slightly different from normal Arduino code because the SDCC compiler doesn't support C++, only C.  It was simple enough to get it to work though, resulting in this code:

// wESP32-Prog tester using STM8S103 board and sDuino

#define IO0   PA1
#define EN    PA2

void setup() {
  // Initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, 1);
  // Initialize EN and IO0 test pins as input with pullup
  pinMode(IO0, INPUT_PULLUP);
  pinMode(EN, INPUT_PULLUP);
    // Init serial port to 115200 bps
  Serial_begin(115200);
}

void loop() {
  // Read a byte from serial port
  int c = Serial_read();
  // Did we get a byte?
  if (c >= 0) {
    // Set lowest bit to value of IO0
    c = (c & 0xFE) | (digitalRead(IO0) ? 0x01 : 0);
    // Set second lowest bit to value of EN
    c = (c & 0xFD) | (digitalRead(EN) ? 0x02 : 0);
    // Echo byte back with altered IO0 and EN bits
    Serial_write(c);
    // Set the green LED state according to the second highest bit
    digitalWrite(LED_BUILTIN, (c & 0x40) ? 0 : 1);
  }
}

 All this does is when a byte comes in, echo it back with the bottom two bits replaced by the current state of the IO0 and EN signals.  The second to highest bit also sets the tester board's on-board LED state.

This firmware works in conjunction with a little Python script on my Linux box:

#!/usr/bin/env python3

import os
import glob
import serial
import time
from termcolor import colored

while True:

  print("Waiting for wESP32-Prog...")
    ports = []
  while not ports:
    ports = glob.glob('/dev/ttyUSB*')
    time.sleep(0.1)

  print("Serial port detected, waiting for access...")
    while (not os.access(ports[0], os.R_OK|os.W_OK)):
    time.sleep(0.1)
    print("Testing wESP32-Prog...")
    test_ok = True
  s = serial.Serial(port=ports[0], baudrate=115200, timeout=0.1)

  s.setRTS(False)
  s.setDTR(False)
  s.write(b'0')
  res = s.read(1)
  if (res not in [b'0', b'1', b'2', b'3']):
    print(colored("ERROR: Serial data did not echo correctly, is the tester connected?", 'red'))
    test_ok = False
  if (res != b'3'):
    print(colored("ERROR: IO0 and/or EN pulled low when neither is asserted!", 'red'))
    test_ok = False

  s.setRTS(True)
  s.write(b'0')
  if (s.read(1) != b'1'):
    print(colored("ERROR: EN not pulled low correctly!", 'red'))
    test_ok = False

  s.setDTR(True)
  s.write(b'0')
  if (s.read(1) != b'3'):
    print(colored("ERROR: IO0 and/or EN pulled low when both are asserted!", 'red'))
    test_ok = False

  s.setRTS(False)
  s.write(b'0')
  if (s.read(1) != b'2'):
    print(colored("ERROR: IO0 not pulled low correctly!", 'red'))
    test_ok = False

  if (test_ok):
    print(colored("OK! All tests passed.", 'green'))
    s.write(b'@')

  s.close()
  print("Please unplug wESP32-Prog.")
    while ports:
    ports = glob.glob('/dev/ttyUSB*')
    time.sleep(0.1)

 What this does is wait for the wESP32-Prog board to be plugged in, which will create a /dev/ttyUSB0 device.  For some reason, trying to immediately open the serial device after this threw an access error, so we wait until it becomes accessible and then open it.

Testing ensures that when we send a byte, the STM8 micro echoes a (modified) byte back to us.  We do this with various states of the RTS and DTR signals which control EN and IO0 respectively through the auto programming circuit.  If everything comes back as expected, we print a success message, turn on the green LED on the STM8 board and wait for the board to be unplugged.

wESP32 tester

The wESP32 is more complex, so the tester has to be as well.  We have a bed of nails that connects to the GPIO header and the programming port.  The fixture has a wESP32-Prog module on board that connects to the wESP32 for programming and to run the testing sequence over the serial connection.

Software still needs to be written, but here's the gist.  The test starts by plugging a PoE powered Ethernet cable in to the RJ45 and pushing the wESP32 onto the pogo pins.  First a MicroPython image will be flashed to the ESP32 and a factory boot.py and test script will be loaded.  The boot.py enables and configures the Ethernet port correctly for the wESP32 to establish a network connection.  This script will remain on the units when they are shipped, so you will have a MicroPython install with working network connection straight out of the box!  The test script will exercise the GPIO pins and measure the V+ voltage while a load of about 12 W is applied.  Most of the GPIO pins will be connected together in physically spread out pairs of which one pin will be an output and the other an input.  These will be driven alternately high and low to ensure connectivity from the module pads to the header footprint with no shorts.

When all these tests running on the ESP32 turn out successful, the test script will notify the PC over the serial port that the unit is OK, after which the test script will be erased and the unit is ready to go.

Production progress

We received wESP32-Prog production units from both Colorado Tech Shop and Boktech!  I am pleased with how fast Boktech turned around this order.  What I am not pleased with is the way the product looks:

The unit on the left is one produced by Boktech.  The one on the right is a production unit from Colorado Tech Shop.  The Colorado Tech Shop unit looks beautiful, the unit from Boktech not so much.  All units from Boktech have ugly brown silk screen like that, while it should be yellow.  Before they started production, they sent me a picture of a unit for first article inspection, and that unit looked very good with nice yellow silk screen, so I approved it.  Unfortunately, production didn't turn out the same.  When I asked about it, they said the first article unit was handmade, not done in the normal production process!  I think they are kind of missing the point of what a first article inspection is for... :-/  Unfortunately, in my discussion with them it has become clear they don't think anything is wrong with either the color change or producing an invalid first article, so I think I'll be looking to try a different Chinese CM.

We also receive a first article wESP32 from Colorado Tech Shop:

They turned out looking really good!  I inspected the boards and quickly added the remaining components to one of the units for testing:

Initial tests are all positive: I can program the ESP32, the 12 V, 5 V and 3.3 V outputs are accurate, and after programming, the ESP32 connects to the network over Ethernet.  I am now running a long term test of the unit under high load (13 W), which has been going for about 5 hours now.  Performance of the production units seems to be equal to the prototypes.

Very happy with the progress!

Discussions