Skip to main content

Project Based Engineering Instrumentation High Level Coding and Microcontrollers

Chapter 12 Logging with Serial - Method 6

List 12.0.1. Parts List
  1. USB Cable
  2. Computer with Python installed
  3. CircuitPlayground Express or Bluefruit
List 12.0.2. Learning Objectives
  1. Understand how to use serial communication to log data from a microcontroller
  2. Learn to read and interpret serial data in Python
  3. Create a simple data logging script using the serial library
Method 6 is another "automatic" way to log data from your microcontroller. This method uses the serial library in Python to read data sent from your CircuitPlayground Express or Bluefruit. The idea is to have the Circuit Playground send data via USB to your laptop just like the REPL in Mu but instead of just viewing the output in Mu a Python script on a laptop can read and process the data. Serial communication is a fundamental method for microcontrollers to send data to a computer. In this chapter, we will explore how to use the serial library in Python to read data from your CircuitPlayground Express or Bluefruit. This method allows you to log data in real-time and can be a powerful tool for data acquisition and analysis. The code on the CPX/CPB is the same button press code used for the last few chapters and again can be found on Github. The code itself is discussed in detail in Chapter ChapterΒ 9.