BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

How do i send data from hardware arduino to blynk application

I am using zergba and can not get any adjustments from my device to the andriod application.

• uno + wifi 328P esp8266
• Smartphone OS Android 9
• latest

#define BLYNK_PRINT Serial


#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>


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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[]="sidd";
char pass[]="pasword";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial
// set AT+CWMODE=1 
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&Serial);

void setup()
{
  
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set ESP8266 baud rate
  Serial.begin(ESP8266_BAUD);
  delay(20);

  Blynk.begin(auth, wifi, ssid, pass);
}

int virtualPin0=0;
int r;
int b;
int g;

void set_ledstrip()
{
  Blynk.virtualWrite(V0, HIGH);
r,g,b=255;
Blynk.virtualWrite(V2, r,g,b);
}

void reset_ledstrip()
{
r,b,g=0;
Blynk.virtualWrite(V2, r,g,b);
}

BLYNK_WRITE(V0)
{
 virtualPin0=param.asInt();
  if(virtualPin0==0)
{

}
else 
{}
}

BLYNK_WRITE(V1)
{
  if (param.asInt()) 
  {       
    set_ledstrip(); //HIGH
  } 
  else 
  {
  }
}

BLYNK_WRITE(V2)
{
  r=param[0].asInt();
  g=param[1].asInt();
  b=param[2].asInt();
}
void loop()
{ 
  Blynk.run();
  analogWrite(6,b);
  analogWrite(9,r);
  analogWrite(11,g);
}

Adjust the refresh interval in milliseconds. Not push.

1 Like

still no response

Are the functions called in the handler getting in the way? How many milliseconds did you choose?
Is the device connecting?

Tried 100ms, 200ms,300ms and 1sec

Yes you mean virtualWrite(V2,r,g,b)

try starting with a simple basic sketch. add in some serial prints to see what is going on. Make sure your Zebra Widget is set to Virtual Pin 2. How are the LEDs wired?

#define BLYNK_PRINT Serial


#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>


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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[]="sidd";
char pass[]="pasword";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial
// set AT+CWMODE=1 
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&Serial);

int r;
int b;
int g;

void setup()
{
  
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set ESP8266 baud rate
  Serial.begin(ESP8266_BAUD);
  delay(20);
  pinMode(6,OUTPUT) ; 
  pinMode(9,OUTPUT) ; 
  pinMode(11,OUTPUT) ; 

  Blynk.begin(auth, wifi, ssid, pass);
}


BLYNK_WRITE(V2)
{
  r=param[0].asInt();
  g=param[1].asInt();
  b=param[2].asInt();
Serial.println(r);
Serial.println(g);
Serial.println(b);

  analogWrite(6,b);
  analogWrite(9,r);
  analogWrite(11,g);
}
void loop()
{ 
  Blynk.run();
 
}

pin 6 blue
pin 9 red
pin 11 green

or how do you mean i now just read the value of the pins true a osciloscoop

the zergba works he is not getting data from the hardware to say its on white.

blue does it but otherones not

after setting

r=0;
b=0;
g=0;

instead of r,b,g=0; int works

@Kitty_Visser my advice is to stop doing the one line posts to the topic. They mean nothing to the people reading the post and, certainly in my case, put people off responding to your topic.

When you PM’d me regarding posting etiquette, I said:

When you create the new topic please provide ALL of the relevant information that is asked for, and provide links to other relevant topics is necessary.

You haven’t done that, and haven’t even provided the basic information that is requested in the template that appears when you create a new topic.

I’d suggest that you take a step back and attempt to outline what it is that you are attempting to achieve with your project. Explain the hardware that you are using, including the type of LED strips that you are using, and how you are driving them (are you using MOSFETS, or attempting to drive them directly from your GPIOs).
Explain what type of widget is attached to each virtual pin, and what function that widget is supposed to provide.
This is all in addition to the missing information about hardware, library versions, app versions and all the other things that are requested for a new topic.

Your initial code includes no pinMode declarations, so won’t work for that reason. Having digitalWrites in your void loop is not a good idea when using Blynk.

Pete.

1 Like