Skip to content

Add SCD40 sensor support#1746

Open
lkoehl wants to merge 1 commit into
OpenRoberta:developfrom
lkoehl:SCD40
Open

Add SCD40 sensor support#1746
lkoehl wants to merge 1 commit into
OpenRoberta:developfrom
lkoehl:SCD40

Conversation

@lkoehl
Copy link
Copy Markdown

@lkoehl lkoehl commented May 29, 2026

Description

Integrates SCD40 CO2, temperature, and humidity sensor support for Calliope targets.

This change adds a new Scd40Sensor AST node, transformer visitor support, SC constants, CO2 mode handling, and AstFactory registration. It also wires the sensor into RobotMbed configuration, validation, code generation, Blockly blocks, messages, and toolbox entries so the SCD40 is available in the frontend for Calliope and Calliope V3.

The Calliope C++ generator and Calliope V3 Python generator now emit SCD40 read logic for CO2, temperature, and humidity. The Calliope V3 helper initializes the external I2C bus for the A0 Grove connector and handles I2C read errors without crashing the user program.

Cross-compiler coverage was added via a new Calliope test program and expected AST, collector, C++, and Python outputs.

Fixes issue #1243

Dependencies:
None. Runtime use requires an SCD40 sensor connected to the Calliope Grove A0/I2C connector.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

The following checks were run locally:

node --check OpenRobertaServer/staticResources/blockly/blockly_compressed.js
python3 -m py_compile OpenRobertaServer/src/test/resources/crossCompilerTests/_expected/robotSpecific/targetLanguage/calliopev3/sensor_scd40.py
git diff --check
mvn -pl RobotMbed -am -DskipTests compile
mvn -pl OpenRobertaServer -am -DfailIfNoTests=false -Dtest=TestToolboxBlocksAreUsedInTestFiles test
mvn -pl OpenRobertaServer -am -DfailIfNoTests=false -DargLine='--add-opens java.base/java.lang=ALL-UNNAMED' -Dtest=ReuseIntegrationAsUnitTest#testAllRobotSpecificProgramsAsUnitTests test

Manual runtime check: Generated and flashed a Calliope V3 Python program using the SCD40 CO2 sensor block. Serial output was used to inspect runtime behavior.

Test Configuration:

  • Firmware version: MicroPython b7ce7a8 on 2024-11-05; Calliope mini v2.1.2b with nRF52833
  • Hardware: Calliope mini v2.1.2b, SCD40 sensor on Grove A0/I2C
  • Toolchain: Maven, Java, Node.js, Python 3
  • SDK: Open Roberta Calliope C++/MicroPython code generation
  • OS: macOS

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Integrate SCD40 CO2/temperature/humidity sensor support across the project. Adds a new Scd40Sensor AST node and transformer visitor, updates SC constants and AstFactory to include CO2 mode, and introduces RobotMbed configuration/visitor hooks and toolbox entries. Also adds blockly UI/messages, configuration blocks, cross-compiler expected outputs (AST, collector results, and generated C++/Python) and a test XML program for Calliope targets so the sensor is available in the frontend and code generation for Calliope/CalliopeV3 is covered.
Copilot AI review requested due to automatic review settings May 29, 2026 18:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants