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.

Tinymacrocosm

Member Since 04 Oct 2014
Offline Last Active Dec 16 2014 09:00 PM
-----

#60659 Bytes sent over SerialPort not the same when received on Netduino over Bluetooth

Posted by Tinymacrocosm on 07 November 2014 - 06:15 PM

Could you explain your solution a bit more? did u just add a jumper between pin 0 and pin1?

 

Sure. No jumpers were used. This line of code on the Netduino:

Bluetooth = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One);

makes Pin0 and Pin1 defined for serial usage. Pin1 becomes the TX pin (send data) and Pin0 becomes the RX pin (receive data). I needed to connect them to the opposite corresponding pin on the Bluetooth.

 

Netduinotojy-mcubluetoothconnection_zps3

(VCC goes to 5V and GND goes to ground - I'm omitting it in the drawing to just focus on what i changed)

 

The Netduino's send data has to be processed by the Bluetooth's receive data. The Bluetooth's send data has to be processed by the Netduino's receive data.

 

When I connected the RX to the RX and the TX to the TX, I was getting garbage data when it was sent, very similar to yours, with values like 6, 0, 0, 248 regardless of what i sent.




#60544 Bytes sent over SerialPort not the same when received on Netduino over Bluetooth

Posted by Tinymacrocosm on 25 October 2014 - 10:10 PM

I am working on a project and I am using this website as a reference to get my Netduino to communicate with my PC.

I've purchased this Bluetooth transceiver. It seems to be an updated version of the one used by the original post. 1.06 vs 1.04 on his website.

 

I set the Bluetooth's TXD to Pin0, RXD to Pin1, and VCC to 5V.

 

This is my code on the Netduino:

static SerialPort Bluetooth;

public static void Main()
{
    Bluetooth = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One);
    Bluetooth.DataReceived += new SerialDataReceivedEventHandler(Bluetooth_DataReceived);

    Bluetooth.Open();

    Thread.Sleep(Timeout.Infinite);
}

static void Bluetooth_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    byte[] bytes = new byte[1];

    while(Bluetooth.BytesToRead > 0)
    {
        Bluetooth.Read(bytes, 0, bytes.Length);
        Debug.Print(bytes[0].ToString());
    }
}

This is my code on my laptop: (it is a WPF application)

SerialPort serialBT;

private void Connect()
{
    // COM7 is the outgoing port that corresponds to the Bluetooth transceiver
    serialBT = new SerialPort("COM7", 9600, Parity.None, 8, StopBits.One);
    serialBT.Open();

    serialBT.Write(new byte[] { 23, 24, 25, 26 }, 0, 4);
    Debug.Print("Values sent");
}

On the Netduino, when I send the byte array of 23, 24, 25, and 26 (just for testing purposes), the DataReceived event fires. However the values it received and prints out in the debug window are 6, 0, 0, and 248 instead of the 23, 24, 25, and 26 that it should be.

 

Other values I send are also just as mysteriously transformed to completely different ones.

 

I've tripled checked the proper COM settings for the Bluetooth transceiver and those are the correct settings. I've flipped the TXD and RXD pins since the original Arduino expects TXD to be Pin1 and RXD to be Pin0, but that causes no data to be received on the Netduino.

 

Using COM2 and Pin2 and Pin3 yield different values. Instead, I get 0,16,16, and 16.




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.