I tried to use a 4051 analog multiplexer to increase my ADC port on a ESP8266. The setup works in Arduino IDE but I’m unable to port it to Blynk. Whenever I put 2 or more virtualWrite in the loop, the ESP8266 keep resetting and disconnecting from the network. Any help will be very much appreciated. Here’s my setup and my code
/**************************************************************
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Blynk community: http://community.blynk.cc
Social networks: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
**************************************************************
This example runs directly on ESP8266 chip.
You need to install this for ESP8266 development:
https://github.com/esp8266/Arduino
Please be sure to select the right ESP8266 module
in the Tools -> Board menu!
Change WiFi ssid, pass, and Blynk auth token to run :)
**************************************************************/
//#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "***********"; //insert here your token generated by Blynk
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth, SSID, password);
pinMode(5, OUTPUT); //s0
pinMode(6, OUTPUT); //s1
pinMode(7, OUTPUT); //s2
}
void pin1() //y0
{
digitalWrite(5, 0);
digitalWrite(6, 0);
digitalWrite(7, 0);
Blynk.virtualWrite(V0, analogRead(A0));
}
void pin2() //y1
{
digitalWrite(5, 1);
digitalWrite(6, 0);
digitalWrite(7, 0);
Blynk.virtualWrite(V1, analogRead(A0));
}
void pin3() //y2
{
digitalWrite(5, 0);
digitalWrite(6, 1);
digitalWrite(7, 0);
Blynk.virtualWrite(V2, analogRead(A0));
}
void loop()
{
Blynk.run();
pin1(); //read sensor value from y0
delay(500);
pin2(); //read sensor value from y1
delay(500);
pin3(); //read sensor value from y2
delay(500);
}
(P/S please don’t be too harsh with comments, I’m still a newbie without any electronic background)