[SOLVED] WiFly module and Blynk issue

Hello!

I want to use Blynk with an Arduino Uno and a WiFly module (RN-131C).

To do that, I tried this code (based on the Blynk example) :

#include <SoftwareSerial.h>
#include <WiFlyHQ.h>
#include <BlynkSimpleWiFly.h>

#define BLYNK_DEBUG   // Optional, this enables lots of prints
#define BLYNK_PRINT   Serial

/* Blynk keys */
char blynkAuthKeys[] = "myBlynkKey";

/* Blynk objects */
WiFly wifly;
SoftwareSerial wifiSerial (3, 2);   /* RX, TX */


void setup()
{
  /* Debug with default serial line */
  Serial.begin (115200);
  Serial.println ("BlynkTest");
  
  /* Wifi used second serial line */
  delay(2);
  wifiSerial.begin(9600);
  delay(2);

  // Bind WiFly driver to the serial
  if (!wifly.begin(&wifiSerial))
  {
    Serial.println ("Failed to start wifly");
  }
  else
  {
    Serial.println ("Started wifly with success");
  }

  Serial.println ("B1");
  Blynk.begin(blynkAuthKeys, wifly, "myBox", "Key"); 
  Serial.println ("B2");
}

void loop()
{
  Serial.println ("LOOP");
  Blynk.run ();
}

Unfortunately, I see that on the UART output :

�BlynkTest
Started wifly with success
B1
BlynkTest
StarteBlynkTest
Starte�BlynkTest
StarteBlynkTest
StartBlynkTest
StarteBlynkTest
StarteBlynkTest
StarteBlynkTest
StartBlynkTest

I looked for a reason of this reset, but I have not found :cry:
Have you an idea ?

Thank you for your help.

Did you provide a stable external power to your WiFly module?

Thank you for your reply.
Yes, for my tests I use a laboratory power supply for the 3.3V.

I tried to comment this line :
Blynk.begin(blynkAuthKeys, wifly, "myBox", "Key");

Arduino is locked into the loop but does not reset.

If I remove also this line :
Blynk.run ();

I have a “LOOP” in loop :stuck_out_tongue:

There’s a way to have more informations during execution of the Blynk.begin ?

I have more information about the origin of my issue.
I added debug into the BlynkWiFly.h file, with source code of my first message.

If I comment this line (into the begin method), I have no reset :
connectWiFi(ssid, pass);

The execution code doesn’t go after :
if (!wifly->isAssociated()) {

Can you switch the serial lines? E.g. use software serial for output and hardware serial for wifi?

1 Like

I did it, it’s exactly the same thing :cry:

I have a good news, it’s working! :smiley:
But I have a bad news for the Blynk team, there’s a bug into the WiFly Adapter :stuck_out_tongue:

Into this file :
https://github.com/blynkkk/blynk-library/blob/master/Adapters/BlynkWiFly.h

Original begin function :

void begin( const char* auth,
                WiFly&      rnxv,
                const char* ssid,
                const char* pass,
                const char* domain = BLYNK_DEFAULT_DOMAIN,
                uint16_t    port   = BLYNK_DEFAULT_PORT)
{
    connectWiFi(ssid, pass);
    config(rnxv, auth, domain, port);
}

Fixed begin function :

void begin( const char* auth,
                WiFly&      rnxv,
                const char* ssid,
                const char* pass,
                const char* domain = BLYNK_DEFAULT_DOMAIN,
                uint16_t    port   = BLYNK_DEFAULT_PORT)
{
    wifly = &rnxv;
    connectWiFi(ssid, pass);
    config(rnxv, auth, domain, port);
}

The reference of the WiFly object is missing.
I removed it from the config function also, because already saved into the fixed begin function.

1 Like

@PEB thanks! @vshymanskyy please check.

Yes. You’re right. The bug will be fixed in next release!