Arduino mega send data to esp8266 then display in blynk app

why doesn’t the blynk ssid appear during configuration with the blynk iot application? the format I use is blynk edgent. I am using arduino mega as a data sender to esp8266 with serial communication.

#define BLYNK_TEMPLATE_ID “TMPLqUlLQPbH”
#define BLYNK_DEVICE_NAME “monitrng”
#define BLYNK_FIRMWARE_VERSION “0.1.0”

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD
//#define USE_WEMOS_D1_MINI

#include “BlynkEdgent.h”

String sData;//menampung data dari arduino
String arrData [4]; //digunakan untuk menjadi wwadah setiap data yang sudah di pecah
bool parsing = false;// memecah data
BlynkTimer timer;

void sendSensor(){
while (Serial.available ()>0){
char in = Serial.read();
sData += in;
}
sData.trim ();
//uji data
if (sData != “”) //arti jika data tidak muncul
{
// format data misal #10#20.9#89.5" = array (setelah parsing)
// parsing data / pecah data dengan membuat variable array
int index = 0;
for (int i=0; i<= sData.length (); i++)
{
char delimiter = ‘#’ ;
if (sData [i] != delimiter)
arrData [index] += sData [i];
else
index++; //variable index bertambah 1
}

      //pastikan data yang dikirim lengkap (level air, temp, counter)
      // urutanya 0=level air, 1=temp, 2=counter
      if (index == 3)
      {
        Blynk.virtualWrite (V0,arrData [0]);
        Blynk.virtualWrite (V1,arrData [1]);
        Blynk.virtualWrite (V2,arrData [2]);
        Blynk.virtualWrite (V3,arrData [3]);
  
      }
      arrData [0] = "";
      arrData [1] = "";
      arrData [2] = "";
      arrData [3] = "";
    }
    sData = "";
    Serial.println ("minta");
     }

void setup()
{
Serial.begin(115200);
delay(100);

BlynkEdgent.begin();
timer.setInterval ( 3000L,sendSensor);
}

void loop() {
BlynkEdgent.run();
timer.run ();
}

So, instead of editing your original post as requested, you’ve created a new topic!
Not a great start.

Using your serial port for both debugging and receiving data from the Mega isn’t likely to work well.
I would have thought that creating a software serial port for that purpose would be a better solution, but to be honest, you’d probably be better using an ESP32 instead of your Mega/NodeMCU combination.

I suggest that you start with a clean Edgent sketch and get that connected successfully, then add-in your additional code.

Pete.

I tried using serial software but there was an error in the program as follows “no matching function for call to blynkwifi” as shown below

I have no idea what you’re trying to achieve with that piece of code, but it makes no sense, especially not in the Edgent sketch.

Pete.


#define BLYNK_TEMPLATE_ID "TMPLqUlLQPbH"
#define BLYNK_DEVICE_NAME "monitrng"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD
//#define USE_WEMOS_D1_MINI

#include <SoftwareSerial.h>
// variable software serial (Rx,Tx)
SoftwareSerial Dataserial (12, 13);
// 12 dan 13 itu nilai dari pin D6 dan D7 dari nodemcu

String sData;//menampung data dari arduino
String arrData [4]; //digunakan untuk menjadi wwadah setiap data yang sudah di pecah
String parsing;// memecah data 
//BlynkTimer timer;

#include "BlynkEdgent.h"

void sendSensor(){
   while (Dataserial.available ()>0);
    {
      char in =  (Dataserial.read());
      sData += in;
    }
    sData.trim ();
    //uji data
    if (sData != "") //arti jika data tidak muncul 
    {
        // format data misal #10#20.9#89.5" = array (setelah parsing)
        // parsing data / pecah data dengan membuat variable array
        int index = 0;
        for (int i=0; i<= sData.length (); i++)
        {
          char delimiter = '#' ; 
          if (sData [i] != delimiter)
            arrData [index] += sData [i];
          else
            index++;  //variable index bertambah 1
        }
       
          //pastikan data yang dikirim lengkap (level air, temp, counter)
          // urutanya 0=level air, 1=temp, 2=counter
          if (index == 3)
          {
            Blynk.virtualWrite (V0,arrData [0]);
            Blynk.virtualWrite (V1,arrData [1]);
            Blynk.virtualWrite (V2,arrData [2]);
            Blynk.virtualWrite (V3,arrData [3]);
      
          }
          arrData [0] = "";
          arrData [1] = "";
          arrData [2] = "";
          arrData [3] = "";
        }
        sData = "";
        Dataserial.println ("minta");
         }
         
void setup() {
  Serial.begin (115200);
  Dataserial.begin (115200);
  Blynk.begin(115200);
//  timer.setInterval ( 3000L,sendSensor);
}

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

eror no matching function for call to blynkwifi

as shown below

You should use

Blynk.begin(auth, ssid, pass);

instead. and

BlynkEdgent.begin();

If you would like to use blynk edgent.

So, are you planning to connect to the internet via a serial connection rather than WiFi?
If so, the Edgent sketch is the wrong starting point.

I think it would be better if you want back to basics, and started by explaining more about your project, what the Mega is used for, what devices are connected to it, how the Mega and NodeMCU are connected, and why you can’t use the NodeMCU on its own.

Pete.

i use arduinomega to send sensor data to esp8266 via serial communication then i connect it to blynk as monitoring sensor. the rx, tx pins on my esp8266 are broken that’s why I used another pin to be the rx tx pin on the esp8266

And what connection method will you be using to send data from your NodeMCU to Blynk? (WiFi, Serial, Ethernet etc)?

But that’s not what your sketch is achieving. The Serial0 UART, which is connected to the Rx and Tx pins is still being used by the sketch.

My guess is that your Rx and Tx pins are fine, you are just creating conflicts by inadvertently using them for multiple things atthe same time.

I’ve previously said…

but you haven’t done this. I’m not going to put much more Input into this topic unless you’re prepared to provide much more background and much more specific detail.

Pete.

1 Like

thank you very much

1 Like