0

I have an esp8266 and I cannot get the value to read HIGH when 3.3v is applied to directly to pin by hand. I have an Arduino Uno powering the esp8266. It connects to the WiFi like it should, and now all I want is to manually see that when I apply 3v that the state will change from 0 to 1. Does anyone know how I can do this.

When I apply 3 volts directly to pin 15 it outputs 0. Even if I try digitalWrite on the pin and set it to HIGH it still says 0 and i serialPrint. My end goal if to use the arduino uno to fire and ouput on pin 8. On the arduino UNO side I am using a super sonic sensor. When the sensor is triggered I want to turn pin 8 on. From there I want to take pin 8 to feed pin 15 on the 8266 as an input. Before I did that I just wanted to see that when you manually apply 3v that the pin would read 1 or HIGH but no matter I do it wont change value. Once I get that value as HIGH I can send a second request to the server like im already but now I want to say that there was an intruder. Im not sure why the value wont change but being a beginner with arduino Im trying to keep it simple and ideally would like to wire it in this manner.

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

const char* ssid = "********";
const char* password = "********";

HTTPClient http;

static const uint8_t D8 = 15;
int featherPin = D8;

//int trigPin = 13;
//int echoPin = 12;
//int ledPin = 10;
//int hornPin = 11;
//
//int spaceIntruded;
//
//long duration, cm, inches;

void setup() {
  Serial.begin(115200);
  pinMode(featherPin,INPUT);

  WiFi.begin(ssid, password);

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

//  Serial.begin (9600);
//  pinMode(trigPin, OUTPUT);
//  pinMode(echoPin, INPUT);
//  pinMode(ledPin, OUTPUT);
//  pinMode(hornPin, OUTPUT);
//  delay(5000);
//  Serial.println("Armed...");

}

void loop() {

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

    http.begin("http://10.150.40.121:3000/");
    http.addHeader("Content-Type", "text/plain");

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

    } else {
      Serial.println("Error in Wifi connection"); 
    }
//    digitalWrite(featherPin, HIGH);
    int sensorValue = digitalRead(featherPin);
    Serial.print(sensorValue);


//    if (digitalRead(featherPin) == HIGH) {
//      http.begin("http://10.150.40.121:3000/home");
//      http.addHeader("Content-Type", "text/plain");
//    
//      int httpCode = http.POST("Message from ESP8266");
//      String payload = http.getString();
//      Serial.println(payload);
//      Serial.print("hi");
//      http.end();
//      } else {
//        Serial.print(featherPin);
//        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);
//  }
    delay(30000);

}
6
  • do you see how part of your code is properly formatted on gray background? .... that is because the text is indented by at least 4 spaces ....... please format the rest of the code ..... select all the code and click the {} icon
    – jsotola
    Commented Jan 5, 2019 at 3:51
  • 1
    when I apply 3v that the state will change from 0 to 1 what are you applying 3v to? which pin? for how long? because you have a delay of 30 seconds in each loop - so you're only checking every 30 seconds Commented Jan 5, 2019 at 5:06
  • p.s. - I didn't think the esp8266 liked such long delays Commented Jan 5, 2019 at 5:06
  • also, what output are you currently getting with your code? Commented Jan 5, 2019 at 5:07
  • Right now when I apply 3 volts directly to pin 15 it outputs 0. Even if I try digitalWrite on the pin and set it to HIGH it still says 0 and i serialPrint. My end goal if to use the arduino uno to fire and ouput on pin 8. On the arduino UNO side I am using a super sonic sensor. When the sensor is triggered I want to turn pin 8 on. From there I want to take pin 8 to feed pin 15 on the 8266 as an input. Before I did that I just wanted to see that when you manually apply 3v that the pin would read 1 or HIGH but no matter I do it wont change value. Once I get that value as HIGH I can send a...
    – user52703
    Commented Jan 5, 2019 at 5:16

1 Answer 1

1

Pin 15 is one of the boot configuration pins (0, 2, 15) and must be LOW at boot. To ensure it, dev boards with esp8266 have external pull-down on pin 15 (and pull-up on 0 and 2). To read the pin HIGH you must overcome the pull-down.

Adafruit Feather HUZZAH has 4.7kOhm resistor for the pull-down, so it is a 'strong' pull down. NodeMcu has 12kOhm resistor on io 15.

From schematics of Adafruit Feather HUZZAH

enter image description here

Note: setting pin as OUTPUT and HIGH doesn't make it read HIGH in code. Only INPUT pin state can be read with digitalRead (only on some MCUs digitalRead reads the same register set by digitalWrite).

13
  • This is unclear to me. What do you mean by overcome the pulldown? Could your break it down a little further or send me in a direction to find a resource that can clarify this. I having a hard time visualizing what you mean fully. Thanks again for taking the time to reply. I am also setting the input on line 36 as an input. I tried making forcing it HIGH to try a different idea but I know Im not fully versed with what I can and cannot do.
    – user52703
    Commented Jan 5, 2019 at 6:35
  • which esp 8266 adafruit wifi module you have exactly?
    – Juraj
    Commented Jan 5, 2019 at 6:43
  • microcenter.com/product/460313/feather-huzzah-with-esp8266-wifi Also it doesnt have to be pin 15 if the pulldown is an issue. I tried Serial printing all the pins digitalRead states from the arduino feather and i picked one that was in an off state so that it would be hot with 3.3v from the arduino when it fires the output on pin 8 when it meets the alarm triggered condition. Let me know if what Im sating is clear.
    – user52703
    Commented Jan 5, 2019 at 6:53
  • you can't determine the state of output pin with digitalRead. most of esp8266 pins are HIGH at power-up or boot
    – Juraj
    Commented Jan 5, 2019 at 7:02
  • 1
    I understand it but from here I can't say more that, that the input must be stronger then the pull-down. but it shouldn't be a problem, but the pull-down is strong (4.7kOhm. 10 kOhm is usual). try other pin.
    – Juraj
    Commented Jan 5, 2019 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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