So I have and arduino uno that is firing an output on pin 8. This code is not in this file just to be clear. From there Im taking that output and using it to fire pin 0 on the wifi module. Im using pin 0 because from what I understand all other pins have a pullup or pulldown resistor. When pin 0 is hot I want to print that value. Sometimes it works when I do it other times the analog values reads very low. I am using the 3.3v from the arduino uno and I plan to get a voltage regulator for the wifi module but would this cause this kind of issue? I am very very new to arduino so if anyone has any ideas I would appreciate a very dumbed down explanation. Thanks a lot. Also the reason why I have the delay turned down so low is because it seemed to make the analog signal pick up more often. Im not sure why this would matter but at a delay of 3000 it would almost never change analog value but when I turned the delay down to one the value came through much more consistently. Currently the code just outputs low analog numbers and occasionally pops up 1023 when voltage is applied but not consistently. And sometimes it just stops altogether until I keep trying for a while. I am getting voltage to the pin however so I know I have a complete circuit and power.


#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

const char* ssid = "ENDOWED Underwear";
const char* password = "endowwear";

HTTPClient http;

static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t D9   = 3;
static const uint8_t D10  = 1;

int featherPin = D3;

void setup() {
  pinMode(featherPin, INPUT);

  WiFi.begin(ssid, password);

  while(WiFi.status() != WL_CONNECTED) {
    Serial.println("Waiting for connection");

void loop() {
  int sensorValue = analogRead(featherPin);

  if (WiFi.status() == WL_CONNECTED) {
        Serial.println("yay connect");

        http.addHeader("Content-Type", "text/plain");

        int httpCode = http.POST("Message from ESP8266");
        String payload = http.getString();
//        Serial.println(payload);

    } else {
        Serial.println("Error in Wifi connection"); 

    if (sensorValue > 850) {

      http.addHeader("Content-Type", "text/plain");

      int httpCode = http.POST("Message from ESP8266");
      String payload = http.getString();
      } else if (sensorValue < 850) {
//        Serial.println("I am not hot");

//  digitalWrite(trigPin, LOW);
//  delayMicroseconds(1);
//  digitalWrite(trigPin, HIGH);
//  delayMicroseconds(2);
//  digitalWrite(trigPin, LOW);
//  pinMode(echoPin, INPUT);
//  duration = pulseIn(echoPin, HIGH);
//  inches = (duration / 2) / 74;
//  Serial.println(inches);
//  spaceIntruded = inches;
//  if (spaceIntruded <= 50 || spaceIntruded >= 900){
//      digitalWrite(ledPin, HIGH);
//      digitalWrite(hornPin, HIGH); 
//      Serial.println("Intruder Detected!");
//      Serial.println("Sending text Notification...");
//      delay(500);
//      Serial.println("Armed...");
//  }
//  else{
//    digitalWrite(hornPin, LOW);
//    digitalWrite(ledPin, LOW);
//  }

  • When pin 0 is hot I want to print that value...? What value? What do you mean by "hot"? – Majenko Jan 5 '19 at 22:27
  • When pin 0 on the Arduino uno is hot meaning it has 3.3v applied to it I want to analogRead the change in value. If no voltage is applied it should read as a lot number and when voltage is applied it should read as a high number and sometimes it does but it in no way consistent. Im not sure if its because Im taking the 3.3v from the arduino uno but i also tried taking it from the 5v on the arduino uno and steeping it down with a voltage regulator and Im getting the same issue. However it was adjustable voltage regulator. Im going to get one that is specifically for 3.3v. – user52703 Jan 5 '19 at 22:39
  • Do you have the pin connected to the analog input pin as well as pin 0? You do know that the ESP8266 has only one analog input, and that is a special pin and not one of the normal Dx pins, yes? – Majenko Jan 5 '19 at 22:43
  • 1
    The pin labelled ADC is the only one that can be used with analogRead. And unless that board includes a divider it can't read more than 1V. – Majenko Jan 5 '19 at 23:05
  • 1
    The ADC pin can only be used with analogRead(). No other pin can, and nothing else can be done with the ADC pin. It is directly connected to the ADC internal to the chip and nothing else. You can't use digitalRead(), digitalWrite(), pinMode() or analogWrite(). It doesn't even have a pin number to use with those functions. – Majenko Jan 6 '19 at 11:13

Analog to Digital conversion is one aspect1 where the ESP8266 is very poor. It has a single ADC pin which can read a maximum of 1V.

That pin is the only pin you can use with analogRead(). Any attempts to use any other pin just use that pin instead. The parameter (pin number) to analogRead(pin) is ignored and no matter what you do that one single ADC pin is what is being read. Also the pin cannot be used for anything else. None of the digital functions can be used with it since the pin doesn't have a GPIO number associated with it.

Some boards include a simple voltage divider on the ADC pin to allow higher voltages to be read, such as the NodeMCU:

enter image description here

If your board doesn't have such a divider you will have to implement it (or something similar) to be able to read the 3.3V incoming voltage.

1 The ESP8266 is great for WiFi but pretty poor for everything else. It is seriously starved of internal peripherals (it doesn't even have I²C). For a more feature-rich solution you might consider upgrading to the ESP32.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.