Kyneo Conectivity

Introduction

Connectivity is at the heart of the Kyneo development, that’s why in the following tutorial, we will explain how to use XBee and or Bluetooth hardware to create a communication network. It is important to note that even though the XBee has an specific bay inside the Kyneo’s board, Bluetooth devices are not standard, so each one should be adapted to the board. However they usually come with a serial connection, which can be plugged into the serial output of the Kyneo (Tx0, Rx0) ports.

Connectivity description

Even though Kyneo has many ports to communicate with sensors and other componentes, in this communication tutorial we will focus on serial communications.

There are two serial ports integrated in the Kyneo board. One is for the GNSS module and the other is shared between the XBee pinout and the USB, this is why, it is very important to remove the XBee in order to program the board, an error will occur otherwise. This Serial is what is going to carry the information to the XBee  or Bluetooth for transmission, this makes simple serial programming the easiest way to transmit data.

The following program is an example of this, this program will generate random numbers from 0 to 100 and print them on the Serial. This way, when connecting an XBee or Bluetooth to this port, the numbers will be sent to a paired device.

In order to visualise the numbers sent on the receiver side, we must connect the XBee to a visualisation tool such an FTDI adapter and plug that to a computer to open a Serial port (Can easily be done through Arduino), or we must connect our device to the Bluetooth net generated, any Bluetooth terminal app should show the received data.

Example Sketch Code – Simple Connectivity

/**************************************************************************************************
 * Kyneo XBee-BT connectivity Example
 * 
 * This sketch will send a random number from an xBee to another equaly configured one. It requires
 * two xBee modules, one conected to the kyneo and the other to the computer via an FTDI adapter. 
 * 
 * Instructions: Charge this program to the kyneo and unplug it. Connect one xBee to the kineo and
 * the other to the FTDI adapter. Plug the FTDI on the computer, open arduino, select the com port
 * and start the serial monitor. Start the kyneo, you should see the random numbers generated on 
 * the serial monitor.
 * 
 * 
 * Created by GEKO Navsat S.L. for Kyneo V2.0 board
 * 
 * This example is free software, given under a GPL3 license
 * 
 * KYNEO is a product designed by GEKO Navsat S.L. in Europe http://www.gekonavsat.com
 * For further information, visit: http://kyneo.eu/
 * 
 *************************************************************************************************/
#include <KyneoBoard.h>                                 //GekoNavsat libraries

int LoopRate = 500;  //milliseconds                     //Variable definition
float RandomNum;
int RandomMax = 100;

void setup() {
  Serial.begin(9600);                                   //Initialize the Serial port 
}  

void loop() {
  
  RandomNum = random(RandomMax);                        //Random number generator
  Serial.println(RandomNum);

  delay(LoopRate);
}  

Dual connectivity description

As we stated before, besides the GNSS module serial, we have only one serial port for the communications use. So, in order to have two communication devices, we will have to emulate one serial port using two of the digital output pins of the Kyneo. This is extremely easy to do using the function SoftwareSerial, we just have to state which pins we want to use as Tx and Rx.

In the following program, a new serial will be emulated and prime numbers from 0 to 6301 will be calculated and out posted from it, besides, non prime number will be sent through the standard serial.

Example Sketch Code – Dual Connectivity

/**************************************************************************************************
 * Kyneo Dual Connectivity Example
 * 
 * This sketch will send a random number from a bluetooth beacon conected to the kyneo. 
 * 
 * Instructions: In order to visualize the data sent, another bluetooth enabled device will be needed,
 * such a smartphone. Any bluetooth terminal should provide the tools to read the data.
 * 
 * 
 * PrimeSieve
 * Paul Badger 2009
 * Generates prime numbers less than 63,001 as shown
 * To extend just add more primes to prime table (and choose a larger data type)
 * The program will generate primes up to the square of the last prime table entry
 * 
 * 
 * Created by GEKO Navsat S.L. for Kyneo V2.0 board
 * 
 * This example is free software, given under a GPL3 license
 * 
 * KYNEO is a product designed by GEKO Navsat S.L. in Europe http://www.gekonavsat.com
 * For further information, visit: http://kyneo.eu/
 * 
 *************************************************************************************************/
#include <KyneoBoard.h>                                 // GekoNavsat libraries
#include <SoftwareSerial.h>                             // Other libraries

SoftwareSerial BTSerial(0, 1); // Rx, Tx                // Object definition

int LoopRate = 500;                                     // Variable definition
byte primes[]={ 
    2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,
    103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 
    199, 211, 223, 227, 229, 233, 239, 241, 251};
const unsigned int TopPrimeIndex = sizeof(primes) - 1;      
const unsigned long TopPrimeSquared = (long)primes[TopPrimeIndex] * (long)primes[TopPrimeIndex];
int primeFlag;


void setup() {
  Serial.begin(9600);                                   // Initialize the Serial port 
  BTSerial.begin(9600);
  BTSerial.println("Setup done /n");
}  

void loop() {

  for (long x = 1; x < TopPrimeSquared; x++){
    for (long j=0; j < TopPrimeIndex; j++){
      
      primeFlag = true;
      if (x == primes[j]) break;
      if (x % primes[j] == 0){                          // If the test number from prime table
        primeFlag = false;                              // Then test number is not prime
        break;
      }
    }
    
    if (primeFlag == true){                             // Found a prime - print it
      BTSerial.println(x);
      delay(LoopRate);
    }else{
      Serial.println(x);
    }
  }
}  

Link to software repository

More information about Kyneo go to Kyneo Manual

For all the latest software visit our GitHub page GEKO Navsat Github's examples

Posted in Tutorials.