‘Hello, world!’

In this sample, we will create and deploy the proverbial 1st app, “Hello, world!” to any device running Windows 10 IoT Core.

NOTE

While deploying and running a Python UWP app is supported on Windows 10 IoT Core, debugging is currently a known issue for Windows 10 IoT Fall Creators Update (Build 16299) and Visual Studio 2017. We are looking into fixing this in a future release of Windows 10 IoT Core.

Set up your PC

  • Follow the instructions here to setup your device and PC.

  • Install Python for Windows (3.*) from http://www.python.org/downloads

  • Download and install PTVS (Python Tools for Visual Studio) VS 2015 latest release from here.

  • In VS 2017 use Visual Studio Installer to ensure that you have Python IoT support installed.

  • Download and install the latest Python UWP SDK (pyuwpsdk.vsix) release from here.

Create new Python project

  • Create new project based on Template > Python > Windows 10 IoT Core > Background Application (IoT)

Output Hello World!

Modify StartupTask.py like this

print("Hello, World from IoT!")

Deploy Python app to your Windows 10 IoT Core device

  • Follow the instructions to setup remote debugging and deploy the app.

    NOTE: For now, use device name in lieu of IP address. If the device name is not unique, use setcomputername tool on the device to reset the device name and reboot. Documentation for this can be found here

  • The Python app will deploy and start on the device.

    NOTE: Launching the debugger for Python can take a few minutes to connect and start debugging the remote Python. If it takes more than a few minutes, there may be a problem with msvsmon on the remote device. Please check the FAQ for any potential fixes/workarounds.

  • The ‘Hello, World from IoT!’ message will be displayed in the output window of Visual Studio. Open the output window by Debug > Window > Output.

Use Windows Devices from Python (e.g. GPIO, I2C, SPI)

  • Right-click on the References node in the Python project

  • Click Add Reference…

  • Click on Browse tab

  • Download pywindevices content from here

  • Navigate to ARM for RPi2 or RPi3 or win32 for MBM

  • Select the PYD file for the device type and configuration you want to use (e.g. _wingpio_d.pyd if a Debug configuration and _wingpio.pyd for a Release configuration)

  • Add import _wingpio as gpio to your StartupTask.py

  • Start using gpio functions (similar steps for I2C or SPI)

  • WinDevices documentation can be found here

Questions/Suggestions

Please refer to the FAQ for issues.


Was this page helpful?
Additional feedback?
Thank you! We appreciate your feedback.
Follow us