Aula 💡🕊️
Published © MIT

Using Raspberry Pi with Hexabitz GNSS Module

This project aims to GNSS data transfer and display by integrating a GNSS module and an Ethernet module.

IntermediateWork in progress2 hours163
Using Raspberry Pi with Hexabitz GNSS Module

Things used in this project

Story

Read more

Schematics

Hexabitz Array Block Diagram

Block Diagram

Code

H1FR5x-main code

C/C++
/*
 BitzOS (BOS) V0.2.9 - Copyright (C) 2017-2023 Hexabitz
 All rights reserved

 File Name     : main.c
 Description   : Main program body.
 */
/* Includes ------------------------------------------------------------------*/
#include "BOS.h"
#include "SAM_M8Q.h"
/* Private variables ---------------------------------------------------------*/

/* Private function prototypes -----------------------------------------------*/

/* Main function ------------------------------------------------------------*/
float longdegree, latdegree, speedknot, speedkm;
char longindicator,latindicator;
uint8_t hours, min, sec;
char data_to_send[10];
char data_to_send1[16];
float height;
int main(void){

	Module_Init();		//Initialize Module &  BitzOS

	//Don't place your code here.
	for(;;){

		}
}

/*-----------------------------------------------------------*/

/* User Task */
void UserTask(void *argument){


	// put your code here, to run repeatedly.
	while(1){

		GPSHandel();
		GetPosition(&longdegree, &latdegree, &longindicator, &latindicator);
		//	GetUTC();
		GetSpeed(&speedknot, &speedkm);
		GetHeight(&height);



	sprintf(data_to_send," - Latitude: %d.%d\n",latdegree);

						messageParams[0] = 8; //length
						memcpy(&messageParams[1],&data_to_send,8);
						SendMessageToModule(2,CODE_H1DR5_Ethernet_Send_Data,9);
						Delay_ms(20);
						IND_blink(50);

	sprintf(data_to_send," - Longitude: %d.%d\n",longdegree);

						messageParams[0] = 8; //length
						memcpy(&messageParams[1],&data_to_send,8);
						SendMessageToModule(2,CODE_H1DR5_Ethernet_Send_Data,9);
						Delay_ms(20);
						IND_blink(50);
	sprintf(data_to_send1," - Speed in km/h: %d.%06d\n",speedkm);

						messageParams[0] = 8; //length
						memcpy(&messageParams[1],&data_to_send1,8);
						SendMessageToModule(2,CODE_H1DR5_Ethernet_Send_Data,9);
						Delay_ms(20);
						IND_blink(50);

	sprintf(data_to_send1," - UTC Time: %02d.%02d.%02d:%02d\n",hours, min, sec);

						messageParams[0] = 8; //length
						memcpy(&messageParams[1],&data_to_send1,8);
						SendMessageToModule(2,CODE_H1DR5_Ethernet_Send_Data,9);
						Delay_ms(20);
						IND_blink(50);

	}
}

/*-----------------------------------------------------------*/

H1DR5x-main code

C/C++
/*
 BitzOS (BOS) V0.2.9 - Copyright (C) 2017-2023 Hexabitz
 All rights reserved

 File Name     : main.c
 Description   : Main program body.
 */
/* Includes ------------------------------------------------------------------*/
#include "BOS.h"


/* Private variables ---------------------------------------------------------*/
    uint8_t myGateway[4]={192,168,1,100};
	uint8_t mySubnet[4]={255,255,255,0};
	uint8_t myIP[4]={192,168,1,101};
	uint8_t Mac_addres[6]={0x07,0x6,0x2,0x3,0x4,0x5};

/* Private function prototypes -----------------------------------------------*/
	//uint8_t Mac_addres[6]={0xb8,0x27,0xeb,0xfd,0x80,0x64};

/* Main function ------------------------------------------------------------*/

int main(void){
	Set_Local_mac_addr(Mac_addres); // Mac_addr ethernet

	Module_Init();		//Initialize Module &  BitzOS

	//Don't place your code here.
	for(;;){}
}

/*-----------------------------------------------------------*/

