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.
Photo

Sm5100B-D + Netduino Plus


  • Please log in to reply
1 reply to this topic

#1 J-zY

J-zY

    New Member

  • Members
  • Pip
  • 1 posts

Posted 24 September 2011 - 09:38 AM

Hello everyone,

For the last week i've been trying to get this http://www.sparkfun.com/products/9607 shield working. This is my code:
   public static void Main()
        {
            // write your code here
            SerialPort serialPort = new SerialPort(SerialPorts.COM2, 9600);

            serialPort.Open();

            while (true)
            {

                int bytesToRead = serialPort.BytesToRead;

                if (bytesToRead > 0)
                {
                    // get the waiting data

                    byte[] buffer = new byte[bytesToRead];

                    serialPort.Read(buffer, 0, buffer.Length);

                    // print out our received data

                    Debug.Print(new String(System.Text.Encoding.UTF8.GetChars(buffer)));

                }



                Thread.Sleep(100); 
            }

        }
I'm powering it with 9v external power and it turns on and I can call it, but it wont print anything. The netduino doesn't reveive any data.

Can somebody tell me what I'm doing wrong? :)

Edited by Stefan, 24 September 2011 - 12:22 PM.
Added [code]-tags


#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 24 September 2011 - 02:12 PM

Welcome J-zY...usernames always more complex...

You missed to add some info about your experiment. For instance, how did you wire the shield to your Netduino: that is important. Since you declared to use the COM2, you should have used the I/Os number 2 and 3.

Moreover, your program is always reading for incoming data. But what kind of data are your expecting?
If you take a look at the shield application example (sketch), it act a trivial loopback by writing a byte and listening for it. However, that is much like making a short across the I/Os, and nothing more.

If you want to make something funnier, you should try to send AT commands to the shield.
The very first command I would post is:
ATV1E0
(followed by a CR)
This turns on the Verbose mode, and turns off the Echo (i.e. the loopback).

Try these basic steps, then turn to something more complex.
Cheers
Biggest fault of Netduino? It runs by electricity.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.