0

UPDATE: I tried CNY70 sensor and the same error is valid for it too. Even outputs of CNY70 and LDR is the same while ESP8266 plugged in. I think ESP8266 interferes with all analog sensors

I connected my esp8266 and ldr sensor to my seeediuno (clon of arduino by seeedstudio) and ldr returns values like 70 110 105 120 etc. When I directly pointed light to ldr, return values don't change, value scatter randomly between 50-130. When I disconnect esp8266 and switch to arduino diecimila from ardunio ide, ldr sensor works fine. I think esp8266 somehow interferes with ldr sensor. How can I fix this problem?

#include "ESP8266WiFi.h"
#include "ESP8266HTTPClient.h"
[![#define SSID "myssşd"
#define PASS "mypass"
#define BID 000001

const char *host = "api.host.com";

void setup() {
  //start serial connection
  Serial.begin(115200);
  //configure pin 2 as an input and enable the internal pull-up resistor
  pinMode(2, INPUT);
  pinMode(13, OUTPUT);
  pinMode(A0, INPUT);

  WiFi.begin(SSID, PASS);

  while(WiFi.status() != WL_CONNECTED){
    delay(1000);
    Serial.println("Connecting...");
  }
  //If connection successful show IP address in serial monitor
  Serial.print("Connected to ");
  Serial.println(SSID);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  //IP address assigned to your ESP
}

void loop() {
  //read the pushbutton value into a variable
  int sensorValMeal = analogRead(A0);
  Serial.println(sensorValMeal);
  delay(1000);
}

This is how my serial prints looks like. You can see the anomally, I added my events as well.

Connecting...
Connecting...
Connecting...
Connecting...
Connected to Anaconda
IP address: 192.168.1.21
42 <- This is start
41
41
41
41
41
41
41
40
40
151 <- I turned my phones light to ldr
78
85
84
89
92
69
97
99
100
96
104 <- I switched of my phone's light
63
103
103
108
108
109
109
114
111
112
111
103
112
113
114
112
116
104
116
116
101
117
118
118
108
122
80
109
118
123
124
125
124
114
127
127
127
98
126
127
124
114
125
127
125
124
127
98
127
126
104
127
127
126
118
128
127
92
123
126
127
128
127
111
130

enter image description here enter image description here

  • esp8266 takes power from 3.3 V pin? – Juraj Dec 8 '18 at 15:41
  • I followed a tutorial at youtube. In the video it was connected to 3.3v pin and I did so. I connected analog sensor to 5v pin as I have seen in online tutorial of LDR and CNY70 sensors. I tried to power sensors via 3.3 V pin but nothing changed. – Furkan Çelik Dec 8 '18 at 16:00
  • the current draw of esp8266 causes voltage drops – Juraj Dec 8 '18 at 18:38
  • I connected 9v battery through Vin but the result is the same. Even 9v is not enough? I don't have any 12v battery. – Furkan Çelik Dec 8 '18 at 19:10
0

You aren't using the Seeduino Arduino clone. You're using (as in writing software for, and programming) the ESP8266. Every instruction you write affects only the ESP8266. The Arduino is nothing more than a power supply (and maybe a USB to Serial adaptor if you use it as such).

To access the analog pins on the Arduino you will need to:

  1. Design a communication protocol between the two boards
  2. Implement that communication protocol for both boards
  3. Program both boards with their own unique sketches that use the protocol to communicate between them.

The Arduino will gather the data using its sketch, then send the results to the ESP8266 for sending through the internet.

Alternatively put the standard AT firmware on the ESP8266 and use that as the protocol above - then you only have to implement it on the Arduino.

0

You read the analog pin of the esp8266, not the analog pin of the Seeeduino.

  • how can I correct that? I connected analog sensor to A0 of seeeduino. – Furkan Çelik Dec 9 '18 at 11:14
  • you have two MCU. you need two sketches – Juraj Dec 9 '18 at 11:15
  • How can I do that? I can create 2 sketch and upload them but I need to transfer variables to ESP8266. Will I transfer variables over rx tx? – Furkan Çelik Dec 9 '18 at 11:30

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.