Communication

Modulino

Arduino Library for Modulinos

The Arduino Modulino® Library simplifies the integration of Modulino®, compact devices that connect via Qwiic and communicate over I2C. It provides an easy-to-use interface for working with sensors, actuators, and other modules on Arduino boards.

Go to repository

The Modulino library is designed to simplify integration with various Modulino. It supports a variety of modules, such as motion sensors, buttons, buzzers, LED displays, and more, all through an I2C (

Wire
) interface.

Hardware Compatibility

The library is compatible with Arduino boards that support I2C (

Wire
) communication.

Each Modulino has a fixed I2C address assigned by default. If you wish to change the I2C address, you can refer to the Utilities section.

Main Features

The Modulino library supports the following hardware modules:

  • Buttons (
    ModulinoButtons
    )
    : Read the state of buttons and control the associated LEDs.
  • Buzzer (
    ModulinoBuzzer
    )
    : Activate and deactivate the buzzer and set its frequency.
  • LEDs (
    ModulinoPixels
    )
    : Control RGB LEDs with customizable display modes.
  • Knob (
    ModulinoKnob
    )
    : Read the value of a rotary encoder.
  • Motion (
    ModulinoMovement
    )
    : Interface with the LSM6DSOX IMU sensor to get acceleration values.
  • Temperature & Humidity (
    ModulinoThermo
    )
    : Get temperature and humidity readings from the HS300x sensor.
  • Distance (
    ModulinoDistance
    )
    : Measures distance using a Time-of-Flight (ToF) sensor (VL53L0x).

Library Initialization

To initialize the Modulino library, include the header file and call the

begin()
method. This will set up the I2C communication and prepare the library for use with the modules.

1#include <Modulino.h>
2Modulino.begin(); // Initialize the Modulino library

Supported Modules

You can initialize a Modulino board easily. The basic setup requires just a call to the

begin()
method for each module. For example:

1ModulinoType modulino_name;
2modulino_name.begin(); // Initialize the ModulinoType module

ModulinoButtons

Manages the state of three buttons and controls their associated LED states. You can read the state of each button and send commands to turn the LEDs on/off.

Modulino Buttons

1ModulinoButtons buttons;
2buttons.begin();
3buttons.setLeds(true, false, true); // Turn on LED 1 and LED 3

ModulinoBuzzer

Allows you to emit sounds through the buzzer. You can set the frequency and duration of the sound.

Modulino Buzzer

1ModulinoBuzzer buzzer;
2buzzer.begin();
3buzzer.tone(440, 1000); // 440Hz frequency for 1000ms

ModulinoPixels

Controls an array of 8 RGB LEDs, allowing you to set the colors and brightness. You can also clear individual LEDs or the entire array.

Modulino Pixels

1ModulinoPixels leds;
2leds.set(0, ModulinoColor(255, 0, 0)); // Set the first LED (Position: 0) to red
3leds.show(); // Display the LEDs

ModulinoKnob

Manages a rotary encoder, allowing you to read the potentiometer value and check if the knob is pressed.

Modulino Knob

1ModulinoKnob knob;
2knob.begin();
3int16_t value = knob.get(); // Get the value of the encoder

ModulinoMovement

Interfaces with the LSM6DSOX IMU sensor to get acceleration readings.

Modulino Movement

1ModulinoMovement movement;
2movement.begin();
3float x = movement.getX();

ModulinoThermo

Reads temperature and humidity data from the HS300x sensor.

Modulino Thermo

1ModulinoThermo thermo;
2thermo.begin();
3float temperature = thermo.getTemperature();
4float humidity = thermo.getHumidity();

ModulinoDistance

Measures distance using a ToF (Time-of-Flight) sensor.

Modulino Distance

1ModulinoDistance distance;
2distance.begin();
3float distanceValue = distance.get();

Example Usage

Here’s an example of how to use some Modulino in a program:

1// This sketch demonstrates how to use the Modulino library to control buttons, LEDs, and a buzzer.
2// It listens for a button press (Button A), turns on the LED 0, and plays a sound through the buzzer when pressed.
3
4#include <Modulino.h>
5
6ModulinoButtons buttons; // Declare a Buttons Modulino
7ModulinoPixels leds; // Declare a Pixels Modulino
8ModulinoBuzzer buzzer; // Declare a Buzzer Modulino
9
10int frequency = 440; // Set frequency to 440Hz
11int duration = 1000; // Set duration to 1000ms
12
13void setup() {
14 Serial.begin(9600);
15
16 Modulino.begin(); // Initialize the Modulino library
17
18 buttons.begin(); // Initialize the Buttons module
19 leds.begin(); // Initialize the Pixels module
20 buzzer.begin(); // Initialize the Buzzer module
21}
22
23void loop() {
24 if (buttons.update()) { // Update the button states
25 if (buttons.isPressed(0)) { // Check if Button A (button 0) is pressed
26 Serial.println("Button A pressed!");
27 leds.set(0, RED); // Turn on LED 0 to red
28 leds.show();
29
30 buzzer.tone(frequency, duration); // Play buzzer sound with the specified frequency and duration
31 delay(duration);
32 } else {
33 leds.clear(0); // Turn off LED 0
34 leds.show();
35 }
36 }
37}

Examples

The examples folder is organized by Modulino type. Each module has its own folder with example sketches that demonstrate both basic and advanced usage (where applicable).

You can explore the examples here.

Utilities

In the Utilities folder, you will find programs designed to help you manage and manipulate the Modulino:

  • AddressChanger: This program allows you to change the I2C address of a Modulino module. It’s helpful when you need to reassign addresses to avoid conflicts or organize your I2C network.

API

The API documentation can be found here.

License

This library is released under the MPL-2.0 license.



MembersDescriptions
class
ModulinoClass
The base class for all Modulino components, providing essential functionality and structure for all subsequent Modulino modules.
class
ModulinoButtons
Handles the functionality of Modulino Buttons, enabling detection of presses and handling input events.
class
ModulinoBuzzer
Handles the functionality of Modulino Buzzer, enabling the sound generation for feedback or alerts.
class
ModulinoPixels
Handles the functionality of Modulino Pixels, managing LEDs strip color, status and brightness.
class
ModulinoKnob
Handles the functionality of Modulino Knob, interfacing with the rotary knob position.
class
ModulinoMovement
Handles the functionality of Modulino Movement,interfacing with the IMU sensor to get acceleration readings.
class
ModulinoThermo
Handles the functionality of Modulino Thermo, managing temperature sensors to provide real-time temperature and humidity readings.
class
ModulinoDistance
Handles the functionality of Modulino Distance, enabling distance measurement using ToF (Time-of-Flight) sensors for precise range detection.

ModulinoClass
ModulinoButtons
ModulinoBuzzer
ModulinoPixels
ModulinoKnob
ModulinoMovement
ModulinoThermo
ModulinoDistance