/* User Task */
void UserTask(void *argument){
	Set_Local_IP(myIP);  // ip ethernet
	Set_SubnetMask(mySubnet);	// SubnetMask laptop
	Set_Remote_IP(myGateway); //ip laptop
	Set_Local_PORT(35);// port ethernet
	Set_Remote_PORT(34);//port laptop
    Set_reseve_mac_and_ip_Remote();

	// Defalt_Value();
		// put your code here, to run repeatedly.
	while(1){


	}
}

/*-----------------------------------------------------------*/

topology.h

C Header File
/*
 BitzOS (BOS) V0.2.9 - Copyright (C) 2017-2023 Hexabitz
 All rights reserved

 File Name     : topology.h
 Description   : Array topology definition.

 */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __topology_H
#define __topology_H
#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32g0xx_hal.h"

#define __N	2					// Number of array modules

// Array modules
#define _mod1	1<<3
#define _mod2	2<<3

// Topology
static uint16_t array[__N ][7] ={
	{_H1FR5,  0, 0, _mod2 | P5, 0, 0, 0}, 								 // Module 1
	{_H1DR5,0, 0,0, 0, _mod1 | P3, 0},					    			 // Module 2
};

// Configurations for duplex serial ports
#if ( _module == 1 )
	#define	H1FR5	1
	#define	_P1pol_normal	1
	#define	_P2pol_normal	1
	#define	_P3pol_normal	1
	#define	_P4pol_normal	1
	#define	_P5pol_normal	1
	#define	_P6pol_normal	1
#endif

#if ( _module == 2 )
	#define	H1DR5			1
	#define	_P1pol_normal	1
	#define	_P2pol_normal	1
	#define	_P3pol_normal	1
	#define	_P4pol_normal	1
	#define	_P5pol_reversed	1
	#define	_P6pol_normal	1

#endif


#ifdef __cplusplus
}
#endif
#endif /*__ topology_H */

/************************ (C) COPYRIGHT HEXABITZ *****END OF FILE****/

Test code to receive UDP messages in Python 3

Python
import socket
UDP_IP = "198.1.168.100"
UDP_PORT = 34

sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
while True:
    data, addr = sock.recvfrom(1024) 
    print("received message: %s" % data)

GUI Test

Python
import tkinter as tk
# Create GUI window
root = tk.Tk()
root.title('Hexabitz GNSS Data')
root.geometry('800x300')
root.config(bg= "whitesmoke")   
# Create labels to display data
q_label = tk.Label(root, text='Using Raspberry Pi with Hexabitz GNSS Module',fg="deeppink",bg="whitesmoke", font=('Trebuchet MS', 22, 'bold'))
utc_label = tk.Label(root, text='UTC: ',fg="navy", font=('Trebuchet MS', 36, 'bold'))
lat_label = tk.Label(root, text='Latitude: ',fg="gold", font=("Helvetica", 36, 'bold'))
lon_label = tk.Label(root, text='Longitude: ',fg="dark green", font=("Helvetica", 36, 'bold'))
Speed_label = tk.Label(root, text='Speed: ',fg="limegreen", font=("Helvetica", 36, 'bold'))
# Position labels in window
q_label.pack()
utc_label.pack()
lat_label.pack()
lon_label.pack()
Speed_label.pack()

# Function to update labels with new data
def update_data():
    # Read data from GNSS module  
    # Update labels with new data
    utc_label.config(text='UTC: ' + str(12.00), fg="navy",bg="whitesmoke", font=('Trebuchet MS', 36, 'bold'))
    lat_label.config(text='Latitude: ' + str(00),fg="gold",bg="whitesmoke", font=("Helvetica", 36, 'bold'))
    lon_label.config(text='Longitude: ' + str(00),fg="dark green",bg="whitesmoke", font=("Helvetica", 36, 'bold'))
    Speed_label.config(text='Speed: ' + str(00),fg="limegreen",bg="whitesmoke", font=("Helvetica", 36, 'bold'))
    # Schedule next update in 1 second
    root.after(1000, update_data)

# Start updating labels with new data
update_data()

# Start GUI main loop
root.mainloop()

topology.h

H1FR5x-Firmware

Credits

Aula 💡🕊️
60 projects • 224 followers
Electronic Engineering
Contact

Comments

Please log in or sign up to comment.