Widget led+physical pin state

Hello.
What I’m trying to do:
Connected esp8266 witty cloud GPIO5 to Arduino Uno 12 digital port(vcc and gnd from esp8266 connected directly to arduino). To esp uploaded a standalone sketch:

> #define BLYNK_PRINT Serial  
> #include <ESP8266WiFi.h>**
> #include <BlynkSimpleEsp8266.h>**

> // You should get Auth Token in the Blynk App.
> // Go to the Project Settings (nut icon).
> char auth[] = "MY AUTH";

> // Your WiFi credentials.
> // Set password to "" for open networks.
> char ssid[] = "my ssid";
> char pass[] = "my pass";
> WidgetLED led1(V0);

> void setup()
> {
>   Serial.begin(9600);
>   Blynk.begin(auth, ssid, pass);
>   pinMode(5,INPUT);
> }

> void loop()
> {
>   Blynk.run();
>   if (digitalRead(5)==HIGH) 
> {
>    led1.on();
> } 
> else 
> {
>    led1.off();
> }
> }

But when there is on Arduino’s 12 pin is HIGH signal or LOW signal esp8266 don’t read it. But when I connect the wire from esp’s gpio5 to arduino VCC or GND(emulation HIGH/LOW signal) all is OK, Led widget change it’s state. But if gpio5 connected to 12 pin arduino-nothing happens.
What’s the problem?

ok. and what sketch do you have on arduino?

another observation: you are checking the state of the led in the main loop, i’m not sure this is correct, because maybe you are sending led1.off(); too many times to blynk server…

@legionercheg do you have a meter to check pin 12 on the Arduino?

Even on an Arduino you should be looking for a state change not simply repeating the same task over and over again in the loop(). This is even more important on an internet connected device.

Would you like the same email sent to you 500 times a second? That is what you are trying to do to the Blynk server.

If you feel you must have something in loop() at least check for a state change. The recommended route is to call functions at timed intervals using one of the six libraries in the Blynk client zip file. It’s called SimpleTimer and an example for you to study is in the IDE as PushData.

Detailed information for SimpleTimer is available at http://playground.arduino.cc/Code/SimpleTimer

On arduino it’s a very simple sketch-reading A0,and if value for example is higher than 500,than 12pin set to HIGH,so from this 12pin esp8266 is reading the state.

But if I sending too much data, when I connect the vcc from arduino in blynk app I see that the led widget changed,and when I connect to GND and even change. But when I “manually” set the 12 pin to HIGH or LOW,Blynk didn’t react on it?

So,if I use this sketch

#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth = “YourAuthToken”;

SimpleTimer timer;

// This function sends Arduino’s up time every second to Virtual Pin (5).
// In the app, Widget’s reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
// You can send any value at any time.
// Please don’t send more that 10 values per second.
Blynk.virtualWrite(V5, millis() / 1000);
}

void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth);

// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
Blynk.run(); // Initiates Blynk
timer.run(); // Initiates SimpleTimer
}

The data will be sent 1 time per second and everything will be OK?

@legionercheg that is just an example and as the name suggests it pushes data to the server. You also need to include the digitalRead() of the Arduino pin etc.

I’m suspecting you don’t have a common ground but you indicated you do. I would check this and I would check pin 12 on the Arduino with a meter.

1 Like

Yes, I’m agree with you that there is a problem with wiring,not with app. My connection is like that:

What I’m doing wrong?
So, when I change wire from 12pin to Vcc or Gnd widget led and value widget show me the change between HIGH and LOW level and everything is OK. But when the wire on 12pin-there is no effect, is it HIGH or LOW, blynk didn’t react on it(

The witty has it’s own USB port that you should be using and disconnect the Vcc from witty to Arduino but leave the GND connected.

1 Like

So,the schematics should change like this?

No.

Don’t connect vcc from witty to the Arduino anywhere.

Power the witty from a separate USB power feed.

1 Like

From usb i can power it for tests,but then when I integrate it to my device,there will be no usb, only 1 dc source that will be powering arduino and esp. Or I need 2 different dc power sources? But I don’t understand why I can’t do the wiring like that:

Is that correct?

Connected like that and all is working well!!! Thanks @Costas :grinning:

ESP’s are 3.3V devices and until recently it was understood that the GPIO pins were only tolerant to 3.3V, possibly 3.6V.

Apparently the Chairman of Espressif took to Facebook to say that this is not the case. The original data came from documents written in Chinese and there may have been some confusion on the translation.

The HIGH and LOW signals are defined as 0.75Vio and 0.25Vio with Vio being declared as 3.3V. However the pins are apparently protected up to 5.8 to 6.0V volts.

The normal practise has been to put a voltage divider between a 5V Arduino and a 3.3V ESP.
You decide. This is an extract from Espressif ESP8266EX datasheet.

1 Like