Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

bytepoet

Member Since 28 Aug 2011
Offline Last Active Jul 14 2012 02:01 AM
-----

Topics I've Started

GPS shield odd results. Novice user.

13 July 2012 - 12:27 AM

using hardware:
Netduino Plus (SolutionReleaseInfo.solutionVersion: 4.1.0.6)
Adafruit GPS Shield
EM-406A GPS Module

using System;
using System.IO.Ports;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace GpsLogger
{
    public class Program
    {
        public static void Main()
        {
            // write your code here
            SerialPort serialPort = new SerialPort("COM1", 4800, Parity.None, 8, StopBits.One);
            serialPort.Open();

            // pin D2 off = gps module turned on
            Debug.Print("Turning on the GPS");
            Thread.Sleep(1000);
            OutputPort powerPin = new OutputPort(Pins.GPIO_PIN_D2, false);

            while (true)
            {
                int bytesToRead = serialPort.BytesToRead;
                if (bytesToRead > 0)
                {   
                    // get the waiting data
                    byte[] buffer = new byte[bytesToRead];
                    //serialPort.Read(buffer, 0, buffer.Length);
                    serialPort.Read(buffer, 0, buffer.Length);
                    // print out our received data
                    Debug.Print("bytestoread is " + bytesToRead.ToString());
                      Debug.Print(new string(System.Text.Encoding.UTF8.GetChars(buffer)));

                }

                Thread.Sleep(500); // wait a bit so we get a few bytes at a time...
            }
        }
    }
}

As soon as i turn on the Netduino Plus, i get a red light on the actual GPS module itsself, along with a white light near the micro gps unit.


When i read the output of the above code, i get the following:
Turning on the GPS
bytestoread is 24
<null>
bytestoread is 11
<null>
bytestoread is 13
<null>
bytestoread is 7
<null>
bytestoread is 13
<null>
bytestoread is 3
<null>
bytestoread is 7
<null>
etc....

so there's characters in there, and i'm not sure how to get them to display.

I have three wires D0(tx), D1(rx), D2(power-on/off) connected.


questions:
1. Is the code proper for an adafruit GPS shield?
2. Is there a reason i get <null> but i can see there's bytes to read?
3. Is there a 100% complete schematic to show all of the wires that should be soldered in the digital IO area?

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.