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

SoftwareSerial library needed/equivalent in Netduino


  • Please log in to reply
10 replies to this topic

#1 riotgibbon

riotgibbon

    New Member

  • Members
  • Pip
  • 8 posts

Posted 13 February 2011 - 06:03 PM

Hi there, I didn't get any responses at all (not even a "dunno") for my first ever question here, so I'll try it another way for the project I got my new NetduinoPlus board for (attaching a CurrentCost energy meter), I can see that when somebody did the same thing on an Arduino, they needed the SoftwareSerial library to access the input - I'm guessing it's a serial port format. As I'm a complete newcomer to this, could anyone please tell me whether this is something that is inherently handled by Netduino, or there's something else appropriate? I'd really appreciate it if someone could give me a clue about this, as I'm completely new here, and heard great things about the helpfulness of the Netduino community in getting people started Project I want to implement in Netduino: http://e.inste.in/20...-to-an-arduino/ Required library: http://www.arduino.c.../SoftwareSerial cheers Toby

#2 Chris Seto

Chris Seto

    Advanced Member

  • Members
  • PipPipPip
  • 405 posts

Posted 13 February 2011 - 06:18 PM

You could make a software serial port with some native code, but that's NOT needed here. In fact, soft serial is not related to this topic in really any way, because the Netduino had hardware serial, and unless you use up all the hardware serail ports, there isn't any reason to use a software "bit bang'd" serial port. Digital pin 0 on the netduino is RX. That's where the TX from your device will connect. Digital pin 1 on the netduino is TX, That's where the RX from your device will connect. Both devices will need to be grounded together.

#3 KodeDaemon

KodeDaemon

    Advanced Member

  • Members
  • PipPipPip
  • 63 posts

Posted 13 February 2011 - 06:19 PM

The Netduino does have two built in UARTs for you to use. As far as using any digital pin for serial I don't believe there is a library for that yet.

#4 riotgibbon

riotgibbon

    New Member

  • Members
  • Pip
  • 8 posts

Posted 13 February 2011 - 06:32 PM

You could make a software serial port with some native code, but that's NOT needed here. In fact, soft serial is not related to this topic in really any way, because the Netduino had hardware serial, and unless you use up all the hardware serail ports, there isn't any reason to use a software "bit bang'd" serial port.

Digital pin 0 on the netduino is RX. That's where the TX from your device will connect.
Digital pin 1 on the netduino is TX, That's where the RX from your device will connect.
Both devices will need to be grounded together.



great stuff, so if I attach the energy monitor to those pins, there's something in the .net micro framework I can use to read the input? An xml file/stream gets sent every 6 seconds from the CurrentCost, so when I've done this on a PC, I've set a .net SerialPort object - http://msdn.microsof...serialport.aspx - to the relevant port, and set up an event handler to catch the input. The parsing after that, I've no problem with

thanks for replying, I'm totally new to Netduino & pretty excited about what it can offer

Is this the relevant class then: http://msdn.microsof...y/dd170258.aspx ?

thanks

Toby

#5 KodeDaemon

KodeDaemon

    Advanced Member

  • Members
  • PipPipPip
  • 63 posts

Posted 13 February 2011 - 06:43 PM

There is a SerialPort class in NetMF as well.

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 13 February 2011 - 11:55 PM

Is this the relevant class then: http://msdn.microsof...y/dd170258.aspx ?


Yes, that's it! You can use COM1 (pins d0/d1) or COM2 (pins d2/d3). If you need serial comm on another port, then you'll need a "software serial" driver. But from what I've seen, a lot of "software serial" use on Arduino is on pins 2/3.

Chris

#7 Illishar

Illishar

    Advanced Member

  • Members
  • PipPipPip
  • 146 posts

Posted 14 February 2011 - 07:48 AM

There might be a 3rd uart as well, on the Netduino. (Since the COM1 is actually the dbgu.) Might not be exposed though.

#8 SirPoonga

SirPoonga

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts

Posted 16 February 2011 - 10:26 PM

How is the usb port connected? The software serial everyone uses on the Arduino is the NewSoftSerial library. http://arduiniana.or.../newsoftserial/ There are several reasons people use this, for example: 1) Need more than on serial port, the Arduino only has on - pins 0 and 1. Let's say you want to use a GPS module and a Cellular module at the same time. 2) They want to debug while working with a serial device - So Serial.print("debug info") in code and connect with terminal software to figure out what is going on. So, on the Netduino does the usb use the same uart as pins 0 and 1? For debugging? If so then if you wanted to connect a GPS module and Cellular module how would you debug it?

#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 16 February 2011 - 10:30 PM

Hi SirPoonga, The USB on the Netduino is a true USB device port on the microcontroller itself. It's completely separate from the two serial ports. If you use Debug.Print(...) in your code, it will send the message via a high-speed USB connection to the PC (which you can then view while debugging in Visual Studio...or by connecting to your device in MFDeploy). The Netduino has two serial ports exposed on pins D0/D1 (COM1) and D2/D3 (COM2). You can use both serial ports and send debug info to the PC at the same time. Chris

#10 SirPoonga

SirPoonga

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts

Posted 16 February 2011 - 10:54 PM

Ok, so if for some reason you wanted to use 3 serial devices that wouldn't work out so well - or get multiple netduinos.

#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 16 February 2011 - 11:33 PM

Ok, so if for some reason you wanted to use 3 serial devices that wouldn't work out so well - or get multiple netduinos.


If you want to use 3 serial devices, you have a few options:
1. Use a SPI->UART adapter
2. Build a "soft serial" library in native code
3. Buy an extra Netduino, start building a super-microcontroller-computer with lots of serial ports :)

Chris




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.