diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/datasheet/datasheet.md b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/datasheet/datasheet.md index e97264c3df..ee6a50189e 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/datasheet/datasheet.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/datasheet/datasheet.md @@ -44,9 +44,9 @@ Maker, beginner, education ## Related Products -- *SKU: ASX00027* – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) -- *SKU: K000007* – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) -- *SKU: AKX00026* – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) +- **SKU: ASX00027** – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) +- **SKU: K000007** – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) +- **SKU: AKX00026** – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) ## Rating diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/product.md b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/product.md index a36cadc128..d631136937 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/product.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/product.md @@ -2,10 +2,10 @@ title: Modulino Buttons url_shop: https://store.arduino.cc/products/modulino-buttons url_guide: https://courses.arduino.cc/plugandmake -primary_button_url: https://docs.arduino.cc/tutorials/modulino-buttons/how-buttons-ardu/ -primary_button_title: With Arduino -secondary_button_url: https://docs.arduino.cc/tutorials/modulino-buttons/how-buttons-mp/ -secondary_button_title: With MicroPython +primary_button_url: https://docs.arduino.cc/tutorials/modulino-buttons/how-buttons/ +primary_button_title: Get Started +secondary_button_url: https://docs.arduino.cc/tutorials/modulino-thermo/how-general/ +secondary_button_title: More on Modulinos forumCategorySlug: '/hardware/accessories/modulino-buttons/214' sku: [ABX00110] --- diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/AdressChangeIDE.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/AdressChangeIDE.png deleted file mode 100644 index d5cd3fd195..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/AdressChangeIDE.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/Modulino_Buttons_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/Modulino_Buttons_Power_Tree.png deleted file mode 100644 index 3281df8b8e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/Modulino_Buttons_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/adressChanger.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/adressChanger.png deleted file mode 100644 index c6eae670c8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/adressChanger.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-jumper.png deleted file mode 100644 index a2aa5b68df..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-qwiic-chain.png deleted file mode 100644 index ae538f5949..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-qwiik.png deleted file mode 100644 index 4df7f0508a..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons.png deleted file mode 100644 index 473282f2a9..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/how-to-buttons-ardu.md b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/how-to-buttons-ardu.md deleted file mode 100644 index 1ff1957351..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/how-to-buttons-ardu.md +++ /dev/null @@ -1,349 +0,0 @@ ---- -title: "How To Use The Modulino Buttons" -description: "Learn how to get the most out of your Modulino Buttons." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-buttons -software: - - ide-v2 - - web-editor ---- - -The Modulino Buttons is a modular sensor that provides tactile input and visual feedback, making it perfect to add interactive controls to your projects! -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - - -![Module demonstration](assets/connection-guide-buttons.gif) - -Pressing a button pulls the signal LOW, and each button has an onboard pull-up resistor. The LEDs can be controlled independently through the onboard microcontroller. - - -## General Characteristics - -The **Modulino Buttons** module uses three tactile buttons and LEDs, which do not have native I²C capabilities. Instead, the buttons and LEDs are controlled by the Modulino's onboard microcontroller (STM32C011F4U6TR). This microcontroller provides I²C communication, allowing for flexible reading of button states and control of the LEDs. One unique feature of this setup is the ability to change the I²C address via software. This means the address can be modified based on your application needs, making it adaptable to different system configurations. - -| Specification | Details | -|-------------------|-----------------------------| -| Buttons | 3 × Tactile pushbuttons | -| LEDs | 3 × Indicator LEDs (orange) | -| Power Supply | 3.3 V | -| Interface | UART, SWD, I2C | -| Pull-up Resistors | Integrated on button inputs | - - -The default I²C address for the **Modulino Buttons** module is: - -| Modulino I²C Address | Hardware I²C Address | Editable Addresses (HEX) | -|----------------------|----------------------|-------------------------------------------------| -| 0x7C | 0x3E | Any custom address (via software configuration) | - -When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. - -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - -## Pinout - -The tactile buttons and LEDs are the core components of this module. These input and output devices are controlled by an onboard STM32 microcontroller, which supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -![Arduino Buttons Pinout](assets/ButtonsPinouts.png) - -### 1x10 Header - -| Pin | Function | -|-------|----------------| -| A | Button A | -| GND | Ground | -| 3V3 | 3.3 V Power | -| PF2 | RESET | -| SWCLK | SWD Clock | -| SWDIO | SWD Data | -| TX1 | USART Transmit | -| RX1 | USART Receive | -| B | Button B | -| C | Button C | - -- **A: Button A** – This pin connects directly to button A. -- **GND: Ground** – Ground connection for power and signal reference. -- **3V3: Power** – 3.3 V power supply input. -- **PF2: RESET** – The reset pin for the microcontroller, which can be used to reset the system. -- **SWCLK: SWD Clock** – Used for providing the clock signal in the SWD interface. -- **SWDIO: SWD Data** – Used for debugging, as part of the Serial Wire Debug (SWD) interface. -- **TX1: USART Transmit** – Used for transmitting data over UART communication. -- **RX1: USART Receive** – Used for receiving data over UART communication. -- **B: Button B** – This pin connects directly to button B. -- **C: Button C** – This pin connects directly to button C. - -### 1x4 Header (I2C) - -The pinout for the Modulino Buttons is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|------------------|-------------------|---------|-------------|---------|------| -| Supply Voltage | - | - | 3.3 (QWIIC) | - | V | -| LED Current Draw | Single LED Active (A,B or C) | - | 2.5 | - | mA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Buttons](assets/Modulino_Buttons_Power_Tree.png) - -## Schematic - -The Modulino Buttons uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Buttons](assets/schematic.png) - -The main components are the **three tactile buttons**, **three user-programmable LEDs** and the **STM32C011F4U6TR** microcontroller (U1), which handles button state reading, LED control, as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -There's also a small power LED indicator that lights up when the board is on. -You can grab the full schematic and PCB files from the [Modulino Buttons](https://docs.arduino.cc/hardware/modulinos/modulino-buttons) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. - -Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-buttons.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-buttons-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-buttons-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. -Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus. - -This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-buttons-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup’s performance. Ensure your cables are properly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.*** - -## How To Use Your Modulino - -### Installing The Modulino Library - -You need the official Modulino library available [here](https://docs.arduino.cc/libraries/modulino/) to use the Modulino Buttons. - -With the Arduino IDE you get some tools that make adding a library easier. To learn how to install the IDE please visit our [page](https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2-downloading-and-installing/). - -After opening the IDE, a tab should be visible on the left. Press the book icon for "library" as highlighted in the image. - -![IDE Library Tab](assets/IDE-Left-Tab.png) - -The process should look like this: - -![Library Install](assets/library-install.gif) - -A message will appear after the installation is successful. - -### Getting Button Press Data - -Interacting with the Modulino Buttons module is simple using the `Modulino` library. - -For the **Buttons** module, there are two key functions: - -- `update()`**:** Requests new data from the button module. -- `isPressed(index)`**:** Checks if a specific button (`A`, `B`, or `C`) is pressed. -- `setLeds(A, B, C)`**:** Sets the state of the LED (`A`, `B`, or `C`). -- ```Modulino.begin();```: By default the Modulino library uses ```Wire1``` if your connection is in a different Wire you will have to edit it, check [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/) (by default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/)) for the library's hardware compatibility. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here is an example sketch demonstrating how to use these functions to detect button presses: - -```arduino -#include - -// Create object instance -ModulinoButtons buttons; - -void setup() { - Serial.begin(9600); - Modulino.begin(); - buttons.begin(); - - // Function to control the LEDs on top of each button - buttons.setLeds(true, true, true); -} - -void loop() { - // Request new data from the Modulino Buttons - if (buttons.update()) { - // Check if any button has been pressed - if (buttons.isPressed(0)) { - Serial.println("Button A pressed!"); - } else if (buttons.isPressed(1)) { - Serial.println("Button B pressed!"); - } else if (buttons.isPressed(2)) { - Serial.println("Button C pressed!"); - } - } -} -``` -The code example provided shows how to initialize the button module, read button states, and control the LEDs. The program begins by turning on all three LEDs, then continuously checks for button presses and reports them through the serial monitor. Each button is identified by its index (0 for A, 1 for B, 2 for C), making it easy to expand the functionality for more complex interactions. This simple interface can be adapted to trigger various actions in your projects, from controlling other components to navigating menus or implementing game controls. - -### Detecting Button Events - -The Modulino Buttons module can be enhanced with the [Button2 library](https://docs.arduino.cc/libraries/button2/) to detect various button events beyond simple presses. This approach allows you to respond to single clicks, double clicks, triple clicks, and long presses. - -For the **Button Events** functionality, there are several key functions: - -- `setButtonStateFunction(function)`**:** Sets a custom function that provides the button state. -- `setClickHandler(function)`**:** Sets a handler for single-click events. -- `setDoubleClickHandler(function)`**:** Sets a handler for double-click events. -- `setTripleClickHandler(function)`**:** Sets a handler for triple-click events. -- `setLongClickHandler(function)`**:** Sets a handler for long-press events. -- `loop()`**:** Must be called repeatedly to check for button state changes. - -Here is an example sketch demonstrating how to implement button event detection: - -```arduino -#include "Modulino.h" -#include "Button2.h" - -Button2 button; -ModulinoButtons modulino_buttons; - -uint8_t button0StateHandler() { - modulino_buttons.update(); - return modulino_buttons.isPressed(0) ? LOW : HIGH; // fake a normal button -> LOW = pressed -} - -void handler(Button2& btn) { - switch (btn.getType()) { - case single_click: - break; - case double_click: - Serial.print("double "); - break; - case triple_click: - Serial.print("triple "); - break; - case long_click: - Serial.print("long"); - break; - } - Serial.print("click"); - Serial.print(" ("); - Serial.print(btn.getNumberOfClicks()); - Serial.println(")"); -} - -void setup() { - - Serial.begin(115200); - - Modulino.begin(); - modulino_buttons.begin(); - - button.setDebounceTime(35); - button.setButtonStateFunction(button0StateHandler); - button.setClickHandler(handler); - button.setDoubleClickHandler(handler); - button.setTripleClickHandler(handler); - button.setLongClickHandler(handler); - button.begin(BTN_VIRTUAL_PIN); -} - -void loop() { - button.loop(); -} -``` - -The code example provided shows how to integrate the Button2 library with the Modulino Buttons module to detect advanced button interactions. It creates a virtual button connected to Button A (index 0) and sets up handlers for different types of clicks. The `button0StateHandler()` function serves as a bridge between the Modulino hardware and the Button2 library by converting the button state to the expected format. When running, the program will detect and report single clicks, double clicks, triple clicks, and long presses through the serial monitor. This approach enables more sophisticated user interfaces in your projects, from navigating multi-level menus to implementing different functions based on how a user interacts with a single button. - -### How To Change I2C Address - -An example sketch, AddressChanger, is also included with the library inside the `Utilities` folder and available [here](https://github.com/arduino-libraries/Modulino/blob/main/examples/Utilities/AddressChanger/AddressChanger.ino). This sketch changes the I²C address at a software level on the Module's microcontroller. - -![Example location on the IDE](assets/AdressChangeIDE.png) - -- Connect the module to your board, remove any other modules that might be in the chain. Connection must be via I²C. -- Upload the sketch. -- Open the Serial Monitor. -- Text should now appear. Make sure the correct bauld-rate is selected if the displayed characters seem corrupted. - - ![Expected console output](assets/adressChanger.png) - -- Select the address and confirm. Valid I²C addresses range from 0x08 to 0x77 (7-bit values in hexadecimal format, e.g., 0x42). -- Your address should now have changed. Make sure to take note of the selected address. - -To keep track of the address in use the module has a white rectangle on the back. Feel free to use this to write the address that was chosen. - -When using a custom address in your sketch, you'll need to specify this address when creating the module object. For example: -```arduino -ModulinoButtons buttons(0x3E); // Replace 0x3E with your specific address -``` - - -## Troubleshooting - -### Buttons Not Responding - -If your Modulino's power LED isn't on or the buttons aren't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `#include "modulino.h"` command, verify that the Modulino library is correctly installed: - -- Check your IDE to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### LEDs Not Working - -If the LEDs aren't lighting up as expected, make sure: - -- The correct LED states are being set in your code (true for on, false for off). -- All exposed electronics are not touching any conductive surfaces, as this could interfere with the operation. - -## Conclusion - -The **Modulino Buttons** is a digital input and output device that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes detecting button presses and controlling LEDs straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both user interfaces and interactive control systems. - -## What Is Next? - -Now that you've learned how to use your Modulino Buttons, you're all set to integrate it into your projects! - -- Create a simple menu system where each button performs a different function. -- Build a game controller for a simple arcade-style game. -- Use the buttons to control other Modulino devices in your project. -- Design an interactive installation where button presses trigger different visual and audio effects. \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/ButtonsPinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/ButtonsPinouts.png deleted file mode 100644 index cd1e959c27..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/ButtonsPinouts.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/Modulino_Buttons_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/Modulino_Buttons_Power_Tree.png deleted file mode 100644 index 3281df8b8e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/Modulino_Buttons_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-jumper.png deleted file mode 100644 index a2aa5b68df..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-qwiic-chain.png deleted file mode 100644 index ae538f5949..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-qwiik.png deleted file mode 100644 index 4df7f0508a..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons.gif b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons.gif deleted file mode 100644 index 73e0d48f1c..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons.gif and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons.png deleted file mode 100644 index 473282f2a9..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/connection-guide-buttons.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/mp-usb-connection.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/mp-usb-connection.png deleted file mode 100644 index fb059f9e8b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/mp-usb-connection.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/schematic.png deleted file mode 100644 index df5f2cfb25..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/schematic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/how-to-buttons-mp.md b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/how-to-buttons-mp.md deleted file mode 100644 index 579cc4dcde..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/how-to-buttons-mp.md +++ /dev/null @@ -1,299 +0,0 @@ ---- -title: "How To Use The Modulino Buttons And MicroPython" -description: "Learn how to get the most out of your Modulino Buttons in a MicroPython environment." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-buttons -software: - - ide-v2 - - web-editor ---- - -The Modulino Buttons is a modular sensor that provides tactile input and visual feedback, making it perfect to add interactive controls to your projects! -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - - -![Module demonstration](assets/connection-guide-buttons.gif) - -Pressing a button pulls the signal LOW, and each button has an onboard pull-up resistor. The LEDs can be controlled independently through the onboard microcontroller. - - -## General Characteristics - -The **Modulino Buttons** module uses three tactile buttons and LEDs, which do not have native I²C capabilities. Instead, the buttons and LEDs are controlled by the Modulino's onboard microcontroller (STM32C011F4U6TR). This microcontroller provides I²C communication, allowing for flexible reading of button states and control of the LEDs. One unique feature of this setup is the ability to change the I²C address via software. This means the address can be modified based on your application needs, making it adaptable to different system configurations. - -| Specification | Details | -|-------------------|-----------------------------| -| Buttons | 3 × Tactile pushbuttons | -| LEDs | 3 × Indicator LEDs (orange) | -| Power Supply | 3.3 V | -| Interface | UART, SWD, I2C | -| Pull-up Resistors | Integrated on button inputs | - - -The default I²C address for the **Modulino Buttons** module is: - -| Modulino I²C Address | Hardware I²C Address | Editable Addresses (HEX) | -|----------------------|----------------------|-------------------------------------------------| -| 0x7C | 0x3E | Any custom address (via software configuration) | - -When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - -## Pinout - -The tactile buttons and LEDs are the core components of this module. These input and output devices are controlled by an onboard STM32 microcontroller, which supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -![Arduino Buttons Pinout](assets/ButtonsPinouts.png) - -### 1x10 Header - -| Pin | Function | -|-------|----------------| -| A | Button A | -| GND | Ground | -| 3V3 | 3.3 V Power | -| PF2 | RESET | -| SWCLK | SWD Clock | -| SWDIO | SWD Data | -| TX1 | USART Transmit | -| RX1 | USART Receive | -| B | Button B | -| C | Button C | - -- **A: Button A** – This pin connects directly to button A. -- **GND: Ground** – Ground connection for power and signal reference. -- **3V3: Power** – 3.3 V power supply input. -- **PF2: RESET** – The reset pin for the microcontroller, which can be used to reset the system. -- **SWCLK: SWD Clock** – Used for providing the clock signal in the SWD interface. -- **SWDIO: SWD Data** – Used for debugging, as part of the Serial Wire Debug (SWD) interface. -- **TX1: USART Transmit** – Used for transmitting data over UART communication. -- **RX1: USART Receive** – Used for receiving data over UART communication. -- **B: Button B** – This pin connects directly to button B. -- **C: Button C** – This pin connects directly to button C. - -### 1x4 Header (I2C) - -The pinout for the Modulino Buttons is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|------------------|-------------------|---------|-------------|---------|------| -| Supply Voltage | - | - | 3.3 (QWIIC) | - | V | -| LED Current Draw | Single LED Active (A,B or C) | - | 2.5 | - | mA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Buttons](assets/Modulino_Buttons_Power_Tree.png) - -## Schematic - -The Modulino Buttons uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Buttons](assets/schematic.png) - -The main components are the **three tactile buttons**, **three user-programmable LEDs** and the **STM32C011F4U6TR** microcontroller (U1), which handles button state reading, LED control, as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -There's also a small power LED indicator that lights up when the board is on. - -You can grab the full schematic and PCB files from the [Modulino Buttons](https://docs.arduino.cc/hardware/modulinos/modulino-buttons) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. - -Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-buttons.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-buttons-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-buttons-jumper.png) - - -## Daisy-Chaining Multiple Modulino Nodes - - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. -Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus. - -This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-buttons-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup’s performance. Ensure your cables are properly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address it independently. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.*** - - -## How To Program Your Modulino - -### Installing The Modulino Library - -To program your Modulino it is recommended you use the official ```Modulino``` micropython library available [here](https://github.com/arduino/arduino-modulino-mpy). The library is fully compatible with the no **Arduino Lab for MicroPython**. - -For information on installing the **Arduino Lab for MicroPython** please visit our [page](https://docs.arduino.cc/micropython/first-steps/install-guide/). - -The ```Modulino``` library is not available by default on MicroPython devices hence installation is needed. - -To simplify the process the [MicroPython Package Installer](https://github.com/arduino/lab-micropython-package-installer/releases) is recommended as it will provide a graphical interface to guide installation. - -After installation, you should now be able to: - -1. Open the tool. -2. Plug in your board to the computer. - - ![USB Connection](assets/mp-usb-connection.png) - - If the board does not appear in the Detected Boards section, click Reload. If the board is still undetected, ensure no other programs (e.g., a code editor) are using the board's COM port. - -3. Search for the ```Modulino``` package by filling in the text box on the search feature. -4. Click Install and wait for the installation confirmation. -5. Disconnect the board from the tool before returning to your code editor to avoid conflicts due to a busy COM port. - -![Package Installer Overview](assets/package-installer-overview.png) - -The module should now be includable in your program using: - -```from modulino import ModulinoThermo``` - -### Getting Button Input and Controlling LEDs - -Interacting with buttons using the `Modulino` library is straightforward. For the **Modulino Buttons** module, there are key functions to detect button presses and control the LEDs associated with each button. - -### Detecting Button Presses - -Each button supports different interactions: - -- **`.on_button_a_press`**, **`.on_button_b_press`**, **`.on_button_c_press`** - Triggers when a button is pressed. -- **`.on_button_a_long_press`**, **`.on_button_b_long_press`**, **`.on_button_c_long_press`** - Triggers when a button is held down for a longer duration. -- **`.on_button_a_release`**, **`.on_button_b_release`**, **`.on_button_c_release`** - Triggers when a button is released. - -By default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it as instructed [here](https://github.com/arduino/arduino-modulino-mpy/tree/main/docs#%E2%84%B9%EF%B8%8F-using-3rd-party-boards). More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -### Reading Button Inputs And Controlling LEDs - -```python -from modulino import ModulinoButtons -from time import sleep - -buttons = ModulinoButtons() - -# Define button press actions -buttons.on_button_a_press = lambda : print("Button A pressed") -buttons.on_button_a_long_press = lambda : print("Button A long press") -buttons.on_button_a_release = lambda : print("Button A released") - -buttons.on_button_b_press = lambda : print("Button B pressed") -buttons.on_button_b_long_press = lambda : print("Button B long press") -buttons.on_button_b_release = lambda : print("Button B released") - -buttons.on_button_c_press = lambda : print("Button C pressed") -buttons.on_button_c_long_press = lambda : print("Button C long press") -buttons.on_button_c_release = lambda : print("Button C released") - -# LED Sequence: Turn each LED on with a delay, then turn them off -buttons.led_a.on() -sleep(0.5) -buttons.led_b.on() -sleep(0.5) -buttons.led_c.on() -sleep(0.5) -buttons.set_led_status(False, False, False) # Turn off all LEDs - -while True: - buttons_state_changed = buttons.update() - - if buttons_state_changed: - led_a_status = buttons.is_pressed(0) # Turn LED A on if button A is pressed - led_b_status = buttons.is_pressed(1) # Turn LED B on if button B is pressed - led_c_status = buttons.is_pressed(2) # Turn LED C on if button C is pressed - buttons.set_led_status(led_a_status, led_b_status, led_c_status) -``` - -### How To Change Address - -A sketch is also available included with the library named `AddressChanger` and also available [here](https://github.com/arduino/arduino-modulino-mpy/blob/main/examples/change_address.py). This sketch changes the I2C address at a software level on the Module's microcontroller. - -- Connect the module to your board via I2C, ensuring no other modules are in the chain. -- Run the script in a MicroPython environment. -- Follow the on-screen instructions (REPL) to select the device and enter a new address. Valid I²C addresses range from 0x08 to 0x77 (7-bit values in hexadecimal format, e.g., 0x42). -- The script will attempt to change the address and confirm success. - -To keep track of the address in use, the module has a white rectangle on the back. Feel free to use this to write the address that was chosen. - -When using a custom address in your MicroPython sketch, you'll need to specify this address when creating the module object. For example: - -```python -buttons_module = ModulinoButtons(address=0x45) # Replace 0x45 with your specific address -``` - -## Troubleshooting - -### Buttons Not Responding - -If your Modulino's power LED isn't on or the buttons aren't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `import ModulinoButtons` command, verify that the Modulino library is correctly installed: - -- Check your library installer to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### LEDs Not Working - -If the LEDs aren't lighting up as expected, make sure: - -- The correct LED states are being set in your code (true for on, false for off). -- All exposed electronics are not touching any conductive surfaces, as this could interfere with the operation. - -## Conclusion - -The **Modulino Buttons** is a digital input and output device that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes detecting button presses and controlling LEDs straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both user interfaces and interactive control systems. - -## What Is Next? - -Now that you've learned how to use your Modulino Buttons, you're all set to integrate it into your projects! - -- Create a simple menu system where each button performs a different function. -- Build a game controller for a simple arcade-style game. -- Use the buttons to control other Modulino devices in your project. -- Design an interactive installation where button presses trigger different visual and audio effects. \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/ButtonsPinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons/assets/ButtonsPinouts.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/ButtonsPinouts.png rename to content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons/assets/ButtonsPinouts.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons.gif b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons/assets/connection-guide-buttons.gif similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/connection-guide-buttons.gif rename to content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons/assets/connection-guide-buttons.gif diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons/assets/schematic.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/schematic.png rename to content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons/assets/schematic.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons/content.md new file mode 100644 index 0000000000..052df4e5c8 --- /dev/null +++ b/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons/content.md @@ -0,0 +1,350 @@ +--- +title: "Modulino Buttons" +description: "Complete guide for the Modulino Buttons tactile input and LED feedback module." +tags: + - Modulino + - Buttons + - Input + - LED + - QWIIC + - I2C +author: 'Pedro Sousa Lima' +hardware: + - hardware/11.modulinos/modulinos/modulino-buttons +software: + - ide-v2 + - web-editor + - micropython +--- + +![Buttons Overview](assets/connection-guide-buttons.gif) + +The Modulino Buttons is a modular sensor that provides tactile input and visual feedback, making it perfect to add interactive controls to your projects! Pressing a button pulls the signal LOW, and each button has an onboard pull-up resistor. The LEDs can be controlled independently through the onboard microcontroller. + +## Hardware Overview + +### General Characteristics + +The **Modulino Buttons** module uses three tactile buttons and LEDs, controlled by the Modulino's onboard microcontroller (STM32C011F4U6TR). This microcontroller provides I²C communication, allowing for flexible reading of button states and control of the LEDs. + +| Specification | Details | +|-------------------|-----------------------------| +| Buttons | 3 × Tactile pushbuttons | +| LEDs | 3 × Indicator LEDs (orange) | +| Power Supply | 3.3 V | +| Interface | UART, SWD, I2C | +| Pull-up Resistors | Integrated on button inputs | + +One unique feature of this setup is the ability to change the I²C address via software, making it adaptable to different system configurations. + +The default I²C address for the **Modulino Buttons** module is: + +| Modulino I²C Address | Hardware I²C Address | Editable Addresses (HEX) | +|----------------------|----------------------|-------------------------------------------------| +| 0x7C | 0x3E | Any custom address (via software configuration) | + +### Pinout + +![Arduino Buttons Pinout](assets/ButtonsPinouts.png) + +#### 1x10 Header + +| Pin | Function | +|-------|----------------| +| A | Button A | +| GND | Ground | +| 3V3 | 3.3 V Power | +| PF2 | RESET | +| SWCLK | SWD Clock | +| SWDIO | SWD Data | +| TX1 | USART Transmit | +| RX1 | USART Receive | +| B | Button B | +| C | Button C | + +#### 1x4 Header (I2C) + +| Pin | Function | +|-------|--------------| +| GND | Ground | +| 3.3 V | Power Supply | +| SDA | I²C Data | +| SCL | I²C Clock | + +### Power Specifications + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|------------------|------------------------------|---------|-------------|---------|------| +| Supply Voltage | - | - | 3.3 (QWIIC) | - | V | +| LED Current Draw | Single LED Active (A,B or C) | - | 2.5 | - | mA | + +The module includes a power LED that draws 1 mA and turns on as soon as it is powered. + +### Schematic + +The Modulino Buttons uses a straightforward circuit design featuring three tactile buttons, three user-programmable LEDs, and the STM32C011F4U6TR microcontroller. + +![Full Schematic Modulino Buttons](assets/schematic.png) + +The main components are the **three tactile buttons**, **three user-programmable LEDs** and the **STM32C011F4U6TR** microcontroller (U1), which handles button state reading, LED control, as well as I²C communication. + +You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. + +You can grab the full schematic and PCB files from the [Modulino Buttons product page](https://docs.arduino.cc/hardware/modulinos/modulino-buttons). + +## Programming with Arduino + +The Modulino Buttons is fully compatible with the Arduino IDE and the official Modulino library. The following examples showcase basic button reading and LED control functionality that can be easily integrated into your interactive projects. + +### Prerequisites + +- Install the Modulino library via the Arduino IDE Library Manager +- Connect your Modulino Buttons via QWIIC or solderable headers + +For detailed instructions on setting up your Arduino environment and installing libraries, please refer to the [Getting Started with Modulinos guide](link-to-generic-guide). + +### Basic Example + +```arduino +#include + +// Create object instance +ModulinoButtons buttons; + +void setup() { + Serial.begin(9600); + Modulino.begin(); + buttons.begin(); + + // Function to control the LEDs on top of each button + buttons.setLeds(true, true, true); +} + +void loop() { + // Request new data from the Modulino Buttons + if (buttons.update()) { + // Check if any button has been pressed + if (buttons.isPressed(0)) { + Serial.println("Button A pressed!"); + } else if (buttons.isPressed(1)) { + Serial.println("Button B pressed!"); + } else if (buttons.isPressed(2)) { + Serial.println("Button C pressed!"); + } + } +} +``` + +### Key Functions + +- `update()`: Requests new data from the button module +- `isPressed(index)`: Checks if a specific button (0=A, 1=B, 2=C) is pressed +- `setLeds(A, B, C)`: Sets the state of the LEDs (true=on, false=off) + +### Advanced Example - Button Events with Button2 Library + +The Modulino Buttons can be enhanced with the Button2 library to detect various button events beyond simple presses. + +```arduino +#include "Modulino.h" +#include "Button2.h" + +Button2 button; +ModulinoButtons modulino_buttons; + +uint8_t button0StateHandler() { + modulino_buttons.update(); + return modulino_buttons.isPressed(0) ? LOW : HIGH; // fake a normal button -> LOW = pressed +} + +void handler(Button2& btn) { + switch (btn.getType()) { + case single_click: + break; + case double_click: + Serial.print("double "); + break; + case triple_click: + Serial.print("triple "); + break; + case long_click: + Serial.print("long"); + break; + } + Serial.print("click"); + Serial.print(" ("); + Serial.print(btn.getNumberOfClicks()); + Serial.println(")"); +} + +void setup() { + Serial.begin(115200); + Modulino.begin(); + modulino_buttons.begin(); + + button.setDebounceTime(35); + button.setButtonStateFunction(button0StateHandler); + button.setClickHandler(handler); + button.setDoubleClickHandler(handler); + button.setTripleClickHandler(handler); + button.setLongClickHandler(handler); + button.begin(BTN_VIRTUAL_PIN); +} + +void loop() { + button.loop(); +} +``` + +## Programming with MicroPython + +The Modulino Buttons is fully compatible with MicroPython through the official Modulino MicroPython library. The following examples demonstrate how to detect button presses, handle various button events, and control the integrated LEDs in your MicroPython projects. + +### Prerequisites + +- Install the Modulino MicroPython library +- Ensure Arduino Lab for MicroPython is installed + +For detailed instructions on setting up your MicroPython environment and installing packages, please refer to the [Getting Started with Modulinos guide](link-to-generic-guide). + +### Basic Example + +```python +from modulino import ModulinoButtons +from time import sleep + +buttons = ModulinoButtons() + +# Define button press actions +buttons.on_button_a_press = lambda : print("Button A pressed") +buttons.on_button_a_long_press = lambda : print("Button A long press") +buttons.on_button_a_release = lambda : print("Button A released") + +buttons.on_button_b_press = lambda : print("Button B pressed") +buttons.on_button_b_long_press = lambda : print("Button B long press") +buttons.on_button_b_release = lambda : print("Button B released") + +buttons.on_button_c_press = lambda : print("Button C pressed") +buttons.on_button_c_long_press = lambda : print("Button C long press") +buttons.on_button_c_release = lambda : print("Button C released") + +# LED Sequence: Turn each LED on with a delay, then turn them off +buttons.led_a.on() +sleep(0.5) +buttons.led_b.on() +sleep(0.5) +buttons.led_c.on() +sleep(0.5) +buttons.set_led_status(False, False, False) # Turn off all LEDs + +while True: + buttons_state_changed = buttons.update() + + if buttons_state_changed: + led_a_status = buttons.is_pressed(0) # Turn LED A on if button A is pressed + led_b_status = buttons.is_pressed(1) # Turn LED B on if button B is pressed + led_c_status = buttons.is_pressed(2) # Turn LED C on if button C is pressed + buttons.set_led_status(led_a_status, led_b_status, led_c_status) +``` + +### Key Functions and Properties + +- `.on_button_x_press`: Callback for button press events +- `.on_button_x_long_press`: Callback for long press events +- `.on_button_x_release`: Callback for button release events +- `.led_x.on()/.off()`: Control individual LEDs +- `.set_led_status(a, b, c)`: Set all LED states at once +- `.is_pressed(index)`: Check if a button is currently pressed +- `.update()`: Check for button state changes + +### Advanced Example - Menu System + +```python +from modulino import ModulinoButtons +from time import sleep + +buttons = ModulinoButtons() + +# Menu system variables +menu_items = ["Option 1", "Option 2", "Option 3", "Settings", "Exit"] +current_index = 0 +in_submenu = False + +def show_menu(): + """Display current menu state via LEDs and serial""" + print("\n--- MENU ---") + for i, item in enumerate(menu_items): + prefix = ">" if i == current_index else " " + print(f"{prefix} {item}") + + # Show position with LEDs + buttons.set_led_status( + current_index == 0, + current_index == 2, + current_index == 4 + ) + +def next_item(): + """Move to next menu item""" + global current_index + current_index = (current_index + 1) % len(menu_items) + show_menu() + +def previous_item(): + """Move to previous menu item""" + global current_index + current_index = (current_index - 1) % len(menu_items) + show_menu() + +def select_item(): + """Select current menu item""" + print(f"\n✓ Selected: {menu_items[current_index]}") + + # Flash all LEDs to confirm selection + for _ in range(3): + buttons.set_led_status(True, True, True) + sleep(0.1) + buttons.set_led_status(False, False, False) + sleep(0.1) + +# Configure button actions +buttons.on_button_a_press = previous_item # Navigate up +buttons.on_button_b_press = select_item # Select +buttons.on_button_c_press = next_item # Navigate down + +# Initialize +print("Menu Navigation System") +print("A: Previous | B: Select | C: Next") +show_menu() + +# Main loop +while True: + buttons.update() + sleep(0.01) +``` + +## Troubleshooting + +### Buttons Not Responding + +If your Modulino's power LED isn't on or the buttons aren't responsive: +- Ensure both the board and the Modulino are connected properly +- Verify that the power LEDs on both are lit +- Check that the QWIIC cable is properly clicked into place + +### LEDs Not Working + +If the LEDs aren't lighting up as expected: +- Verify correct LED states are being set in your code +- Check that exposed electronics are not touching conductive surfaces +- Ensure adequate power supply for LED operation + +## Project Ideas + +- **Simple Menu System**: Each button performs a different function or navigates menus +- **Game Controller**: Build controls for arcade-style games +- **Interactive Control Panel**: Control other Modulino devices in your project +- **Pattern Memory Game**: Create a Simon-style memory game with LED feedback +- **Morse Code Trainer**: Practice Morse code with button input and LED feedback +- **Smart Home Controller**: Three-button interface for home automation +- **Music Box Controller**: Each button plays different notes or controls playback \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/datasheet/datasheet.md b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/datasheet/datasheet.md index d81d8762fe..75037d7f38 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/datasheet/datasheet.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/datasheet/datasheet.md @@ -41,9 +41,9 @@ Maker, beginner, education ## Related Products -- *SKU: ASX00027* – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) -- *SKU: K000007* – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) -- *SKU: AKX00026* – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) +- **SKU: ASX00027** – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) +- **SKU: K000007** – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) +- **SKU: AKX00026** – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) ## Rating diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/product.md b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/product.md index 44edf0aa4f..bab35cf069 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/product.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/product.md @@ -2,10 +2,10 @@ title: Modulino Buzzer url_shop: https://store.arduino.cc/products/modulino-buzzer url_guide: https://courses.arduino.cc/plugandmake -primary_button_url: https://docs.arduino.cc/tutorials/modulino-buzzer/how-buzzer-ardu/ -primary_button_title: With Arduino -secondary_button_url: https://docs.arduino.cc/tutorials/modulino-buzzer/how-buzzer-mp/ -secondary_button_title: With MicroPython +primary_button_url: https://docs.arduino.cc/tutorials/modulino-buzzer/how-buzzer/ +primary_button_title: Get Started +secondary_button_url: https://docs.arduino.cc/tutorials/modulino-thermo/how-general/ +secondary_button_title: More on Modulinos forumCategorySlug: '/hardware/accessories/modulino-buzzer/215' sku: [ABX00108] --- diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/IDE-Left-Tab.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/IDE-Left-Tab.png deleted file mode 100644 index c7bb86575e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/IDE-Left-Tab.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/Modulino_Buzzer_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/Modulino_Buzzer_Power_Tree.png deleted file mode 100644 index 7ca852c52b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/Modulino_Buzzer_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/addressChangeIDE.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/addressChangeIDE.png deleted file mode 100644 index d5cd3fd195..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/addressChangeIDE.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/adressChanger.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/adressChanger.png deleted file mode 100644 index c6eae670c8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/adressChanger.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer-jumper.png deleted file mode 100644 index 1a45271300..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer-qwiic-chain.png deleted file mode 100644 index a90c8fdf46..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer-qwiik.png deleted file mode 100644 index 6ee9d1c03a..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer.png deleted file mode 100644 index 4f6bd1cd6c..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/connection-guide-buzzer.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/library-install.gif b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/library-install.gif deleted file mode 100644 index 16f396c353..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/library-install.gif and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/content.md deleted file mode 100644 index 0c74563365..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/content.md +++ /dev/null @@ -1,268 +0,0 @@ ---- -title: "How To Use The Modulino Buzzer" -description: "Learn how to get the most out of your Modulino Buzzer." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-buzzer -software: - - ide-v2 - - web-editor ---- - -The Modulino Buzzer is a modular sensor that generates audio output, making it perfect to add sound feedback to your projects! -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - - -## Hardware Specifications - -The Modulino Buzzer based on the buzzer (PKLCS1212E4001-R1) is capable of generating different tones and sound patterns. Take a look at the following table to know more about its characteristics: - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|----------------------|-----------|---------|---------|---------|------| -| Frequency | - | - | 4,000 | - | Hz | -| Sound Pressure Level | - | 75 | 85 | - | dB | - -### Sensor Details - -The **Modulino Buzzer** module uses the **PKLCS1212E4001-R1** buzzer, which does not have native I²C capabilities. Instead, the buzzer is controlled by the Modulino's onboard microcontroller (STM32C011F4U6T). This microcontroller provides I²C communication, allowing for flexible control of the buzzer. - -One unique feature of this setup is the ability to change the I²C address via software. This means the address can be modified based on your application needs, making it adaptable to different system configurations. - -The default I²C address for the **Modulino Buzzer** module is: - -| Modulino I²C Address | Hardware I²C Address |Editable Addresses (HEX)| -|----------------------|----------------------|----------------------| -| 0x3C | 0x1E |Any custom address (via software configuration) - - -When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. - -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - - -## Pinout - -The PKLCS1212E4001-R1 buzzer is the core component of this module. This audio output device is controlled by an onboard STM32 microcontroller, which supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -![Arduino Buzzer Pinout](assets/BuzzerPinouts.png) - -### 1x8 Header - -| Pin | Function | -|--------|-----------------| -| GND | Ground | -| 3V3 | 3.3V Power | -| RESET | Reset | -| SWCLK | SWD Clock | -| SWDIO | SWD Data | -| TX1 | USART Transmit | -| RX1 | USART Receive | -| PA0 | Buzzer | - -- **GND:** Provides ground reference for the circuit. -- **3V3:** Supplies 3.3 V power to connected components and modules. -- **Reset:** The reset pin for the microcontroller, which can be used to reset the system. -- **SWCLK:** Used for providing the clock signal in the SWD interface. -- **SWDIO:** Used for debugging, as part of the Serial Wire Debug (SWD) interface. -- **TX1:** Used for transmitting data over UART communication. -- **RX1:** Used for receiving data over UART communication. -- **PA0:** This pin is used to control the buzzer's output signal. In fact, this pin can be used to bypass the I²C interface and control the buzzer directly using a square wave. -![Direct control via signal](assets/buzzerPA0.gif) - - -### 1x4 Header (I2C) - -The pinout for the Modulino Buzzer is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Typical | Unit | -|---------------------|-----------|---------|------| -| Operating Voltage | - | 3.3 | V | -| Current Consumption | - | ~6.4 | mA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. -J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: -![Power Tree Modulino Buzzer](assets/Modulino_Buzzer_Power_Tree.png) - -## Schematic - -The Modulino Buzzer uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Buzzer](assets/schematic.png) - -The main components are the **PKLCS1212E4001-R1 buzzer** and the **STM32C011F6U6TR** microcontroller (U1), which handles tone generation as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -There's also a small power LED indicator that lights up when the board is on. - -You can grab the full schematic and PCB files from the [Modulino Buzzer](https://docs.arduino.cc/hardware/modulinos/modulino-buzzer) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -If your board doesn’t have a QWIIC connector, you can still access the same I²C bus and power the module using the solderable header pads just make sure you wire it to 3.3V and match the I²C pinout. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-buzzer.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-buzzer-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-buzzer-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. - -Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus as long as you select the correct I²C pins depending on your board. - -This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-buzzer-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup’s performance. Ensure your cables are properly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.*** - -## How To Use Your Modulino - -### Installing The Modulino Library - -You need the official Modulino library available [here](https://docs.arduino.cc/libraries/modulino/) to use the Modulino Buzzer. - -With the Arduino IDE you get some tools that make adding a library easier. To learn how to install the IDE please visit our [page](https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2-downloading-and-installing/). - -After opening the IDE, a tab should be visible on the left. Press the book icon for "library" as highlighted in the image. - -![IDE Library Tab](assets/IDE-Left-Tab.png) - -The process should look like this: - -![Library Install](assets/library-install.gif) - -A message will appear after the installation is successful. - -### Play A Simple Tune - -Getting sound feedback from the buzzer is fairly simple using the ```Modulino``` library. For the **Modulino Buzzer** there is one important function: - -- ```tone(frequency, duration)```: Generates a tone with the specified frequency (in Hz) and duration (in milliseconds). -- ```Modulino.begin();```: By default the Modulino library uses ```Wire1``` if your connection is in a different Wire you will have to edit it, check [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/) (by default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/)) for the library's hardware compatibility. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here is an example sketch of how to implement this function to control the buzzer: - -```arduino -#include - -ModulinoBuzzer buzzer; - -int frequency = 440; // Frequency of the tone in Hz -int duration = 1000; // Duration of the tone in milliseconds - -void setup(){ - Modulino.begin(); - buzzer.begin(); -} - -void loop(){ - buzzer.tone(frequency, duration); // Generate the tone - delay(1000); // Wait for 1 second - buzzer.tone(0, duration); // Stop the tone - delay(1000); // Wait for 1 second -} -``` - -The code example provided shows how to initialize the buzzer and generate tones. The buzzer alternates between playing a 440 Hz tone for one second and staying silent for one second. -It can be easily adapted to play different melodies or to provide sound feedback for your projects based on specific conditions or events. - -### How To Change I2C Address - -An example sketch, AddressChanger, is also included with the library inside the `Utilities` folder and available [here](https://github.com/arduino-libraries/Modulino/blob/main/examples/Utilities/AddressChanger/AddressChanger.ino). This sketch changes the I²C address at a software level on the Module's microcontroller. - -![Example location on the IDE](assets/addressChangeIDE.png) - -- Connect the module to your board, remove any other modules that might be in the chain. Connection must be via I²C. -- Upload the sketch. -- Open the Serial Monitor. -- Text should now appear. Make sure the correct bauld-rate is selected if the displayed characters seem corrupted. - - ![Expected console output](assets/adressChanger.png) - -- Select the address and confirm. Valid I²C addresses range from 0x08 to 0x77 (7-bit values in hexadecimal format, e.g., 0x42). -- Your address should now have changed. Make sure to take note of the selected address. - -To keep track of the address in use the module has a white rectangle on the back. Feel free to use this to write the address that was chosen. - -When using a custom address in your sketch, you'll need to specify this address when creating the module object. For example: - -```arduino -ModulinoBuzzer buzzer(0x3E); // Replace 0x3E with your specific address -``` - - -## Troubleshooting - -### Buzzer Not Sounding - -If your Modulino's power LED isn't on or the buzzer isn't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `#include "modulino.h"` command, verify that the Modulino library is correctly installed: - -- Check your IDE to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### Distorted Sound - -If the buzzer sound is distorted or not playing as expected, make sure: - -- The correct frequency values are being used (typically between 20 Hz and 20 kHz for audible sounds). -- All exposed electronics are not touching any conductive surfaces, as this could interfere with the sound output. - -## Conclusion - -The **Modulino Buzzer** is a digital sound output device that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes generating sound feedback straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both interactive feedback and audio alert systems. - -## What Is Next? - -Now that you've learned how to use your Modulino Buzzer, you're all set to integrate it into your projects! - -- Experiment with different frequencies to create various tones and melodies. -- Try creating a simple alarm system that triggers the buzzer when certain conditions are met. -- Use the buzzer to provide feedback in your interactive projects when a button is pressed or a threshold is reached. -- Create a music box that plays different tunes when specific inputs are detected! - diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/BuzzerPinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/BuzzerPinouts.png deleted file mode 100644 index 4c1c420282..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/BuzzerPinouts.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/Modulino_Buzzer_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/Modulino_Buzzer_Power_Tree.png deleted file mode 100644 index 7ca852c52b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/Modulino_Buzzer_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/buzzerPA0.gif b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/buzzerPA0.gif deleted file mode 100644 index 7f133eb687..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/buzzerPA0.gif and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer-jumper.png deleted file mode 100644 index 1b61af02f8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer-qwiic-chain.png deleted file mode 100644 index a90c8fdf46..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer-qwiik.png deleted file mode 100644 index 0dbdad86af..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer.png deleted file mode 100644 index 4f6bd1cd6c..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/connection-guide-buzzer.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/mp-usb-connection.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/mp-usb-connection.png deleted file mode 100644 index fb059f9e8b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/mp-usb-connection.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/package-installer-overview.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/package-installer-overview.png deleted file mode 100644 index 67678dc808..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/package-installer-overview.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/schematic.png deleted file mode 100644 index 4d0d4a9098..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/assets/schematic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/content.md deleted file mode 100644 index bb3221e880..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-mp/content.md +++ /dev/null @@ -1,269 +0,0 @@ ---- -title: "How To Use The Modulino Buzzer And MicroPython" -description: "Learn how to get the most out of your Modulino Buzzer in a MicroPython environment." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-buzzer -software: - - ide-v2 - - web-editor ---- - -The Modulino Buzzer is a modular sensor that generates audio output, making it perfect to add sound feedback to your projects! -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - - -## Hardware Specifications - -The Modulino Buzzer based on the buzzer (PKLCS1212E4001-R1) is capable of generating different tones and sound patterns. Take a look at the following table to know more about its characteristics: - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|----------------------|-----------|---------|---------|---------|------| -| Frequency | - | - | 4,000 | - | Hz | -| Sound Pressure Level | - | 75 | 85 | - | dB | - -### Sensor Details - -The **Modulino Buzzer** module uses the **PKLCS1212E4001-R1** buzzer, which does not have native I²C capabilities. Instead, the buzzer is controlled by the Modulino's onboard microcontroller (STM32C011F4U6T). This microcontroller provides I²C communication, allowing for flexible control of the buzzer. - -One unique feature of this setup is the ability to change the I²C address via software. This means the address can be modified based on your application needs, making it adaptable to different system configurations. - -The default I²C address for the **Modulino Buzzer** module is: - -| Modulino I²C Address | Hardware I²C Address |Editable Addresses (HEX)| -|----------------------|----------------------|----------------------| -| 0x3C | 0x1E |Any custom address (via software configuration) - - -When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. - -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - - -## Pinout - -The PKLCS1212E4001-R1 buzzer is the core component of this module. This audio output device is controlled by an onboard STM32 microcontroller, which supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -![Arduino Buzzer Pinout](assets/BuzzerPinouts.png) - -| Pin | Function | -|--------|-----------------| -| GND | Ground | -| 3V3 | 3.3V Power | -| RESET | Reset | -| SWCLK | SWD Clock | -| SWDIO | SWD Data | -| TX1 | USART Transmit | -| RX1 | USART Receive | -| PA0 | Buzzer | - -- **GND:** Provides ground reference for the circuit. -- **3V3:** Supplies 3.3 V power to connected components and modules. -- **Reset:** The reset pin for the microcontroller, which can be used to reset the system. -- **SWCLK:** Used for providing the clock signal in the SWD interface. -- **SWDIO:** Used for debugging, as part of the Serial Wire Debug (SWD) interface. -- **TX1:** Used for transmitting data over UART communication. -- **RX1:** Used for receiving data over UART communication. -- **PA0:** This pin is used to control the buzzer's output signal. In fact, this pin can be used to bypass the I²C interface and control the buzzer directly using a square wave. -![Direct control via signal](assets/buzzerPA0.gif) - - -### 1x4 Header (I2C) - -The pinout for the Modulino Buzzer is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Typical | Unit | -|---------------------|-----------|---------|------| -| Operating Voltage | - | 3.3 | V | -| Current Consumption | - | ~6.4 | mA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. - -J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Buzzer](assets/Modulino_Buzzer_Power_Tree.png) - -## Schematic - -The Modulino Buzzer uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Buzzer](assets/schematic.png) - -The main components are the **PKLCS1212E4001-R1 buzzer** and the **STM32C011F6U6TR** microcontroller (U1), which handles tone generation as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -There's also a small power LED indicator that lights up when the board is on. - -You can grab the full schematic and PCB files from the [Modulino Buzzer](https://docs.arduino.cc/hardware/modulinos/modulino-buzzer) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -If your board doesn’t have a QWIIC connector, you can still access the same I²C bus and power the module using the solderable header pads just make sure you wire it to 3.3V and match the I²C pinout. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-buzzer.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-buzzer-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-buzzer-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. - -Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus as long as you select the correct I²C pins depending on your board. - -This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-buzzer-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup’s performance. Ensure your cables are properly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.*** - -## How To Program Your Modulino - -### Installing The Modulino Library - -To program your Modulino it is recommended you use the official ```Modulino``` micropython library available [here](https://github.com/arduino/arduino-modulino-mpy). The library is fully compatible with the no **Arduino Lab for MicroPython**. - -For information on installing the **Arduino Lab for MicroPython** please visit our [page](https://docs.arduino.cc/micropython/first-steps/install-guide/). - -The ```Modulino``` library is not available by default on MicroPython devices hence installation is needed. - -To simplify the process the [MicroPython Package Installer](https://github.com/arduino/lab-micropython-package-installer/releases) is recommended as it will provide a graphical interface to guide installation. - -After installation, you should now be able to: - -1. Open the tool. -2. Plug in your board to the computer. - - ![USB Connection](assets/mp-usb-connection.png) - - If the board does not appear in the Detected Boards section, click Reload. If the board is still undetected, ensure no other programs (e.g., a code editor) are using the board's COM port. - -3. Search for the ```Modulino``` package by filling in the text box on the search feature. -4. Click Install and wait for the installation confirmation. -5. Disconnect the board from the tool before returning to your code editor to avoid conflicts due to a busy COM port. - -![Package Installer Overview](assets/package-installer-overview.png) - -The module should now be includable in your program using: - -```from modulino import ModulinoBuzzer``` - -### Play a Simple Tune with MicroPython - -Playing a sound from the **Modulino Buzzer** module is easy using the `Modulino` library. The crucial function to generate a tone is: - -- `tone(frequency, duration, blocking)` - Generates a tone with the specified frequency (in Hz) and duration (in milliseconds). -- By default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it as instructed [here](https://github.com/arduino/arduino-modulino-mpy/tree/main/docs#%E2%84%B9%EF%B8%8F-using-3rd-party-boards). More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here’s a basic example to control the buzzer: - -```python -from modulino import ModulinoBuzzer -from time import sleep - -buzzer = ModulinoBuzzer() - -frequency = 440 # Frequency of the tone in Hz -duration = 1000 # Duration of the tone in milliseconds - -# Play the tone -buzzer.tone(frequency, duration, blocking=True) -sleep(1) # Wait for 1 second - -# Stop the tone -buzzer.tone(0, duration, blocking=True) -sleep(1) # Wait for 1 second -``` - -### How To Change Address - -A sketch is also available included with the library named `AddressChanger` and also available [here](https://github.com/arduino/arduino-modulino-mpy/blob/main/examples/change_address.py). This sketch changes the I2C address at a software level on the Module's microcontroller. - -- Connect the module to your board via I2C, ensuring no other modules are in the chain. -- Run the script in a MicroPython environment. -- Follow the on-screen instructions (REPL) to select the device and enter a new address. Valid I²C addresses range from 0x08 to 0x77 (7-bit values in hexadecimal format, e.g., 0x42). -- The script will attempt to change the address and confirm success. - -To keep track of the address in use, the module has a white rectangle on the back. Feel free to use this to write the address that was chosen. - -When using a custom address in your MicroPython sketch, you'll need to specify this address when creating the module object. For example: - -```python -buzzer_module = ModulinoBuzzer(address=0x45) # Replace 0x45 with your specific address -``` - - -## Troubleshooting - -### Buzzer Not Sounding - -If your Modulino's power LED isn't on or the buzzer isn't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `from modulino import ModulinoBuzzer"` command, verify that the Modulino library is correctly installed: - -- Check if the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### Distorted Sound - -If the buzzer sound is distorted or not playing as expected, make sure: - -- The correct frequency values are being used (typically between 20 Hz and 20 kHz for audible sounds). -- All exposed electronics are not touching any conductive surfaces, as this could interfere with the sound output. - -## Conclusion - -The **Modulino Buzzer** is a digital sound output device that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes generating sound feedback straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both interactive feedback and audio alert systems. - -## What Is Next? - -Now that you've learned how to use your Modulino Buzzer, you're all set to integrate it into your projects! - -- Experiment with different frequencies to create various tones and melodies. -- Try creating a simple alarm system that triggers the buzzer when certain conditions are met. -- Use the buzzer to provide feedback in your interactive projects when a button is pressed or a threshold is reached. -- Create a music box that plays different tunes when specific inputs are detected! - diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/assets/BuzzerOverview.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/assets/BuzzerOverview.png new file mode 100644 index 0000000000..aa71e573da Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/assets/BuzzerOverview.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/BuzzerPinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/assets/BuzzerPinouts.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/BuzzerPinouts.png rename to content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/assets/BuzzerPinouts.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/buzzerPA0.gif b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/assets/buzzerPA0.gif similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/buzzerPA0.gif rename to content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/assets/buzzerPA0.gif diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/assets/schematic.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer-ardu/assets/schematic.png rename to content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/assets/schematic.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/content.md new file mode 100644 index 0000000000..d0f10c457f --- /dev/null +++ b/content/hardware/11.accessories/modulino-nodes/modulino-buzzer/tutorials/how-buzzer/content.md @@ -0,0 +1,337 @@ +--- +title: "Modulino Buzzer" +description: "Complete guide for the Modulino Buzzer audio output module." +tags: + - Modulino + - Buzzer + - Audio + - Sound + - QWIIC + - I2C +author: 'Pedro Sousa Lima' +hardware: + - hardware/11.modulinos/modulinos/modulino-buzzer +software: + - ide-v2 + - web-editor + - micropython +--- + +![Buzzer Overview](assets/BuzzerOverview.png) + +The Modulino Buzzer is a modular sensor that generates audio output, making it perfect to add sound feedback to your projects! It uses the standardised Modulino form factor with QWIIC connectors for easy integration. + +## Hardware Overview + +### General Characteristics + +The Modulino Buzzer is based on the PKLCS1212E4001-R1 buzzer, capable of generating different tones and sound patterns. + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|----------------------|-----------|---------|---------|---------|------| +| Frequency | - | - | 4,000 | - | Hz | +| Sound Pressure Level | - | 75 | 85 | - | dB | + +### Sensor Details + +The **Modulino Buzzer** module uses the **PKLCS1212E4001-R1** buzzer, which does not have native I²C capabilities. Instead, the buzzer is controlled by the Modulino's onboard microcontroller (STM32C011F4U6T). This microcontroller provides I²C communication, allowing for flexible control of the buzzer. + +One unique feature of this setup is the ability to change the I²C address via software, making it adaptable to different system configurations. + +The default I²C address for the **Modulino Buzzer** module is: + +| Modulino I²C Address | Hardware I²C Address | Editable Addresses (HEX) | +|----------------------|----------------------|--------------------------------------------------| +| 0x3C | 0x1E | Any custom address (via software configuration) | + +### Pinout + +![Arduino Buzzer Pinout](assets/BuzzerPinouts.png) + +#### 1x8 Header + +| Pin | Function | +|--------|-----------------| +| GND | Ground | +| 3V3 | 3.3V Power | +| RESET | Reset | +| SWCLK | SWD Clock | +| SWDIO | SWD Data | +| TX1 | USART Transmit | +| RX1 | USART Receive | +| PA0 | Buzzer | + +**PA0**: This pin can be used to bypass the I²C interface and control the buzzer directly using a square wave. +![Control through PA0 Pin](assets/buzzerPA0.gif) + +#### 1x4 Header (I2C) + +| Pin | Function | +|-------|--------------| +| GND | Ground | +| 3.3 V | Power Supply | +| SDA | I²C Data | +| SCL | I²C Clock | + +### Power Specifications + +| Parameter | Condition | Typical | Unit | +|---------------------|-----------|---------|------| +| Operating Voltage | - | 3.3 | V | +| Current Consumption | - | ~6.4 | mA | + +The module includes a power LED that draws 1 mA and turns on as soon as it is powered. + +### Schematic + +The Modulino Buzzer features a simple yet effective circuit design for audio generation. + +![Full Schematic Modulino Buzzer](assets/schematic.png) + +The main components are the **PKLCS1212E4001-R1 buzzer** and the **STM32C011F6U6TR** microcontroller (U1), which handles tone generation as well as I²C communication. + +You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. + +There's also a small power LED indicator that lights up when the board is on. + +You can grab the full schematic and PCB files from the [Modulino Buzzer product page](https://docs.arduino.cc/hardware/modulinos/modulino-buzzer). + +## Programming with Arduino + +The Modulino Buzzer is fully compatible with the Arduino IDE and the official Modulino library. The following examples showcase how to generate tones, create melodies, and add audio feedback to your Arduino projects. + +### Prerequisites + +- Install the Modulino library via the Arduino IDE Library Manager +- Connect your Modulino Buzzer via QWIIC or solderable headers + +For detailed instructions on setting up your Arduino environment and installing libraries, please refer to the [Getting Started with Modulinos guide](link-to-generic-guide). + +### Basic Example + +```arduino +#include + +ModulinoBuzzer buzzer; + +int frequency = 440; // Frequency of the tone in Hz +int duration = 1000; // Duration of the tone in milliseconds + +void setup(){ + Modulino.begin(); + buzzer.begin(); +} + +void loop(){ + buzzer.tone(frequency, duration); // Generate the tone + delay(1000); // Wait for 1 second + buzzer.tone(0, duration); // Stop the tone + delay(1000); // Wait for 1 second +} +``` + +### Key Functions + +- `tone(frequency, duration)`: Generates a tone with the specified frequency (in Hz) and duration (in milliseconds) +- Setting frequency to 0 stops the tone + +### Advanced Example - Musical Melody + +```arduino +#include + +ModulinoBuzzer buzzer; + +// Musical notes (frequencies in Hz) +#define NOTE_C4 262 +#define NOTE_D4 294 +#define NOTE_E4 330 +#define NOTE_F4 349 +#define NOTE_G4 392 +#define NOTE_A4 440 +#define NOTE_B4 494 +#define NOTE_C5 523 +#define REST 0 + +// Simple melody: "Twinkle Twinkle Little Star" +int melody[] = { + NOTE_C4, NOTE_C4, NOTE_G4, NOTE_G4, NOTE_A4, NOTE_A4, NOTE_G4, REST, + NOTE_F4, NOTE_F4, NOTE_E4, NOTE_E4, NOTE_D4, NOTE_D4, NOTE_C4, REST +}; + +// Note durations: 4 = quarter note, 8 = eighth note, etc. +int noteDurations[] = { + 4, 4, 4, 4, 4, 4, 2, 4, + 4, 4, 4, 4, 4, 4, 2, 4 +}; + +void setup() { + Serial.begin(9600); + Modulino.begin(); + buzzer.begin(); + + Serial.println("Playing melody..."); + playMelody(); +} + +void playMelody() { + for (int thisNote = 0; thisNote < 16; thisNote++) { + // Calculate the note duration + int noteDuration = 1000 / noteDurations[thisNote]; + + buzzer.tone(melody[thisNote], noteDuration); + + // Pause between notes + int pauseBetweenNotes = noteDuration * 1.30; + delay(pauseBetweenNotes); + + // Stop the tone + buzzer.tone(0, 10); + } +} + +void loop() { + // Play melody every 5 seconds + delay(5000); + playMelody(); +} +``` + +## Programming with MicroPython + +The Modulino Buzzer is fully compatible with MicroPython through the official Modulino MicroPython library. The following examples demonstrate how to generate tones, create sound patterns, and implement audio feedback in your MicroPython projects. + +### Prerequisites + +- Install the Modulino MicroPython library +- Ensure Arduino Lab for MicroPython is installed + +For detailed instructions on setting up your MicroPython environment and installing packages, please refer to the [Getting Started with Modulinos guide](link-to-generic-guide). + +### Basic Example + +```python +from modulino import ModulinoBuzzer +from time import sleep + +buzzer = ModulinoBuzzer() + +frequency = 440 # Frequency of the tone in Hz +duration = 1000 # Duration of the tone in milliseconds + +# Play the tone +buzzer.tone(frequency, duration, blocking=True) +sleep(1) # Wait for 1 second + +# Stop the tone +buzzer.tone(0, duration, blocking=True) +sleep(1) # Wait for 1 second +``` + +### Key Functions + +- `tone(frequency, duration, blocking)`: Generates a tone with specified frequency and duration + `blocking=True`: Waits for tone to complete before continuing + `blocking=False`: Returns immediately while tone plays + +### Advanced Example - Alarm System + +```python +from modulino import ModulinoBuzzer +from time import sleep + +buzzer = ModulinoBuzzer() + +# Define different alarm patterns +def beep_pattern(): + """Simple beep pattern""" + for _ in range(3): + buzzer.tone(1000, 100, blocking=True) + sleep(0.1) + +def alarm_pattern(): + """Urgent alarm pattern""" + for i in range(5): + frequency = 800 + (i * 100) + buzzer.tone(frequency, 200, blocking=True) + sleep(0.05) + +def siren_pattern(): + """Police siren-like pattern""" + for _ in range(3): + # Rising tone + for freq in range(400, 800, 50): + buzzer.tone(freq, 50, blocking=True) + # Falling tone + for freq in range(800, 400, -50): + buzzer.tone(freq, 50, blocking=True) + +def notification_sound(): + """Pleasant notification sound""" + notes = [523, 659, 784, 1047] # C5, E5, G5, C6 + for note in notes: + buzzer.tone(note, 150, blocking=True) + sleep(0.05) + +def success_sound(): + """Success/completion sound""" + buzzer.tone(523, 100, blocking=True) # C5 + sleep(0.05) + buzzer.tone(659, 100, blocking=True) # E5 + sleep(0.05) + buzzer.tone(784, 200, blocking=True) # G5 + +# Demonstration menu +patterns = { + "1": ("Beep Pattern", beep_pattern), + "2": ("Alarm Pattern", alarm_pattern), + "3": ("Siren Pattern", siren_pattern), + "4": ("Notification", notification_sound), + "5": ("Success Sound", success_sound) +} + +print("🔊 Buzzer Pattern Demo") +print("Select a pattern:") +for key, (name, _) in patterns.items(): + print(f" {key}: {name}") + +while True: + choice = input("\nEnter pattern number (1-5): ") + + if choice in patterns: + name, pattern_func = patterns[choice] + print(f"Playing: {name}") + pattern_func() + print("Done!") + else: + print("Invalid choice. Please enter 1-5.") + + sleep(1) +``` + +## Troubleshooting + +### Buzzer Not Sounding + +If your Modulino's power LED isn't on or the buzzer isn't responsive: +- Ensure both the board and the Modulino are connected properly +- Verify that the power LEDs on both are lit +- Check that the QWIIC cable is properly clicked into place + +### Distorted Sound + +If the buzzer sound is distorted or not playing as expected: +- Verify correct frequency values are being used (typically 20 Hz to 20 kHz for audible sounds) +- Check that exposed electronics are not touching conductive surfaces +- Ensure stable power supply + +## Project Ideas + +- **Simple Alarm System**: Trigger the buzzer when certain conditions are met +- **Music Box**: Play different tunes based on sensor inputs +- **Timer Alert**: Create a pomodoro timer with audio notifications +- **Game Sound Effects**: Add audio feedback to interactive games +- **Morse Code Transmitter**: Send messages using Morse code patterns +- **Parking Sensor**: Combine with Modulino Distance for proximity alerts +- **Temperature Alert**: Use with Modulino Thermo for temperature warnings +- **Interactive Doorbell**: Create custom doorbell melodies \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/datasheet/datasheet.md b/content/hardware/11.accessories/modulino-nodes/modulino-distance/datasheet/datasheet.md index 661a550042..c1cb0c2f90 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-distance/datasheet/datasheet.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-distance/datasheet/datasheet.md @@ -41,9 +41,9 @@ Maker, beginner, education ## Related Products -- *SKU: ASX00027* – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) -- *SKU: K000007* – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) -- *SKU: AKX00026* – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) +- **SKU: ASX00027** – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) +- **SKU: K000007** – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) +- **SKU: AKX00026** – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) ## Rating diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/product.md b/content/hardware/11.accessories/modulino-nodes/modulino-distance/product.md index c99c36391e..da6b60477c 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-distance/product.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-distance/product.md @@ -2,10 +2,10 @@ title: Modulino Distance url_shop: https://store.arduino.cc/products/modulino-distance url_guide: https://courses.arduino.cc/plugandmake -primary_button_url: https://docs.arduino.cc/tutorials/modulino-distance/how-distance-ardu/ -primary_button_title: With Arduino -secondary_button_url: https://docs.arduino.cc/tutorials/modulino-distance/how-distance-mp/ -secondary_button_title: With MicroPython +primary_button_url: https://docs.arduino.cc/tutorials/modulino-distance/how-distance/ +primary_button_title: Get Started +secondary_button_url: https://docs.arduino.cc/tutorials/modulino-thermo/how-general/ +secondary_button_title: More on Modulinos forumCategorySlug: '/hardware/accessories/modulino-distance/216' sku: [ABX00102] --- diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/IDE-Left-Tab.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/IDE-Left-Tab.png deleted file mode 100644 index c7bb86575e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/IDE-Left-Tab.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/Modulino_Distance_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/Modulino_Distance_Power_Tree.png deleted file mode 100644 index 64b9ae3a3c..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/Modulino_Distance_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance-jumper.png deleted file mode 100644 index df073cc73b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance-qwiic-chain.png deleted file mode 100644 index 9399b6deb1..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance-qwiik.png deleted file mode 100644 index 37768f52e8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance.png deleted file mode 100644 index e011bec29e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/connection-guide-distance.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/library-install.gif b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/library-install.gif deleted file mode 100644 index 16f396c353..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/library-install.gif and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/content.md deleted file mode 100644 index 14d6e61714..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/content.md +++ /dev/null @@ -1,232 +0,0 @@ ---- -title: "How To Use The Modulino Distance" -description: "Learn how to get the most out of your Modulino Distance." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-distance -software: - - ide-v2 - - web-editor ---- - -The Modulino Distance is a modular sensor that measures distance using Time-of-Flight (ToF) technology, making it perfect to add precise distance sensing and depth mapping to your projects! -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - -## General Characteristics - -The Modulino Distance is capable of measuring distances using Time-of-Flight technology. Take a look at the following table to know more about its measuring ranges: - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|-----------------------|----------------------|---------|---------|---------|------| -| Range | Distance Measurement | 1 | - | 1300 | mm | -| Resolution | - | - | 1 | - | mm | -| Operating Temperature | - | -30 | - | 85 | °C | - - -### Sensor Details - -The VL53L4CDV0DH/1 sensor from STMicroelectronics is the core component of this module. This ToF sensor natively supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|---------------|---------------|---------|---------|---------|------| -| Field of View | - | - | 18 | - | ° | -| Wavelength | Laser Emitter | - | 940 | - | nm | - -The default address for the Module is: - -| Modulino I²C Address | Hardware I²C Address | -|----------------------|----------------------| -| 0x52 | 0x52 | - -***Note: Since the address cannot be changed on this Modulino specifically, using two or more identical modules on the same I²C bus will result in address conflicts and cause communication issues.*** - -## Pinout - -The pinout for the Modulino Distance is shown below. Please note that the exposed solderable pins are directly connected to the QWIIC connectors using the same I²C interface. - -![Arduino Distance Pinout](assets/DistancePinouts.png) - -### 1x4 Header (Sensor GPIO) - -| Pin | Function | -|-------|----------------| -| GND | Ground | -| 3V3 | 3.3 V Power | -| GPIO1 | Digital Output | -| XSHUT | Xshutdown | - -- **GND: Ground** – Ground connection for power and signal reference. -- **3V3: Power** – 3.3 V power supply input. -- **GPIO1: Digital Output** – General purpose digital output pin. -- **XSHUT: Xshutdown** – Shutdown control pin for the sensor. - -### 1x4 Header (I2C) - -The pinout for the Modulino Buzzer is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3V3 | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - -Depending on the board connected to the modulino, the I²C pin names to program it may differ. Please check the [board tutorials](https://docs.arduino.cc/hardware/) on your modulino's compatible board or the [Modulino library](https://github.com/arduino-libraries/Modulino/tree/main/docs) to learn more. - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -| --------------------- | ----------------------- | ------- | ----------- | ------- | ---- | -| Supply Voltage | - | - | 3.3 (QWIIC) | - | V | -| Current Consumption | Active measurement mode | - | 24 | 40 | mA | -| Operating Temperature | - | -30 | - | 85 | °C | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Distance](assets/Modulino_Distance_Power_Tree.png) - -## Schematic - -The Modulino Distance uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Distance](assets/schematic.png) - -The main component is the **VL53L4CDV0DH/1** sensor (U1), which handles distance measurements using Time-of-Flight technology, as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3 V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -There's also a small power indicator LED that lights up when the board is on. - -You can grab the full schematic and PCB files from the [Modulino Distance](https://docs.arduino.cc/hardware/modulinos/modulino-distance) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. - -Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-distance.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3 V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-distance-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-distance-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus. This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-distance-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup's performance. Ensure your cables are correctly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Multiple modules with the same address will cause conflicts on the I²C bus.*** - -## How To Use Your Modulino - -### Installing The Modulino Library - -You need the official Modulino library available [here](https://docs.arduino.cc/libraries/modulino/) to use the Modulino Thermo. - -With the Arduino IDE you get some tools that make adding a library easier. To learn how to install the IDE please visit our [page](https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2-downloading-and-installing/). - -After opening the IDE, a tab should be visible on the left. Press the book icon for "library" as highlighted in the image. - -![IDE Library Tab](assets/IDE-Left-Tab.png) - -The process should look like this: - -![Library Install](assets/library-install.gif) - -A message will appear after the installation is successful. - -### Getting Distance Data - -Getting data from the sensor is fairly simple using the ```Modulino``` library. For the **Modulino Distance** there are two important functions: - -- ```available()```: Checks if new distance data is available. -- ```get()```: Retrieves the measured distance from the sensor (default in cm). -- ```Modulino.begin();```: By default the Modulino library uses ```Wire1``` if your connection is in a different Wire you will have to edit it, check [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/) (by default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/)) for the library's hardware compatibility. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here is an example sketch of how to implement these functions to acquire data and show it using the serial monitor: - -```arduino -#include "Modulino.h" - -// Create object instance -ModulinoDistance distance; - -void setup() { - Serial.begin(9600); - - // Initialize the Modulino system and distance sensor - Modulino.begin(); - distance.begin(); -} - -void loop() { - if (distance.available()) { - int measure = distance.get(); - Serial.println(measure); - } - delay(10); -} -``` - -## Troubleshooting - -### Sensor Not Reachable - -If your Modulino's power LED isn't on or the sensor isn't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `#include "modulino.h"` command, verify that the Modulino library is correctly installed: - -- Check your IDE to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### Inaccurate Values - -If the sensor values are not accurate, make sure: - -- The sensor lens is clean and free from dust or obstructions. -- All exposed electronics are not touching any conductive surfaces, as this could interfere with readings. -- The object being measured is within the sensor's detection range. - -## Conclusion - -The **Modulino Distance** is a digital Time-of-Flight distance sensor that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes accessing distance data straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both quick tests and longer-term setups. - -## What Is Next? - -Now that you've learned how to use your Modulino Distance, you're all set to integrate it into your projects! - -- Create a parking assistance system that provides audio feedback as objects get closer, similar to car parking sensors. -- Build a theremin-like musical instrument that changes pitch or volume based on hand movements in front of the sensor. -- Design an automatic dispenser that activates when hands are detected beneath it (for soap, sanitizer, etc.). \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/DistancePinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/DistancePinouts.png deleted file mode 100644 index f657054092..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/DistancePinouts.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/Modulino_Distance_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/Modulino_Distance_Power_Tree.png deleted file mode 100644 index 64b9ae3a3c..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/Modulino_Distance_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance-jumper.png deleted file mode 100644 index df073cc73b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance-qwiic-chain.png deleted file mode 100644 index 9399b6deb1..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance-qwiik.png deleted file mode 100644 index 21e4b96ff0..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance.png deleted file mode 100644 index e011bec29e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/connection-guide-distance.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/mp-usb-connection.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/mp-usb-connection.png deleted file mode 100644 index fb059f9e8b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/mp-usb-connection.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/package-installer-overview.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/package-installer-overview.png deleted file mode 100644 index 67678dc808..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/package-installer-overview.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/schematic.png deleted file mode 100644 index 20dd38803b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/assets/schematic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/content.md deleted file mode 100644 index a8cc998584..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/content.md +++ /dev/null @@ -1,236 +0,0 @@ ---- -title: "How To Use The Modulino Distance And MicroPython" -description: "Learn how to get the most out of your Modulino Distance in a MicroPython environment." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-distance -software: - - ide-v2 - - web-editor ---- - -The Modulino Distance is a modular sensor that measures distance using Time-of-Flight (ToF) technology, making it perfect to add precise distance sensing and depth mapping to your projects! -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - -## General Characteristics - -The Modulino Distance is capable of measuring distances using Time-of-Flight technology. Take a look at the following table to know more about its measuring ranges: - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|-----------------------|----------------------|---------|---------|---------|------| -| Range | Distance Measurement | 1 | - | 1300 | mm | -| Resolution | - | - | 1 | - | mm | -| Operating Temperature | - | -30 | - | 85 | °C | - - -### Sensor Details - -The VL53L4CDV0DH/1 sensor from STMicroelectronics is the core component of this module. This ToF sensor natively supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|---------------|---------------|---------|---------|---------|------| -| Field of View | - | - | 18 | - | ° | -| Wavelength | Laser Emitter | - | 940 | - | nm | - -The default address for the Module is: - -| Modulino I²C Address | Hardware I²C Address | -|----------------------|----------------------| -| 0x52 | 0x52 | - -***Note: Since the address cannot be changed on this Modulino specifically, using two or more identical modules on the same I²C bus will result in address conflicts and cause communication issues.*** - -## Pinout - -The pinout for the Modulino Distance is shown below. Please note that the exposed solderable pins are directly connected to the QWIIC connectors using the same I²C interface. - -![Arduino Distance Pinout](assets/DistancePinouts.png) - -### 1x4 Header (Sensor GPIO) - -| Pin | Function | -|-------|----------------| -| GND | Ground | -| 3V3 | 3.3V Power | -| GPIO1 | Digital Output | -| XSHUT | Xshutdown | - -- **GND: Ground** – Ground connection for power and signal reference. -- **3V3: Power** – 3.3V power supply input. -- **GPIO1: Digital Output** – General purpose digital output pin. -- **XSHUT: Xshutdown** – Shutdown control pin for the sensor. - - -### 1x4 Header (I2C) - -The pinout for the Modulino Buzzer is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - -Depending on the board connected to the modulino, the I²C pin names to program it may differ. Please check the [board tutorials](https://docs.arduino.cc/hardware/) on your modulino's compatible board or the [Modulino library](https://github.com/arduino-libraries/Modulino/tree/main/docs) to learn more. - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -| --------------------- | ----------------------- | ------- | ----------- | ------- | ---- | -| Supply Voltage | - | - | 3.3 (QWIIC) | - | V | -| Current Consumption | Active measurement mode | - | 24 | 40 | mA | -| Operating Temperature | - | -30 | - | 85 | °C | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Distance](assets/Modulino_Distance_Power_Tree.png) - -## Schematic - -The Modulino Distance uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Distance](assets/schematic.png) - -The main component is the **VL53L5CX** sensor (U1), which handles distance measurements using Time-of-Flight technology, as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -There's also a small power indicator LED that lights up when the board is on. - -You can grab the full schematic and PCB files from the [Modulino Distance](https://docs.arduino.cc/hardware/modulinos/modulino-distance) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. - -Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-distance.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-distance-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-distance-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus. This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-distance-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup's performance. Ensure your cables are correctly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Multiple modules with the same address will cause conflicts on the I²C bus.*** - -## How To Program Your Modulino - -### Installing The Modulino Library - -To program your Modulino it is recommended you use the official ```Modulino``` micropython library available [here](https://github.com/arduino/arduino-modulino-mpy). The library is fully compatible with the no **Arduino Lab for MicroPython**. - -For information on installing the **Arduino Lab for MicroPython** please visit our [page](https://docs.arduino.cc/micropython/first-steps/install-guide/). - -The ```Modulino``` library is not available by default on MicroPython devices hence installation is needed. - -To simplify the process the [MicroPython Package Installer](https://github.com/arduino/lab-micropython-package-installer/releases) is recommended as it will provide a graphical interface to guide installation. - -After installation, you should now be able to: - -1. Open the tool. -2. Plug in your board to the computer. - - ![USB Connection](assets/mp-usb-connection.png) - - If the board does not appear in the Detected Boards section, click Reload. If the board is still undetected, ensure no other programs (e.g., a code editor) are using the board's COM port. - -3. Search for the ```Modulino``` package by filling in the text box on the search feature. -4. Click Install and wait for the installation confirmation. -5. Disconnect the board from the tool before returning to your code editor to avoid conflicts due to a busy COM port. - -![Package Installer Overview](assets/package-installer-overview.png) - -The module should now be includable in your program using: - -```from modulino import ModulinoDistance``` - -### Getting Distance Data - -Getting data from the sensor is straightforward using the ```Modulino``` library. -For the **Modulino Distance**, there is one crucial function: - -- ```.distance``` - Provides the distance measurement from the sensor. (Default in cm) -- By default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it as instructed [here](https://github.com/arduino/arduino-modulino-mpy/tree/main/docs#%E2%84%B9%EF%B8%8F-using-3rd-party-boards). More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here is an example of how to implement this function to acquire data: - -```python -from modulino import ModulinoDistance -from time import sleep_ms - -distance = ModulinoDistance() - -while True: - print(f"📏 Distance: {distance.distance} cm") - sleep_ms(50) -``` - -This simple code creates an instance of the ModulinoDistance class and continuously reads the distance values, displaying them in centimeters with a 50ms delay between readings. - -## Troubleshooting - -### Sensor Not Reachable - -If your Modulino's power LED isn't on or the sensor isn't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `import ModulinoDistance` command, verify that the Modulino library is correctly installed: - -- Check the package installer to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### Inaccurate Values - -If the sensor values are not accurate, make sure: - -- The sensor lens is clean and free from dust or obstructions. -- All exposed electronics are not touching any conductive surfaces, as this could interfere with readings. -- The object being measured is within the sensor's detection range. - -## Conclusion - -The **Modulino Distance** is a digital Time-of-Flight distance sensor that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes accessing distance data straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both quick tests and longer-term setups. - -## What Is Next? - -Now that you've learned how to use your Modulino Distance, you're all set to integrate it into your projects! - -- Create a parking assistance system that provides audio feedback as objects get closer, similar to car parking sensors. -- Build a theremin-like musical instrument that changes pitch or volume based on hand movements in front of the sensor. -- Design an automatic dispenser that activates when hands are detected beneath it (for soap, sanitizer, etc.). - diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/DistancePinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/assets/DistancePinouts.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/DistancePinouts.png rename to content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/assets/DistancePinouts.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/assets/distanceOverview.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/assets/distanceOverview.png new file mode 100644 index 0000000000..7b3b798588 Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/assets/distanceOverview.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/assets/schematic.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/assets/schematic.png rename to content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/assets/schematic.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/content.md new file mode 100644 index 0000000000..a3b46f8b47 --- /dev/null +++ b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/content.md @@ -0,0 +1,360 @@ +--- +title: "Modulino Distance" +description: "Complete guide for the Modulino Distance Time-of-Flight sensor module." +tags: + - Modulino + - Distance + - ToF + - Sensor + - QWIIC + - I2C +author: 'Pedro Sousa Lima' +hardware: + - hardware/11.modulinos/modulinos/modulino-distance +software: + - ide-v2 + - web-editor + - micropython +--- + +![Distance Overview](assets/distanceOverview.png) + +The Modulino Distance is a modular sensor that measures distance using Time-of-Flight (ToF) technology, making it perfect to add precise distance sensing and depth mapping to your projects! + +## Hardware Overview + +### General Characteristics + +The Modulino Distance is capable of measuring distances using Time-of-Flight technology with the following specifications: + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|-----------------------|----------------------|---------|---------|---------|------| +| Range | Distance Measurement | 1 | - | 1300 | mm | +| Resolution | - | - | 1 | - | mm | +| Operating Temperature | - | -30 | - | 85 | °C | + +### Sensor Details + +The VL53L4CDV0DH/1 sensor from STMicroelectronics is the core component of this module. This ToF sensor natively supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|---------------|---------------|---------|---------|---------|------| +| Field of View | - | - | 18 | - | ° | +| Wavelength | Laser Emitter | - | 940 | - | nm | + +The default address for the Module is: + +| Modulino I²C Address | Hardware I²C Address | +|----------------------|----------------------| +| 0x52 | 0x52 | + +***Note: Since the address cannot be changed on this Modulino specifically, using two or more identical modules on the same I²C bus will result in address conflicts and cause communication issues.*** + +### Pinout + +![Arduino Distance Pinout](assets/DistancePinouts.png) + +#### 1x4 Header (Sensor GPIO) + +| Pin | Function | +|-------|----------------| +| GND | Ground | +| 3V3 | 3.3 V Power | +| GPIO1 | Digital Output | +| XSHUT | Xshutdown | + +#### 1x4 Header (I2C) + +| Pin | Function | +|-------|--------------| +| GND | Ground | +| 3.3 V | Power Supply | +| SDA | I²C Data | +| SCL | I²C Clock | + +### Power Specifications + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|-----------------------|-------------------------|---------|-------------|---------|------| +| Supply Voltage | - | - | 3.3 (QWIIC) | - | V | +| Current Consumption | Active measurement mode | - | 24 | 40 | mA | +| Operating Temperature | - | -30 | - | 85 | °C | + +The module includes a power LED that draws 1 mA and turns on as soon as it is powered. + +### Schematic + +The Modulino Distance uses a straightforward circuit built around the Time-of-Flight sensor. + +![Full Schematic Modulino Distance](assets/schematic.png) + +The main component is the **VL53L4CDV0DH/1** sensor (U1), which handles distance measurements using Time-of-Flight technology, as well as I²C communication. + +You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3 V**, which comes from the QWIIC cable or the **3V3 pin** on J4. + +There's also a small power indicator LED that lights up when the board is on. + +You can grab the full schematic and PCB files from the [Modulino Distance product page](https://docs.arduino.cc/hardware/modulinos/modulino-distance). + +## Programming with Arduino + +The Modulino Distance is fully compatible with the Arduino IDE and the official Modulino library. The following examples showcase how to read distance measurements and implement proximity-based features in your Arduino projects. + +### Prerequisites + +- Install the Modulino library via the Arduino IDE Library Manager +- Connect your Modulino Distance via QWIIC or solderable headers + +For detailed instructions on setting up your Arduino environment and installing libraries, please refer to the [Getting Started with Modulinos guide](link-to-generic-guide). + +### Basic Example + +```arduino +#include "Modulino.h" + +// Create object instance +ModulinoDistance distance; + +void setup() { + Serial.begin(9600); + + // Initialize the Modulino system and distance sensor + Modulino.begin(); + distance.begin(); +} + +void loop() { + if (distance.available()) { + int measure = distance.get(); + Serial.println(measure); + } + delay(10); +} +``` + +### Key Functions + +- `available()`: Checks if new distance data is available +- `get()`: Retrieves the measured distance from the sensor (default in cm) + +### Advanced Example - Parking Sensor + +```arduino +#include "Modulino.h" + +ModulinoDistance distance; + +// Distance thresholds in cm +const int DANGER_ZONE = 10; // Less than 10cm +const int WARNING_ZONE = 30; // 10-30cm +const int CAUTION_ZONE = 50; // 30-50cm +const int SAFE_ZONE = 100; // 50-100cm + +void setup() { + Serial.begin(9600); + Modulino.begin(); + distance.begin(); + + Serial.println("Parking Sensor Active"); + Serial.println("==================="); +} + +void loop() { + if (distance.available()) { + int measure = distance.get(); + + // Determine zone and provide feedback + if (measure < DANGER_ZONE) { + Serial.print("🔴 STOP! Distance: "); + Serial.print(measure); + Serial.println(" cm - TOO CLOSE!"); + } + else if (measure < WARNING_ZONE) { + Serial.print("🟠 WARNING - Distance: "); + Serial.print(measure); + Serial.println(" cm - Very close"); + } + else if (measure < CAUTION_ZONE) { + Serial.print("🟡 CAUTION - Distance: "); + Serial.print(measure); + Serial.println(" cm - Getting close"); + } + else if (measure < SAFE_ZONE) { + Serial.print("🟢 SAFE - Distance: "); + Serial.print(measure); + Serial.println(" cm - Good distance"); + } + else { + Serial.print("✓ Clear - Distance: "); + Serial.print(measure); + Serial.println(" cm"); + } + } + + delay(100); // Update 10 times per second +} +``` + +## Programming with MicroPython + +The Modulino Distance is fully compatible with MicroPython through the official Modulino MicroPython library. The following examples demonstrate how to read distance measurements and create proximity-activated systems in your MicroPython projects. + +### Prerequisites + +- Install the Modulino MicroPython library +- Ensure Arduino Lab for MicroPython is installed + +For detailed instructions on setting up your MicroPython environment and installing packages, please refer to the [Getting Started with Modulinos guide](link-to-generic-guide). + +### Basic Example + +```python +from modulino import ModulinoDistance +from time import sleep_ms + +distance = ModulinoDistance() + +while True: + print(f"📏 Distance: {distance.distance} cm") + sleep_ms(50) +``` + +### Key Properties + +- `.distance`: Provides the distance measurement from the sensor (default in cm) + +### Advanced Example - Proximity-Activated System + +```python +from modulino import ModulinoDistance +from time import sleep, ticks_ms + +distance = ModulinoDistance() + +# Configuration +ACTIVATION_DISTANCE = 20 # cm +DEACTIVATION_DISTANCE = 30 # cm +DEBOUNCE_TIME = 500 # milliseconds + +# State tracking +is_activated = False +last_activation_time = 0 +activation_count = 0 + +def check_proximity(): + """Check distance and manage activation state""" + global is_activated, last_activation_time, activation_count + + current_distance = distance.distance + current_time = ticks_ms() + + # Check if we should activate + if not is_activated and current_distance < ACTIVATION_DISTANCE: + # Debounce check + if current_time - last_activation_time > DEBOUNCE_TIME: + is_activated = True + activation_count += 1 + last_activation_time = current_time + print(f"\n✋ ACTIVATED! Object detected at {current_distance} cm") + print(f" Activation count: {activation_count}") + return True + + # Check if we should deactivate + elif is_activated and current_distance > DEACTIVATION_DISTANCE: + is_activated = False + duration = (current_time - last_activation_time) / 1000 + print(f"\n👋 DEACTIVATED after {duration:.1f} seconds") + return False + + return is_activated + +def hand_wave_detector(): + """Detect hand wave gestures""" + samples = [] + sample_time = 50 # ms + wave_threshold = 5 # minimum changes + + print("\nWave your hand in front of the sensor...") + + for _ in range(20): # Collect 1 second of samples + samples.append(distance.distance) + sleep(sample_time / 1000) + + # Detect changes in distance + changes = 0 + for i in range(1, len(samples)): + if abs(samples[i] - samples[i-1]) > 5: # 5cm change threshold + changes += 1 + + if changes >= wave_threshold: + print(f"👋 Wave detected! ({changes} movements)") + return True + + return False + +# Menu system +print("🎯 Distance Sensor Applications") +print("1. Proximity Activation Demo") +print("2. Hand Wave Detection") +print("3. Distance Monitor") + +while True: + choice = input("\nSelect mode (1-3): ") + + if choice == "1": + print(f"\nProximity activation mode") + print(f"Activation: < {ACTIVATION_DISTANCE} cm") + print(f"Deactivation: > {DEACTIVATION_DISTANCE} cm") + + while True: + activated = check_proximity() + if activated: + print(f" Status: ACTIVE | Distance: {distance.distance} cm", end='\r') + else: + print(f" Status: IDLE | Distance: {distance.distance} cm", end='\r') + sleep(0.1) + + elif choice == "2": + print("\nHand wave detection mode") + while True: + if hand_wave_detector(): + print(" Action triggered by wave!") + sleep(0.5) + + elif choice == "3": + print("\nDistance monitoring mode") + while True: + d = distance.distance + # Create visual bar graph + bar_length = min(d // 2, 50) # Scale to max 50 characters + bar = "█" * bar_length + print(f"Distance: {d:4d} cm |{bar}", end='\r') + sleep(0.05) +``` + +## Troubleshooting + +### Sensor Not Reachable + +If your Modulino's power LED isn't on or the sensor isn't responsive: +- Ensure both the board and the Modulino are connected properly +- Verify that the power LEDs on both are lit +- Check that the QWIIC cable is properly clicked into place + +### Inaccurate Values + +If the sensor values are not accurate: +- Ensure the sensor lens is clean and free from dust or obstructions +- Verify the object being measured is within the sensor's detection range +- Check that exposed electronics are not touching conductive surfaces + +## Project Ideas + +- **Parking Assistance System**: Provide audio feedback as objects get closer +- **Theremin Musical Instrument**: Change pitch based on hand movements +- **Automatic Dispenser**: Activate when hands are detected +- **Security System**: Detect when someone approaches a protected area +- **Liquid Level Monitor**: Measure distance to liquid surface in a tank +- **Robot Obstacle Avoidance**: Help robots navigate around objects +- **Interactive Art Installation**: Trigger effects based on viewer proximity +- **Smart Trash Can**: Automatically open lid when someone approaches \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/image.png b/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/image.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/image.png rename to content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance/image.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/datasheet/datasheet.md b/content/hardware/11.accessories/modulino-nodes/modulino-knob/datasheet/datasheet.md index cfd87a3847..4122a745f5 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-knob/datasheet/datasheet.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-knob/datasheet/datasheet.md @@ -43,9 +43,9 @@ Maker, beginner, education ## Related Products -- *SKU: ASX00027* – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) -- *SKU: K000007* – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) -- *SKU: AKX00026* – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) +- **SKU: ASX00027** – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) +- **SKU: K000007** – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) +- **SKU: AKX00026** – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) ## Rating diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/product.md b/content/hardware/11.accessories/modulino-nodes/modulino-knob/product.md index e2182454ba..e0383520fb 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-knob/product.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-knob/product.md @@ -2,10 +2,10 @@ title: Modulino Knob url_shop: https://store.arduino.cc/products/modulino-knob url_guide: https://courses.arduino.cc/plugandmake -primary_button_url: https://docs.arduino.cc/tutorials/modulino-knob/how-knob-ardu/ -primary_button_title: With Arduino -secondary_button_url: https://docs.arduino.cc/tutorials/modulino-knob/how-knob-mp/ -secondary_button_title: With MicroPython +primary_button_url: https://docs.arduino.cc/tutorials/modulino-knob/how-knob/ +primary_button_title: Get Started +secondary_button_url: https://docs.arduino.cc/tutorials/modulino-thermo/how-general/ +secondary_button_title: More on Modulinos forumCategorySlug: '/hardware/accessories/modulino-knob/217' sku: [ABX00107] --- diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/AdressChangeIDE.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/AdressChangeIDE.png deleted file mode 100644 index d5cd3fd195..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/AdressChangeIDE.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/Modulino_Knob_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/Modulino_Knob_Power_Tree.png deleted file mode 100644 index f50d5ba207..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/Modulino_Knob_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/adressChanger.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/adressChanger.png deleted file mode 100644 index c6eae670c8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/adressChanger.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob-jumper.png deleted file mode 100644 index f53484a929..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob-qwiic-chain.png deleted file mode 100644 index bdb182ec7e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob-qwiic.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob-qwiic.png deleted file mode 100644 index 82dccffca5..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob-qwiic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob.png deleted file mode 100644 index 8e5bc0b051..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/connection-guide-knob.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/library-dependencies.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/library-dependencies.png deleted file mode 100644 index d25bd9720b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/library-dependencies.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/library-install.gif b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/library-install.gif deleted file mode 100644 index 16f396c353..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/library-install.gif and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/library-menu.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/library-menu.png deleted file mode 100644 index 2339cf8450..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/library-menu.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/content.md deleted file mode 100644 index 44f4ad3ee5..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/content.md +++ /dev/null @@ -1,253 +0,0 @@ ---- -title: "How To Use The Modulino Knob" -description: "Learn how to get the most out of your Modulino Knob." -tags: - - Modulino - - QWIIC - - I2C -author: 'Christoher Méndez' -hardware: - - hardware/11.modulinos/modulinos/modulino-knob -software: - - ide-v2 - - web-editor ---- - -The Modulino Knob is a modular sensor based on a quadrature rotary encoder that translates angular motion (rotation) into a digital signal. The sensor value will increase or decrease according to the rotation direction. Also, it includes an SPST switch that is activated when the knob is pressed. - -It uses the Modulino form factor, streamlining integration through the I2C protocol. It provides QWIIC connectors and exposed solderable pins (for boards without a QWIIC interface). - -## General Characteristics - -The Modulino Knob has the following measurement specifications: - - -| **Parameter** | **Condition** | **Minimum** | **Typical** | **Maximum** | **Unit** | -| -------------- | ------------- | ----------- | ---------------- | ----------- | -------- | -| Sensor | Angle | - | 360 (continuous) | - | ° | -| Steps | - | - | 30 | - | - | -| Resolution | - | - | 12 | - | bit | - -### Sensor Details - -The PEC11J-9215F-S0015 rotary encoder is the core component of this module. This sensor output is processed by an STM32C011F4 microcontroller for digital communication (I2C), meaning that the encoder is communicated through the I2C pins using the mentioned microcontroller as an intermediary. - -The default address for the Module is: - -| **Modulino I2C Address** | **Hardware I2C Address** | -| ------------------------ | ------------------------ | -| 0x76 | 0x3A | - -When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. - -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - - -## Pinout - -The rotary encoder is the core component of this module. This input device is controlled by an onboard STM32 microcontroller, which supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -![Arduino Knob Pinout](assets/KnobPinouts.png) - -The board also includes direct connections to the rotary encoder bypassing the built-in microcontroller. - -### 1x10 Header - -| Pin | Function | -|-------|----------------| -| PA2 | Button | -| GND | Ground | -| 3V3 | 3.3 V Power | -| PF2 | RESET | -| SWCLK | SWD Clock | -| SWDIO | SWD Data | -| TX1 | USART Transmit | -| RX1 | USART Receive | -| PA0 | Encoder A | -| PA1 | Encoder B | - -- **PA2: Button:**This pin connects directly to the built-in button of the rotary encoder. -- **GND: Ground:**Ground connection for power and signal reference. -- **3V3: Power:**3.3 V power supply input. -- **PF2: RESET:**The reset pin for the microcontroller, which can be used to reset the system. -- **SWCLK: SWD Clock:**Used for providing the clock signal in the SWD interface. -- **SWDIO: SWD Data:**Used for debugging, as part of the Serial Wire Debug (SWD) interface. -- **TX1: USART Transmit:**Used for transmitting data over UART communication. -- **RX1: USART Receive:**Used for receiving data over UART communication. -- **PA0: Encoder A:**These pins connect directly to the rotary encoder's quadrature outputs. -- **PA1: Encoder B:**These pins connect directly to the rotary encoder's quadrature outputs. - -### 1x4 Header (I2C) - -The pinout for the Modulino Knob is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - -## Power Specifications - -The board must be powered **only** by +3.3 VDC when using the solderable pins or the QWIIC interface as per the standard. - -| Parameter | Typical | Unit | -| --------------- | ------- | ---- | -| Supply Voltage | 3.3 | V | -| Average Current | 3.4 | mA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Knob](assets/Modulino_Knob_Power_Tree.png) - -## Schematic - -The Modulino Knob uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Knob](assets/schematic.png) - -The main components are the **rotary encoder with integrated pushbutton** (PECHL-9215E-S0015) and the **STM32C011F4U6TR** microcontroller (U1), which handles encoder position reading, button state detection, as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J3). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J3. - -There's also a small power LED indicator (green) that lights up when the board is on. - -You can grab the full schematic and PCB files from the [Modulino Knob](https://docs.arduino.cc/hardware/modulinos/modulino-knob) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It's plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-knob.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-knob-qwiic.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-knob-jumper.png) - -### Daisy-Chaining Multiple Modulino Nodes - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus. This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-knob-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup's performance. Ensure your cables are properly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.*** - -## How To Use Your Modulino - -### Installing The Modulino Library - -You need the official Modulino library available [here](https://github.com/arduino-libraries/Modulino) to use the Modulino Knob. - -With the Arduino IDE, you get some tools that make adding a library easier. To learn how to install the IDE, please visit our [page](https://docs.arduino.cc/micropython/first-steps/install-guide/). - -After opening the IDE, a tab should be visible on the left. Press the book icon for "library" as highlighted in the image. - -![IDE Library Tab](assets/library-menu.png) - -You can now search for the library `Modulino` by filling in the `Filter your search` text box. A prompt might appear saying that additional dependencies are required. This is not a problem, as they will be automatically added when you confirm the prompt. - -![Add Dependencies Prompt](assets/library-dependencies.png) - -The libraries should now start to install. A message will appear after the installation is successful. - -The process should be like this: - -![Library Install](assets/library-install.gif) - -### Getting Knob Data - -Data can be obtained from the sensor using the `Modulino` library. - -For the **Knob** there are two important functions: - -- `get()`: Returns a numerical value relative to the knob rotation. -- `isPressed()`: Returns the state of the knob built-in button. -- `knob.get();` retrieves a unitless value relative to the knob rotation. -- `knob.isPressed();` retrieves the knob button state. -- `knob.set();` changes the initial position of the encoder. -- `Modulino.begin();`: By default the Modulino library uses ```Wire1``` if your connection is in a different Wire you will have to edit it, check [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/) (by default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/)) for the library's hardware compatibility. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here is an example sketch of how to implement these functions to acquire data: - -```arduino -#include - -ModulinoKnob knob; - -void setup() { - Serial.begin(9600); - Modulino.begin(); - knob.begin(); -} - -void loop(){ - int position = knob.get(); - bool click = knob.isPressed(); - - Serial.print("Current position is: "); - Serial.println(position); - - if(click){ - Serial.println("Clicked!"); - } - -} -``` - -### How To Change I2C Address - -An example sketch, AddressChanger, is also included with the library inside the `Utilities` folder and available [here](https://github.com/arduino-libraries/Modulino/blob/main/examples/Utilities/AddressChanger/AddressChanger.ino). This sketch changes the I²C address at a software level on the Module's microcontroller. - -![Example location on the IDE](assets/AdressChangeIDE.png) - -- Connect the module to your board, remove any other modules that might be in the chain. Connection must be via I²C. -- Upload the sketch. -- Open the Serial Monitor. -- Text should now appear. Make sure the correct bauld-rate is selected if the displayed characters seem corrupted. - - ![Expected console output](assets/adressChanger.png) - -- Select the address and confirm. Valid I²C addresses range from 0x08 to 0x77 (7-bit values in hexadecimal format, e.g., 0x42). -- Your address should now have changed. Make sure to take note of the selected address. - -To keep track of the address in use the module has a white rectangle on the back. Feel free to use this to write the address that was chosen. - -When using a custom address in your sketch, you'll need to specify this address when creating the module object. For example: - -```arduino -ModulinoKnob knob(0x3E); // Replace 0x3E with your specific address -``` - - -## Conclusion - -The **Modulino Knob** provides a simple solution for UI interface, volume control or rotational measurement in any project. With its **I2C interface**, compact **Modulino form factor**, and **robustness**, it seamlessly integrates into both beginner and advanced applications. - -By leveraging the **Modulino library**, users can quickly access sensor data and implement functionalities such as **user interface control and angle measurement tool**. With just a few lines of code, you can start **controlling your projects**, making it easier than ever to bring intelligent sensing to your applications. - -## What Is Next? - -After mastering the basics of the Modulino Knob, try these project ideas: - -- Calculate what is the encoder rotation angle per step to convert the arbitrary output into a rotation angle output. -- Control the Arduino onboard LED with the press of the knob button. -- Use the Modulino Knob to control the navigation on a UI display on an LCD or OLED screen. \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/KnobPinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/KnobPinouts.png deleted file mode 100644 index ea4147de61..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/KnobPinouts.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/Modulino_Knob_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/Modulino_Knob_Power_Tree.png deleted file mode 100644 index f50d5ba207..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/Modulino_Knob_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob-jumper.png deleted file mode 100644 index 61ae95f8bc..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob-qwiic-chain.png deleted file mode 100644 index bdb182ec7e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob-qwiic.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob-qwiic.png deleted file mode 100644 index 82dccffca5..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob-qwiic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob.png deleted file mode 100644 index 8e5bc0b051..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/connection-guide-knob.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/mp-usb-connection.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/mp-usb-connection.png deleted file mode 100644 index fb059f9e8b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/mp-usb-connection.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/package-installer-overview.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/package-installer-overview.png deleted file mode 100644 index 67678dc808..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/package-installer-overview.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/schematic.png deleted file mode 100644 index 4b20ab5c12..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/assets/schematic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/content.md deleted file mode 100644 index b3d29bc8c6..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-mp/content.md +++ /dev/null @@ -1,263 +0,0 @@ ---- -title: "How To Use The Modulino Knob with MicroPython" -description: "Learn how to get the most out of your Modulino Knob in a MicroPython environment." -tags: - - Modulino - - QWIIC - - I2C -author: 'Christoher Méndez' -hardware: - - hardware/11.modulinos/modulinos/modulino-knob -software: - - ide-v2 - - web-editor ---- - -The Modulino Knob is a modular sensor based on a quadrature rotary encoder that translates angular motion (rotation) into a digital signal. The sensor value will increase or decrease according to the rotation direction. Also, it includes an SPST switch that is activated when the knob is pressed. - -It uses the Modulino form factor, streamlining integration through the I2C protocol. It provides QWIIC connectors and exposed solderable pins (for boards without a QWIIC interface). - -## General Characteristics - -The Modulino Knob has the following measurement specifications: - - -| **Parameter** | **Condition** | **Minimum** | **Typical** | **Maximum** | **Unit** | -| -------------- | ------------- | ----------- | ---------------- | ----------- | -------- | -| Sensor | Angle | - | 360 (continuous) | - | ° | -| Steps | - | - | 30 | - | - | -| Resolution | - | - | 12 | - | bit | - -### Sensor Details - -The PEC11J-9215F-S0015 rotary encoder is the core component of this module. This sensor output is processed by an STM32C011F4 microcontroller for digital communication (I2C), meaning that the encoder is communicated through the I2C pins using the mentioned microcontroller as an intermediary. - -The default address for the Module is: - -| **Modulino I2C Address** | **Hardware I2C Address** | -| ------------------------ | ------------------------ | -| 0x76 | 0x3A | - -When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. - -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - - -## Pinout - -The rotary encoder is the core component of this module. This input device is controlled by an onboard STM32 microcontroller, which supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -![Arduino Knob Pinout](assets/KnobPinouts.png) - -The board also includes direct connections to the rotary encoder bypassing the built-in microcontroller. - -### 1x10 Header - -| Pin | Function | -|-------|----------------| -| PA2 | Button | -| GND | Ground | -| 3V3 | 3.3 V Power | -| PF2 | RESET | -| SWCLK | SWD Clock | -| SWDIO | SWD Data | -| TX1 | USART Transmit | -| RX1 | USART Receive | -| PA0 | Encoder A | -| PA1 | Encoder B | - -- **PA2: Button:**This pin connects directly to the built-in button of the rotary encoder. -- **GND: Ground:**Ground connection for power and signal reference. -- **3V3: Power:**3.3 V power supply input. -- **PF2: RESET:**The reset pin for the microcontroller, which can be used to reset the system. -- **SWCLK: SWD Clock:**Used for providing the clock signal in the SWD interface. -- **SWDIO: SWD Data:**Used for debugging, as part of the Serial Wire Debug (SWD) interface. -- **TX1: USART Transmit:**Used for transmitting data over UART communication. -- **RX1: USART Receive:**Used for receiving data over UART communication. -- **PA0: Encoder A:**These pins connect directly to the rotary encoder's quadrature outputs. -- **PA1: Encoder B:**These pins connect directly to the rotary encoder's quadrature outputs. - -### 1x4 Header (I2C) - -The pinout for the Modulino Knob is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - -## Power Specifications - -The board must be powered **only** by +3.3 VDC when using the solderable pins or the QWIIC interface as per the standard. - -| Parameter | Typical | Unit | -| --------------- | ------- | ---- | -| Supply Voltage | 3.3 | V | -| Average Current | 3.4 | mA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Knob](assets/Modulino_Knob_Power_Tree.png) - -## Schematic - -The Modulino Knob uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Knob](assets/schematic.png) - -The main components are the **rotary encoder with integrated pushbutton** (PECHL-9215E-S0015) and the **STM32C011F4U6TR** microcontroller (U1), which handles encoder position reading, button state detection, as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J3). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J3. - -There's also a small power LED indicator (green) that lights up when the board is on. - -You can grab the full schematic and PCB files from the [Modulino Knob](https://docs.arduino.cc/hardware/modulinos/modulino-knob) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It's plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-knob.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-knob-qwiic.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-knob-jumper.png) - -### Daisy-Chaining Multiple Modulino Nodes - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus. This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-knob-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup's performance. Ensure your cables are properly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.*** - -## How To Program Your Modulino - -### Installing The Modulino Library - -To program your Modulino it is recommended you use the official `Modulino` micropython library available [here](https://github.com/arduino/arduino-modulino-mpy). The library is fully compatible with the **Arduino Lab for MicroPython**. - -For information on installing the **Arduino Lab for MicroPython** please visit our [page](https://docs.arduino.cc/micropython/first-steps/install-guide/). - -The `Modulino` library is not available by default on MicroPython devices hence installation is needed. - -To simplify the process the [MicroPython Package Installer](https://github.com/arduino/lab-micropython-package-installer/releases) is recommended as it will provide a graphical interface to guide the installation. - -After installation, you should now be able to: - -1. Open the tool. -2. Plug in your board to the computer. - - ![USB Connection](assets/mp-usb-connection.png) - - If the board does not appear in the Detected Boards section, click Reload. If the board is still undetected, ensure no other programs (e.g., a code editor) are using the board's COM port. - -3. Search for the `Modulino` package by filling in the text box on the search feature. -4. Click Install and wait for the installation confirmation. -5. Disconnect the board from the tool before returning to your code editor to avoid conflicts due to a busy COM port. - -![Package Installer Overview](assets/package-installer-overview.png) - -The module should now be includable in your program using: - -```python -from modulino import ModulinoThermo -``` - -### Getting Knob Data - -Data can be obtained from the sensor using the `Modulino` package. - -For the **Knob** there is a crucial function: - -- `ModulinoKnob` is imported from the `modulino` package to interact with the **Modulino Knob** sensor. -- `sleep` is imported from the `time` module to introduce delays between readings. -- `.update` - Check for new available data from the sensor and execute callback functions to react to the button press or rotation. -- `knob.value` lets you set the sensor initial value from which the encoder rotation will start increasing or decreasing. -- `knob.range` lets you set the minimum and maximum possible value of the encoder output. -- `knob.on_press` this function establish what will happen when the knob button is pressed. -- `knob.on_release` calls the `on_release()` function when the knob button is released. -- `knob.on_rotate_clockwise` prints the rotation value when the knob is turned clockwise. -- `knob.on_rotate_counter_clockwise` prints the rotation value when the knob is turned counter-clockwise. -- `knob.update()` function is called continuously checking for knob new values. If the rotation or button state is changed, it will print a message on the Terminal. -By default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it as instructed [here](https://github.com/arduino/arduino-modulino-mpy/tree/main/docs#%E2%84%B9%EF%B8%8F-using-3rd-party-boards). More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - - -Here is an example of how to implement this function to acquire data: - -```python -from modulino import ModulinoKnob -from time import sleep - -knob = ModulinoKnob() -knob.value = 0 # (Optional) Set an initial value -knob.range = (-10, 10) # (Optional) Set a value range - -def on_release(): - knob.reset() - print("🔘 Released! Knob's value was reset.") - -knob.on_press = lambda: print("🔘 Pressed!") -knob.on_release = on_release -knob.on_rotate_clockwise = lambda steps, value: print(f"🎛️ Rotated {steps} steps clockwise! Value: {value}") -knob.on_rotate_counter_clockwise = lambda steps, value: print(f"🎛️ Rotated {steps} steps counter clockwise! Value: {value}") - -while True: - if(knob.update()): - print("👀 Knob value or state changed!") - - sleep(0.1) -``` - -The code can be easily adapted to trigger actions at certain rotation thresholds or to log data for analysis. - -### How To Change Address - -A sketch is also available included with the library named `AddressChanger` and also available [here](https://github.com/arduino/arduino-modulino-mpy/blob/main/examples/change_address.py). This sketch changes the I2C address at a software level on the Module's microcontroller. - -- Connect the module to your board via I2C, ensuring no other modules are in the chain. -- Run the script in a MicroPython environment. -- Follow the on-screen instructions (REPL) to select the device and enter a new address. Valid I²C addresses range from 0x08 to 0x77 (7-bit values in hexadecimal format, e.g., 0x42). -- The script will attempt to change the address and confirm success. - -To keep track of the address in use, the module has a white rectangle on the back. Feel free to use this to write the address that was chosen. - -When using a custom address in your MicroPython sketch, you'll need to specify this address when creating the module object. For example: - -```python -knob_module = ModulinoKnob(address=0x45) # Replace 0x45 with your specific address -``` - -## Conclusion - -The **Modulino Knob** provides a simple solution for UI interface, volume control or rotational measurement in any project. With its **I2C interface**, compact **Modulino form factor**, and **robustness**, it seamlessly integrates into both beginner and advanced applications. - -By leveraging the **Modulino package**, users can quickly access sensor data and implement functionalities such as **user interface control and angle measurement tool**. With just a few lines of code, you can start **controlling your projects**, making it easier than ever to bring intelligent sensing to your applications. - -## What Is Next? - -After mastering the basics of the Modulino Knob, try these project ideas: - -- Calculate what is the encoder rotation angle per step to convert the arbitrary output into a rotation angle output. -- Control the Arduino onboard LED with the press of the knob button. -- Use the Modulino Knob to control the navigation on a UI display on an LCD or OLED screen. \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob/assets/KnobOverview.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob/assets/KnobOverview.png new file mode 100644 index 0000000000..5e7a267866 Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob/assets/KnobOverview.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/KnobPinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob/assets/KnobPinouts.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/KnobPinouts.png rename to content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob/assets/KnobPinouts.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob/assets/schematic.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob-ardu/assets/schematic.png rename to content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob/assets/schematic.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob/content.md new file mode 100644 index 0000000000..14c93a7334 --- /dev/null +++ b/content/hardware/11.accessories/modulino-nodes/modulino-knob/tutorials/how-knob/content.md @@ -0,0 +1,399 @@ +--- +title: "Modulino Knob" +description: "Complete guide for the Modulino Knob rotary encoder module." +tags: + - Modulino + - Knob + - Encoder + - Input + - QWIIC + - I2C +author: 'Christopher Méndez' +hardware: + - hardware/11.modulinos/modulinos/modulino-knob +software: + - ide-v2 + - web-editor + - micropython +--- + +![Knob Overview](assets/KnobOverview.png) + +The Modulino Knob is a modular sensor based on a quadrature rotary encoder that translates angular motion (rotation) into a digital signal. The sensor value will increase or decrease according to the rotation direction. Also, it includes an SPST switch that is activated when the knob is pressed. + +## Hardware Overview + +### General Characteristics + +The Modulino Knob has the following measurement specifications: + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|------------|-----------|---------|------------------|---------|------| +| Sensor | Angle | - | 360 (continuous) | - | ° | +| Steps | - | - | 30 | - | - | +| Resolution | - | - | 12 | - | bit | + +### Sensor Details + +The PEC11J-9215F-S0015 rotary encoder is the core component of this module. This sensor output is processed by an STM32C011F4 microcontroller for digital communication (I²C), meaning that the encoder is communicated through the I²C pins using the mentioned microcontroller as an intermediary. + +The default address for the Module is: + +| Modulino I²C Address | Hardware I²C Address | +|----------------------|----------------------| +| 0x76 | 0x3A | + +The I²C address can be changed via software configuration. + +### Pinout + +![Arduino Knob Pinout](assets/KnobPinouts.png) + +#### 1x10 Header + +| Pin | Function | +|-------|----------------| +| PA2 | Button | +| GND | Ground | +| 3V3 | 3.3 V Power | +| PF2 | RESET | +| SWCLK | SWD Clock | +| SWDIO | SWD Data | +| TX1 | USART Transmit | +| RX1 | USART Receive | +| PA0 | Encoder A | +| PA1 | Encoder B | + +The board includes direct connections to the rotary encoder (PA0, PA1, PA2) bypassing the built-in microcontroller. + +#### 1x4 Header (I2C) + +| Pin | Function | +|-------|--------------| +| GND | Ground | +| 3.3 V | Power Supply | +| SDA | I²C Data | +| SCL | I²C Clock | + +### Power Specifications + +| Parameter | Typical | Unit | +|-----------------|---------|------| +| Supply Voltage | 3.3 | V | +| Average Current | 3.4 | mA | + +The module includes a power LED that draws 1 mA and turns on as soon as it is powered. + +### Schematic + +The Modulino Knob features a robust circuit design for rotational input and button detection. + +![Full Schematic Modulino Knob](assets/schematic.png) + +The main components are the **rotary encoder with integrated pushbutton** (PECHL-9215E-S0015) and the **STM32C011F4U6TR** microcontroller (U1), which handles encoder position reading, button state detection, as well as I²C communication. + +You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J3). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J3. + +There's also a small power LED indicator (green) that lights up when the board is on. + +You can grab the full schematic and PCB files from the [Modulino Knob product page](https://docs.arduino.cc/hardware/modulinos/modulino-knob). + +## Programming with Arduino + +The Modulino Knob is fully compatible with the Arduino IDE and the official Modulino library. The following examples showcase how to read rotational input, detect button presses, and implement user interface controls in your Arduino projects. + +### Prerequisites + +- Install the Modulino library via the Arduino IDE Library Manager +- Connect your Modulino Knob via QWIIC or solderable headers + +For detailed instructions on setting up your Arduino environment and installing libraries, please refer to the [Getting Started with Modulinos guide](link-to-generic-guide). + +### Basic Example + +```arduino +#include + +ModulinoKnob knob; + +void setup() { + Serial.begin(9600); + Modulino.begin(); + knob.begin(); +} + +void loop(){ + int position = knob.get(); + bool click = knob.isPressed(); + + Serial.print("Current position is: "); + Serial.println(position); + + if(click){ + Serial.println("Clicked!"); + } +} +``` + +### Key Functions + +- `get()`: Returns a numerical value relative to the knob rotation +- `isPressed()`: Returns the state of the knob's built-in button +- `set()`: Changes the initial position of the encoder + +### Advanced Example - Menu Navigation + +```arduino +#include + +ModulinoKnob knob; + +// Menu configuration +const int MENU_ITEMS = 5; +String menuOptions[] = {"Settings", "Display", "Audio", "Network", "Exit"}; +int currentSelection = 0; +int lastPosition = 0; +bool lastButtonState = false; + +void setup() { + Serial.begin(9600); + Modulino.begin(); + knob.begin(); + + // Set initial position to 0 + knob.set(0); + lastPosition = 0; + + displayMenu(); +} + +void displayMenu() { + Serial.println("\n======= MENU ======="); + for (int i = 0; i < MENU_ITEMS; i++) { + if (i == currentSelection) { + Serial.print("> "); // Selection indicator + } else { + Serial.print(" "); + } + Serial.println(menuOptions[i]); + } + Serial.println("=================="); + Serial.println("Rotate to navigate, press to select"); +} + +void selectMenuItem() { + Serial.print("\n✓ Selected: "); + Serial.println(menuOptions[currentSelection]); + + // Handle selection + switch(currentSelection) { + case 0: + Serial.println("Opening Settings..."); + break; + case 1: + Serial.println("Opening Display options..."); + break; + case 2: + Serial.println("Opening Audio settings..."); + break; + case 3: + Serial.println("Opening Network configuration..."); + break; + case 4: + Serial.println("Exiting menu..."); + break; + } + + delay(1000); + displayMenu(); +} + +void loop() { + int currentPosition = knob.get(); + bool buttonPressed = knob.isPressed(); + + // Check for rotation + int rotation = currentPosition - lastPosition; + + if (rotation != 0) { + // Update selection based on rotation direction + if (rotation > 0) { + currentSelection++; + if (currentSelection >= MENU_ITEMS) { + currentSelection = 0; // Wrap around + } + } else { + currentSelection--; + if (currentSelection < 0) { + currentSelection = MENU_ITEMS - 1; // Wrap around + } + } + + lastPosition = currentPosition; + displayMenu(); + } + + // Check for button press (on release to avoid multiple triggers) + if (!buttonPressed && lastButtonState) { + selectMenuItem(); + } + + lastButtonState = buttonPressed; + + delay(50); // Small delay for debouncing +} +``` + +## Programming with MicroPython + +The Modulino Knob is fully compatible with MicroPython through the official Modulino MicroPython library. The following examples demonstrate how to read rotational input, handle button events, and create interactive controls in your MicroPython projects. + +### Prerequisites + +- Install the Modulino MicroPython library +- Ensure Arduino Lab for MicroPython is installed + +For detailed instructions on setting up your MicroPython environment and installing packages, please refer to the [Getting Started with Modulinos guide](link-to-generic-guide). + +### Basic Example + +```python +from modulino import ModulinoKnob +from time import sleep + +knob = ModulinoKnob() +knob.value = 0 # (Optional) Set an initial value +knob.range = (-10, 10) # (Optional) Set a value range + +def on_release(): + knob.reset() + print("🔘 Released! Knob's value was reset.") + +knob.on_press = lambda: print("🔘 Pressed!") +knob.on_release = on_release +knob.on_rotate_clockwise = lambda steps, value: print(f"🎛️ Rotated {steps} steps clockwise! Value: {value}") +knob.on_rotate_counter_clockwise = lambda steps, value: print(f"🎛️ Rotated {steps} steps counter clockwise! Value: {value}") + +while True: + if(knob.update()): + print("👀 Knob value or state changed!") + + sleep(0.1) +``` + +### Key Functions and Properties + +- `.value`: Set/get the sensor's current value +- `.range`: Set the minimum and maximum possible value +- `.on_press`: Callback for button press +- `.on_release`: Callback for button release +- `.on_rotate_clockwise`: Callback for clockwise rotation +- `.on_rotate_counter_clockwise`: Callback for counter-clockwise rotation +- `.update()`: Check for new values and trigger callbacks +- `.reset()`: Reset the encoder value + +### Advanced Example - Volume Control with Visual Feedback + +```python +from modulino import ModulinoKnob +from time import sleep + +knob = ModulinoKnob() + +# Volume control configuration +knob.value = 50 # Start at 50% +knob.range = (0, 100) # Volume range 0-100% + +# State tracking +is_muted = False +last_volume = 50 + +def draw_volume_bar(volume, muted=False): + """Draw a visual representation of the volume""" + bar_length = 20 + filled = int((volume / 100) * bar_length) + empty = bar_length - filled + + if muted: + bar = "[" + "X" * bar_length + "]" + status = "🔇 MUTED" + else: + bar = "[" + "█" * filled + "░" * empty + "]" + if volume == 0: + status = "🔈" + elif volume < 33: + status = "🔉" + elif volume < 66: + status = "🔊" + else: + status = "🔊" + + print(f"\rVolume: {bar} {volume:3d}% {status} ", end="") + +def toggle_mute(): + """Toggle mute state""" + global is_muted, last_volume + + is_muted = not is_muted + + if is_muted: + last_volume = knob.value + knob.value = 0 + print("\n🔇 Muted!") + else: + knob.value = last_volume + print(f"\n🔊 Unmuted! Volume: {last_volume}%") + +def volume_change(steps, value): + """Handle volume changes""" + global is_muted + + if is_muted: + is_muted = False # Unmute when rotating + + draw_volume_bar(value) + +# Configure callbacks +knob.on_press = toggle_mute +knob.on_rotate_clockwise = volume_change +knob.on_rotate_counter_clockwise = volume_change + +print("🎛️ Volume Control System") +print("Rotate: Change volume | Press: Mute/Unmute") +print("-" * 40) + +# Initial display +draw_volume_bar(knob.value) + +# Main loop +while True: + knob.update() + sleep(0.01) +``` + +## Troubleshooting + +### Knob Not Responding + +If your Modulino's power LED isn't on or the knob isn't responsive: +- Ensure both the board and the Modulino are connected properly +- Verify that the power LEDs on both are lit +- Check that the QWIIC cable is properly clicked into place + +### Erratic Values + +If the encoder values jump unexpectedly: +- Check for loose connections +- Ensure the module is not near sources of electromagnetic interference +- Try adjusting the debounce time if using button events + +## Project Ideas + +- **Volume Control**: Adjust audio levels with tactile feedback +- **Menu Navigation**: Navigate through LCD or OLED display menus +- **Parameter Adjustment**: Fine-tune values in real-time applications +- **Game Controller**: Use rotation for steering or aiming in games +- **Light Dimmer**: Control LED brightness smoothly +- **Frequency Tuner**: Adjust frequencies for signal generators +- **Camera Control**: Pan/tilt control for camera systems +- **Smart Thermostat**: Set temperature with precise control \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/datasheet/datasheet.md b/content/hardware/11.accessories/modulino-nodes/modulino-movement/datasheet/datasheet.md index 3d252ebccf..323edc415c 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-movement/datasheet/datasheet.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-movement/datasheet/datasheet.md @@ -52,11 +52,11 @@ Below are some project ideas focused on the Modulino® Movement module and its b ## Related Products -- *SKU: ASX00027* - [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) +- **SKU: ASX00027** - [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) -- *SKU: K000007* - [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) +- **SKU: K000007** - [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) -- *SKU: AKX00026* - [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) +- **SKU: AKX00026** - [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) ## Rating diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/product.md b/content/hardware/11.accessories/modulino-nodes/modulino-movement/product.md index abd2e4ecea..0d52b66d02 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-movement/product.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-movement/product.md @@ -2,10 +2,10 @@ title: Modulino Movement url_shop: https://store.arduino.cc/products/modulino-movement url_guide: https://courses.arduino.cc/plugandmake -primary_button_url: https://docs.arduino.cc/tutorials/modulino-movement/how-movement-ardu/ -primary_button_title: With Arduino -secondary_button_url: https://docs.arduino.cc/tutorials/modulino-movement/how-movement-mp/ -secondary_button_title: With MicroPython +primary_button_url: https://docs.arduino.cc/tutorials/modulino-movement/how-movement/ +primary_button_title: Get Started +secondary_button_url: https://docs.arduino.cc/tutorials/modulino-thermo/how-general/ +secondary_button_title: More on Modulinos forumCategorySlug: '/hardware/accessories/modulino-movement/218' sku: [ABX00101] --- diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/IDE-Left-Tab.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/IDE-Left-Tab.png deleted file mode 100644 index c7bb86575e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/IDE-Left-Tab.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/Modulino_Movement_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/Modulino_Movement_Power_Tree.png deleted file mode 100644 index fe775335ff..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/Modulino_Movement_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement-jumper.png deleted file mode 100644 index 5381b10c45..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement-qwiic-chain.png deleted file mode 100644 index c6c89cc127..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement-qwiik.png deleted file mode 100644 index 331a2f823c..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement.png deleted file mode 100644 index c21dcc1db7..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/connection-guide-movement.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/library-dependencies.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/library-dependencies.png deleted file mode 100644 index d25bd9720b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/library-dependencies.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/library-install.gif b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/library-install.gif deleted file mode 100644 index 16f396c353..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/library-install.gif and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/schematic.png deleted file mode 100644 index a804960788..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/schematic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/content.md deleted file mode 100644 index d7543e2756..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/content.md +++ /dev/null @@ -1,326 +0,0 @@ ---- -title: "How To Use The Modulino Movement" -description: "Learn how to get the most out of your Modulino Movement." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-movement -software: - - ide-v2 - - web-editor ---- - -The Modulino Movement is a modular sensor that measures acceleration and angular velocity, making it perfect to add motion sensing to your projects! The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - - -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple modulinos in a very simple way. In addition to the QWIIC's connectors, the Modulinos also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - -## General Characteristics - -The Modulino Movement is capable of measuring acceleration and angular velocity. Take a look at the following table to know more about its measuring ranges: - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|---------------------------------|-------------------------|---------|---------|---------|----------| -| **Accelerometer Range** | Configurable Full Scale | ±2 | ±8 | ±16 | g | -| **Gyroscope Range** | Configurable Full Scale | ±125 | ±1000 | ±2000 | dps | -| **Accelerometer Sensitivity** | @ ±2g | 0.061 | - | - | mg/LSB | -| **Gyroscope Sensitivity** | @ ±125dps | 4.375 | - | - | mdps/LSB | -| **Accelerometer Noise Density** | High-performance mode | - | 70 | - | µg/√Hz | -| **Gyroscope Noise Density** | High-performance mode | - | 3.8 | - | mdps/√Hz | -| **Temperature Sensor Range** | - | -40 | - | +85 | °C | -| **FIFO Buffer** | - | - | 9 | - | KB | -| **Sampling Rate** | Output Data Rate | 1.6 | - | 6664 | Hz | - -### Sensor Details - -The LSM6DSOXTR sensor from STMicroelectronics is the core component of this module. This 6-axis IMU (accelerometer and gyroscope) natively supports digital communication (I²C and SPI), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. -The default address for the Module is: - -| Modulino I²C Address | Hardware I²C Address | -|----------------------|----------------------| -| 0x6A or 0x7E | 0x6A or 0x7E | - -When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - -## Pinout - -The pinout for the Modulino Movement is shown below. Please note that the exposed solderable pins are directly connected to the QWIIC connectors using the same I²C interface. - -![Arduino Movement Pinout](assets/MovementPinouts.png) - -Depending on the board connected to the modulino, the I²C pin names to program it may differ. Please check the [board tutorials](https://docs.arduino.cc/hardware/) on your modulino's compatible board or the [Modulino library](https://github.com/arduino-libraries/Modulino/tree/main/docs) to learn more. - -### 1x10 Header - -| Pin | Function | -|---------|------------------| -| VDDIO | Power | -| GND | Ground | -| INT1 | Interrupt 1 | -| INT2 | Interrupt 2 | -| SDO/SA0 | SPI Data Out | -| SCx | SPI Clock | -| SDx | SPI Data | -| CS | SPI Chip Select | -| SDOAUX | Auxiliary Output | -| OCSAUX | Auxiliary Output | - -- **VDDIO: Power** – I/O voltage supply pin for the sensor. -- **GND: Ground** – Ground connection for power and signal reference. -- **INT1: Interrupt 1** – Programmable interrupt output pin. -- **INT2: Interrupt 2** – Programmable interrupt output pin. -- **SDO/SA0: SPI Data Out** – SPI data output pin, also used as I2C address selection. -- **SCx: SPI Clock** – Clock signal for SPI communication. -- **SDx: SPI Data** – SPI data input pin. -- **CS: SPI Chip Select** – Chip select pin for SPI communication. -- **SDOAUX: Auxiliary Output** – Auxiliary data output pin. -- **OCSAUX: Auxiliary Output** – Auxiliary output control signal pin. - -### 1x4 Header (I2C) - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I2C Data | -| SCL | I2C Clock | - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|-----------------------------------------------|---------------------|---------|-------------|---------|------| -| Supply Voltage | - | 1.71 | 3.3 (QWIIC) | 3.6 | V | -| I/O Voltage | - | 1.62 | - | 3.6 | V | -| Gyro + Accel Current (High Performance Mode) | Both sensors active | - | 0.55 | - | mA | -| Accelerometer Current (High Performance Mode) | - | - | 170 | - | µA | -| Accelerometer Current (Low Power Mode) | ODR = 50 Hz | - | 26 | - | µA | -| Accelerometer Current (Ultra-Low Power Mode) | ODR = 50 Hz | - | 9.5 | - | µA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Movement](assets/Modulino_Movement_Power_Tree.png) - -## Schematic - -The Modulino Movement uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Movement](assets/schematic.png) - -The main component is the **LSM6DSOXTR** sensor (U1), which handles both acceleration and gyroscope measurements, as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -There's also a small power indicator LED that lights up when the board is on. - -Some options for customizing the module's features via onboard solder jumpers are available: - -### **VDDIO Independence:** - -- By default, **VDDIO is connected to +3V3**. -- To make **VDDIO independent**, cut the corresponding solder jumper. - -### SPI Mode Selection: - -- The LSM6DSOXTR supports both **3-wire and 4-wire SPI**. -- You can configure SPI communication and connect additional sensors by cutting or soldering the appropriate jumpers. Please take a look at the IMU's datasheet for more information. - -You can grab the full schematic and PCB files from the [Modulino Movement](https://docs.arduino.cc/hardware/modulinos/modulino-movement) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It's plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -If your board doesn't have a QWIIC connector, you can still access the same I²C bus and power the module using the solderable header pads just make sure you wire it to 3.3V and match the I²C pinout. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-movement.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-movement-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -When connecting multiple I²C devices, address conflicts may occur if two or more devices share the same default I²C address. The Modulino addresses this potential issue by allowing you to select a different address through a simple hardware modification. We cover this process in detail in the [**Changing I²C Address**](#changing-i2c-address) section, enabling you to integrate multiple identical modules or different devices that share the same default address in your project. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-movement-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus as long as you select the correct I²C pins depending on your board. This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-movement-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup's performance. Ensure your cables are correctly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.*** - -### Changing I2C Address - -The Modulino Movement can be configured to use an alternative I2C address (0x6B) instead of the default address (0x6A). To change the address, follow these steps carefully: - -1. Disconnect all power from the module -2. Locate the address selection solder jumpers on the back of the board -3. Cut the trace on the jumper marked **Default** (0x6A) -4. Solder closed the jumper marked **0x6B** - -After completing these modifications, your module will use the new address (0x6B) when powered on again. - -**IMPORTANT**: Ensure the module remains unpowered during this entire process. Never have both jumpers closed simultaneously when power is applied, as this will create a short circuit between power and ground that could damage your module. - -![I2C Address Change](assets/I2C-change-movement.png) - -When using a custom address in your sketch, you'll need to specify this address when creating the module object. For example: -```arduino -ModulinoMovement movement(0x7E); -``` - - - -## How To Use Your Modulino - -### Installing The Modulino Library - -You need the official Modulino library available [here](https://docs.arduino.cc/libraries/modulino/) to use the Modulino Movement. With the Arduino IDE you get some tools that make adding a library easier. To learn how to install the IDE please visit our [page](https://www.support.arduino.cc/hc/en-us/articles/360019833020-Download-and-install-Arduino-IDE). - -After opening the IDE, a tab should be visible on the left. Press the book icon for "library" as highlighted in the image. - -![IDE Library Tab](assets/IDE-Left-Tab.png) - -You can now look for the library ```Modulino``` by filling in the ```Filter your search``` textbox. - -A prompt might appear saying that additional dependencies are required. This is not a problem, as they will be automatically added when you confirm the prompt. - -![Add Dependencies Prompt](assets/library-dependencies.png) - -The process should look like this: - -![Library Install](assets/library-install.gif) - -A message will appear after the installation is successful. - -### Getting Acceleration Data - -Getting data from the sensor is fairly simple using the ```Modulino``` library. For the **Modulino Movement** there are four important functions: - -- ```update()```: Updates the sensor readings. -- ```getX()```: Retrieves the acceleration value on the **X-axis** in **g**. -- ```getY()```: Retrieves the acceleration value on the **Y-axis** in **g**. -- ```getZ()```: Retrieves the acceleration value on the **Z-axis** in **g**. -- ```getRoll()```: Retrieves the angular rotation around the X-axis in **dps**. -- ```getPitch()```: Retrieves the angular rotation around the Y-axis in **dps**. -- ```getYaw()```: Retrieves the angular rotation around the Z-axis in **dps**. -- ```Modulino.begin();```: By default the Modulino library uses ```Wire1``` if your connection is in a different Wire you will have to edit it, check [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/) (by default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/)) for the library's hardware compatibility. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here is an example sketch of how to implement these functions to acquire data and show it using the serial monitor: - -```arduino -#include "Modulino.h" - -// Create a ModulinoMovement -ModulinoMovement movement; - - -float x, y, z; -float roll, pitch, yaw; - - -void setup() { - Serial.begin(9600); - // Initialize Modulino I2C communication - Modulino.begin(); - // Detect and connect to movement sensor module - movement.begin(); -} - -void loop() { - // Read new movement data from the sensor - movement.update(); - - // Get acceleration and gyroscope values - x = movement.getX(); - y = movement.getY(); - z = movement.getZ(); - roll = movement.getRoll(); - pitch = movement.getPitch(); - yaw = movement.getYaw(); - - // Print acceleration values - Serial.print("A: "); - Serial.print(x, 3); - Serial.print(", "); - Serial.print(y, 3); - Serial.print(", "); - Serial.print(z, 3); - - // Print divider between acceleration and gyroscope - Serial.print(" | G: "); - - // Print gyroscope values - Serial.print(roll, 1); - Serial.print(", "); - Serial.print(pitch, 1); - Serial.print(", "); - Serial.println(yaw, 1); - - delay(200); -} -``` - -The code example provided shows how to initialize the sensor, read the acceleration data, and display it on the serial monitor. The data is continuously updated, showing the current acceleration values in real time. - -It can be easily adapted to trigger actions at certain movement thresholds or to detect specific motion patterns in your projects. - -## Troubleshooting - -### Sensor Not Reachable - -If your Modulino's power LED isn't on or the sensor isn't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `#include "modulino.h"` command, verify that the Modulino library is correctly installed: - -- Check your IDE to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### Inaccurate Values - -If the sensor values are not accurate, make sure: - -- The sensor is not placed on an unstable surface that might cause unwanted vibrations. -- All exposed electronics are not touching any conductive surfaces, as this could interfere with readings. -- The board is mounted securely when measuring precise movements. - -## Conclusion - -The **Modulino Movement** is a digital 6-axis IMU sensor that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes accessing motion data straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both quick tests and longer-term setups. - -## What Is Next? - -Now that you've learned how to use your Modulino Movement, you're all set to integrate it into your projects! - -- Use the movement data to detect different patterns and use these as inputs for your projects. -- Create a motion-activated alarm that triggers when unexpected movement is detected. -- Build a balance game that challenges players to keep the sensor level within certain parameters. -- Make a pedometer that counts steps based on the characteristic motion patterns of walking. \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/I2C-change-movement.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/I2C-change-movement.png deleted file mode 100644 index a3c9a51894..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/I2C-change-movement.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/Modulino_Movement_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/Modulino_Movement_Power_Tree.png deleted file mode 100644 index fe775335ff..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/Modulino_Movement_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/MovementPinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/MovementPinouts.png deleted file mode 100644 index 9dd2cf39e3..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/MovementPinouts.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement-jumper.png deleted file mode 100644 index b72819526f..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement-qwiic-chain.png deleted file mode 100644 index c6c89cc127..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement-qwiik.png deleted file mode 100644 index 331a2f823c..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement.png deleted file mode 100644 index c21dcc1db7..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/connection-guide-movement.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/mp-usb-connection.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/mp-usb-connection.png deleted file mode 100644 index fb059f9e8b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/mp-usb-connection.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/package-installer-overview.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/package-installer-overview.png deleted file mode 100644 index 67678dc808..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/package-installer-overview.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/schematic.png deleted file mode 100644 index a804960788..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/assets/schematic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/content.md deleted file mode 100644 index 0a82cf4646..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/content.md +++ /dev/null @@ -1,292 +0,0 @@ ---- -title: "How To Use The Modulino Movement And MicroPython" -description: "Learn how to get the most out of your Modulino Movement in a MicroPython environment." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-movement -software: - - ide-v2 - - web-editor ---- - -The Modulino Movement is a modular sensor that measures acceleration and angular velocity, making it perfect to add motion sensing to your projects! The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - -## General Characteristics - -The Modulino Movement is capable of measuring acceleration and angular velocity. Take a look at the following table to know more about its measuring ranges: - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|---------------------------------|-------------------------|---------|---------|---------|----------| -| **Accelerometer Range** | Configurable Full Scale | ±2 | ±8 | ±16 | g | -| **Gyroscope Range** | Configurable Full Scale | ±125 | ±1000 | ±2000 | dps | -| **Accelerometer Sensitivity** | @ ±2g | 0.061 | - | - | mg/LSB | -| **Gyroscope Sensitivity** | @ ±125dps | 4.375 | - | - | mdps/LSB | -| **Accelerometer Noise Density** | High-performance mode | - | 70 | - | µg/√Hz | -| **Gyroscope Noise Density** | High-performance mode | - | 3.8 | - | mdps/√Hz | -| **Temperature Sensor Range** | - | -40 | - | +85 | °C | -| **FIFO Buffer** | - | - | 9 | - | KB | -| **Sampling Rate** | Output Data Rate | 1.6 | - | 6664 | Hz | - -### Sensor Details - -The LSM6DSOXTR sensor from STMicroelectronics is the core component of this module. This 6-axis IMU (accelerometer and gyroscope) natively supports digital communication (I²C and SPI), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -The default address for the Module is: - -| Modulino I²C Address | Hardware I²C Address | -|----------------------|----------------------| -| 0x6A or 0x7E | 0x6A or 0x7E | - -When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. - -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - -## Pinout - -The pinout for the Modulino Movement is shown below. Please note that the exposed solderable pins are directly connected to the QWIIC connectors using the same I²C interface. - -![Arduino Movement Pinout](assets/MovementPinouts.png) - -Depending on the board connected to the modulino, the I²C pin names to program it may differ. Please check the [board tutorials](https://docs.arduino.cc/hardware/) on your modulino's compatible board or the [Modulino library](https://github.com/arduino-libraries/Modulino/tree/main/docs) to learn more. - -### 1x10 Header - -| Pin | Function | -|---------|------------------| -| VDDIO | Power | -| GND | Ground | -| INT1 | Interrupt 1 | -| INT2 | Interrupt 2 | -| SDO/SA0 | SPI Data Out | -| SCx | SPI Clock | -| SDx | SPI Data | -| CS | SPI Chip Select | -| SDOAUX | Auxiliary Output | -| OCSAUX | Auxiliary Output | - -- **VDDIO: Power** – I/O voltage supply pin for the sensor. -- **GND: Ground** – Ground connection for power and signal reference. -- **INT1: Interrupt 1** – Programmable interrupt output pin. -- **INT2: Interrupt 2** – Programmable interrupt output pin. -- **SDO/SA0: SPI Data Out** – SPI data output pin, also used as I2C address selection. -- **SCx: SPI Clock** – Clock signal for SPI communication. -- **SDx: SPI Data** – SPI data input pin. -- **CS: SPI Chip Select** – Chip select pin for SPI communication. -- **SDOAUX: Auxiliary Output** – Auxiliary data output pin. -- **OCSAUX: Auxiliary Output** – Auxiliary output control signal pin. - -### 1x4 Header (I2C) - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I2C Data | -| SCL | I2C Clock | - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|-----------------------------------------------|---------------------|---------|-------------|---------|------| -| Supply Voltage | - | 1.71 | 3.3 (QWIIC) | 3.6 | V | -| I/O Voltage | - | 1.62 | - | 3.6 | V | -| Gyro + Accel Current (High Performance Mode) | Both sensors active | - | 0.55 | - | mA | -| Accelerometer Current (High Performance Mode) | - | - | 170 | - | µA | -| Accelerometer Current (Low Power Mode) | ODR = 50 Hz | - | 26 | - | µA | -| Accelerometer Current (Ultra-Low Power Mode) | ODR = 50 Hz | - | 9.5 | - | µA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Movement](assets/Modulino_Movement_Power_Tree.png) - -## Schematic - -The Modulino Movement uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Movement](assets/schematic.png) - -The main component is the **LSM6DSOXTR** sensor (U1), which handles both acceleration and gyroscope measurements, as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -There's also a small power indicator LED that lights up when the board is on. - -Some options for customizing the module's features via onboard solder jumpers are available: - -### **VDDIO Independence:** - -- By default, **VDDIO is connected to +3V3**. -- To make **VDDIO independent**, cut the corresponding solder jumper. - -### SPI Mode Selection: - -- The LSM6DSOXTR supports both **3-wire and 4-wire SPI**. -- You can configure SPI communication and connect additional sensors by cutting or soldering the appropriate jumpers. Please take a look at the IMU's datasheet for more information. - -You can grab the full schematic and PCB files from the [Modulino Movement](https://docs.arduino.cc/hardware/modulinos/modulino-movement) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It's plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -If your board doesn't have a QWIIC connector, you can still access the same I²C bus and power the module using the solderable header pads just make sure you wire it to 3.3V and match the I²C pinout. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-movement.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-movement-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -When connecting multiple I²C devices, address conflicts may occur if two or more devices share the same default I²C address. The Modulino addresses this potential issue by allowing you to select a different address through a simple hardware modification. We cover this process in detail in the [**Changing I²C Address**](#changing-i2c-address) section, enabling you to integrate multiple identical modules or different devices that share the same default address in your project. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-movement-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus as long as you select the correct I²C pins depending on your board. This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-movement-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup's performance. Ensure your cables are correctly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.*** - -### Changing I2C Address - -The Modulino Movement can be configured to use an alternative I2C address (0x6B) instead of the default address (0x6A). To change the address, follow these steps carefully: - -1. Disconnect all power from the module -2. Locate the address selection solder jumpers on the back of the board -3. Cut the trace on the jumper marked **Default** (0x6A) -4. Solder closed the jumper marked **0x6B** - -After completing these modifications, your module will use the new address (0x6B) when powered on again. - -**IMPORTANT**: Ensure the module remains unpowered during this entire process. Never have both jumpers closed simultaneously when power is applied, as this will create a short circuit between power and ground that could damage your module. - -![I2C Address Change](assets/I2C-change-movement.png) - -When using a custom address in your MicroPython sketch, you'll need to specify this address when creating the module object. For example: -```python -movement_module = ModulinoMovement(address=0x7E) -``` - - -## How To Program Your Modulino - -### Installing The Modulino Library - -To program your Modulino it is recommended you use the official ```Modulino``` micropython library available [here](https://github.com/arduino/arduino-modulino-mpy). The library is fully compatible with the no **Arduino Lab for MicroPython**. - -For information on installing the **Arduino Lab for MicroPython** please visit our [page](https://docs.arduino.cc/micropython/first-steps/install-guide/). - -The ```Modulino``` library is not available by default on MicroPython devices hence installation is needed. - -To simplify the process the [MicroPython Package Installer](https://github.com/arduino/lab-micropython-package-installer/releases) is recommended as it will provide a graphical interface to guide installation. -After installation, you should now be able to: - -1. Open the tool. -2. Plug in your board to the computer. - - ![USB Connection](assets/mp-usb-connection.png) - - If the board does not appear in the Detected Boards section, click Reload. If the board is still undetected, ensure no other programs (e.g., a code editor) are using the board's COM port. - -3. Search for the ```Modulino``` package by filling in the text box on the search feature. -4. Click Install and wait for the installation confirmation. -5. Disconnect the board from the tool before returning to your code editor to avoid conflicts due to a busy COM port. - -![Package Installer Overview](assets/package-installer-overview.png) - -The module should now be includable in your program using: - -```from modulino import ModulinoThermo``` - -### Get Acceleration and Gyroscope Data - -Getting motion data from the **Modulino Movement** module is simple using the `Modulino` library. The module provides two crucial functions for motion sensing: - -- `.accelerometer` - Retrieves the acceleration values (x, y, z). -- `.gyro` - Retrieves the angular velocity (x, y, z) in **dps**. -- By default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it as instructed [here](https://github.com/arduino/arduino-modulino-mpy/tree/main/docs#%E2%84%B9%EF%B8%8F-using-3rd-party-boards). More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - - -Here’s an example demonstrating how to acquire motion data: - -```python -from modulino import ModulinoMovement -from time import sleep_ms - -movement = ModulinoMovement() - -while True: - acc = movement.accelerometer - gyro = movement.gyro - - print(f"🏃 Accelerometer: x:{acc.x:>8.3f} y:{acc.y:>8.3f} z:{acc.z:>8.3f} g") - print(f"🌐 Gyroscope: x:{gyro.x:>8.3f} y:{gyro.y:>8.3f} z:{gyro.z:>8.3f} dps") - print("") - sleep_ms(100) -``` - -The code example provided shows how to initialize the sensor, read the acceleration data, and display it on the console. - -The data is continuously updated, showing the current acceleration values in real time. -It can be easily adapted to trigger actions at certain movement thresholds or to detect specific motion patterns in your projects. - -## Troubleshooting - -### Sensor Not Reachable - -If your Modulino's power LED isn't on or the sensor isn't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `import ModulinoMovement` command, verify that the Modulino library is correctly installed: - -- Check your Library installer to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### Inaccurate Values - -If the sensor values are not accurate, make sure: - -- The sensor is not placed on an unstable surface that might cause unwanted vibrations. -- All exposed electronics are not touching any conductive surfaces, as this could interfere with readings. -- The board is mounted securely when measuring precise movements. - -## Conclusion - -The **Modulino Movement** is a digital 6-axis IMU sensor that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes accessing motion data straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both quick tests and longer-term setups. - -## What Is Next? - -Now that you've learned how to use your Modulino Movement, you're all set to integrate it into your projects! - -- Use the movement data to detect different patterns and use these as inputs for your projects. -- Create a motion-activated alarm that triggers when unexpected movement is detected. -- Build a balance game that challenges players to keep the sensor level within certain parameters. -- Make a pedometer that counts steps based on the characteristic motion patterns of walking. \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/I2C-change-movement.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/assets/I2C-change-movement.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/I2C-change-movement.png rename to content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/assets/I2C-change-movement.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/assets/MovementOverview.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/assets/MovementOverview.png new file mode 100644 index 0000000000..1dca7e801f Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/assets/MovementOverview.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/MovementPinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/assets/MovementPinouts.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/assets/MovementPinouts.png rename to content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/assets/MovementPinouts.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/content.md new file mode 100644 index 0000000000..032ab46a53 --- /dev/null +++ b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/content.md @@ -0,0 +1,471 @@ +--- +title: "Modulino Movement" +description: "Complete guide for the Modulino Movement 6-axis IMU sensor module." +tags: + - Modulino + - Movement + - IMU + - Accelerometer + - Gyroscope + - QWIIC + - I2C +author: 'Pedro Sousa Lima' +hardware: + - hardware/11.modulinos/modulinos/modulino-movement +software: + - ide-v2 + - web-editor + - micropython +--- + +![Movement Overview](assets/MovementOverview.png) + +The Modulino Movement is a modular sensor that measures acceleration and angular velocity, making it perfect to add motion sensing to your projects! It provides 6-axis motion detection through its integrated accelerometer and gyroscope. + +## Hardware Overview + +### General Characteristics + +The Modulino Movement is capable of measuring acceleration and angular velocity with the following specifications: + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|---------------------------------|-------------------------|---------|---------|---------|----------| +| **Accelerometer Range** | Configurable Full Scale | ±2 | ±8 | ±16 | g | +| **Gyroscope Range** | Configurable Full Scale | ±125 | ±1000 | ±2000 | dps | +| **Accelerometer Sensitivity** | @ ±2g | 0.061 | - | - | mg/LSB | +| **Gyroscope Sensitivity** | @ ±125dps | 4.375 | - | - | mdps/LSB | +| **Accelerometer Noise Density** | High-performance mode | - | 70 | - | µg/√Hz | +| **Gyroscope Noise Density** | High-performance mode | - | 3.8 | - | mdps/√Hz | +| **Temperature Sensor Range** | - | -40 | - | +85 | °C | +| **FIFO Buffer** | - | - | 9 | - | KB | +| **Sampling Rate** | Output Data Rate | 1.6 | - | 6664 | Hz | + +### Sensor Details + +The LSM6DSOXTR sensor from STMicroelectronics is the core component of this module. This 6-axis IMU (accelerometer and gyroscope) natively supports digital communication (I²C and SPI), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. + +The default address for the Module is: + +| Modulino I²C Address | Hardware I²C Address | +|----------------------|----------------------| +| 0x6A or 0x7E | 0x6A or 0x7E | + +The address can be changed through hardware modification (see the generic guide for details). + +![Address change hardware](assets/I2C-change-movement.png) + +1. Disconnect all power from the module +2. Locate the address selection solder jumpers on the back of the board +3. Cut the trace on the jumper marked **Default** (0x6A) +4. Solder closed the jumper marked **0x6B** + +**IMPORTANT**: Never have both jumpers closed simultaneously when power is applied, as this will create a short circuit that could damage your module. + +### Pinout + +![Arduino Movement Pinout](assets/MovementPinouts.png) + +#### 1x10 Header + +| Pin | Function | +|---------|------------------| +| VDDIO | Power | +| GND | Ground | +| INT1 | Interrupt 1 | +| INT2 | Interrupt 2 | +| SDO/SA0 | SPI Data Out | +| SCx | SPI Clock | +| SDx | SPI Data | +| CS | SPI Chip Select | +| SDOAUX | Auxiliary Output | +| OCSAUX | Auxiliary Output | + +#### 1x4 Header (I2C) + +| Pin | Function | +|-------|--------------| +| GND | Ground | +| 3.3 V | Power Supply | +| SDA | I²C Data | +| SCL | I²C Clock | + +### Power Specifications + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|-----------------------------------------------|---------------------|---------|-------------|---------|------| +| Supply Voltage | - | 1.71 | 3.3 (QWIIC) | 3.6 | V | +| I/O Voltage | - | 1.62 | - | 3.6 | V | +| Gyro + Accel Current (High Performance Mode) | Both sensors active | - | 0.55 | - | mA | +| Accelerometer Current (High Performance Mode) | - | - | 170 | - | µA | +| Accelerometer Current (Low Power Mode) | ODR = 50 Hz | - | 26 | - | µA | +| Accelerometer Current (Ultra-Low Power Mode) | ODR = 50 Hz | - | 9.5 | - | µA | + +## Programming with Arduino + +### Prerequisites + +- Install the Modulino library via the Arduino IDE Library Manager +- Connect your Modulino Movement via QWIIC or solderable headers + +### Basic Example + +```arduino +#include "Modulino.h" + +// Create a ModulinoMovement +ModulinoMovement movement; + +float x, y, z; +float roll, pitch, yaw; + +void setup() { + Serial.begin(9600); + // Initialize Modulino I2C communication + Modulino.begin(); + // Detect and connect to movement sensor module + movement.begin(); +} + +void loop() { + // Read new movement data from the sensor + movement.update(); + + // Get acceleration and gyroscope values + x = movement.getX(); + y = movement.getY(); + z = movement.getZ(); + roll = movement.getRoll(); + pitch = movement.getPitch(); + yaw = movement.getYaw(); + + // Print acceleration values + Serial.print("A: "); + Serial.print(x, 3); + Serial.print(", "); + Serial.print(y, 3); + Serial.print(", "); + Serial.print(z, 3); + + // Print divider between acceleration and gyroscope + Serial.print(" | G: "); + + // Print gyroscope values + Serial.print(roll, 1); + Serial.print(", "); + Serial.print(pitch, 1); + Serial.print(", "); + Serial.println(yaw, 1); + + delay(200); +} +``` + +### Key Functions + +- `update()`: Updates the sensor readings +- `getX()`, `getY()`, `getZ()`: Retrieve acceleration values in g +- `getRoll()`, `getPitch()`, `getYaw()`: Retrieve angular rotation in dps + +### Advanced Example - Motion Detection System + +```arduino +#include "Modulino.h" + +ModulinoMovement movement; + +// Motion detection thresholds +const float MOTION_THRESHOLD = 0.15; // g units for acceleration +const float ROTATION_THRESHOLD = 20.0; // degrees per second + +// Calibration variables +float baseX = 0, baseY = 0, baseZ = 1.0; // Expect 1g on Z when flat +float baseRoll = 0, basePitch = 0, baseYaw = 0; +bool isCalibrated = false; + +// Motion state tracking +bool inMotion = false; +unsigned long motionStartTime = 0; +unsigned long stillStartTime = 0; +const unsigned long STILL_TIMEOUT = 2000; // 2 seconds to detect stillness + +void setup() { + Serial.begin(9600); + Modulino.begin(); + movement.begin(); + + Serial.println("Motion Detection System"); + Serial.println("======================"); + Serial.println("Keep device still for calibration..."); + + delay(2000); + calibrateSensor(); +} + +void calibrateSensor() { + const int samples = 50; + float sumX = 0, sumY = 0, sumZ = 0; + float sumRoll = 0, sumPitch = 0, sumYaw = 0; + + for (int i = 0; i < samples; i++) { + movement.update(); + sumX += movement.getX(); + sumY += movement.getY(); + sumZ += movement.getZ(); + sumRoll += movement.getRoll(); + sumPitch += movement.getPitch(); + sumYaw += movement.getYaw(); + delay(20); + } + + baseX = sumX / samples; + baseY = sumY / samples; + baseZ = sumZ / samples; + baseRoll = sumRoll / samples; + basePitch = sumPitch / samples; + baseYaw = sumYaw / samples; + + isCalibrated = true; + Serial.println("✓ Calibration complete!"); + Serial.println(); +} + +void detectMotion() { + movement.update(); + + // Calculate deltas from baseline + float deltaX = abs(movement.getX() - baseX); + float deltaY = abs(movement.getY() - baseY); + float deltaZ = abs(movement.getZ() - baseZ); + float deltaRoll = abs(movement.getRoll() - baseRoll); + float deltaPitch = abs(movement.getPitch() - basePitch); + float deltaYaw = abs(movement.getYaw() - baseYaw); + + // Check if any threshold is exceeded + bool motionDetected = (deltaX > MOTION_THRESHOLD || + deltaY > MOTION_THRESHOLD || + deltaZ > MOTION_THRESHOLD || + deltaRoll > ROTATION_THRESHOLD || + deltaPitch > ROTATION_THRESHOLD || + deltaYaw > ROTATION_THRESHOLD); + + // State machine for motion detection + if (motionDetected && !inMotion) { + // Motion just started + inMotion = true; + motionStartTime = millis(); + Serial.println("🏃 MOTION DETECTED!"); + + // Identify type of motion + if (deltaRoll > ROTATION_THRESHOLD || deltaPitch > ROTATION_THRESHOLD) { + Serial.println(" Type: Rotation"); + } + if (deltaX > MOTION_THRESHOLD || deltaY > MOTION_THRESHOLD) { + Serial.println(" Type: Linear movement"); + } + if (deltaZ > MOTION_THRESHOLD * 2) { + Serial.println(" Type: Vertical movement"); + } + } + else if (!motionDetected && inMotion) { + // Motion might have stopped + if (stillStartTime == 0) { + stillStartTime = millis(); + } + else if (millis() - stillStartTime > STILL_TIMEOUT) { + // Device has been still for timeout period + inMotion = false; + unsigned long duration = (millis() - motionStartTime) / 1000; + Serial.print("✋ Motion stopped. Duration: "); + Serial.print(duration); + Serial.println(" seconds"); + stillStartTime = 0; + } + } + else if (motionDetected && inMotion) { + // Still in motion, reset still timer + stillStartTime = 0; + } +} + +void loop() { + if (isCalibrated) { + detectMotion(); + delay(50); + } +} +``` + +## Programming with MicroPython + +The Modulino Movement is fully compatible with MicroPython through the official Modulino MicroPython library. The following examples demonstrate how to read motion data from the 6-axis IMU and implement motion detection features in your MicroPython projects. + +### Prerequisites + +- Install the Modulino MicroPython library +- Ensure Arduino Lab for MicroPython is installed + +For detailed instructions on setting up your MicroPython environment and installing packages, please refer to the [Getting Started with Modulinos guide](link-to-generic-guide). + +### Basic Example + +```python +from modulino import ModulinoMovement +from time import sleep_ms + +movement = ModulinoMovement() + +while True: + acc = movement.accelerometer + gyro = movement.gyro + + print(f"🏃 Accelerometer: x:{acc.x:>8.3f} y:{acc.y:>8.3f} z:{acc.z:>8.3f} g") + print(f"🌀 Gyroscope: x:{gyro.x:>8.3f} y:{gyro.y:>8.3f} z:{gyro.z:>8.3f} dps") + print("") + sleep_ms(100) +``` + +### Key Properties + +- `.accelerometer`: Returns acceleration values (x, y, z) in g +- `.gyro`: Returns angular velocity (x, y, z) in dps + +### Advanced Example - Step Counter + +```python +from modulino import ModulinoMovement +from time import sleep_ms, ticks_ms +import math + +movement = ModulinoMovement() + +# Step detection parameters +STEP_THRESHOLD = 1.2 # Magnitude threshold for step detection +MIN_STEP_INTERVAL = 300 # Minimum time between steps (ms) +MAX_STEP_INTERVAL = 2000 # Maximum time between steps (ms) + +# State tracking +step_count = 0 +last_step_time = 0 +last_magnitude = 0 +peak_detected = False + +# Calibration +calibration_samples = [] +baseline_magnitude = 1.0 + +def calculate_magnitude(x, y, z): + """Calculate the magnitude of acceleration vector""" + return math.sqrt(x*x + y*y + z*z) + +def calibrate(): + """Calibrate the baseline acceleration magnitude""" + global baseline_magnitude + + print("Calibrating... Keep device still") + samples = [] + + for _ in range(50): + acc = movement.accelerometer + mag = calculate_magnitude(acc.x, acc.y, acc.z) + samples.append(mag) + sleep_ms(20) + + baseline_magnitude = sum(samples) / len(samples) + print(f"Calibration complete. Baseline: {baseline_magnitude:.3f}g") + +def detect_step(): + """Detect steps based on acceleration patterns""" + global step_count, last_step_time, last_magnitude, peak_detected + + current_time = ticks_ms() + acc = movement.accelerometer + + # Calculate acceleration magnitude + magnitude = calculate_magnitude(acc.x, acc.y, acc.z) + + # Detect peaks in acceleration + if magnitude > STEP_THRESHOLD and magnitude > last_magnitude and not peak_detected: + # Check if enough time has passed since last step + time_since_last = current_time - last_step_time + + if time_since_last > MIN_STEP_INTERVAL: + if time_since_last < MAX_STEP_INTERVAL or step_count == 0: + step_count += 1 + last_step_time = current_time + peak_detected = True + + # Calculate step rate + if step_count > 1: + step_rate = 60000 / time_since_last # steps per minute + print(f"👣 Step {step_count} detected! Rate: {step_rate:.0f} spm") + else: + print(f"👣 Step {step_count} detected!") + + # Reset peak detection when magnitude drops + if magnitude < last_magnitude: + peak_detected = False + + last_magnitude = magnitude + +def calculate_distance(steps, stride_length=0.7): + """Estimate distance traveled based on steps""" + return steps * stride_length + +def calculate_calories(steps, weight_kg=70): + """Estimate calories burned based on steps""" + # Rough estimate: 0.04 calories per step per kg of body weight + return steps * 0.04 * weight_kg / 70 + +# Main program +print("🚶 Step Counter Application") +print("=" * 30) + +calibrate() +print("\nStart walking!") +print("Press Ctrl+C to see statistics\n") + +try: + while True: + detect_step() + sleep_ms(50) + +except KeyboardInterrupt: + # Display statistics + distance = calculate_distance(step_count) + calories = calculate_calories(step_count) + + print("\n" + "=" * 30) + print("📊 Walking Statistics:") + print(f" Total Steps: {step_count}") + print(f" Distance: {distance:.2f} meters") + print(f" Calories: {calories:.1f} kcal") + print("=" * 30) +``` + +## Troubleshooting + +### Sensor Not Reachable + +If your Modulino's power LED isn't on or the sensor isn't responsive: +- Ensure both the board and the Modulino are connected properly +- Verify that the power LEDs on both are lit +- Check that the QWIIC cable is properly clicked into place + +### Inaccurate Values + +If the sensor values are not accurate: +- Ensure the sensor is not on an unstable surface causing unwanted vibrations +- Verify exposed electronics are not touching conductive surfaces +- Mount the board securely when measuring precise movements +- Consider calibrating the sensor before use + +## Project Ideas + +- **Motion-Activated Alarm**: Trigger alerts when unexpected movement is detected +- **Balance Game**: Challenge players to keep the sensor level +- **Pedometer**: Count steps based on characteristic motion patterns +- **Gesture Recognition**: Detect specific motion patterns for control +- **Tilt Controller**: Use tilt angles to control games or robots +- **Vibration Monitor**: Detect and log vibrations in machinery +- **Fall Detection**: Identify sudden acceleration changes indicating falls +- **Orientation Tracker**: Monitor device orientation in 3D space \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/image.png b/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/image.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-ardu/image.png rename to content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement/image.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/datasheet/datasheet.md b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/datasheet/datasheet.md index ef2117914b..f48d49ee98 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/datasheet/datasheet.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/datasheet/datasheet.md @@ -41,9 +41,9 @@ Maker, beginner, education ## Related Products -- *SKU: ASX00027* – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) -- *SKU: K000007* – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) -- *SKU: AKX00026* – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) +- **SKU: ASX00027** – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) +- **SKU: K000007** – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) +- **SKU: AKX00026** – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) ## Rating @@ -53,7 +53,7 @@ Maker, beginner, education - **Operating temperature:** –40 °C to +85 °C **Typical current consumption:** -- Up to **33 mA per RGB LED** at full brightness * 8 LEDs (264 mA total), plus ~3.4 mA for the microcontroller. Actual usage depends on brightness and color settings. +- Up to **33 mA per RGB LED*** at full brightness ** 8 LEDs (264 mA total), plus ~3.4 mA for the microcontroller. Actual usage depends on brightness and color settings. ## Power Tree The power tree for the Modulino® node can be consulted below: diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/product.md b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/product.md index 135ad3dc88..ffd7035dba 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/product.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/product.md @@ -2,10 +2,10 @@ title: Modulino Pixels url_shop: https://store.arduino.cc/products/modulino-pixels url_guide: https://courses.arduino.cc/plugandmake -primary_button_url: https://docs.arduino.cc/tutorials/modulino-pixels/how-pixels-ardu/ -primary_button_title: With Arduino -secondary_button_url: https://docs.arduino.cc/tutorials/modulino-pixels/how-pixels-mp/ -secondary_button_title: With MicroPython +primary_button_url: https://docs.arduino.cc/tutorials/modulino-pixels/how-pixels/ +primary_button_title: Get Started +secondary_button_url: https://docs.arduino.cc/tutorials/modulino-thermo/how-general/ +secondary_button_title: More on Modulinos forumCategorySlug: '/hardware/accessories/modulino-pixels/219' sku: [ABX00109] --- diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/IDE-Left-Tab.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/IDE-Left-Tab.png deleted file mode 100644 index c7bb86575e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/IDE-Left-Tab.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/Modulino_Pixels_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/Modulino_Pixels_Power_Tree.png deleted file mode 100644 index 1360acf9f8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/Modulino_Pixels_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/addressChangeIDE.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/addressChangeIDE.png deleted file mode 100644 index d5cd3fd195..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/addressChangeIDE.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/adressChanger.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/adressChanger.png deleted file mode 100644 index c6eae670c8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/adressChanger.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels-jumper.png deleted file mode 100644 index cdce255db8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels-qwiic-chain.png deleted file mode 100644 index 5899d68721..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels-qwiik.png deleted file mode 100644 index 3b09f3b752..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels.png deleted file mode 100644 index 229410a0c3..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/connection-guide-pixels.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/library-install.gif b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/library-install.gif deleted file mode 100644 index 16f396c353..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/library-install.gif and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/pixel-expantion-mc.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/pixel-expantion-mc.png deleted file mode 100644 index ef177015f8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/pixel-expantion-mc.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/schematic.png deleted file mode 100644 index 8f5504efee..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/schematic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/content.md deleted file mode 100644 index 5850c78318..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/content.md +++ /dev/null @@ -1,276 +0,0 @@ ---- -title: "How To Use The Modulino Pixels" -description: "Learn how to get the most out of your Modulino Pixels." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-pixels -software: - - ide-v2 - - web-editor ---- - -The Modulino Pixels is a modular sensor that generates RGB light effects, making it perfect to add colorful visual feedback to your projects! -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - - -## Hardware Specifications - -The Modulino Pixels based on 8 LC8822-2020 addressable LEDs is capable of generating colorful light patterns and effects. Take a look at the following table to know more about its characteristics: - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|------------------|-------------------|---------|---------|---------|------| -| Supply Voltage | - | 2.0 | 3.3 | 3.6 | V | -| Resolution (ADC) | Default | - | 12-bit | - | mcd | -| Communication | I²C,USART,SPI | - | I²C | - | - | - -## Pinout - -The LC8822-2020 addressable LEDs are the core components of this module. These RGB light output devices are controlled by an onboard STM32C011F4U6TR microcontroller, which supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -![Modulino Pixels Pinout](assets/PixelsPinouts.png) - -### 1x10 Header (LC8822-2020 and Microcontroller Signals) - -| Pin | Function | -|--------|-----------------| -| GND | Ground | -| GND | Ground | -| 3V3 | 3.3V Power | -| RESET | Reset | -| SWCLK | SWD Clock | -| SWDIO | SWD Data | -| TX1 | USART Transmit | -| RX1 | USART Receive | -| D0 | Pixels Data Out | -| C0 | Pixels Clock Out| - -- **GND: Ground**: Provides ground reference for the circuit. Multiple ground pins ensure stable power distribution. -- **3V3: 3.3V Power**: Supplies 3.3V power to connected components and modules. -- **RESET: Reset**: Used to reset the microcontroller or connected system. -- **SWCLK and SWDIO: SWD Interface**: Used for debugging, programming, and reprogramming the microcontroller via Serial Wire Debug protocol. -- **TX1 and RX1: USART Communication**: Enable serial communication for data transmission and reception with other devices or modules. -- **D0: Pixels Data Out**: Sends pixel data to addressable LED strips in a daisy chain configuration for lighting control. -- **C0: Pixels Clock Out**: Provides clock signal synchronization for addressable LED strips, ensuring proper timing for pixel data. - -### 1x4 Header (I2C) - -The pinout for the Modulino Pixels is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - -## I2C Address - -The **Modulino Pixels** module uses **LC8822-2020** addressable LEDs, which do not have native I²C capabilities. Instead, the LED array is controlled by the Modulino's onboard microcontroller (STM32C011F4U6TR). This microcontroller provides I²C communication, allowing for flexible control of the LEDs. - -One unique feature of this setup is the ability to change the I²C address via software. This means the address can be modified based on your application needs, making it adaptable to different system configurations. The default I²C address for the **Modulino Pixels** module is: - -| Modulino I²C Address | Hardware I²C Address | Editable Addresses (HEX) | -|----------------------|----------------------|-----------------------------------| -| 0x6C | 0x36 | Any custom address (via software) | - -When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. - -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Typical | Maximum | Unit | -|------------------------|----------------|---------|---------|------| -| Operating Voltage | - | 3.3 | - | V | -| Power Dissipation | - | - | 350 | mW | -| Standby Current | No data signal | - | 1 | mA | -| Max LED Output Current | Per Channel | 18 | - | mA | - - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. - -J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Pixels](assets/Modulino_Pixels_Power_Tree.png) - -## Schematic - -The Modulino Pixels uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Pixels](assets/schematic.png) - -The main components are the **8 LC8822-2020 addressable LEDs** and the **STM32C011F4U6TR** microcontroller (U1), which handles LED control as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -The **LC8822-2020** LEDs are connected in a daisy chain, with the first LED receiving clock and data signals from the microcontroller. The **CO (Clock Out)** and **DO (Data Out)** of the last LED in the chain are accessible via the **1x10 header**, allowing for expansion. ![LED Expantion](assets/expansion-guide-pixels.png) - -These can also be found in small pads near the STM32 microcontroller alongside a few user defines pads that can be used by editing the firmware: - -![Exposed user-defined and LED expansion pads](assets/pixel-expantion-mc.png) - -There's also a small power LED indicator that lights up when the board is on. - -You can grab the full schematic and PCB files from the [Modulino Pixels](https://docs.arduino.cc/hardware/modulinos/modulino-pixels) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. -Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-pixels.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-pixels-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-pixels-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. - -Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus. - -This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-pixels-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup’s performance. Ensure your cables are properly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.*** - -## How To Use Your Modulino - -### Installing The Modulino Library - -You need the official Modulino library available [here](https://github.com/arduino-libraries/Modulino) to use the Modulino Thermo. - -With the Arduino IDE you get some tools that make adding a library easier. To learn how to install the IDE please visit our [page](https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2-downloading-and-installing/). - -After opening the IDE, a tab should be visible on the left. Press the book icon for "library" as highlighted in the image. - -![IDE Library Tab](assets/IDE-Left-Tab.png) - -The process should look like this: - -![Library Install](assets/library-install.gif) - -A message will appear after the installation is successful. - -### Set LED Colors - -Controlling RGB LEDs using the **Modulino Pixels** module is straightforward with the `Modulino` library. - -For the **Pixels**, there are two important functions: - -- `set(index, color, brightness)`: Sets a specific LED to a chosen color and brightness level. (`RED`,`BLUE`,`GREEN`,`VIOLET`,`WHITE`) -- `show()`: Applies the changes to the LEDs. -- ```Modulino.begin();```: By default the Modulino library uses ```Wire1``` if your connection is in a different Wire you will have to edit it, check [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/) (by default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/)) for the library's hardware compatibility. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here is an example of how to implement these functions to control the LEDs: - -```arduino -#include - -ModulinoPixels leds; - -int brightness = 25; - -void setup(){ - Modulino.begin(); - leds.begin(); -} - -void loop(){ - // Set all LEDs to blue - for (int i = 0; i < 8; i++) { - leds.set(i, BLUE, brightness); - leds.show(); - } -} -``` - -The code example provided demonstrates how to initialize the LED module and set all 8 LEDs to blue with a brightness level of 25%. The for-loop cycles through each LED (indexed 0-7), sets its color and brightness, and then uses the show() function to apply the change. This creates a simple blue light display that can be easily modified to create more complex lighting patterns or visual indicators for your projects. - -### How To Change I²C Address - -An example sketch, AddressChanger, is also included with the library inside the `Utilities` folder and available [here](https://github.com/arduino-libraries/Modulino/blob/main/examples/Utilities/AddressChanger/AddressChanger.ino). This sketch changes the I²C address at a software level on the Module's microcontroller. - -![Example location on the IDE](assets/addressChangeIDE.png) - -- Connect the module to your board, remove any other modules that might be in the chain. Connection must be via I²C. -- Upload the sketch. -- Open the Serial Monitor. -- Text should now appear. Make sure the correct bauld-rate is selected if the displayed characters seem corrupted. - - ![Expected console output](assets/adressChanger.png) - -- Select the address and confirm. -- Your address should now have changed. Make sure to take note of the selected address. - -To keep track of the address in use the module has a white rectangle on the back. Feel free to use this to write the address that was chosen. - -When using a custom address in your sketch, you'll need to specify this address when creating the module object. For example: - -```arduino -ModulinoPixels pixels(0x3E); // Replace 0x3E with your specific address -``` - -## Troubleshooting - -### LEDs Not Lighting - -If your Modulino's power LED isn't on or the RGB LEDs aren't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `#include "modulino.h"` command, verify that the Modulino library is correctly installed: - -- Check your IDE to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### Incorrect Colors or Flickering - -If the LED colors are incorrect or the LEDs are flickering unexpectedly, make sure: - -- The brightness values are within the appropriate range (typically 0-255). -- All exposed electronics are not touching any conductive surfaces, as this could interfere with the LED output. -- The power supply is stable and providing sufficient current for all LEDs at the desired brightness. - -## Conclusion - -The **Modulino Pixels** is a digital RGB LED control module that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes generating colorful light effects straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both visual feedback and creative lighting projects. - -## What Is Next? - -Now that you've learned how to use your Modulino Pixels, you're all set to integrate it into your projects! - -- Create an animated progress bar that visually displays status, or battery charge level using a gradient of colors. -- Build a live sound level indicator that responds to ambient noise. -- Design a pomodoro timer with color coded work and rest periods to boost your productivity. -- Program an interactive game where players must match patterns of colors in the correct sequence, with difficulty increasing as they progress. diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/image.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/image.png deleted file mode 100644 index bceefec75d..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/image.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/Modulino_Pixels_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/Modulino_Pixels_Power_Tree.png deleted file mode 100644 index 1360acf9f8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/Modulino_Pixels_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/PixelsPinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/PixelsPinouts.png deleted file mode 100644 index 753e749422..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/PixelsPinouts.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels-jumper.png deleted file mode 100644 index 6796fa2911..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels-qwiic-chain.png deleted file mode 100644 index 5899d68721..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels-qwiik.png deleted file mode 100644 index 621425659d..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels.png deleted file mode 100644 index 229410a0c3..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/connection-guide-pixels.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/expansion-guide-pixels.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/expansion-guide-pixels.png deleted file mode 100644 index 427dc10d40..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/expansion-guide-pixels.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/mp-usb-connection.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/mp-usb-connection.png deleted file mode 100644 index fb059f9e8b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/mp-usb-connection.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/package-installer-overview.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/package-installer-overview.png deleted file mode 100644 index 67678dc808..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/package-installer-overview.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/pixel-expantion-mc.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/pixel-expantion-mc.png deleted file mode 100644 index ef177015f8..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/pixel-expantion-mc.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/schematic.png deleted file mode 100644 index 8f5504efee..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/assets/schematic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/content.md deleted file mode 100644 index 2ea4fc2ee4..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/content.md +++ /dev/null @@ -1,332 +0,0 @@ ---- -title: "How To Use The Modulino Pixels And MicroPython" -description: "Learn how to get the most out of your Modulino Pixels in a MicroPython environment." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-pixels -software: - - ide-v2 - - web-editor ---- - -The Modulino Pixels is a modular sensor that generates RGB light effects, making it perfect to add colorful visual feedback to your projects! -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - -## Hardware Specifications - -The Modulino Pixels based on 8 LC8822-2020 addressable LEDs is capable of generating colorful light patterns and effects. Take a look at the following table to know more about its characteristics: - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|------------------|-------------------|---------|---------|---------|------| -| Supply Voltage | - | 2.0 | 3.3 | 3.6 | V | -| Resolution (ADC) | Default | - | 12-bit | - | mcd | -| Communication | I²C,USART,SPI | - | I²C | - | - | - -## Pinout - -The LC8822-2020 addressable LEDs are the core components of this module. These RGB light output devices are controlled by an onboard STM32C011F4U6TR microcontroller, which supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -![Modulino Pixels Pinout](assets/PixelsPinouts.png) - -### 1x10 Header (LC8822-2020 and Microcontroller Signals) - -| Pin | Function | -|--------|-----------------| -| GND | Ground | -| GND | Ground | -| 3V3 | 3.3V Power | -| RESET | Reset | -| SWCLK | SWD Clock | -| SWDIO | SWD Data | -| TX1 | USART Transmit | -| RX1 | USART Receive | -| D0 | Pixels Data Out | -| C0 | Pixels Clock Out| - -- **GND: Ground**: Provides ground reference for the circuit. Multiple ground pins ensure stable power distribution. -- **3V3: 3.3V Power**: Supplies 3.3V power to connected components and modules. -- **RESET: Reset**: Used to reset the microcontroller or connected system. -- **SWCLK and SWDIO: SWD Interface**: Used for debugging, programming, and reprogramming the microcontroller via Serial Wire Debug protocol. -- **TX1 and RX1: USART Communication**: Enable serial communication for data transmission and reception with other devices or modules. -- **D0: Pixels Data Out**: Sends pixel data to addressable LED strips in a daisy chain configuration for lighting control. -- **C0: Pixels Clock Out**: Provides clock signal synchronization for addressable LED strips, ensuring proper timing for pixel data. - -### 1x4 Header (I2C) - -The pinout for the Modulino Pixels is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - -## I2C Address - -The **Modulino Pixels** module uses **LC8822-2020** addressable LEDs, which do not have native I²C capabilities. Instead, the LED array is controlled by the Modulino's onboard microcontroller (STM32C011F4U6TR). This microcontroller provides I²C communication, allowing for flexible control of the LEDs. - -One unique feature of this setup is the ability to change the I²C address via software. This means the address can be modified based on your application needs, making it adaptable to different system configurations. The default I²C address for the **Modulino Pixels** module is: - -| Modulino I²C Address | Hardware I²C Address | Editable Addresses (HEX) | -|----------------------|----------------------|-----------------------------------| -| 0x6C | 0x36 | Any custom address (via software) | - -When scanning for I²C address on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. - -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Typical | Maximum | Unit | -|------------------------|----------------|---------|---------|------| -| Operating Voltage | - | 3.3 | - | V | -| Power Dissipation | - | - | 350 | mW | -| Standby Current | No data signal | - | 1 | mA | -| Max LED Output Current | Per Channel | 18 | - | mA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. - -J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Pixels](assets/Modulino_Pixels_Power_Tree.png) - -## Schematic - -The Modulino Pixels uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Pixels](assets/schematic.png) - -The main components are the **8 LC8822-2020 addressable LEDs** and the **STM32C011F4U6TR** microcontroller (U1), which handles LED control as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -The **LC8822-2020** LEDs are connected in a daisy chain, with the first LED receiving clock and data signals from the microcontroller. The **CO (Clock Out)** and **DO (Data Out)** of the last LED in the chain are accessible via the **1x10 header**, allowing for expansion. - -![LED Expantion](assets/expansion-guide-pixels.png) - -These can also be found in small pads near the STM32 microcontroller alongside a few user defines pads that can be used by editing the firmware: - -![Exposed user-defined and LED expansion pads](assets/pixel-expantion-mc.png) - -There's also a small power LED indicator that lights up when the board is on. - -You can grab the full schematic and PCB files from the [Modulino Pixels](https://docs.arduino.cc/hardware/modulinos/modulino-pixels) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. - -Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-pixels.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-pixels-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-pixels-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. - -Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus. - -This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-pixels-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup’s performance. Ensure your cables are properly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Later in this article we teach how to [change the address](#how-to-change-i2c-address). Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually.*** - -Later in this article we teach how to [change the address](#how-to-change-i2c-address). - -## How To Program Your Modulino - -### Installing The Modulino Library - -To program your Modulino it is recommended you use the official ```Modulino``` micropython library available [here](https://github.com/arduino/arduino-modulino-mpy). The library is fully compatible with the no **Arduino Lab for MicroPython**. - -For information on installing the **Arduino Lab for MicroPython** please visit our [page](https://docs.arduino.cc/micropython/first-steps/install-guide/). - - - -The ```Modulino``` library is not available by default on MicroPython devices hence installation is needed. - -To simplify the process the [MicroPython Package Installer](https://github.com/arduino/lab-micropython-package-installer/releases) is recommended as it will provide a graphical interface to guide installation. - -After installation, you should now be able to: - -1. Open the tool. -2. Plug in your board to the computer. - - ![USB Connection](assets/mp-usb-connection.png) - - If the board does not appear in the Detected Boards section, click Reload. If the board is still undetected, ensure no other programs (e.g., a code editor) are using the board's COM port. - -3. Search for the ```Modulino``` package by filling in the text box on the search feature. -4. Click Install and wait for the installation confirmation. -5. Disconnect the board from the tool before returning to your code editor to avoid conflicts due to a busy COM port. - -![Package Installer Overview](assets/package-installer-overview.png) - -The module should now be includable in your program using: - -```from modulino import ModulinoBuzzer``` - -### Control RGB LEDs with MicroPython - -Getting LED data from the **Modulino Pixels** module is simple using the `Modulino` library. The crucial functions to control the LEDs are: - -- `set_rgb(index, r, g, b, brightness)`: Sets a specific LED to an RGB color with the specified brightness. -- `set_all_rgb(r, g, b, brightness)`: Sets all LEDs to an RGB color with the specified brightness. -- `set_all_color(color, brightness)`: Sets all LEDs to a predefined color. (`RED`,`BLUE`,`GREEN`,`VIOLET`,`WHITE`) -- `clear_all()`: Turns off all LEDs. -- `show()`: Sends the updated data to the LEDs. -- By default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it as instructed [here](https://github.com/arduino/arduino-modulino-mpy/tree/main/docs#%E2%84%B9%EF%B8%8F-using-3rd-party-boards). More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here’s an example demonstrating how to set colors and create a **Knight Rider animation**: - -```python -from modulino import ModulinoPixels, ModulinoColor -from time import sleep - -pixels = ModulinoPixels() - -# Set each LED to a different color from a color wheel -for index in range(0, 8): - color_wheel_colors = [ - (255, 0, 0), - (255, 85, 0), - (255, 255, 0), - (0, 255, 0), - (0, 255, 255), - (0, 0, 255), - (255, 0, 255), - (255, 0, 0) - ] - pixels.set_rgb(index, *color_wheel_colors[index], 100) -pixels.show() -sleep(1) - -# Set all LEDs to solid colors -pixels.set_all_rgb(255, 0, 0, 100) # Red -pixels.show() -sleep(1) - -pixels.set_all_color(ModulinoColor.GREEN, 100) -pixels.show() -sleep(1) - -pixels.set_all_color(ModulinoColor.BLUE, 100) -pixels.show() -sleep(1) - -# Knight Rider animation -def set_glowing_led(index, r, g, b, brightness): - """ - Set the color of the LED at the given index with its - neighboring LEDs slightly dimmed to create a glowing effect. - """ - pixels.clear_all() - pixels.set_rgb(index, r, g, b, brightness) - - if index > 0: - pixels.set_rgb(index - 1, r, g, b, brightness // 8) # Left LED - if index < 7: - pixels.set_rgb(index + 1, r, g, b, brightness // 8) # Right LED - - pixels.show() - -for j in range(3): - for i in range(8): - set_glowing_led(i, 255, 0, 0, 100) - sleep(0.05) - - for i in range(7, -1, -1): - set_glowing_led(i, 255, 0, 0, 100) - sleep(0.05) - -# Turn off all LEDs -pixels.clear_all().show() -``` - -This example shows different ways to control the Pixels. It starts by creating a rainbow pattern using different colors for each LED. Next, it demonstrates setting all LEDs to the same color, using both RGB values and predefined color constants. The final section implements a Knight Rider animation by lighting one main LED at full brightness while slightly illuminating adjacent LEDs at reduced brightness. The `set_glowing_led()` function handles this effect by managing the primary LED and its neighbors, creating a back-and-forth scanning pattern that repeats three times before turning off all LEDs. - -### How To Change Address - -A sketch is also available included with the library named `AddressChanger` and also available [here](https://github.com/arduino/arduino-modulino-mpy/blob/main/examples/change_address.py). This sketch changes the I2C address at a software level on the Module's microcontroller. - -- Connect the module to your board via I2C, ensuring no other modules are in the chain. -- Run the script in a MicroPython environment. -- Follow the on-screen instructions (REPL) to select the device and enter a new address. Valid I²C addresses range from 0x08 to 0x77 (7-bit values in hexadecimal format, e.g., 0x42). -- The script will attempt to change the address and confirm success. - -To keep track of the address in use, the module has a white rectangle on the back. Feel free to use this to write the address that was chosen. - -When using a custom address in your MicroPython sketch, you'll need to specify this address when creating the module object. For example: - -```python -pixels_module = ModulinoPixels(address=0x45) # Replace 0x45 with your specific address -``` - -## Troubleshooting - -### LEDs Not Lighting - -If your Modulino's power LED isn't on or the RGB LEDs aren't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `import ModulinoPixels"` command, verify that the Modulino library is correctly installed: - -- Check your IDE to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### Incorrect Colors or Flickering - -If the LED colors are incorrect or the LEDs are flickering unexpectedly, make sure: - -- The brightness values are within the appropriate range (typically 0-255). -- All exposed electronics are not touching any conductive surfaces, as this could interfere with the LED output. -- The power supply is stable and providing sufficient current for all LEDs at the desired brightness. - -## Conclusion - -The **Modulino Pixels** is a digital RGB LED control module that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes generating colorful light effects straightforward, allowing you to focus on experimenting or building your system logic. It's a small, reliable module suited for both visual feedback and creative lighting projects. - -## What Is Next? - -Now that you've learned how to use your Modulino Pixels, you're all set to integrate it into your projects! - -- Create an animated progress bar that visually displays status, or battery charge level using a gradient of colors. -- Build a live sound level indicator that responds to ambient noise. -- Design a pomodoro timer with color coded work and rest periods to boost your productivity. -- Program an interactive game where players must match patterns of colors in the correct sequence, with difficulty increasing as they progress. diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/image.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/image.png deleted file mode 100644 index bceefec75d..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-mp/image.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/PixelsPinouts.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/assets/PixelsPinouts.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/PixelsPinouts.png rename to content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/assets/PixelsPinouts.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/expansion-guide-pixels.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/assets/expansion-guide-pixels.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels-ardu/assets/expansion-guide-pixels.png rename to content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/assets/expansion-guide-pixels.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/assets/pixelsOverview.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/assets/pixelsOverview.png new file mode 100644 index 0000000000..13526c3f7d Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/assets/pixelsOverview.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/content.md new file mode 100644 index 0000000000..ea503323fa --- /dev/null +++ b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/content.md @@ -0,0 +1,443 @@ +--- +title: "Modulino Pixels" +description: "Complete guide for the Modulino Pixels RGB LED module." +tags: + - Modulino + - LED + - RGB + - QWIIC + - I2C +author: 'Pedro Sousa Lima' +hardware: + - hardware/11.modulinos/modulinos/modulino-pixels +software: + - ide-v2 + - web-editor + - micropython +--- + +![Pixels Overview](assets/pixelsOverview.png) + +The Modulino Pixels is a modular sensor that generates RGB light effects, making it perfect to add colourful visual feedback to your projects! It features 8 individually addressable RGB LEDs controlled through I2C. + +## Hardware Overview + +### General Characteristics + +The Modulino Pixels is based on 8 LC8822-2020 addressable LEDs capable of generating colourful light patterns and effects. + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|------------------|----------------|---------|---------|---------|------| +| Supply Voltage | - | 2.0 | 3.3 | 3.6 | V | +| Resolution (ADC) | Default | - | 12-bit | - | - | +| Communication | I2C,USART,SPI | - | I2C | - | - | + +### Module Details + +The **Modulino Pixels** module uses **LC8822-2020** addressable LEDs, which do not have native I2C capabilities. Instead, the LED array is controlled by the Modulino's onboard microcontroller (STM32C011F4U6TR). This microcontroller provides I2C communication, allowing for flexible control of the LEDs. + +One unique feature of this setup is the ability to change the I2C address via software, making it adaptable to different system configurations. + +The default I2C address for the **Modulino Pixels** module is: + +| Modulino I2C Address | Hardware I2C Address | Editable Addresses (HEX) | +|----------------------|----------------------|-----------------------------------| +| 0x6C | 0x36 | Any custom address (via software) | + +### Pinout + +![Modulino Pixels Pinout](assets/PixelsPinouts.png) + +#### 1x10 Header (LC8822-2020 and Microcontroller Signals) + +| Pin | Function | +|--------|-----------------| +| GND | Ground | +| GND | Ground | +| 3V3 | 3.3V Power | +| RESET | Reset | +| SWCLK | SWD Clock | +| SWDIO | SWD Data | +| TX1 | USART Transmit | +| RX1 | USART Receive | +| D0 | Pixels Data Out | +| C0 | Pixels Clock Out| + +The **D0** and **C0** pins allow for expansion by daisy-chaining additional LED strips. +![Expantion Pins](assets/expansion-guide-pixels.png) + +#### 1x4 Header (I2C) + +| Pin | Function | +|-------|--------------| +| GND | Ground | +| 3.3 V | Power Supply | +| SDA | I2C Data | +| SCL | I2C Clock | + +### Power Specifications + +| Parameter | Condition | Typical | Maximum | Unit | +|------------------------|----------------|---------|---------|------| +| Operating Voltage | - | 3.3 | - | V | +| Power Dissipation | - | - | 350 | mW | +| Standby Current | No data signal | - | 1 | mA | +| Max LED Output Current | Per Channel | 18 | - | mA | + +The module includes a power LED that draws 1 mA and turns on as soon as it is powered. + +## Programming with Arduino + +### Prerequisites + +- Install the Modulino library via the Arduino IDE Library Manager +- Connect your Modulino Pixels via QWIIC or solderable headers + +### Basic Example + +```arduino +#include + +ModulinoPixels leds; + +int brightness = 25; + +void setup(){ + Modulino.begin(); + leds.begin(); +} + +void loop(){ + // Set all LEDs to blue + for (int i = 0; i < 8; i++) { + leds.set(i, BLUE, brightness); + leds.show(); + } +} +``` + +### Key Functions + +- `set(index, color, brightness)`: Sets a specific LED (0-7) to a colour with brightness +- `show()`: Applies the changes to the LEDs +- Available colours: `RED`, `BLUE`, `GREEN`, `VIOLET`, `WHITE` + +### Advanced Example - Rainbow Animation + +```arduino +#include + +ModulinoPixels leds; + +// Color definitions for rainbow +const int NUM_LEDS = 8; +int colors[][3] = { + {255, 0, 0}, // Red + {255, 127, 0}, // Orange + {255, 255, 0}, // Yellow + {0, 255, 0}, // Green + {0, 0, 255}, // Blue + {75, 0, 130}, // Indigo + {148, 0, 211}, // Violet + {255, 0, 0} // Back to Red +}; + +void setup() { + Serial.begin(9600); + Modulino.begin(); + leds.begin(); + + Serial.println("Rainbow Animation Started"); +} + +void rainbowCycle() { + static int offset = 0; + + for (int i = 0; i < NUM_LEDS; i++) { + int colorIndex = (i + offset) % NUM_LEDS; + + // Custom color setting using RGB values + // Since the library uses predefined colors, we'll use + // the closest match or cycle through available colors + switch(colorIndex) { + case 0: + case 7: + leds.set(i, RED, 50); + break; + case 1: + case 2: + leds.set(i, GREEN, 50); + break; + case 3: + case 4: + leds.set(i, BLUE, 50); + break; + case 5: + case 6: + leds.set(i, VIOLET, 50); + break; + } + } + + leds.show(); + offset = (offset + 1) % NUM_LEDS; +} + +void breathingEffect() { + static int brightness = 0; + static int direction = 1; + + // Update brightness + brightness += direction * 5; + + if (brightness >= 100 || brightness <= 0) { + direction = -direction; + } + + // Set all LEDs to same color with varying brightness + for (int i = 0; i < NUM_LEDS; i++) { + leds.set(i, BLUE, brightness); + } + leds.show(); +} + +void chaseEffect() { + static int position = 0; + + // Turn off all LEDs + for (int i = 0; i < NUM_LEDS; i++) { + leds.set(i, WHITE, 0); + } + + // Light up current position and trailing LEDs + leds.set(position, WHITE, 100); + if (position > 0) { + leds.set(position - 1, WHITE, 30); + } else { + leds.set(NUM_LEDS - 1, WHITE, 30); + } + + leds.show(); + position = (position + 1) % NUM_LEDS; +} + +void loop() { + // Cycle through different effects + for (int i = 0; i < 50; i++) { + rainbowCycle(); + delay(100); + } + + for (int i = 0; i < 100; i++) { + breathingEffect(); + delay(30); + } + + for (int i = 0; i < 30; i++) { + chaseEffect(); + delay(80); + } +} +``` + +## Programming with MicroPython + +### Prerequisites + +- Install the Modulino MicroPython library +- Ensure Arduino Lab for MicroPython is installed + +### Basic Example + +```python +from modulino import ModulinoPixels, ModulinoColor +from time import sleep + +pixels = ModulinoPixels() + +# Set all LEDs to green +pixels.set_all_color(ModulinoColor.GREEN, 100) +pixels.show() +sleep(1) + +# Turn off all LEDs +pixels.clear_all().show() +``` + +### Key Functions + +- `set_rgb(index, r, g, b, brightness)`: Set specific LED to RGB colour +- `set_all_rgb(r, g, b, brightness)`: Set all LEDs to RGB colour +- `set_all_color(color, brightness)`: Set all LEDs to predefined colour +- `clear_all()`: Turn off all LEDs +- `show()`: Send updated data to LEDs + +### Advanced Example - Interactive Light Patterns + +```python +from modulino import ModulinoPixels, ModulinoColor +from time import sleep, ticks_ms + +pixels = ModulinoPixels() + +def wheel(pos): + """Generate rainbow colors across 0-255 positions""" + if pos < 85: + return (255 - pos * 3, pos * 3, 0) + elif pos < 170: + pos -= 85 + return (0, 255 - pos * 3, pos * 3) + else: + pos -= 170 + return (pos * 3, 0, 255 - pos * 3) + +def rainbow_cycle(wait=0.01): + """Draw rainbow that uniformly distributes itself across all LEDs""" + for j in range(256): + for i in range(8): + pixel_index = (i * 256 // 8) + j + r, g, b = wheel(pixel_index & 255) + pixels.set_rgb(i, r, g, b, 50) + pixels.show() + sleep(wait) + +def color_wipe(r, g, b, wait=0.05): + """Wipe color across display a pixel at a time""" + for i in range(8): + pixels.set_rgb(i, r, g, b, 100) + pixels.show() + sleep(wait) + +def theater_chase(r, g, b, wait=0.1): + """Movie theater light style chaser animation""" + for q in range(3): + for i in range(0, 8, 3): + if i + q < 8: + pixels.set_rgb(i + q, r, g, b, 100) + pixels.show() + sleep(wait) + + for i in range(0, 8, 3): + if i + q < 8: + pixels.set_rgb(i + q, 0, 0, 0, 0) + +def pulse_color(r, g, b, duration=2): + """Pulse all LEDs with specified color""" + steps = 50 + for i in range(steps): + brightness = int((1 + i) * 100 / steps) + pixels.set_all_rgb(r, g, b, brightness) + pixels.show() + sleep(duration / (steps * 2)) + + for i in range(steps, 0, -1): + brightness = int(i * 100 / steps) + pixels.set_all_rgb(r, g, b, brightness) + pixels.show() + sleep(duration / (steps * 2)) + +def fire_effect(): + """Simulate fire/flame effect""" + import random + + # Base fire colors + base_r = 255 + base_g = 80 + base_b = 0 + + for _ in range(100): + for i in range(8): + # Add random flicker + flicker = random.randint(-40, 40) + r = max(0, min(255, base_r + flicker)) + g = max(0, min(255, base_g + flicker // 2)) + b = base_b + + brightness = random.randint(30, 100) + pixels.set_rgb(i, r, g, b, brightness) + + pixels.show() + sleep(0.05) + +def progress_bar(percentage, color_r=0, color_g=255, color_b=0): + """Display a progress bar""" + pixels.clear_all() + + # Calculate how many LEDs to light + leds_to_light = int((percentage / 100) * 8) + + for i in range(leds_to_light): + pixels.set_rgb(i, color_r, color_g, color_b, 100) + + # Partial LED for precise percentage + if leds_to_light < 8 and percentage > 0: + remainder = (percentage / 100 * 8) - leds_to_light + if remainder > 0: + brightness = int(remainder * 100) + pixels.set_rgb(leds_to_light, color_r, color_g, color_b, brightness) + + pixels.show() + +# Demo menu +print("LED Pattern Showcase") +print("====================") +patterns = [ + ("Rainbow Cycle", lambda: rainbow_cycle()), + ("Color Wipe - Red", lambda: color_wipe(255, 0, 0)), + ("Color Wipe - Green", lambda: color_wipe(0, 255, 0)), + ("Color Wipe - Blue", lambda: color_wipe(0, 0, 255)), + ("Theater Chase", lambda: theater_chase(127, 127, 127)), + ("Pulse White", lambda: pulse_color(255, 255, 255)), + ("Fire Effect", lambda: fire_effect()), + ("Progress Demo", lambda: [progress_bar(i) for i in range(0, 101, 5)]) +] + +for i, (name, _) in enumerate(patterns, 1): + print(f"{i}. {name}") + +while True: + choice = input("\nSelect pattern (1-8): ") + + try: + idx = int(choice) - 1 + if 0 <= idx < len(patterns): + name, pattern_func = patterns[idx] + print(f"Running: {name}") + pattern_func() + pixels.clear_all().show() + else: + print("Invalid selection") + except ValueError: + print("Please enter a number") + except KeyboardInterrupt: + pixels.clear_all().show() + print("\nExiting...") + break +``` + +## Troubleshooting + +### LEDs Not Lighting + +If your Modulino's power LED isn't on or the RGB LEDs aren't responsive: +- Ensure both the board and the Modulino are connected properly +- Verify that the power LEDs on both are lit +- Check that the QWIIC cable is properly clicked into place + +### Incorrect Colours or Flickering + +If the LED colours are incorrect or the LEDs are flickering: +- Verify brightness values are within the appropriate range (0-255) +- Check that exposed electronics are not touching conductive surfaces +- Ensure stable power supply with sufficient current for all LEDs + +## Project Ideas + +- **Progress Bar**: Visually display status or battery charge level +- **Sound Level Indicator**: Respond to ambient noise with light +- **Pomodoro Timer**: Colour-coded work and rest periods +- **Simon Game**: Match colour patterns in sequence +- **Notification System**: Different colours for different alerts +- **Mood Lighting**: Create ambient lighting effects +- **Temperature Indicator**: Use with Modulino Thermo for visual temperature feedback +- **Music Visualiser**: Sync lights to music or sounds \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/image.png b/content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/image.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-distance/tutorials/how-distance-mp/image.png rename to content/hardware/11.accessories/modulino-nodes/modulino-pixels/tutorials/how-pixels/image.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/datasheet/datasheet.md b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/datasheet/datasheet.md index fd8f8ebdea..802d211329 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/datasheet/datasheet.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/datasheet/datasheet.md @@ -43,9 +43,9 @@ The Modulino® Thermo node can be used in numerous scenarios within IoT and elec ## Related Products -- *SKU: ASX00027* – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) -- *SKU: K000007* – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) -- *SKU: AKX00026* – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) +- **SKU: ASX00027** – [Arduino® Sensor Kit](https://store.arduino.cc/products/arduino-sensor-kit) +- **SKU: K000007** – [Arduino® Starter Kit](https://store.arduino.cc/products/arduino-starter-kit-multi-language) +- **SKU: AKX00026** – [Arduino® Oplà IoT Kit](https://store.arduino.cc/products/opla-iot-kit) ## Rating diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/product.md b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/product.md index 763c6850f3..aba92bd489 100644 --- a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/product.md +++ b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/product.md @@ -2,10 +2,10 @@ title: Modulino Thermo url_shop: https://store.arduino.cc/products/modulino-thermo url_guide: https://courses.arduino.cc/plugandmake -primary_button_url: https://docs.arduino.cc/tutorials/modulino-thermo/how-thermo-ardu/ -primary_button_title: With Arduino -secondary_button_url: https://docs.arduino.cc/tutorials/modulino-thermo/how-thermo-mp/ -secondary_button_title: With MicroPython +primary_button_url: https://docs.arduino.cc/tutorials/modulino-thermo/how-thermo/ +primary_button_title: Get Started +secondary_button_url: https://docs.arduino.cc/tutorials/modulino-thermo/how-general/ +secondary_button_title: More on Modulinos forumCategorySlug: '/hardware/accessories/modulino-thermo/220' sku: [ABX00103] --- diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/ThermoOverview.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/ThermoOverview.png new file mode 100644 index 0000000000..31fd0ba8e5 Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/ThermoOverview.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/I2CAdressChange.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/I2CAdressChange.png new file mode 100644 index 0000000000..289409cc21 Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/I2CAdressChange.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/IDE-Left-Tab.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/IDE-Left-Tab.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/IDE-Left-Tab.png rename to content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/IDE-Left-Tab.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/adressChangeFile.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/adressChangeFile.png new file mode 100644 index 0000000000..261226b331 Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/adressChangeFile.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/connection-guide-gen-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/connection-guide-gen-jumper.png new file mode 100644 index 0000000000..81b8b83eb0 Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/connection-guide-gen-jumper.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/connection-guide-gen.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/connection-guide-gen.png new file mode 100644 index 0000000000..b9b45cb39f Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/connection-guide-gen.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/connection-guide-thermo-qwiic-chain.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo-qwiic-chain.png rename to content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/connection-guide-thermo-qwiic-chain.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/library-install.gif b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/library-install.gif similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-ardu/assets/library-install.gif rename to content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/library-install.gif diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/package-installer-overview.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/package-installer-overview.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-buttons/tutorials/how-buttons-mp/assets/package-installer-overview.png rename to content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/assets/package-installer-overview.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/connection-guide-gen-qwiic.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/connection-guide-gen-qwiic.png new file mode 100644 index 0000000000..c49ac03586 Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/connection-guide-gen-qwiic.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/content.md new file mode 100644 index 0000000000..6ba510d201 --- /dev/null +++ b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/content.md @@ -0,0 +1,247 @@ +--- +title: "Getting Started with Modulinos" +description: "Learn the fundamentals of connecting, configuring, and programming Modulino sensors and actuators." +tags: + - Modulino + - QWIIC + - I2C +author: 'Arduino Team' +hardware: + - hardware/11.modulinos/modulinos +software: + - ide-v2 + - web-editor + - micropython +--- + +The Modulino ecosystem provides modular sensors and actuators that streamline prototyping and development. Each module follows a standardised form factor with QWIIC connectors and I²C protocol integration, allowing simple connection and programming of multiple nodes. In addition to QWIIC connectors, Modulinos expose solderable pins for compatibility with boards that don't support QWIIC. + +## The Modulino System + +Modulinos are designed to work seamlessly together through: +- **Standardised QWIIC connectors** for plug-and-play connectivity +- **I²C communication** for simple two-wire data transfer +- **Daisy-chain capability** for connecting multiple modules +- **Compact form factor** for space-efficient designs +- **Cross-platform support** for Arduino and MicroPython + +## How To Connect Your Modulino + +The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It's plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. + +Note that the dedicated I²C pins will differ from board to board, meaning it is always a good idea to check your specific model. + +![Connection Options](assets/connection-guide-gen.png) + +### QWIIC Connector (Recommended) + +Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple—just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarised, there is no need to worry about accidentally swapping connections. + +![QWIIC Connection](connection-guide-gen-qwiic.png) + +QWIIC is a plug-and-play I²C Connect System that uses standardised 4-pin connectors: +- GND +- 3.3V +- SDA (Data) +- SCL (Clock) + +The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. + +### Solderable Header + +When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in each module's guide to connect to the right pins of your board. + +![Solderable Header](assets/connection-guide-gen-jumper.png) + +### Daisy-Chaining Multiple Modulino Nodes + +Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. + +![QWIIC Chain](assets/connection-guide-thermo-qwiic-chain.png) + +Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus. + +This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. + +***Important considerations for daisy-chaining:*** +- The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added +- The cables you use for these connections will play a significant role in the setup's performance +- Ensure your cables are properly connected and capable of handling the required data transfer +- Each module should have a unique address on a chain if you plan to address them individually +- Multiple modules with the same address will cause conflicts on the I²C bus and will not allow you to address them individually + +## Power Specifications + +All Modulinos are typically powered by **+3.3 VDC** when using the QWIIC interface as per the I²C standard. Each module includes: +- Power LED indicator (typically draws 1 mA) +- Shared power distribution between QWIIC connectors and headers +- Protection against reverse polarity (on most modules) + +Always check your specific module's documentation for detailed power consumption specifications. + +## Installing The Modulino Library + +### For Arduino IDE + +You need the official Modulino library to use any Modulino module with Arduino. The Arduino IDE provides tools that make adding a library straightforward. + +To install the IDE, please visit our [getting started page](https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2-downloading-and-installing/). + +After opening the IDE: +1. Look for the tab on the left side +2. Click the book icon for "Library Manager" +![Library Tab](assets/IDE-Left-Tab.png) +3. Search for "Modulino" in the search box +4. Click "Install" +![Library Manager](assets/library-install.gif) + +A prompt might appear saying that additional dependencies are required. This is not a problem, as they will be automatically added when you confirm the prompt. + +**Important Wire Configuration:** +By default, the Modulino library uses `Wire1`. If your board model has a different pinout for the dedicated I²C pins, you might have to edit it. Check [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/) for more information on Wire configuration. + +### For MicroPython + +To program your Modulino with MicroPython, use the official `Modulino` MicroPython library available [here](https://github.com/arduino/arduino-modulino-mpy). The library is fully compatible with the Arduino Lab for MicroPython. + +For information on installing the **Arduino Lab for MicroPython**, please visit our [installation guide](https://docs.arduino.cc/micropython/first-steps/install-guide/). + +The `Modulino` library is not available by default on MicroPython devices, hence installation is needed. + +#### Using the MicroPython Package Installer + +To simplify the process, the [MicroPython Package Installer](https://github.com/arduino/lab-micropython-package-installer/releases) is recommended as it provides a graphical interface to guide installation. + +1. Open the tool +2. Plug in your board to the computer + If the board does not appear in the Detected Boards section, click Reload + If the board is still undetected, ensure no other programs are using the board's COM port + ![alt text](assets/package-installer-overview.png) +1. Search for the `Modulino` package by filling in the text box on the search feature +2. Click Install and wait for the installation confirmation +3. Disconnect the board from the tool before returning to your code editor to avoid conflicts due to a busy COM port + +After installation, you can import modules using: +```python +from modulino import ModulinoThermo, ModulinoBuzzer, ModulinoButtons +# Import the specific modules you need +``` + +**Wire Configuration for MicroPython:** +By default, the Modulino library uses `Wire1`. If your board model has a different pinout for the dedicated I²C pins, you might have to edit it as instructed [here](https://github.com/arduino/arduino-modulino-mpy/tree/main/docs#ℹ️-using-3rd-party-boards). + +## How To Change I²C Address + +Some Modulinos support software-configurable I²C addresses, allowing multiple identical modules to work on the same bus. Modules with fixed addresses cannot be changed and will require alternative solutions for multiple units. + +### For Arduino (Software-Configurable Modules) + +An example sketch, `AddressChanger`, is included with the library inside the `Utilities` folder and available [here](https://github.com/arduino-libraries/Modulino/blob/main/examples/Utilities/AddressChanger/AddressChanger.ino).![Sketch Location](assets/adressChangeFile.png) + +To change the address: +1. Connect the module to your board (remove any other modules from the chain) +2. Upload the AddressChanger sketch +3. Open the Serial Monitor +4. Ensure the correct baud rate is selected if displayed characters seem corrupted +5. Select the new address and confirm +![Address Selection](assets/I2CAdressChange.png) +6. Valid I²C addresses range from 0x08 to 0x77 (7-bit values in hexadecimal format) + +When using a custom address in your sketch, specify this address when creating the module object: +```arduino +ModulinoBuzzer buzzer(0x3E); // Replace 0x3E with your specific address +``` + +### For MicroPython (Software-Configurable Modules) + +A script is available [here](https://github.com/arduino/arduino-modulino-mpy/blob/main/examples/change_address.py). + +To change the address: +1. Connect the module to your board via I²C (ensure no other modules are in the chain) +2. Run the script in a MicroPython environment +3. Follow the on-screen instructions (REPL) to select the device and enter a new address +4. The script will attempt to change the address and confirm success + +When using a custom address in MicroPython: +```python +buzzer_module = ModulinoBuzzer(address=0x45) # Replace 0x45 with your specific address +``` + +### Tracking Address Changes + +To keep track of the address in use, modules have a white rectangle on the back. Use this space to write the selected address for future reference. + +## Module Addressing Reference + +| Module | Default Modulino Address | Hardware Address | Configurable | +|--------|-------------------------|------------------|--------------| +| Buttons | 0x7C | 0x3E | Software | +| Buzzer | 0x3C | 0x1E | Software | +| Distance | 0x52 | 0x52 | No | +| Knob | 0x76 | 0x3A | Software | +| Movement | 0x6A | 0x6A | Hardware (0x6A/0x6B) | +| Pixels | 0x6C | 0x36 | Software | +| Thermo | 0x44 | 0x44 | No | + +When scanning for I²C addresses on the bus, you might find the modulino using the **Hardware I²C Address**. However, you should always use the **Modulino I²C Address** when using the official Modulino library. + +## General Troubleshooting + +### Module Not Responding + +If your Modulino's power LED isn't on or the module isn't responsive: +- Ensure both the board and the Modulino are connected to your computer +- Verify that the power LEDs on both are lit +- Check that the QWIIC cable is properly clicked into place +- Verify the module is receiving 3.3V power + +### Library Not Installed Properly + +**Arduino IDE:** +If you encounter an issue with the `#include "Modulino.h"` command: +- Check your IDE to ensure the library is installed and up-to-date +- Re-install the library through the Library Manager +- Verify all dependencies were installed + +**MicroPython:** +If you encounter an issue with `from modulino import` commands: +- Check the package installer to ensure the library is installed +- Re-install the library through the Package Installer +- Ensure the board was disconnected from other programs during installation + +### I²C Communication Issues + +- Verify correct Wire configuration (Wire vs Wire1) +- Check for address conflicts between modules +- Ensure pull-up resistors are present on the I²C bus +- Verify cable length isn't exceeding I²C specifications +- Check that all connections are secure + +### Inaccurate Sensor Values + +- Ensure all exposed electronics are not touching conductive surfaces +- Verify the module is not placed near interference sources +- Check that power supply is stable and within specifications +- Allow sensors time to stabilise after power-on + +## Best Practices + +1. **Power Management**: Always use 3.3V for QWIIC connections. Never exceed voltage specifications. + +2. **Cable Management**: Use appropriate length QWIIC cables. Excessive cable length can cause signal degradation. + +3. **Address Management**: Document all address changes on the white label provided on each module. + +4. **Environmental Considerations**: Keep modules away from sources of electromagnetic interference, excessive heat, or moisture unless specifically rated for such conditions. + +5. **Development Workflow**: Test modules individually before connecting them in a chain to isolate any issues. + +## What's Next? + +Now that you understand the fundamentals of the Modulino system: +- Explore individual module guides for specific features and capabilities +- Experiment with combining multiple modules in your projects +- Share your creations with the Arduino community +- Check for updates and new modules in the Modulino ecosystem + +For detailed information about specific modules, refer to their individual documentation pages, which include pinouts, specifications, and programming examples for both Arduino and MicroPython. \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/image.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/image.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-ardu/image.png rename to content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-general/image.png diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/IDE-Left-Tab.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/IDE-Left-Tab.png deleted file mode 100644 index c7bb86575e..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/IDE-Left-Tab.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/Modulino_Thermo_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/Modulino_Thermo_Power_Tree.png deleted file mode 100644 index 75ecb8a8e7..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/Modulino_Thermo_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo-jumper.png deleted file mode 100644 index 0742e36a31..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo-qwiik.png deleted file mode 100644 index e10a27ebdb..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo.png deleted file mode 100644 index 35591967a9..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/connection-guide-thermo.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/library-install.gif b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/library-install.gif deleted file mode 100644 index 16f396c353..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/library-install.gif and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/schematic.png deleted file mode 100644 index b094fac53d..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/schematic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/content.md deleted file mode 100644 index f54ced5150..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/content.md +++ /dev/null @@ -1,231 +0,0 @@ ---- -title: "How To Use The Modulino Thermo" -description: "Learn how to get the most out of your Modulino Thermo." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-thermo -software: - - ide-v2 - - web-editor ---- - -The Modulino Thermo is a modular sensor that measures temperature and humidity, making it perfect to add environmental monitoring to your projects! -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - -## General Characteristics - -The Modulino Thermo is capable of measuring temperature and relative humidity. Take a look at the following table to know more about its measuring ranges: - - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|-----------|-------------|---------|---------|---------|------| -| Range | Temperature | \-40 | \- | +125 | °C | -| \- | Humidity | 0 | \- | 100% | φ RH | -| Accuracy | Temperature | \- | ±0,25 | \- | °C | -| \- | Humidity | \- | ±2.8% | \- | φ | - -### Sensor Details - -The HS3003 sensor from Renesas is the core component of this module. This temperature and humidity sensor natively supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -The default address for the Module is: - -| Modulino I²C Address | Hardware I²C Address | -|----------------------|----------------------| -| 0x44 | 0x44 | - -***Note: Since the address cannot be changed on this Modulino specifically, using two or more identical modules on the same I²C bus will result in address conflicts and cause communication issues.*** - -## Pinout - -The pinout for the Modulino Thermo is shown below. Please note that the exposed solderable pins are directly connected to the QWIIC connectors using the same I²C interface. - -![Arduino Thermo Pinout](assets/ThermoPinouts.jpg) - -Depending on the board connected to the modulino, the I²C pin names to program it may differ. Please check the [board tutorials](https://docs.arduino.cc/hardware/) on your modulino's compatible board or the [Modulino library](https://github.com/arduino-libraries/Modulino/tree/main/docs) to learn more. - -### 1x4 Header (I2C) - -The pinout for the Modulino Buzzer is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3.3 V | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|-----------------|-------------------------------------------------------------------|---------|-------------|---------|------| -| Supply Voltage | \- | 2.3 | 3.3 (QWIIC) | 5.5 | V | -| Average Current | 1 humidity + temperature measurement/s 3.3 VDD - Max 5,5@ 3.3 VDD | \- | 1024.4 | 24.4 | µA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. - -J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Thermo](assets/Modulino_Thermo_Power_Tree.png) - -## Schematic - -The Modulino Thermo uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Thermo](assets/schematic.png) - -The main component is the **HS3003** sensor (U1), which handles both temperature and humidity measurements, as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -There's also a small power indicator LED that lights up when the board is on. -You can grab the full schematic and PCB files from the [Modulino Thermo](https://docs.arduino.cc/hardware/modulinos/modulino-thermo) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -If your board doesn’t have a QWIIC connector, you can still access the same I²C bus and power the module using the solderable header pads just make sure you wire it to 3.3V and match the I²C pinout. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-thermo.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-thermo-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-thermo-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. - -Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus as long as you select the correct I²C pins depending on your board. - -This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-thermo-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup’s performance. Ensure your cables are correctly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Multiple modules with the same address will cause conflicts on the I²C bus.*** - -## How To Use Your Modulino - -### Installing The Modulino Library - -You need the official Modulino library available [here](https://docs.arduino.cc/libraries/modulino/) to use the Modulino Thermo. - -With the Arduino IDE you get some tools that make adding a library easier. To learn how to install the IDE please visit our [page](https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2-downloading-and-installing/). - -After opening the IDE, a tab should be visible on the left. Press the book icon for "library" as highlighted in the image. - -![IDE Library Tab](assets/IDE-Left-Tab.png) - -The process should look like this: - -![Library Install](assets/library-install.gif) - -A message will appear after the installation is successful. - - -### Getting Temperature And Humidity Data - -Getting data from the sensor is fairly simple using the ```Modulino``` library. For the **Modulino Thermo** there are two important functions: - -- ```getTemperature()```: Provides the temperature measurement from the sensor. (default in Celsius C) -- ```getHumidity()```: Provides the relative humidity measurement from the sensor. (default in Relative Percentage %) -- ```Modulino.begin();```: By default the Modulino library uses ```Wire1``` if your connection is in a different Wire you will have to edit it, check [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/) (by default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/)) for the library's hardware compatibility. More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here is an example sketch of how to implement these functions to acquire data and show it using the serial monitor: - -```arduino -#include - -// Create object instance -ModulinoThermo thermo; - -// Global Variables -float celsius = 0; -float humidity = 0; - -void setup(){ - // Initialization of the serial port, modulino object and thermo one - - Serial.begin(115200); - Modulino.begin(); - thermo.begin(); -} - -void loop(){ - celsius = thermo.getTemperature(); - humidity = thermo.getHumidity(); - - Serial.print("Temperature (C) is: "); - Serial.println(celsius); - - Serial.print("Humidity (rH) is: "); - Serial.println(humidity); - - delay(1000); -} -``` - -The code example provided shows how to initialize the sensor, read the data, and display it on the serial monitor. The data is updated every second, showing the current temperature and humidity values in real time. - -It can be easily adapted to trigger actions at certain temperature/humidity thresholds or to log data for analysis. - -## Troubleshooting - -### Sensor Not Reachable - -If your Modulino's power LED isn't on or the sensor isn't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `#include "modulino.h"` command, verify that the Modulino library is correctly installed: - -- Check your IDE to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### Inaccurate Values - -If the sensor values are not accurate, make sure: - -- The sensor is not placed near any components that might generate heat (like motors or power supplies). -- All exposed electronics are not touching any conductive surfaces, as this could interfere with readings. - -## Conclusion - -The **Modulino Thermo** is a digital temperature and humidity sensor that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes accessing sensor data straightforward, allowing you to focus on experimenting or building your system logic. It’s a small, reliable module suited for both quick tests and longer-term setups. - -## What Is Next? - -Now that you've learned how to use your Modulino Thermo, you're all set to integrate it into your projects! - -- Experiment with temperature and humidity. What happens if you place your Modulino in the refrigerator? -- Try breathing near the sensor. Does the humidity change? -- Place your Modulino on the outside of your mug and fill it with a hot beverage. Can you create an automatic system to know when your tea has cooled down? -- How does the temperature change throughout the day at home? Let your Modulino run for an entire day and check out the data! \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/image.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/image.png deleted file mode 100644 index bceefec75d..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/image.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/Modulino_Thermo_Power_Tree.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/Modulino_Thermo_Power_Tree.png deleted file mode 100644 index 75ecb8a8e7..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/Modulino_Thermo_Power_Tree.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/ThermoPinouts.jpg b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/ThermoPinouts.jpg deleted file mode 100644 index 22c8b59c70..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/ThermoPinouts.jpg and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo-jumper.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo-jumper.png deleted file mode 100644 index 650231c828..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo-jumper.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo-qwiic-chain.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo-qwiic-chain.png deleted file mode 100644 index 28d62417a5..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo-qwiic-chain.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo-qwiik.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo-qwiik.png deleted file mode 100644 index e10a27ebdb..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo-qwiik.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo.png deleted file mode 100644 index 35591967a9..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/connection-guide-thermo.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/mp-usb-connection.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/mp-usb-connection.png deleted file mode 100644 index fb059f9e8b..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/mp-usb-connection.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/package-installer-overview.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/package-installer-overview.png deleted file mode 100644 index 67678dc808..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/package-installer-overview.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/schematic.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/schematic.png deleted file mode 100644 index b094fac53d..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/assets/schematic.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/content.md deleted file mode 100644 index 0423fa4909..0000000000 --- a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/content.md +++ /dev/null @@ -1,233 +0,0 @@ ---- -title: "How To Use The Modulino Thermo And MicroPython" -description: "Learn how to get the most out of your Modulino Thermo in a MicroPython environment." -tags: - - Modulino - - QWIIC - - I2C -author: 'Pedro Sousa Lima' -hardware: - - hardware/11.modulinos/modulinos/modulino-thermo -software: - - ide-v2 - - web-editor ---- - -The Modulino Thermo is a modular sensor that measures temperature and humidity, making it perfect to add environmental monitoring to your projects! -The Modulino form factor is shaped with two QWIIC connectors and the I²C protocol integration, allowing the connection and programming of multiple Modulino nodes in a very simple way. In addition to the QWIIC's connectors, the Modulino nodes also expose solderable pins that can be used in multiple ways and make them compatible with boards that are not QWIIC compatible. - - -## General Characteristics - -The Modulino Thermo is capable of measuring temperature and relative humidity. Take a look at the following table to know more about its measuring ranges: - - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|-----------|-------------|---------|---------|---------|------| -| Range | Temperature | \-40 | \- | +125 | °C | -| \- | Humidity | 0 | \- | 100% | φ RH | -| Accuracy | Temperature | \- | ±0,25 | \- | °C | -| \- | Humidity | \- | ±2.8% | \- | φ | - -### Sensor Details - -The HS3003 sensor from Renesas is the core component of this module. This temperature and humidity sensor natively supports digital communication (I²C), meaning it connects directly to the I²C bus on the module without requiring additional conversion circuitry. - -The default address for the Module is: - -| Modulino I²C Address | Hardware I²C Address | -|----------------------|----------------------| -| 0x44 | 0x44 | - -***Note: Since the address cannot be changed on this Modulino specifically, using two or more identical modules on the same I²C bus will result in address conflicts and cause communication issues.*** - -## Pinout - -The pinout for the Modulino Thermo is shown below. Please note that the exposed solderable pins are directly connected to the QWIIC connectors using the same I²C interface. - -![Arduino Thermo Pinout](assets/ThermoPinouts.jpg) - -### 1x4 Header (I2C) - -The pinout for the Modulino Buzzer is shown below. While the recommended connection method is via the QWIIC connectors, this solderable header provides a connection option when using the modulino with a non-QWIIC compatible board. - -| Pin | Function | -|-------|--------------| -| GND | Ground | -| 3V3 | Power Supply | -| SDA | I²C Data | -| SCL | I²C Clock | - -Depending on the board connected to the modulino, the I²C pin names to program it may differ. Please check the [board tutorials](https://docs.arduino.cc/hardware/) on your modulino's compatible board or the [Modulino library](https://github.com/arduino-libraries/Modulino/tree/main/docs) to learn more. - -## Power Specifications - -The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I²C standard. - -| Parameter | Condition | Minimum | Typical | Maximum | Unit | -|-----------------|-------------------------------------------------------------------|---------|-------------|---------|------| -| Supply Voltage | \- | 2.3 | 3.3 (QWIIC) | 5.5 | V | -| Average Current | 1 humidity + temperature measurement/s 3.3 VDD - Max 5,5@ 3.3 VDD | \- | 1024.4 | 24.4 | µA | - -The module additionally includes a power LED that draws 1 mA and turns on as soon as it is powered. - -J1 (Qwiic connector), J2 (Qwiic connector), and the headers all share the same power branch. The power distribution of the module is therefore as follows: - -![Power Tree Modulino Thermo](assets/Modulino_Thermo_Power_Tree.png) - -## Schematic - -The Modulino Thermo uses a simple circuit, as shown in the schematic below: - -![Full Schematic Modulino Thermo](assets/schematic.png) - -The main component is the **HS3003** sensor (U1), which handles both temperature and humidity measurements, as well as I²C communication. - -You can connect to the I²C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, this is the recommended method) or the **solderable pins** (J4). The board runs on **3.3V**, which comes from the QWIIC cable or the **3V3 pin** on J4. - -There's also a small power indicator LED that lights up when the board is on. - -You can grab the full schematic and PCB files from the [Modulino Thermo](https://docs.arduino.cc/hardware/modulinos/modulino-thermo) product page. - -## How To Connect Your Modulino - -The easiest and most reliable way to connect your Modulino is through the QWIIC Connect System. It’s plug-and-play, uses standard I²C, and makes it easy to join multiple modules. If your board supports QWIIC, this is the recommended way to go. Note that the dedicated I²C pins will differ from board to board meaning it is always a good idea to check your specific model. - -If your board doesn’t have a QWIIC connector, you can still access the same I²C bus and power the module using the solderable header pads just make sure you wire it to 3.3V and match the I²C pinout. - -![Modulino Wiring Options QWIIC(A - recommended) and Header(B)](assets/connection-guide-thermo.png) - -### QWIIC Connector - -Whenever available, the **QWIIC Connect System** is the preferred method. Connecting to the Modulino is extremely simple, just use a standard QWIIC cable to connect your board to either of the QWIIC connectors on the Modulino. Because the cable and connectors are polarized, there is no need to worry about accidentally swapping connections. - -QWIIC is a plug-and-play I²C Connect System that uses standardized 4-pin connectors: - -- GND -- 3.3V -- SDA (Data) -- SCL (Clock) - -![Connection Guide QWIIC](assets/connection-guide-thermo-qwiik.png) - -The Modulino features two QWIIC connectors, which are internally connected in parallel. This means you can daisy-chain multiple modules easily by connecting additional QWIIC cables between them. - -### Solderable Header - -When QWIIC is not available, you can use the exposed solderable pins on the module. You can solder pins to the unpopulated pads; just remember the pinout provided in this guide to connect to the right pins of your board. - -![Connection Guide Solder Pads](assets/connection-guide-thermo-jumper.png) - -## Daisy-Chaining Multiple Modulino Nodes - -Regardless of whether you connect the first Modulino via QWIIC or through the solderable pins, you can still take advantage of the extra QWIIC connector to daisy-chain additional modules. - -Each Modulino includes two QWIIC connectors wired in parallel, allowing you to connect one module to the next in a chain. As long as each module is configured with a unique I²C address, they can all communicate on the same bus as long as you select the correct I²C pins depending on your board. - -This approach keeps your setup clean, modular, and expandable without adding extra wiring complexity. - -![Modulino Wiring Options](assets/connection-guide-thermo-qwiic-chain.png) - -***The number of modules you can connect will depend on what modules you are chaining together, as this system allows for multiple sensors from different manufacturers to be added. Also, the cables you use for these connections will play a significant role in the setup’s performance. Ensure your cables are correctly connected and capable of handling the required data transfer. -Each module should have a unique address on a chain if you plan to address them individually. Multiple modules with the same address will cause conflicts on the I²C bus.*** - -## How To Program Your Modulino - -### Installing The Modulino Library - -To program your Modulino it is recommended you use the official ```Modulino``` micropython library available [here](https://github.com/arduino/arduino-modulino-mpy). The library is fully compatible with the no **Arduino Lab for MicroPython**. - -For information on installing the **Arduino Lab for MicroPython** please visit our [page](https://docs.arduino.cc/micropython/first-steps/install-guide/). - -The ```Modulino``` library is not available by default on MicroPython devices hence installation is needed. - -To simplify the process the [MicroPython Package Installer](https://github.com/arduino/lab-micropython-package-installer/releases) is recommended as it will provide a graphical interface to guide installation. - -After installation, you should now be able to: - -1. Open the tool. -2. Plug in your board to the computer. - - ![USB Connection](assets/mp-usb-connection.png) - - If the board does not appear in the Detected Boards section, click Reload. If the board is still undetected, ensure no other programs (e.g., a code editor) are using the board's COM port. - -3. Search for the ```Modulino``` package by filling in the text box on the search feature. -4. Click Install and wait for the installation confirmation. -5. Disconnect the board from the tool before returning to your code editor to avoid conflicts due to a busy COM port. - -![Package Installer Overview](assets/package-installer-overview.png) - -The module should now be includable in your program using: - -```from modulino import ModulinoThermo``` - -### Get Temperature And Humidity Data - -Getting data from the sensor is fairly simple using the ```Modulino``` library. - -For the **Thermo** there are two crucial functions: - -- ```.temperature``` - Provides the temperature measurement from the sensor. (Default in °C) -- ```.relative_humidity``` - Provides the relative humidity from the sensor. (Default in %) - -By default the Modulino library uses ```Wire1``` if your board model has a different pinout for the dedicated I²C pins you might have to edit it as instructed [here](https://github.com/arduino/arduino-modulino-mpy/tree/main/docs#%E2%84%B9%EF%B8%8F-using-3rd-party-boards). More information on **Wire** can be found [here](https://docs.arduino.cc/language-reference/en/functions/communication/wire/). - -Here is an example of how to implement these functions to acquire data: - -```python -from modulino import ModulinoThermo -from time import sleep - -thermo_module = ModulinoThermo() - -while True:     - temperature = thermo_module.temperature - humidity = thermo_module.relative_humidity -    -    if temperature != None and humidity != None: -        print(f"🌡️ Temperature: {temperature:.1f} °C") -        print(f"💧 Humidity: {humidity:.1f} %")     -        print() -        -    sleep(2) -``` - -The code example provided shows how to initialize the sensor, read the data, and display it on the serial monitor. The data is updated every second, showing the current temperature and humidity values in real time. -It can be easily adapted to trigger actions at certain temperature/humidity thresholds or to log data for analysis. - -## Troubleshooting - -### Sensor Not Reachable - -If your Modulino's power LED isn't on or the sensor isn't responsive, first check that the board is properly connected: - -- Ensure both the board and the Modulino are connected to your computer, and that the power LEDs on both are lit. -- If the issue persists, make sure the Qwiic cable is properly clicked into place. - -### Library Not Installed Properly - -If you encounter an issue with the `#include "modulino.h"` command, verify that the Modulino library is correctly installed: - -- Check your IDE to ensure the library is installed and up-to-date. -- Re-install the library through the Library Manager. - -### Inaccurate Values - -If the sensor values are not accurate, make sure: - -- The sensor is not placed near any components that might generate heat (like motors or power supplies). -- All exposed electronics are not touching any conductive surfaces, as this could interfere with readings. - -## Conclusion - -The **Modulino Thermo** is a digital temperature and humidity sensor that communicates over I²C and follows the Modulino form factor. It includes standard Qwiic connectors for quick, solderless connections and easy daisy-chaining with other modules. Paired with the Modulino library, it makes accessing sensor data straightforward, allowing you to focus on experimenting or building your system logic. It’s a small, reliable module suited for both quick tests and longer-term setups. - -## What Is Next? - -Now that you've learned how to use your Modulino Thermo, you're all set to integrate it into your projects! - -- Experiment with temperature and humidity. What happens if you place your Modulino in the refrigerator? -- Try breathing near the sensor. Does the humidity change? -- Place your Modulino on the outside of your mug and fill it with a hot beverage. Can you create an automatic system to know when your tea has cooled down? -- How does the temperature change throughout the day at home? Let your Modulino run for an entire day and check out the data! \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/image.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/image.png deleted file mode 100644 index bceefec75d..0000000000 Binary files a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-mp/image.png and /dev/null differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo/ThermoOverview.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo/ThermoOverview.png new file mode 100644 index 0000000000..31fd0ba8e5 Binary files /dev/null and b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo/ThermoOverview.png differ diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/ThermoPinouts.jpg b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo/assets/ThermoPinouts.jpg similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo-ardu/assets/ThermoPinouts.jpg rename to content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo/assets/ThermoPinouts.jpg diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo/content.md b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo/content.md new file mode 100644 index 0000000000..e9250f6a8b --- /dev/null +++ b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo/content.md @@ -0,0 +1,320 @@ +--- +title: "Modulino Thermo" +description: "Complete guide for the Modulino Thermo temperature and humidity sensor." +tags: + - Modulino + - Temperature + - Humidity + - QWIIC + - I2C +author: 'Pedro Sousa Lima' +hardware: + - hardware/11.modulinos/modulinos/modulino-thermo +software: + - ide-v2 + - web-editor + - micropython +--- + +![Thermo Overview](ThermoOverview.png) + +The Modulino Thermo is a modular sensor that measures temperature and humidity, making it perfect to add environmental monitoring to your projects! It uses the standardised Modulino form factor with QWIIC connectors for easy integration. + +## Hardware Overview + +### General Characteristics + +The Modulino Thermo is capable of measuring temperature and relative humidity with the following specifications: + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|-----------|-------------|---------|---------|---------|------| +| Range | Temperature | -40 | - | +125 | °C | +| - | Humidity | 0 | - | 100 | φ RH | +| Accuracy | Temperature | - | ±0.25 | - | °C | +| - | Humidity | - | ±2.8 | - | φ | + +### Sensor Details + +The **HS3003** sensor from Renesas is the core component of this module. This temperature and humidity sensor natively supports digital communication (I2C), meaning it connects directly to the I2C bus on the module without requiring additional conversion circuitry. + +The default address for the Module is: + +| Modulino I2C Address | Hardware I2C Address | +|----------------------|----------------------| +| 0x44 | 0x44 | + +***Note: Since the address cannot be changed on this Modulino specifically, using two or more identical modules on the same I2C bus will result in address conflicts and cause communication issues.*** + +### Pinout + +![Arduino Thermo Pinout](assets/ThermoPinouts.jpg) + +#### 1x4 Header (I2C) + +| Pin | Function | +|-------|--------------| +| GND | Ground | +| 3.3 V | Power Supply | +| SDA | I2C Data | +| SCL | I2C Clock | + +### Power Specifications + +The board is typically powered by +3.3 VDC when using the QWIIC interface as per the I2C standard. + +| Parameter | Condition | Minimum | Typical | Maximum | Unit | +|-----------------|---------------------------------------------------|---------|-------------|---------|------| +| Supply Voltage | - | 2.3 | 3.3 (QWIIC) | 5.5 | V | +| Average Current | 1 humidity + temperature measurement/s @ 3.3 VDD | - | 24.4 | 1024.4 | µA | + +The module includes a power LED that draws 1 mA and turns on as soon as it is powered. J1 (QWIIC connector), J2 (QWIIC connector), and the headers all share the same power branch. + +### Schematic + +The Modulino Thermo uses a simple circuit built around the **HS3003** sensor (U1), which handles both temperature and humidity measurements, as well as I2C communication. + +You can connect to the I2C pins (SDA and SCL) using either the **QWIIC connectors** (J1 and J2, recommended) or the **solderable pins** (J4). The board runs on **3.3V** from the QWIIC cable or the **3V3 pin** on J4. + +Full schematic and PCB files are available from the [Modulino Thermo product page](https://docs.arduino.cc/hardware/modulinos/modulino-thermo). + +## Programming with Arduino + +### Prerequisites + +- Install the Modulino library via the Arduino IDE Library Manager (see [Getting Started with Modulinos](link-to-generic-guide) for detailed instructions) +- Connect your Modulino Thermo via QWIIC or solderable headers + +### Basic Example + +```arduino +#include + +// Create object instance +ModulinoThermo thermo; + +// Global Variables +float celsius = 0; +float humidity = 0; + +void setup(){ + // Initialization of the serial port, modulino object and thermo one + Serial.begin(115200); + Modulino.begin(); + thermo.begin(); +} + +void loop(){ + celsius = thermo.getTemperature(); + humidity = thermo.getHumidity(); + + Serial.print("Temperature (C) is: "); + Serial.println(celsius); + + Serial.print("Humidity (rH) is: "); + Serial.println(humidity); + + delay(1000); +} +``` + +### Key Functions + +- `getTemperature()`: Returns temperature measurement in Celsius +- `getHumidity()`: Returns relative humidity as a percentage +- `Modulino.begin()`: Initialises the Modulino system (uses `Wire1` by default) + +### Advanced Example - Temperature Alert System + +```arduino +#include + +ModulinoThermo thermo; +const float TEMP_THRESHOLD = 25.0; // Alert above 25°C +const float HUMIDITY_THRESHOLD = 70.0; // Alert above 70% humidity + +void setup(){ + Serial.begin(115200); + Modulino.begin(); + thermo.begin(); + + Serial.println("Environmental Monitor Started"); +} + +void loop(){ + float temp = thermo.getTemperature(); + float hum = thermo.getHumidity(); + + // Check temperature threshold + if(temp > TEMP_THRESHOLD) { + Serial.print("⚠️ HIGH TEMPERATURE: "); + Serial.print(temp); + Serial.println("°C"); + } + + // Check humidity threshold + if(hum > HUMIDITY_THRESHOLD) { + Serial.print("⚠️ HIGH HUMIDITY: "); + Serial.print(hum); + Serial.println("%"); + } + + // Normal readings + if(temp <= TEMP_THRESHOLD && hum <= HUMIDITY_THRESHOLD) { + Serial.print("Normal - Temp: "); + Serial.print(temp); + Serial.print("°C, Humidity: "); + Serial.print(hum); + Serial.println("%"); + } + + delay(5000); // Check every 5 seconds +} +``` + +## Programming with MicroPython + +### Prerequisites + +- Install the Modulino MicroPython library (see [Getting Started with Modulinos](link-to-generic-guide) for detailed instructions) +- Ensure Arduino Lab for MicroPython is installed + +### Basic Example + +```python +from modulino import ModulinoThermo +from time import sleep + +thermo_module = ModulinoThermo() + +while True: + temperature = thermo_module.temperature + humidity = thermo_module.relative_humidity + + if temperature != None and humidity != None: + print(f"🌡️ Temperature: {temperature:.1f} °C") + print(f"💧 Humidity: {humidity:.1f} %") + print() + + sleep(2) +``` + +### Key Properties + +- `.temperature`: Returns temperature measurement in Celsius +- `.relative_humidity`: Returns relative humidity as a percentage + +### Advanced Example - Data Logger + +```python +from modulino import ModulinoThermo +from time import sleep, ticks_ms + +thermo = ModulinoThermo() + +# Configuration +LOG_INTERVAL = 60000 # Log every minute (in milliseconds) +SAMPLES_TO_KEEP = 60 # Keep last hour of data + +# Data storage +data_log = [] +last_log_time = ticks_ms() + +def calculate_average(values): + """Calculate average of a list of values""" + if not values: + return 0 + return sum(values) / len(values) + +def log_data(): + """Log temperature and humidity data""" + temp = thermo.temperature + hum = thermo.relative_humidity + + if temp is not None and hum is not None: + timestamp = ticks_ms() + data_log.append({ + 'time': timestamp, + 'temp': temp, + 'humidity': hum + }) + + # Keep only recent samples + if len(data_log) > SAMPLES_TO_KEEP: + data_log.pop(0) + + return True + return False + +def print_statistics(): + """Print statistics from logged data""" + if not data_log: + print("No data collected yet") + return + + temps = [d['temp'] for d in data_log] + hums = [d['humidity'] for d in data_log] + + print("\n📊 Statistics (last hour):") + print(f" Samples: {len(data_log)}") + print(f" Avg Temp: {calculate_average(temps):.1f}°C") + print(f" Min Temp: {min(temps):.1f}°C") + print(f" Max Temp: {max(temps):.1f}°C") + print(f" Avg Humidity: {calculate_average(hums):.1f}%") + print(f" Min Humidity: {min(hums):.1f}%") + print(f" Max Humidity: {max(hums):.1f}%") + +# Main loop +print("🌡️ Environmental Data Logger Started") +print("Logging data every minute...") + +while True: + current_time = ticks_ms() + + # Log data at intervals + if current_time - last_log_time >= LOG_INTERVAL: + if log_data(): + print(f"✅ Data logged: {thermo.temperature:.1f}°C, {thermo.relative_humidity:.1f}%") + print_statistics() + last_log_time = current_time + + # Show current readings + temp = thermo.temperature + hum = thermo.relative_humidity + if temp is not None and hum is not None: + print(f"Current: {temp:.1f}°C, {hum:.1f}%", end='\r') + + sleep(1) +``` + +## Troubleshooting + +### Sensor Not Reachable + +If your Modulino's power LED isn't on or the sensor isn't responsive: +- Ensure both the board and the Modulino are connected to your computer +- Verify that the power LEDs on both are lit +- Check that the QWIIC cable is properly clicked into place + +### Inaccurate Values + +If the sensor values are not accurate: +- Ensure the sensor is not placed near heat-generating components (motors, power supplies) +- Verify all exposed electronics are not touching conductive surfaces +- Allow the sensor time to stabilise after power-on + +### Library Issues + +See the [Getting Started with Modulinos](link-to-generic-guide) guide for library installation troubleshooting. + +## Project Ideas + +Now that you've learned how to use your Modulino Thermo, try these projects: + +- **Smart Greenhouse Monitor**: Track temperature and humidity for optimal plant growth +- **Weather Station**: Combine with other Modulinos to create a complete weather monitoring system +- **HVAC Controller**: Monitor room conditions and trigger heating/cooling systems +- **Food Storage Monitor**: Ensure proper conditions in pantries or wine cellars +- **Data Logger**: Record environmental conditions over time for analysis +- **Comfort Zone Indicator**: Use with Modulino Pixels to show comfort levels with colours +- **Morning Routine Assistant**: Check if the bathroom is warm enough before your shower +- **Pet Habitat Monitor**: Ensure reptile or tropical fish environments stay optimal \ No newline at end of file diff --git a/content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/image.png b/content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo/image.png similarity index 100% rename from content/hardware/11.accessories/modulino-nodes/modulino-movement/tutorials/how-movement-mp/image.png rename to content/hardware/11.accessories/modulino-nodes/modulino-thermo/tutorials/how-thermo/image.png