Skip to content

Receiving and sending data between a computer and a microcontroller with MicroPython or CiruitPython via USB

License

Notifications You must be signed in to change notification settings

chris-reichl/PC_to_Python-Microcontroller_via_USB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


PC to MicroPython / CircuitPython via USB

About The Project

For a project I had to exchange data between my computer and a MicroPython microcontroller via USB connection. There are many examples for receiving data from the microcontroller, but only a few examples for sending data from the computer to the microcontroller.

For this reason I wrote a Python and Node.js program myself, which exchanges data with a Raspberry Pi Pico and lights up the microcontroller's built-in LED.

Thus, data can be exchanged between on the PC with Python or Node.js and on the microcontroller with MicroPython or CircuitPython.

MicroPython:

  • Node.js <----> MicroPython
  • Python <----> MicroPython

CircuitPython:

  • Node.js <----> CircuitPython
  • Python <----> CircuitPython

Prepear the Microcontroller

Load the script from the MicroPython folder to a microcontroller running MicroPython or if you want to use CircuitPython then load the script from the CircuitPython folder on a microcontroller with CircuitPython.

I have developed the script with a Raspberry Pi Pico. But it is also compatible for other MicroPython / CircuitPython compatible controllers. You may have to change the LED pin number.

Node.js <----> MicroPython/CircuitPython

Sending and receiving data between a Node.js application and a MicroPython or CircuitPython microcontroller.

Installation

  1. Install Node.js
  2. Clone the repo
    git clone https://github.com/chrissreichl/PC_to_MicroPython_via_USB.git
  3. Install serialport package
    npm i serialport
  4. Connect the microcontroller via USB to your computer.
  5. Search the COM port number of the microcontroller in your device manager.
  6. Adjust the COM port number in the main.js sample script if necessary.
  7. Start the main.js script in your terminal
    node main.js

Now the LED of the microcontroller should light up for 2 seconds and you should see an output in the terminal. Congratulations, you have successfully sent commands via USB to the MicroPython/CircuitPython microcontroller!

(back to top)

Python <----> MicroPython/CircuitPython

Sending and receiving data between a Python application and a MicroPython or CircuitPython microcontroller

Installation

  1. Install Python
  2. Clone the repo
    git clone https://github.com/chrissreichl/PC_to_MicroPython_via_USB.git
  3. Install pyserial
    pip install pyserial
  4. Connect the microcontroller via USB to your computer.
  5. Search the COM port number of the microcontroller in your device manager.
  6. Adjust the COM port number in the main.py sample script if necessary.
  7. Start the main.py script in your terminal
    python main.py

Now the LED of the microcontroller should light up for 2 seconds and you should see an output in the terminal. Congratulations, you have successfully sent commands via USB to the MicroPython/CircuitPython microcontroller!

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

About

Receiving and sending data between a computer and a microcontroller with MicroPython or CiruitPython via USB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published