windows iot serial communication

ALFREDO LANDERO SANCHEZ 1 Reputation point
2022-08-15T18:45:48.967+00:00

I am working with windows 10 iot and raspberry pi 2 mode B. I need to make a serial communication between my raspberry and an arduino. This is possible? do you have any example please?

Windows for IoT
Windows for IoT
A family of Microsoft operating systems designed for use in Internet of Things (IoT) devices.
382 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,525 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sander van de Velde 28,236 Reputation points MVP
    2022-08-16T06:40:43.743+00:00

    Hello @ALFREDO LANDERO SANCHEZ ,

    For IoT, reading data over a serial connection and sending that to the cloud is another protocol.

    This is also the case with Linux.

    First, check if your serial device is accessible in the /dev folder.

    Try to read the data from that serial port depending on your programming language. (eg. in .Net core (C#), check out the serial port class)

    If you want to use Azure IoT Edge, this open-source project on GitHub is a good starting point.

    There, you will notice you have to give the Docker container to the serial port (because Docker containers are sandboxed by default)

    0 comments No comments

  2. Sean Liming 4,511 Reputation points
    2022-08-16T16:12:14.23+00:00

    You can use the Windows.Devices.SerialCommunication name space in your application to create serial communication. Here some code to send a message:

            string aqs = SerialDevice.GetDeviceSelector("UART1");  
            DeviceInformationCollection deviceInfo = await DeviceInformation.FindAllAsync(aqs);  
            SerialDevice myCom1 = await SerialDevice.FromIdAsync(deviceInfo[0].Id);  
            myCom1.BaudRate = 9600;  
            myCom1.DataBits = 8;  
            myCom1.Parity = SerialParity.None;  
            myCom1.StopBits = SerialStopBitCount.One;  
            myCom1.Handshake = SerialHandshake.None;  
    
             DataWriter dataWriter = new DataWriter(myCom1.OutputStream);  
             dataWriter.WriteBytes(<your message>);
    
    0 comments No comments