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
#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() {
Serial.begin(115200);
pinMode(featherPin, INPUT);
WiFi.begin(ssid, password);
while(WiFi.status() != WL_CONNECTED) {
delay(10);
Serial.println("Waiting for connection");
}
}
void loop() {
int sensorValue = analogRead(featherPin);
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");
}
if (sensorValue > 850) {
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 if (sensorValue < 850) {
Serial.print(sensorValue);
// 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(1);
}
When pin 0 is hot I want to print that value
...? What value? What do you mean by "hot"?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 usedigitalRead()
,digitalWrite()
,pinMode()
oranalogWrite()
. It doesn't even have a pin number to use with those functions.