ESP8266 ADC not working?

Hi all,

IoTaWatt is a great project, thanks for creating it Bob!

tldr: analogRead(A0) on IoTaWatt board only returns 10 or 12, even when tied to GND. Same code on a ESP8266 I pulled out of a drawer works fine.

I’m working on a new web stack and simplifying the hardware connections but find the A0 pin on the ESP-12S board doesn’t seem to be working. The .brd shows it’s not connected to anything, optical inspection of the board also confirms that, and sanding the board edge confirms there are only two copper layers (matching the .brd).

I’m using the A0 (ADC) pin on a separate ESP8266 prototype to test not having the need for a 9VAC ref and instead using a clamper and a bare wire couple to the 60Hz (single-phase in my US home) to get the phase reference, and will later compare the data with and without the voltage reference to confirm it’s an acceptable rate. I’ve tested the identical code and compiled via platformio with same .ini in both cases and my random ESP works well and couples to the 60Hz well.

Ultimately I’ll probably keep the 9VAC and instead drop the USB line instead and simply power the board from the 9VAC ref but curious why the current test and ADC isn’t working on the board. Any thoughts?

Thanks!

Code

#define ANALOG_PIN A0
#define MAX_VALS 1000

typedef uint32_t uint;
typedef unsigned long ulong;

ulong mtime;
uint vals[MAX_VALS];
//ADC_MODE(ADC_TOUT);

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  mtime = millis();

  for (uint i = 0; i < MAX_VALS; i++)
    vals[i] = analogRead(ANALOG_PIN);
  mtime = millis() - mtime;

  for (uint i = 0; i < MAX_VALS; i++)
  {
    // <= to print a least one 'x'
    for (uint j = 0; j <= vals[i]; j++)
      Serial.print("x");
    Serial.print(" ");
    Serial.println(vals[i]);
  }
  Serial.println(mtime);
  Serial.println("");

  delay(1000);
}

platformio.ini

[env:esp12e]
platform = espressif8266
board = esp12e
framework = arduino

Screen Shot 2021-10-17 at 3.26.37 PM