First of all I’m a Arduino newbie. I have successfully set up the MKR 1400 with Hologram and added a Grove RGB display using the Grove Connection Carrier. My next Grove device I wanted to add was the GPS unit. When I tried to compile the sample code for the Grove GPS unit I discovered that the board does not support the required <SoftwareSerial.h>. My goal is to have a inexpensive monitoring device for my sailboat that is on a mooring.
I cannot find any articles on the web where someone has implemented a similar configuration. Do I need to explor directly connecting the GPS unit directly to the MKR 1400?
Any advice will be appreciated.
Hi there~
The USB connector exposes as a virtual serial port that can be controlled by writing and reading to the Serial object. Pins 13/14, instead, expose a Hardware serial port mapped to Serial1 object.
So you can connect the grove-gps to Pins 13/14, and use below code to communicate with MKR1400. I do not have the MKR-1400 and I can not verify the code. thanks.
[code]
unsigned char buffer[64]; // buffer array for data receive over serial port
int count=0; // counter for buffer array
void setup()
{
Serial1.begin(9600); // the SoftSerial baud rate
Serial.begin(9600); // the Serial port of Arduino baud rate.
}
void loop()
{
if (Serial1.available()) // if date is coming from software serial port ==> data is coming from Serial1 shield
{
while(Serial1.available()) // reading data into char array
{
buffer[count++]=Serial1.read(); // writing data into array
if(count == 64)break;
}
Serial.write(buffer,count); // if no data transmission ends, write buffer to hardware serial port
clearBufferArray(); // call clearBufferArray function to clear the stored data from the array
count = 0; // set counter of while loop to zero
}
if (Serial.available()) // if data is available on hardware serial port ==> data is coming from PC or notebook
Serial1.write(Serial.read()); // write it to the SoftSerial shield
}
void clearBufferArray() // function to clear buffer array
{
for (int i=0; i<count;i++)
{
buffer[i]=NULL;
} // clear all index of array with command NULL
}[/code]