Posts tagged: MikroC

Using a GPS Click on a Raspberry Pi

By , January 22, 2014 12:21 pm
The Raspberry Pi and the GPS Click

The Raspberry Pi and the GPS Click

About the Script

gps2udp is a script that connects a MikroElektronika GPS click board via USB to a Raspberry PI. The serial GPS data is pushed out through a UDP socket onto the network interface. The GPS is set to run at 115200 baud using the stty command.

Download

You can download the gps2udp script here: rpi_gps_click_to_udp.zip

Installation

Step 1. Install the supporting serial libraries on the Raspberry Pi:

sudo apt-get install setserial netcat screen

Step 2. Copy the script gps2udp.sh to your raspberry pi.

Step 3. Change the permissions on the gps2udp.sh script so it will run.

chmod 777 gps2udp.sh

Step 4. Start the script from the command prompt.

./gps2udp.sh

Running the gps2udp.sh Script

Running the gps2udp.sh Script

If you want you could make this script a startup item.

Connecting to the UDP socket

Once you have started the gps2dps.sh script on the Raspberry Pi you can connect to the gps datastream using a UDP socket from any computer on your network.

Viewing UDP data in mikroC

The easiest way to view a UDP datastream is to use the mikroC UDP terminal program. It is found in the Tools > UDP Terminal menu.

Open the Tools Menu and start the UDP terminal.

Open the Tools Menu and start the UDP terminal.

Start by typing in the ip address for the raspberry pi. In my case this is 192.168.1.137

Enter the port 36700 for the UDP connection.

To start the connection you need to send a bit of data over the UDP socket. Type "1" in the send text field and click the "send" button. GPS data should start flowing into the receive window.

You can connect to the Raspberry Pi using the UDP terminal.

You can connect to the Raspberry Pi using the UDP terminal.

Linux/Mac/Cygwin Command Line

You can also connect to the Raspberry PI hosted GPS click from your desktop system with a tool called netcat. Tip: You need to have the full-featured version of nc / netcat installed that supports UDP connections.

Viewing UDP from the terminal

Viewing UDP from the terminal

My Raspberry Pi has an ip address of 192.168.1.137 and the UDP port is 36700.

To start the desktop connection to the Raspberry Pi hosted GPS click open the terminal and type in:

netcat -u 192.168.1.137 36700

or

nc -u 192.168.1.137 36700

Once the connection has been made you need to press the enter key once to start the UDP data flowing. When you are done you can close the network connection on the desktop by pressing Control-C.

Source Code

Here is the source code for the gps2udp.sh bash script. The USB serial port for the GPS Click board is known as /dev/ttyACM0.

 

flattr this!

Mikromedia Fan Control Project

By , November 16, 2013 6:20 pm

This weekend I put together a fan control project with a Mikromedia Workstation PIC32 development board, a DS1820 one wire temperature sensor, and a darlington solid state transistor.

The project is powered using a PIC32 microcontroller that reads the temperature sensor and updates the TFT display. When the ambient temperature in the room is over 26 degrees centigrade the PIC32 microcontroller turns on the fan.

The serial port makes it easy to monitor the temperature.

The serial port makes it easy to monitor the temperature.

The microcontroller also outputs the current temperature and fan state using the PIC32 chip's serial port. This serial data can be read on a laptop using the Mikromedia Workstation V7 board's built in USB FTDI serial chip.

flattr this!