简体   繁体   中英

Connecting an ESP8266 to an Arduino Uno using Blynk

I am working on a project where I am trying to turn on LEDs over wifi using the Blynk app through an ESP8266 and an Arduino uno. I believe the circuit is set up properly as I was able to run an empty script and through the serial monitor send the "AT" command and get feedback. Also the ESP8266 is showing up on my wifi settings. However, from there I tried to setup a quickstart device on the blynk app and that's where I am stuck.

The major error seems to be that I can't download the necessary library, "ESP8266_Lib.h", in order for the program, Blynk initially gives you, to run. I tried to download the latest version of the blynk library on github but that still did not help.

After this phase of the project, I hope to move to an adrafruit gemma board, and hope that won't cause any further issues. The code Blynk provided and the error message is below: '''

/*************************************************************

  This is a simple demo of sending and receiving some data.   Be
sure to check out other examples! 
*************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud 
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPLAFgrm8rq"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            "h51Uz7shHDeBiaiIXRvEQUYDsBZbwzBf"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

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

BlynkTimer timer;

// This function is called every time the Virtual Pin 0 state changes 
BLYNK_WRITE(V0) {   // Set incoming value from pin V0 to a variable   
int value = param.asInt();

  // Update state  
Blynk.virtualWrite(V1, value); }

// This function is called every time the device is connected to the Blynk.Cloud 
    BLYNK_CONNECTED()
{   // Change Web Link Button message to "Congratulations!"   
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
Blynk.setProperty(V3, "onImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
Blynk.setProperty(V3, "url","https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}

// This function sends Arduino's uptime every second to Virtual Pin 2
 void myTimerEvent() {
    // You can send any value at any time. 
  // Please don't send more that 10 values per second.  
Blynk.virtualWrite(V2, millis() / 1000); }

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

  Blynk.begin(auth, ssid, pass);   // You can also specify server:  
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);  
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

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

void loop() {   
 Blynk.run();  
 timer.run();  
// You can inject your own code or combine it with other sketches.   
// Check other examples on how to communicate with Blynk. Remember   
// to avoid delay() function!
}

j:19:10: fatal error: ESP8266_Lib.h: No such file or directory 19 | #include <ESP8266_Lib.h> | ^~~~~~~~~~~~~~~ compilation terminated. exit status 1 ESP8266_Lib.h: No such file or director

The BlynkESP8266_Lib is only available in the release zip of the Blynk libraries on the Release page . See the Assets section.

Copy the folder BlynkESP8266_Lib from the zip into libraries folder in your sketchbook folder. (Location of the sketchbook folder is set in the Preferences dialog of the Arduino IDE.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM