ESP8266-01 couldn't detect sensor value(AnalogRead)
Posted: Mon Nov 21, 2016 1:50 pm
I am trying to program my ESP8266-01 to detect a turbidity sensor through an Arduino UNO. The code works fine on the Arduino UNO but once I uploaded it on to the ESP8266 Module, what showed on the serial monitor of Arduino IDE are just zeroes. I'm just a few days into this project, can someone help? Can the ESP8266 actually detect analog values? Is there any specifications I need to select for the board? Or is there any connections I need to make? Or is it impossible?
The following are my code:
#include <SPI.h>
int sensor1 = A0 ;//the port of the sensor's connected to on Arduino UNO
void setup() {
Serial.begin(115200);
delay(10);
}
void loop() {
int voltage = 0;
int sensorValue = analogRead(sensor2);
float voltage = sensorValue * (5.0 / 1024.0);
Serial.println(voltage);
Serial.print(" Turbidity:");
Serial.println(voltage);
delay(3000);
}
My connections:
RX>>RX//what's working for me
TX>>TX
VCC,CH_PD>>3.3v
GPIO0>>Ground
GND>>Ground
RST,GPIO2>>not connected
Sensor's connected to A0, 5v and GND of Arduino UNO.
The following are my code:
#include <SPI.h>
int sensor1 = A0 ;//the port of the sensor's connected to on Arduino UNO
void setup() {
Serial.begin(115200);
delay(10);
}
void loop() {
int voltage = 0;
int sensorValue = analogRead(sensor2);
float voltage = sensorValue * (5.0 / 1024.0);
Serial.println(voltage);
Serial.print(" Turbidity:");
Serial.println(voltage);
delay(3000);
}
My connections:
RX>>RX//what's working for me
TX>>TX
VCC,CH_PD>>3.3v
GPIO0>>Ground
GND>>Ground
RST,GPIO2>>not connected
Sensor's connected to A0, 5v and GND of Arduino UNO.