Skip to main content

Codi:bit MicroPython API documentation

πŸ“š Documentation Structure​

This documentation is organized using the DiΓ‘taxis framework, which provides four types of documentation for effective technical writing:

🎯 Tutorials​

Purpose: Learning - Complete learning paths that users can follow from start to finish

  • Getting Started: Introduction to Codi:bit, first program, basic concepts
  • Basic Projects: LED control, button handling, display usage
  • Sensor Projects: Light detection, sound sensing, environment monitoring
  • Advanced Projects: Multi-sensor applications, interactive projects

πŸ”§ How-to Guides​

Purpose: Tasks - Specific methods for performing particular tasks

πŸ“– Reference​

Purpose: Information - API and technical details

  • Built-in Sensors API: Complete API documentation for all built-in sensors
  • Hardware Reference: Pin assignments, specifications, power management
  • System Reference: MicroPython and ESP32 related information

πŸ“š Explanation​

Purpose: Understanding - Concepts and background knowledge

  • Concepts: Sensor principles, communication protocols, programming concepts
  • Architecture: Library structure, hardware architecture, performance optimization
  • Education: Educational philosophy, STEM education

πŸš€ Getting Started​

Quick Start​

from codibit import *

# Display text
display.draw_text("Hello Codi:bit!", 0, 0)
display.show()

# Read button state
if button_a.is_pressed():
print("Button A is pressed!")

# Read light sensor
light_level = light.read_level()
print(f"Light level: {light_level}")

# Read microphone
sound_level = microphone.get_level()
print(f"Sound level: {sound_level}")

Hardware Overview​

Codi:bit is an ESP32-based educational microcontroller board with:

  • Display: SH1106 OLED (128x64 pixels)
  • Sensors:
    • MMC5603NJ magnetometer
    • QMI8658C 6-axis IMU (accelerometer, gyroscope)
    • ALS-PT19 light sensor
    • Microphone sensor
  • I/O:
    • WS2812B RGB LED
    • Buzzer
    • 2 buttons (A and B)
  • Connectivity: WiFi, Bluetooth

πŸ“ Documentation Sections​

Tutorials (Learning)​

  • Getting Started: Hardware introduction and first program
  • Basic Projects: LED blinking, button response, display usage
  • Sensor Projects: Light detection, sound sensing, environment monitoring
  • Advanced Projects: Multi-sensor applications, interactive projects

How-to Guides (Tasks)​

Reference (Information)​

  • Built-in Sensors API: Complete API documentation for all sensors
  • Hardware Reference: Pin mappings and specifications
  • System Reference: MicroPython and ESP32 details

Explanation (Understanding)​

  • Concepts: Sensor principles and programming concepts
  • Architecture: Library design and hardware architecture
  • Education: Educational approach and STEM learning

🎯 Learning Path​

For Beginners​

  1. Start with Getting Started
  2. Learn Button Usage for user input
  3. Explore Light Change Detection for sensor usage
  4. Try Microphone Usage for sound detection

For Developers​

  1. Check Built-in Sensors API for function details
  2. Review hardware specifications for pin assignments
  3. Understand library architecture for system design

For Educators​

  1. Read educational philosophy and STEM concepts
  2. Explore tutorials for classroom activities
  3. Use examples for hands-on learning

πŸ“š Code Examples​

Button Example​

from codibit import *
import time

while True:
if button_a.is_pressed():
print("Button A pressed!")
if button_b.is_pressed():
print("Button B pressed!")
time.sleep(0.1)

Light Sensor Example​

from codibit import *
import time

while True:
level = light.read_level()
print(f"Light level: {level}")
time.sleep(1)

Microphone Example​

from codibit import *
import time

while True:
if microphone.is_loud():
print("Loud sound detected!")
time.sleep(0.1)

πŸ“š Additional Resources​


Start Learning: Begin with Getting Started to learn about Codi:bit hardware and create your first program!