Skip to content

Commit ce9110a

Browse files
committed
Initial commit - Update on top of the pre-changes based on PR#672
1 parent 263fd75 commit ce9110a

File tree

6 files changed

+249
-0
lines changed

6 files changed

+249
-0
lines changed
Loading
Loading
Loading
Loading
Loading

content/hardware/04.pro/carriers/portenta-mid-carrier/tutorials/user-manual/content.md

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,6 +2338,255 @@ You may find additional examples within the library to try various functionaliti
23382338

23392339
For more details on how the library works, including a comprehensive guide on setup and usage of the above examples, please refer to this [library documentation](https://github.com/arduino-libraries/Arduino_Cellular/tree/main/docs).
23402340

2341+
#### AT Commands Utility
2342+
2343+
This section explains using AT commands to interact with the Cat.4 modem. These instructions will guide you through setting up your environment, sending AT commands, and managing your modem effectively.
2344+
2345+
AT commands, also known as Hayes commands, are instructions used to control modems. These commands allow you to perform various functions, such as checking the modem status, signal quality, and network registration. Understanding how to send these commands is essential for managing and troubleshooting your Arduino Pro 4G Module.
2346+
2347+
#### Using Linux
2348+
2349+
This section provides instructions on using **ModemManager** and **mmcli** to send AT commands to your Cat.4 modem on the Portenta X8.
2350+
2351+
Ensure that the Pro 4G Module is properly mounted on the Portenta Mid Carrier and that the Portenta X8 recognizes it. You can always use the following commands to verify the connection:
2352+
2353+
```bash
2354+
lsusb
2355+
2356+
# Or
2357+
dmesg
2358+
```
2359+
2360+
***Please set up the Pro 4G Module referring to [this section](#using-linux-4). Otherwise, the __ModemManager__ service may not work as intended or be recognized.***
2361+
2362+
First, identify the modem with:
2363+
2364+
```bash
2365+
mmcli -L
2366+
```
2367+
2368+
The output will list the modems detected as the Pro 4G Module. Note the modem's device ID, for example:
2369+
2370+
```bash
2371+
/org/freedesktop/ModemManager1/Modem/0
2372+
```
2373+
2374+
![Arduino Pro 4G Module - AT Commands](assets/portentaMIDcarrier_mpcie_4gmodem_at1.png)
2375+
2376+
To send AT commands, *ModemManager* must be in debug mode.
2377+
2378+
```bash
2379+
sudo systemctl stop ModemManager
2380+
```
2381+
2382+
The command below starts *ModemManager* in the background and redirects its output to a log file.
2383+
2384+
```bash
2385+
sudo ModemManager --debug > /var/log/modemmanager.log 2>&1 &
2386+
```
2387+
2388+
To send an AT command, the following command can be used:
2389+
2390+
```bash
2391+
sudo mmcli -m /org/freedesktop/ModemManager1/Modem/0 --command="ATI"
2392+
```
2393+
2394+
![Arduino Pro 4G Module - AT Commands](assets/portentaMIDcarrier_mpcie_4gmodem_at2.png)
2395+
2396+
You can now start sending AT commands. Here are a few basic AT commands to test the modem:
2397+
2398+
| **AT Command** | **Description** |
2399+
|:--------------: |:------------------------------------------------------------------------------------------: |
2400+
| ATI | Retrieves the modem's basic information such as manufacturer, model, and firmware version. |
2401+
| AT+CSQ | Checks the signal quality of the modem |
2402+
| AT+GMI | Retrieves the manufacturer identification |
2403+
| AT+GMM | Retrieves the model identification of the modem |
2404+
| ATV | Displays the active configuration profile |
2405+
| AT+CGMR | Retrieves the firmware version of the modem |
2406+
| AT+CPAS | Reports the current status of the modem |
2407+
| AT+CEER | Provides detailed information on the last error cause |
2408+
| AT+QNWINFO | Retrieves the current network information |
2409+
2410+
![Arduino Pro 4G Module - AT Commands Test](assets/portentaMIDcarrier_mpcie_4gmodem_at3.png)
2411+
2412+
You can use Docker to manage the dependencies and tools needed to send AT commands and ensure a consistent environment. The idea would be that you will have the environment running in a separate instance for testing purposes.
2413+
2414+
```
2415+
# Use the official Debian image
2416+
FROM debian:latest
2417+
2418+
# Install necessary packages
2419+
RUN apt-get update && \
2420+
apt-get install -y modemmanager && \
2421+
apt-get install -y mmcli && \
2422+
apt-get clean && \
2423+
rm -rf /var/lib/apt/lists/*
2424+
2425+
# Set the working directory
2426+
WORKDIR /app
2427+
2428+
# Set the default command to bash
2429+
CMD ["bash"]
2430+
```
2431+
2432+
Create a file named *Dockerfile* with the content above. This *Dockerfile* sets up a Debian-based image with *ModemManager* and *mmcli* installed.
2433+
2434+
Open a terminal in the directory containing the Dockerfile and build the Docker image:
2435+
2436+
```bash
2437+
docker build -t modem-manager .
2438+
```
2439+
2440+
Run the container with the Pro 4G Module attached. This command will start the container and open a bash shell:
2441+
2442+
```bash
2443+
docker run --rm -it --device=/dev/cdc-wdm0 modem-manager
2444+
```
2445+
2446+
Inside the Docker container, identify the modem and send AT commands:
2447+
2448+
```bash
2449+
# List modems
2450+
mmcli -L
2451+
```
2452+
2453+
```bash
2454+
# Replace `/org/freedesktop/ModemManager1/Modem/0` with your actual modem's device ID if required after verification
2455+
sudo mmcli -m /org/freedesktop/ModemManager1/Modem/0 --command="ATI"
2456+
```
2457+
2458+
You can create a script to automate the process of starting *ModemManager* in debug mode and sending an AT command:
2459+
2460+
```python
2461+
#!/bin/bash
2462+
2463+
# Stop ModemManager
2464+
sudo systemctl stop ModemManager
2465+
2466+
# Start ModemManager in debug mode quietly
2467+
sudo ModemManager --debug > /var/log/modemmanager.log 2>&1 &
2468+
2469+
# Wait a few seconds to ensure ModemManager is fully started
2470+
sleep 5
2471+
2472+
# Send AT command
2473+
mmcli -m /org/freedesktop/ModemManager1/Modem/0 --command="ATI"
2474+
```
2475+
2476+
Save this script as run_mm_debug.sh, make it executable, and run it:
2477+
2478+
```bash
2479+
chmod +x run_mm_debug.sh
2480+
```
2481+
2482+
```bash
2483+
./run_mm_debug.sh
2484+
```
2485+
2486+
To stop the ModemManager process running in debug mode, find its process ID (PID) and kill it:
2487+
2488+
```bash
2489+
ps aux | grep ModemManager
2490+
```
2491+
2492+
```bash
2493+
sudo kill <PID>
2494+
```
2495+
2496+
Using **`nmcli`**, you can easily send AT commands to your Cat.4 modem to perform various tasks like checking the modem status, signal quality, and network registration. This method provides a straightforward way to interact with your modem from a Linux environment, whether you are performing a simple check or managing more advanced functions.
2497+
2498+
By following these steps, you can effectively manage and troubleshoot your modem using AT commands in the Linux environment.
2499+
2500+
#### Using Arduino
2501+
2502+
The AT commands can also be sent to the Pro 4G Module using the Portenta H7 or Portenta C33 with the Arduino IDE.
2503+
2504+
It will require [**Arduino_Cellular**](https://github.com/arduino-libraries/Arduino_cellular) library. You can access the library through the Arduino IDE's library manager by navigating to **Sketch -> Include Library -> Manage Libraries** or using the IDE's side panel with books icon.
2505+
2506+
![Arduino Cellular Library for Pro 4G Modules](assets/arduino_cellular_library.png)
2507+
2508+
Please ensure the mini PCIe power configuration is set as outlined in the [Mini PCIe Power Breakout Header](#mini-pcie-power-breakout-header-j9) section. The Portenta H7 or C33 requires **SERIAL1 Breakout** pins to be connected to designated **PCIe Breakout** pins :
2509+
2510+
| **SERIAL1 Breakout Pins (17)** | **PCIe Breakout Pins (16)** |
2511+
|--------------------------------|-----------------------------|
2512+
| SERIAL1 RX | mPCIe_CK_P |
2513+
| SERIAL1 TX | mPCIe_CK_N |
2514+
| SERIAL1 RTS | mPCIe_RX_N |
2515+
| SERIAL1 CTS | mPCIe_RX_P |
2516+
| mPCIE_GPIO_RST (GPIO6) | mPCIe_RST |
2517+
2518+
***Please use a 5.0 V external power source when using an Arduino Pro 4G Module (EMEA / GNSS Global) or any other mPCIe modules due to their high power consumption. This is important for maintaining a stable power supply to the Portenta SOM and the carrier, particularly for extended periods of use.***
2519+
2520+
The image below shows the setup, featuring the Portenta H7 and Pro 4G Module connected to the Portenta Mid Carrier along with a mini PCIe power configuration:
2521+
2522+
![Portenta Mid Carrier Mini PCIe & Portenta H7/C33 Setup](assets/portentaMIDcarrier_h7_c33_mpcie_set.png)
2523+
2524+
The following example is called **ModemTerminal**, which can be found within the [**Arduino_Cellular**](https://github.com/arduino-libraries/Arduino_cellular) library, compatible with the Portenta H7 and Portenta C33.
2525+
2526+
```arduino
2527+
/**
2528+
* The ModemTerminal example demonstrates how to use the ArduinoCellular library to send raw AT commands to the modem.
2529+
*
2530+
* Instructions:
2531+
* 1. Insert a SIM card with or without PIN code in the Arduino Pro 4G Module.
2532+
* 2. Provide sufficient power to the Arduino Pro 4G Module. Ideally, use a 5V power supply
2533+
* with a current rating of at least 2A and connect it to the VIN and GND pins.
2534+
* 3. Specify the APN, login, and password for your cellular network provider.
2535+
* 4. Upload the sketch to the connected Arduino board.
2536+
* 5. Open the serial monitor and type AT commands to interact with the modem.
2537+
*
2538+
* Initial author: Cristian Dragomir
2539+
*/
2540+
2541+
#include "ArduinoCellular.h"
2542+
#include "arduino_secrets.h"
2543+
2544+
ArduinoCellular cellular = ArduinoCellular();
2545+
2546+
void setup(){
2547+
Serial.begin(115200);
2548+
while (!Serial);
2549+
cellular.setDebugStream(Serial); // Uncomment this line to enable debug output
2550+
cellular.begin();
2551+
2552+
if(String(SECRET_PINNUMBER).length() > 0 && !cellular.unlockSIM(SECRET_PINNUMBER)){
2553+
Serial.println("Failed to unlock SIM card.");
2554+
while(true); // Stop here
2555+
}
2556+
2557+
Serial.println("Connecting...");
2558+
cellular.connect(SECRET_GPRS_APN, SECRET_GPRS_LOGIN, SECRET_GPRS_PASSWORD);
2559+
Serial.println("Connected!");
2560+
Serial.println("You can now send AT commands to the modem.");
2561+
}
2562+
2563+
void loop() {
2564+
while(Serial.available() == 0); // Wait for user input
2565+
2566+
// Read data from serial until newline
2567+
String userInput = Serial.readStringUntil('\n');
2568+
2569+
// Call the sendATCommand function with the read data
2570+
String response = cellular.sendATCommand(userInput.c_str());
2571+
Serial.println(response);
2572+
}
2573+
```
2574+
2575+
The example lets you send raw AT commands to the Pro 4G Module using the Arduino IDE with the Portenta H7 and Portenta C33. The script requires **arduino_secrets.h** to be defined with the following credentials:
2576+
2577+
- SIM Card PIN Number
2578+
- GPRS APN
2579+
- GPRS Login
2580+
- GPRS Password
2581+
2582+
These parameters are always required to use the SIM functionalities within the modem. The image below shows an anticipated result of the modem detected and connecting to a network using the Portenta H7 as the core device:
2583+
2584+
![Arduino Pro 4G Module - AT Commands Test with Portenta H7](assets/portentaMIDcarrier_mpcie_4gmodem_at3_h7.png)
2585+
2586+
It will show a similar result when the Portenta C33 is used as the core device with the Portenta Mid Carrier and the Pro 4G Module:
2587+
2588+
![Arduino Pro 4G Module - AT Commands Test with Portenta C33](assets/portentaMIDcarrier_mpcie_4gmodem_at3_c33.png)
2589+
23412590
#### Ethernet
23422591

23432592
The Portenta Mid Carrier features an Ethernet port with an RJ45 connector model _TRJK7003A97NL_ with integrated magnetics. These magnetics are crucial for voltage isolation, noise suppression, signal quality maintenance, and rejecting common mode noise, ensuring adherence to waveform standards.

0 commit comments

Comments
 (0)