CM4-Duino
| ||
Overview
I am a CM4 duino basic expansion board, an expansion board that can be used with Raspberry Pi Compute Module 4, and supports 5V DC power supply with Typc-C interface. Onboard HDMI interface, one CSI interface and one USB interface, standard arduino interface, etc...
Precautions for use
1: Do not plug and unplug any device except USB and HDMI when powered on.
2: Type C interface can be used as a power supply or as a USB interface to burn images (need to use BOOT switch to switch).
3: In order to ensure the normal power supply of CM4, please do not connect other devices when using the Type C interface to burn the image.
4: When CM4 is in normal use, it needs to provide a 5V 2A power supply for CM4. Otherwise, there may be problems such as automatic shutdown, frequency reduction, and so on.
5: USB2.0 is closed by default, if you want to open it, you need to add dtoverlay=dwc2,dr_mode=host in config.txt.
Product Size
What's on board
Label | Name | Description |
1 | Power supply/burning interface | 5V/2A power supply, can also be used as an eMMC burning interface |
2 | USB 2.0 interface | USB 2.0 interface, support various USB devices to be inserted |
3 | HDMI port | HDMI port, supports 4K 30fps output |
4 | BOOT switch button | ON: Compute Module 4 boots to USB Type-C port OFF: Compute Module 4 boots to eMMC or Micro SD card |
5 | CM4 Connector | Applies to all versions of Compute Module 4 |
6 | CAM Interface | MIPI CSI Camera Interface |
7 | User LED | LED blinks and sparkles |
8 | ADC Chip | 8-bit ADC, I2C interface, 8-channel ADC chip ADS7830 |
9 | User Button | Button Module |
10 | GPIO | Arduino interface GPIO |
11 | Function Switch | For details, please refer to the function pin description |
12 | M.2 Interface | A module that supports NVME SSD solid state or other PCIE channels |
13 | Micro SD Card Slot | For inserting a Micro SD card with the system to start the Compute Module 4 Lite |
Hardware Connection
Note
Do not plug or unplug any device while it is powered on!
Writing Image
- Write Image for Compute Module Boards eMMC version
- Wrote Image for Compute Module Boards Lite version
USB2.0
The USB port is disabled by default on the CM4 to save power. If you need to start, you need to add the following to the config.txt file:
dtoverlay=dwc2,dr_mode=host
After restarting:
If you use the latest Raspberry Pi OS (image after October 30, 2021) USB2.0 is OTG mode by default, CM4 will report an error:
config failed, hub doesn't have any ports! (err -19)
However, USB can still be used. If you want to remove this error, remove otg_mode=1 in [cm4] of config.txt, and add dtoverlay=dwc2, dr_mode=host (USB cannot be recognized without adding it).
ADC
Basic introduction
The ADS7830 is a single-supply, low-power, 8-bit data acquisition device with a serial I2C interface and an 8-channel multiplexer. The analog-to-digital (A/D) converter has a track-and-hold amplifier and an internal asynchronous clock.
The ADS7830 has a resolution of 8 bits, a total of 8 inputs, and a maximum sampling rate of 70KSPS.
It can be set to differential mode and single-ended input, and the program defaults to single-ended input.
The I2C address is: 0x48
Download Program
Open the Raspberry Pi terminal and execute the following command:
sudo apt-get install p7zip-full https://files.waveshare.com/upload/5/5d/CM4-duino-code.zip 7z x CM4-duino-code.zip -O./ cd CM4-duino-code
Python
Run the demo, the program supports python2/3.
# python2 sudo python ADS7830.py # python3 sudo python3 ADS7830.py
As shown in the figure below, A0-A7 are 7 analog input channels:
Note: A total of 8 ADCs are collected from 0-7. If the channel is suspended, the value of the channel will float up and down, and the data will be invalid.
LED usage
A programmable LED is onboard:
Using GPIO6:
Button usage
Onboard 2 buttons USER1 USER2:
USER1 uses GPIO4, USER uses GPIO5, and USER2 can choose whether it is the reset of CM4 through the resistor, and the default connected GPIO5.
Functional pin description
Label | Name | Description |
1 | BT-DIS | Disable Bluetooth, only support core board with wireless module |
2 | WIFI-DIS | Disable WIFI, only support core board with wireless module |
3 | IO-VREF | IO logic voltage selection |
4 | RUN/GL-EN | Reset or shutdown CM4 |
5 | CFG | CFG pin function select 3.3V or A6 |
6 | USER | User button Function selection, D5 or RST |
7 | I2C ADDR | ADC function module I2C address selection, default address: 0x48 |
CSI DSI
Note: The following is a general description of CM4, specific devices are different: this module does not have a DSI interface, and only HDMI0, and CSI0.
Configuration file
CSI and DSI are disabled by default. When using the camera and DSI, it will occupy three I2C devices: I2C-10, I2C-11, and I2C-0.
- Open a terminal and run the following commands:
sudo apt-get install p7zip-full -y wget https://files.waveshare.com/upload/7/75/CM4_dt_blob.7z 7z x CM4_dt_blob.7z -O./CM4_dt_blob sudo chmod 777 -R CM4_dt_blob cd CM4_dt_blob/ # If using two cameras and DSI1, please execute: sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts # When using any DSI, there is no image output on HDMI1. Even if you do not connect a DSI screen, as long as the corresponding file is compiled, there will be no output on HDMI1. # To restore it, simply delete the corresponding dt-blob.bin file: sudo rm -rf /boot/dt-blob.bin #Execution is complete, power off and reboot CM4
New Version (Bullseye)
Camera Config
-
Execute the following commands to edit "/boot/config.txt" file.
sudo nano /boot/config.txt
- Block or remove the automatic camera detection statement:
-
Add the driver of the camera you are using, here I take IMX219 as an example and connect it to CAM0, and attach the adapter.
Model CAM0 Set Sentence CAM1 Set Sentence OV9281 dtoverlay=ov9281,cam0 dtoverlay=ov9281,cam1 IMX290/IMX327 dtoverlay=imx290,clock-frequency=37125000,cam0 dtoverlay=imx290,clock-frequency=37125000,cam1 IMX378 dtoverlay=imx378,cam0 dtoverlay=imx378,cam1 IMX219 dtoverlay=imx219,cam0 dtoverlay=imx219,cam1 IMX477 dtoverlay=imx477,cam0 dtoverlay=imx477,cam1 IMX708 dtoverlay=imx708,cam0 dtoverlay=imx708,cam1 - If you are using the official Raspberry Pi camera and only one camera is connected, there is no need to set the config file. If it is not an official camera, set the "dtoverlay" statement without the "cam" suffix.
- CM4-NANO - only CAM0 is used, so you only need to add "dtoverlay=imx219,cam0".
5. Ctrl+x to exit the editor.
6. Reboot the Raspberry Pi.
sudo reboot
Camera Test
- Enter the camera detection command, you can see that the camera is detected by now.
libcamera-hello --list-cameras
- Display the camera screen on the desktop.
- Taking photos.
libcamera-jpeg -o test.jpg
- Record a video of 10s.
libcamera-vid -t 10000 -o test.h264
Other Commands:
libcamera-hello -t
Check whether the camera is detected:
libcamera-hello --list-cameras
Open the corresponding cameras:
libcamera-hello --camera 1 libcamera-hello --camera 0
Take a photo:
libcamera-jpeg -o test.jpg #Add --camera to specify a camera
Old Version (Buster)
Camera Config
-
1. Execute the following command to enter the Raspberry Pi configuration.
- Test the recording function:
- Where -t 10000 means recording for 10 seconds, users can adjust according to their own needs.
- Please refer to CSI.
sudo raspi-config
2. Choose Interfacing Options and enter.
3. Choose Camera:
4. Choose to enable the camera interface.
5. The system prompts as follows:
6. Back to the main interface, select Finish.
7. Reboot the system.
Camera Test
raspistill -o image.jpg
raspivid -o video.h264 -t 10000
Resource
Document
- Schematic
- Raspberry Pi Compute Module 4 IO Board Brief
- Raspberry Pi Compute Module 4 IO Board Datasheet
- CSI Camera Reference
Demo codes
3D Drawing
Software
FAQ
Please use the 2242 NVME SSD.
{{{5}}}
Support
Technical Support
If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)