(using) SparkFun Blynk Board WITHOUT overwriting firmware (acting as shield with Arduino Leonardo)

Hello - we’re trying to add some code to the SparkFun Blynk Board. We don’t want to overwrite the firmware, because that allows it to work with the iphone app, but we need to add our own voids and Blynk.Write commands in order to control this servo RC car via wifi wit the Joystick XY. any ideas?

our code:

#include <Servo.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_NeoPixel.h>
#include <SoftwareSerial.h>
//#define BLYNK_PRINT Serial

char BlynkAuth[] = "6dfb81c116d84003a505056239c23559";
char ssid[] = "Linksys23266";
char pass[] = "roboboyz";

Servo servoR;
Servo servoL;

int pos = 90;


void forward()
{
  servoR.write(110);
  servoL.write(110);
}

void turnRight()
{
  servoR.write(80);
  servoL.write(90);
  delay (2000);
}

void turnLeft()
{
  servoR.write(90);
  servoL.write(80);
  delay(2000);
}

void reverse()
{
  servoR.write(70);
  servoL.write(70);
  delay(2000);
}

void Stop()
{
  servoR.write(94);
  servoL.write(94);
  delay(2000);
}

void setup()
{
  Blynk.begin(BlynkAuth, ssid, pass);  // wifi username and password
  servoR.attach(12);
  servoL.attach(13);
  Serial.begin(9600);
  delay(1000);
}

BLYNK_WRITE(V1) 
{
  int x = param[0].asInt();
  int y = param[1].asInt();

  // Do something with x and y
  Serial.print("X = ");
  Serial.print(x);
  Serial.print("; Y = ");
  Serial.println(y);
  if(y>220)
  forward();
  else if(y<35)
  reverse();
  else if(x>220)
  turnRight();
  else if(x<35)
  turnLeft();
  else
  Stop();
}

void loop()
{
  Blynk.run();
}

Also - we have no problem with connecting it to an Arduino Leonardo to store the code on. only problem is, then what? how do you get it to recieve info from the blynk board?

Not sure I understand why that is a problem, when downloading your sketch, doesn’t the firmware always get overwritten with the same version you have chosen in the IDE?.. should be no different that any other ESP based board.

https://learn.sparkfun.com/tutorials/getting-started-with-the-sparkfun-blynk-board

SparkFun also has technical support for their products:

https://www.sparkfun.com/technical_assistance

Don’t really understand this question… both boards will communicate with Blynk’s Cloud Server and then to the App on your iPhone (either as multiple devices for one project or as individual projects, one for each board… your choice).

The Sparkfun board will use it’s built in WiFi to connect to the internet (via your router), but the Leonardo will require the USB script (which essentially turns your PC into an ethernet adapter for basic Arduino boards).

http://help.blynk.cc/hardware-and-libraries/arduino/usb-serial

We’ve decided to just use the blynk as a “Bridge” - have it output our code via serial to another arduino controller due to its severe limitations.

Hello,

Trying to get our code to compile so we can start sending Joystick X/Y via serial to our Arduino Leonardo to control 2 servos (we’re trying to make a WiFi car).

Everytime we compile (and add our WiFi password which is 12345678) we get this:

invalid conversion from 'char*' to 'uint16_t {aka short unsigned int}' [-fpermissive]

We keep getting the same error when we compile, and its always due to the char pass[]. We’re not sure why, we’ve gone back to old libraries and changed libraries several times.

We’ve even tried removing the password altogether, but we have to at least have a blank pass[] in order to connect.

Here’s our code:

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

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

BLYNK_WRITE(V1) {
  int x = param[0].asInt();
  int y = param[1].asInt();

  // Do something with x and y
  Serial.print("X = ");
  Serial.print(x);
  Serial.print("; Y = ");
  Serial.println(y);
}

void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
}

@vshymanskyy any ideas?

You haven’t stated how your are using WiFi with a Leonardo. And you are not using the correct library for WiFi anyhow.

Check out the Sketch Builder for the varying library options based on your hardware and connection methods.

https://examples.blynk.cc/?board=Arduino%20Leonardo&shield=Arduino%20WiFi%20Shield&example=GettingStarted%2FBlynkBlink

We’re using the Blynk Board to receive XY coords from the blynk app, then passing those via serial to the Leonardo, where we’re controlling the motors (as we couldn’t figure out how to do that on the Blynk itself).

What is the library I’m missing? We took that example directly from there.

Ah, I didn’t realize you had just posted a prior topic… I have merged both into the original and edited your title to be more relevant to your issues.

If you don’t want to use the Sparkfun Blynk Board or the Leonardo as it is, then using the Sparkfun Blynk Board as a shield will make things more complicated. But start with using this example and check out the links shown in the sketch to make sure your "shield’ is set up correctly (although I have no idea if that will work with the Sparkfun board)

https://examples.blynk.cc/?board=Arduino%20Leonardo&shield=ESP8266%20WiFi%20Shield&example=GettingStarted%2FBlynkBlink

Here is that other link I was referring too (it has actually been moved to the Help center): @Dmitriy, another broken link in the example sketch referenced above. Correct link is below.

http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware

So it is possible to include nested voids (that we would pass in XY values into, to determine position, and then pass those through to the servo motors) inside BLYNK_WRITE? and forgo using a separate board altogether?

basically what we’re looking for:

#include <Servo.h>
#include <SoftwareSerial.h>

Servo servoR;
Servo servoL;

int pos = 90;

void setup() {
  servoR.attach(12);
  servoL.attach(13);
  Serial.begin(9600);
  delay(1000);
}

void forward()
{
  servoR.write(110);
  servoL.write(110);
}

void turnRight()
{
  servoR.write(80);
  servoL.write(90);
  delay (2000);
}

void turnLeft()
{
  servoR.write(90);
  servoL.write(80);
  delay(2000);
}

void reverse()
{
  servoR.write(70);
  servoL.write(70);
  delay(2000);
}

void Stop()
{
  servoR.write(94);
  servoL.write(94);
  delay(2000);
}

void setup()
{
  servoR.attach(12);
  servoL.attach(13);
  Serial.begin(9600);
  delay(1000);
}

void loop()
{
  if(y>220)
  forward();
  else if(y<35)
  reverse();
  else if(x>220)
  turnRight();
  else if(x<35)
  turnLeft();
  else
  Stop();
}

With Blynk, the basic programming recommendation is to separate tasks into groups and use BlynkTimer to call those groups based on timing and variable input from BLYNK_WRITE() functions (that get automatically called whenever widget status changes). Keep the main void loop() clear of other nested loops and delays (actually, avoid delay() all together, use timers instead.

http://docs.blynk.cc/#blynk-firmware-blynktimer

As there are many ways of doing the same thing, each suited to needs, and hardware and programming experience. I recommend you start searching this forum for keywords like Robot, RC, Car, Joystick, Servo, etc…

Grab any and all sketch examples and start breaking them down until you have an idea how they work, then use whatever methods combine to do what you want.

This forum is here to assist with specific questions regarding commands and such, but over-all programming how-to is up to each individual to learn on their own… sometimes someone will chip in with some code snippets, but you are your best teacher.