Hello I have the Infamous WiFi R3 ATmega2560+ESP8266.
I already got it to work with BlynkEdgentNCP and I have no issue, I just wondered how to use Blynk.Air with it?
I have tried using Blynk.Air with an ESP32 and BlynkEdgent and it worked straight away, but BlynkEdgentNCP doesn’t seem to work.
I go to Blynk.Air see that the device is online, select the firmware I want to upload, select the device and press upload, then the process bar appears but it just sits completely still and doesn’t do anything.
This is my test sketch.
/*************************************************************
NOTE: This example requires the connectivity module on your board to be
flashed using Blynk.NCP firmware.
The easiest way to install the NCP firmware for ESP8622 is using ESP8266_Flasher.exe:
https://github.com/JhonControl/ESP8266-Flasher/blob/master/esp8266_flasher/esp8266_flasher.exe
Firmware is here:
https://docs.blynk.io/en/getting-started/supported-boards#connectivity-modules-supported-by-blynk.ncp
*************************************************************/
/* Fill in information from your Blynk Template here */
/* Read more: https://bit.ly/BlynkInject */
#define BLYNK_TEMPLATE_ID "TMPL5ADymW6jr"
#define BLYNK_TEMPLATE_NAME "Quickstart Template"
//Ensure that the Blynk App is installed on your smartphone.
//Open the Blynk App -> click Add New Device -> select Find Devices Nearby (You might need to do it manually)
/* The firmware version of the Primary MCU (used for OTA updates) */
#define BLYNK_FIRMWARE_VERSION "0.1.0"
// Debug output
#define BLYNK_PRINT Serial
// Redefine NCP connection port settings, if needed
#define BLYNK_NCP_SERIAL Serial3
// BAUDRATE
#define BLYNK_NCP_BAUD 115200
// Need arduinoOTA library
#include <BlynkEdgentNCP.h>
// Declaring a global variabl for sensor data
int sensorVal;
// This function creates the timer object. It's part of Blynk library
BlynkTimer timer;
//What to do when successfully connected to Blynk
BLYNK_CONNECTED() {
//Makes sure that V1 is in sync in case of lost connection.
Blynk.syncVirtual(V1);
//Message that shows up in Serial Monitor.
BLYNK_LOG("Connected to Blynk 🙌");
//A LED lights up when connected to server.
digitalWrite(13, HIGH);
}
//What to do when not connected to Blynk
BLYNK_DISCONNECTED() {
//Message that shows up in Serial Monitor.
BLYNK_LOG("Blynk disconnected");
}
//Virtual pin 1 in datastream
BLYNK_WRITE(V1) {
// This monitors if the virtual pin value changes, then followed by the action.
// In this case "if V1 value is ==1 then digitalWrite 26, HIGH else LOW"
if (param.asInt() == 1) {
// execute this code if the switch widget is now ON (Remember to set the on value to 1)
digitalWrite(26, HIGH); // Set digital pin 2 HIGH
} else {
// execute this code if the switch widget is now OFF(Remember to set the off value to 0)
digitalWrite(26, LOW); // Set digital pin 2 LOW
}
}
//This is for preventing dataoverflow so it only sends the updated value with certain intervals.
//The update interval is defined by timer.setInterval in the void setup section.
void myTimerEvent() {
// You can send any value at any time.
// Please don't send more that 10 values per second.
//send among of seconds that has past to virtual pin V0
Blynk.virtualWrite(V0, millis() / 1000);
// This function describes what will happen with each timer tick
// e.g. writing sensor value to datastream V2
Blynk.virtualWrite(V2, sensorVal);
//Only for monitoring the sensor locally in the Serial Monitor
Serial.println(sensorVal);
}
void setup() {
// Define LED pins
pinMode(8, OUTPUT);
pinMode(26, OUTPUT);
Serial.begin(115200);
Serial.println();
// Give Serial Monitor some time to connect
delay(3000);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
//Setup part for Blynk is below this line, don't touch it.
//*****************************************************************************
//Writes message to the Serial Monitor
BLYNK_LOG("Main firmware: %s", BLYNK_FIRMWARE_VERSION);
BLYNK_LOG("Build: %s", __DATE__ " " __TIME__);
// Initialize the Blynk.NCP hardware + error message if failed
if (Blynk.initNCP()) {
String ver = Blynk.getNcpVersion();
BLYNK_LOG("Blynk.NCP firmware: %s", ver.c_str());
} else {
BLYNK_LOG("Cannot communicate to Blynk.NCP");
BLYNK_LOG(" Please ensure you have flashed your board with the Blynk.NCP firmware, before running this example.");
BLYNK_LOG(" See: https://github.com/blynkkk/BlynkNcpExample");
return;
}
// Print state changes
Blynk.onStateChange([]() {
BLYNK_LOG("State: %s", Blynk.getStateString());
});
// Set config mode timeout to 30 minutes, for testing purposes
Blynk.setConfigTimeout(30 * 60);
// Product setup
Blynk.begin(BLYNK_TEMPLATE_ID, BLYNK_TEMPLATE_NAME);
//*****************************************************************************
}
void loop() {
// Reading sensor from hardware analog pin A0
sensorVal = analogRead(A0);
// runs BlynkTimer
timer.run();
// Runs all Blynk stuff
Blynk.run();
}