Software Serial - YUN, Xbee

HI there,
I am using a YUN with and XBee Pro S3B to obtain serial info from my Xbee network from sensors.
It seems that when using the software serial example, and replacing the #include <BlynkApiArduino.h> with the //#include <BlynkSimpleYun.h> cannot get it compiled. Using the #include <BlynkApiArduino.h> I get connection issues running it from the Yun.

Code///

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SoftwareSerial.h>
//#include <BlynkSimpleYun.h>  // issues
#include <Bridge.h>

#include <BlynkApiArduino.h>  //issues 
#include <Adapters/BlynkSerial.h>

typedef BlynkTransportSerial<SoftwareSerial> SwSerialConnection;

SoftwareSerial SwSerial(10, 11); // RX, TX
SwSerialConnection connection(SwSerial);
BlynkSerial<SwSerialConnection> Blynk(connection);

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

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, 9600);
}

void loop()
{
  Blynk.run();
if (SwSerial.available())
    Serial.write(SwSerial.read());
  if (Serial.available())
    SwSerial.write(Serial.read());
}

ALWAYS wrap your code by pressing this magic button (Backtick`) 3 times (before the code and after it):

This makes your code beautiful with highlighted syntax, like this:

//comment goes here
void helloWorld() {
   String message =  "hello" + "world";
}

You can also select the code and press </> button in the top menu:

Sorry please find the next version of the code:
from #include <BlynkSimpleYun.h> or #include <BlynkApiArduino.h> want to run the Software Serial seems that its not really compatible with the YUN. Basically, I gather the serial write info from the main Xbee and re-transmits it to the YUN via the XBee. and now with the wonder of Blynk possibly display the info to my phone?

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <BlynkSimpleYun.h>
#include <SoftwareSerial.h>
#include <BlynkApiArduino.h>
#include <Adapters/BlynkSerial.h>

typedef BlynkTransportSerial<SoftwareSerial> SwSerialConnection;
SoftwareSerial SwSerial(10, 11); // RX, TX
SwSerialConnection connection(SwSerial);
BlynkSerial<SwSerialConnection> Blynk(connection);

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

void setup()
{
  Blynk.begin(auth, 19200);   
  Serial.begin(19200); 
 }

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

is seems that some minor library adjustments are needed to replace the BlynkApiArduino.h with the BlynkSimpleYun.h?
once connected and replaced the BlynkApiArduino.h file with BlynkSimpleYun, its almost working, but authentication seems not working thereafter. It would have been so nice to get the Serial Data displayed on “dashboard” from a couple of sensors out in the field that’s connected to the XBee, Arduino network…

The Serial data that I refer is incoming string data that’s currently displayd through LCD panels, from there I am calling the same data to the YUN successfully , ready for my future Blynk app

Hi, @Thunderbolt

Did you check this example: https://github.com/blynkkk/blynk-library/tree/master/examples/BoardsAndShields/Arduino_Yun?
and
https://github.com/blynkkk/blynk-library/tree/master/examples/BoardsAndShields/Arduino_SoftwareSerial

Is it working for you?

I assume you also have your own sketch which works with zigbee, right? And you are trying to combine them together. Correct?

Thanks.

Hi Pavel
With the following code I get Serial print to the Arduino Serial Sceen (yeah)as well as connectivity from the YUN to BLYNK tested!Yeah

The only issue now is to get the serial output to the Blynk app? can you assist please?

#include <Bridge.h>
#include <BlynkSimpleYun.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SoftwareSerial.h>
//#include <BlynkApiArduino.h>
#include <Adapters/BlynkSerial.h>

typedef BlynkTransportSerial<SoftwareSerial> SwSerialConnection;

SoftwareSerial SwSerial(10, 11); // RX, TX
SwSerialConnection connection(SwSerial);
BlynkSerial<SwSerialConnection> Blynk(connection);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "8f339e21e21d47c290354bff069cad77";

void setup()
{
Serial.begin(19200);
Blynk.begin(auth, 19200);
}

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

Output from XBEE and YUN to the serial monitor from Arduino…

#09BARS SCR: 2.44 Ç
#11BARS SND: 2.25 Ç
#0218Bo= GOOD Ç
#0318Middel=BAD Ç^
#09BARS SCR: 2.43 Ç
#0412Bo= GOOD Ç
#0512Onder= GOOD Ç
#09BARS SCR: 2.43 Ç
#0612Klip= GOOD Ç

Hi Pavel or anyone
Any inputs?

have you tried
BLYNK_LOG
BLYNK_PRINT

@vshymanskyy - do we have any examples?

Hi. Fisrt, we didn’t check any XBee configurations yet//
Second, could you please explain in simple terms, what devices do you connect and how, and what operation do you want to achieve. Thx.

Hi Pavel
There is no config really necessary to check on the Xbee.

  1. Xbee on the YUN passes it’s serial info as soft serial to port (10,11) as per sketch issued on the group
  2. As it is serial strings passed through as issued on the arduino serial screen example issued on the group.
  3. I get digital and analog readings from other arduino mega’s and send the strings through the Xbee network to the master which then display the info on lcd screens. Also of the readings are over or under the limits set, the remote units then send a ASCII char to trigger a Alarm e. g. Sound, Led and sms. These sensors are piezo sensors measuring water pressure. The second set are normal optocouplers sending a 3.3v signal, pulling the digital inputs high. These are coming from electric fence zones.
    All these strings are issued and refreshed every 3 seconds.
    All I need if the serial strings which are the same as on the lcd. 's and issued on the group cannot be displayed, then if your app cannot trigger a alarms(led) from ASCII char. Maybe I am asking for too much here?

Let me know.
Regards

@Pavel and @vshymanskyy, is there any way be able to read and write from XBee I/O pins directly from Blynk apps? For example if an Xbee is connected to an Electron, and a second Xbee is connected to a sensor, can I read the sensor on the Blynk app through the Electron?