Loading...

You have no items in your shopping cart.

 
 
 
×

Registration

Profile Informations

Login Datas

or login

First name is required!
Last name is required!
First name is not valid!
Last name is not valid!
This is not an email address!
Email address is required!
This email is already registered!
Password is required!
Enter a valid password!
Please enter 6 or more characters!
Please enter 16 or less characters!
Passwords are not same!
Terms and Conditions are required!
Email or Password is wrong!
Captcha is required!
Captcha is wrong!

Play GPS Shield With Iteaduino Plus

Recently we launched a board Arduino Plug for Iteaduino Plus, which breaks out SPI, IIC and UART interfaces on Iteaduino Plus to one Arduino-compatible interface and another compatible with Xbee. There is an OLED screen on the shield that can be connected via IIC.

In the last blog, we demontrated how to use the OLED screen on Arduino Plug, now let’s experience its Arduino interface. Such an interface is designed to facilitate the users to insert and to use the Arduino shields offered by Itead, and you can click HERE to know about all the shields.

Here we take ITEAD GPS Shield as an example. Simply connect Arduino Plug to Iteaduino Plus with the cable, insert the shield directly into the four Arduino-compatible sockets, which will then be used directly in the system. As there is UART interface on ITEAD GPS Shield, it will search after GPS satellite signals automatically after power-up and send out positioning data via UART interface every second. Through UART interface, we can read the data and parse information such as altitude, latitude and longitude, etc. with Iteaduino Plus.

After power-up and entering the system , ITEAD GPS Shield has already started to work. Once we read data from UART interface of UART4, we can receive the information sent by it. In ITEAD OS, we pre-installed minicom software, thus users can easily monitor data stream in several UART interfaces.

Open minicom software, and then proceed with some simple configurations:

sudo minicom -c on -s

Set the device as ttyS3 – this is the UART4 interface for Iteaduino Plus to connect to the Plugs 

Set the baud rate as 34800 8N1 to match with the GPS module serial port

Then save the settings. We can see a variety of data sent out by GPS in the window. For detailed description about the GPS data, you can find it HERE.

Next, we can write a  code to read data from UART and parse the latitude and longitude, and then display the latitude and longitude information on the OLED screen. To do this, we only need to use UART API offered in ITEAD OS SDK and OLED screen operation API functions mentioned before.

Create a c file, enter the following code and save.

#include 
#include 
#include 
#include 
#include 
#include 
#include "oled_test_1106.h"
int byteGPS=-1;
int cont=0;
int bien=0;
int conta=0;
int indices[13];
int i=0;
int j=0;
char comandoGPR[7] = "$GPRMC";
char linea[300] = "";


void main(void)
{
	SerialBegin(UART4,9600);
	ssd1306_begin();
	ssd1306_fill(0x00);
	
	for (i=0;i<300;i++){    
	 	linea[i]=' ';
	}   

	while(1){
		byteGPS=SerialRead(UART4);     
		if (byteGPS == -1) {           
			delay(100); 
		} else {
			linea[conta]=byteGPS;      
			conta++;                      
			if (byteGPS==13){            
				cont=0;
				bien=0;
				for (i=1;i<7;i++){   
					if (linea[i]==comandoGPR[i-1]){
						bien++;
					}
				}
				if(bien==6){              
					for (i=0;i<300;i++){
						if (linea[i]==','){    
							indices[cont]=i;
							cont++;
						}
						if (linea[i]=='*'){   
							indices[12]=i;
							cont++;
						}
					}
					printf("");     
					printf("");
					printf("---------------\n");
					for (i=0;i<12;i++){
						switch(i){
							case 0 : break;	
							case 1 : break;
							case 2 : 
								setCursor(15,0);
								oled_write_str("Latitude:\n");
								setCursor(15,2);
								printf("Latitude: ");				
								for (j=indices[2];j<(indices[2+1]-1);j++){
									printf("%c",toascii(linea[j+1])); 
									oled_write(linea[j+1]);
								}
								printf("\n");
								break;
							case 3 : break;
							case 4 : 
								setCursor(15,4);
								oled_write_str("Longitude:\n");
								printf("Longitude: ");	
								setCursor(15,6);
								for (j=indices[4];j<(indices[4+1]-1);j++){
									printf("%c",toascii(linea[j+1])); 
									oled_write(linea[j+1]);
								}
								printf("\n");
								break; 
							default:break;
						}
					}
					printf("---------------\n");
				}
				conta=0;                    
				for (i=0;i<300;i++){    	
				linea[i]=' ';             
				}                 
			}
		}
 	}
}

Then use the following command to compile the short code to make it an executable file and execute it – as it is only a DEMO, the dynamic link library used here is testable. In the official version of ITEAD OS, you cannot copy it directly and get it running, yet we will provide an easier way to compile so that you do not need to consider about all the dynamic link libraries and dependencies. After running, we can see the latitude and longitude – if there is no antenna connected or no GPS signal, it will only display two rows of texts instead of showing the specific latitude and longitude data.

gcc gps.c oled_test_1106.c font.c -o test -lcci2c -liteadIO -ldl