It would be possible to do so, you would need to enable Caller ID Display (CLIP) with the AT command:
AT+CLIP=1
Once that is activated, when you receive a call you should get a response with the following format
RING
+CLIP: "<phonenumber>",<type>,<subaddr>,<satype>
From there you will be able to hang up the call with the AT command
ATH
To separate the number out you would need to put together some code to remove the other stuff from the response that was given by the first AT command.
Thanks Dan. Iâm very new to this - Iâm not sure how I would write code to wait for and receive a call.
I assume where you have written âRINGâ, that is when an incoming call is being made?
What is the â+CLIP:â bit, is that an AT command?
Hi all,
Want to prefece this with the fact that I am a total NOOB with all kinds of coding and electronics.
I was able to follow the tutorial as best I could, besides some hiccups to do with permission. However, when trialing the hat using the Python codes I ran to greater issues. PhoneCall.py worked, however, GPS.py resulted:
AT+CGPSINFO
+CGPSINFO: , , , , , , , ,
Not sure if this is a problem to do with the Pi, GPS or location I am testing it in. Further, I was unable to send a text using SMS.py and waspromptedd with the following:
ERROR
Back:
+CMS ERROR: Unknown error
error
Received Short Message Test:
Please send message to phone *04XXXXXX
Setting SMS modeâŚ
AT+CMGF=1
OK
and this is then followed by the activation date of my sim card. (Optus pre-paid)
I am just wondering if this a purely sim related issue as I was able to make that phone call using it. Any suggestions and comments would be greatly appreciated.
Youâre definitely not alone with these early roadblocks. The fact that PhoneCall.py worked means your HAT, SIM, and AT-command interface are basically healthy, great start.
GPS Issue (+CGPSINFO: , , , , , , , ,)
This response just means the GPS hasnât acquired a satellite fix yet. Common causes:
Youâre indoors or under cover â GPS needs a clear view of the sky. Try placing the GPS receiverâs sticker side face down and outside
Itâs a cold start â first-time or long-unpowered modules can take 5â15 minutes to download satellite data.
Suggestions:
Move the Pi + HAT outdoors with a clear view of the sky.
Before running GPS.py, try sending these manually:
AT+CGPS=1,1 // Enables GPS engine with NMEA output to UART
AT+CGPSINFO // Poll for current GPS fix
Wait 5â10 minutes, then run AT+CGPSINFO again. Once it gets a fix, itâll return something like:
Even if calling works, SMS can be tripped up by SIM or network quirks:
SIM activation â Some Optus prepaid SIMs allow calls but block SMS until activated via the Optus app or website.
Balance/profile â Ensure the SIM has credit and isnât data-only.
Text mode â Confirm the modem is in text mode:
AT+CMGF=1
PIN status â Check that the SIM isnât PIN-locked:
AT+CPIN?
Debug steps:
Insert the SIM into a phone and confirm you can send/receive SMS.
On the Pi, check:
AT+CSQ // Signal strength
AT+CREG? // Network registration status
AT+COPS? // Current operator
If Optus still doesnât behave, try a Telstra or Vodafone SIM to compare.
Post back the results of those commands or any new errors, and weâll help you dig in further. Once GPS has a lock and SMS is sorted, youâll be all set!
Sorry this may be dumb, but where am i imputting these commands? Also thank you so much for the response Ryan, sorry for my delay lifes caught up to me recently.
Additionally, I have been able to replace the SIM card with my personal one. In doing so, I have changed the error code from the previous to
"`AT+CMGR=1 ERROR
AT+CMGR=1 back: AT+CMGR=1
OK
You can input AT commands using a serial terminal program on your Raspberry Pi that connects to the modemâs serial port. Common tools for this are:
minicom
screen
picocom
Theres plenty of online tutorials that can help you learn how to use any one of these.
This error usually means the modem tried to read SMS message number 1, but thereâs no message stored there. Thatâs totally normal if your SMS inbox is empty.
You can check which messages are stored (if any) by running:
AT+CPMS?
(to check message storage status) and
AT+CMGL="ALL"
(to list all messages).
Next steps to confirm SMS and SIM status
Please try these commands (after connecting to the modem via serial terminal):
AT
AT+CPIN?
AT+CSQ
AT+CREG?
AT+COPS?
AT+CMGF=1
They will tell us if:
The modem is responding
The SIM card is ready (not PIN locked)
Signal strength is good
Network registration is successful
SMS text mode is enabled
Once you share the responses from these commands, I can help you troubleshoot further.
I was able to send a message through minicom using AT+CMGS:"+614XXXXXXX"
But I am still running into problems using the provided python code.
The modem is responding, text mode is enabled, and the signal strength is good. However I am receiving:
It looks like your SIM messages are full - if you run into further issues with the scripts would it be possible to specify the file, and errorâs from the REPL?
If you run the commands: AT+CMGL="ALL" to display all of your SMSâs
WARNING AT+CMGD=1,4 Deletes all of your SMSâs (not recommended on your personal SIM)
Then when you think you have emptied them: AT+CPMS? to see the memory status
I used a SIM7600X G4 HAT on my Raspberry but run into an error while initializing. I followed the tutorial, everything fine so far but when I run the init script (which should be part of the rc.local) I run into errors:
Hi there, @Rene306428, and welcome to the forum, glad to have you here.
Thatâs definitely a strange error. Iâm wondering if this might be a permissions issue.The fact that the script is reading âDirectory nonexistentâ makes me think that the script doesnât have necessary permissions to read /sys/class/gpio/.
Can you confirm that you previously ran the command:
sudo chmod 777 -R /home/pi/SIM7600X-4G-HAT-Demo
With a particular attention to that -R option since that would then apply to all folders beneath it.
The output of the below command should indicate its permissions:
Thanks for your reply. Yes I run this without any errors. Since I run the init script manual on the cli in the user context this may a reason. I copied the sh âŚinit into the rc.local but then I donât see any output. The main problem is that I ran into errors while running the next command:
wscadmin@womomon:~/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835 $ chmod +x configure && ./configure && sudo make && sudo make install
The out put ends with the following errors:
âŚ
checking whether we are using the GNU C compiler⌠yes checking whether gcc accepts -g⌠yes checking for gcc option to accept ISO C89⌠none needed checking dependency style of gcc⌠gcc3 checking for clock_gettime in -lrt⌠yes checking for doxygen⌠no configure: WARNING: Doxygen not found - continuing without Doxygen support checking for ranlib⌠ranlib checking for gcc⌠(cached) gcc checking whether we are using the GNU C compiler⌠(cached) yes checking whether gcc accepts -g⌠(cached) yes checking for gcc option to accept ISO C89⌠(cached) none needed checking dependency style of gcc⌠(cached) gcc3 checking that generated files are newer than configure⌠done configure: creating ./config.status config.status: creating Makefile config.status: creating src/Makefile config.status: creating doc/Makefile config.status: creating config.h config.status: config.h is unchanged config.status: executing depfiles commands make all-recursive make[1]: Entering directory â/home/wscadmin/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835â Making all in src make[2]: Entering directory â/home/wscadmin/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835/srcâ gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT bcm2835.o -MD -MP -MF .deps/bcm2835.Tpo -c -o bcm2835.o bcm2835.c bcm2835.c: In function ââŹËbcm2835_peri_readââŹâ˘: bcm2835.c:115:51: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] 115 | printf(âbcm2835_peri_read paddr %08X\nâ, (unsigned) paddr); | ^ bcm2835.c: In function ââŹËbcm2835_peri_read_nbââŹâ˘: bcm2835.c:155:54: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] 155 | printf(âbcm2835_peri_read_nb paddr %08X\nâ, (unsigned) paddr); | ^ bcm2835.c: In function ââŹËbcm2835_peri_writeââŹâ˘: bcm2835.c:171:63: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] 171 | printf(âbcm2835_peri_write paddr %08X, value %08X\nâ, (unsigned) paddr, value); | ^ bcm2835.c: In function ââŹËbcm2835_peri_write_nbââŹâ˘: bcm2835.c:202:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] 202 | (unsigned) paddr, value); | ^ bcm2835.c: In function ââŹËbcm2835_gpio_set_pudââŹâ˘: bcm2835.c:531:5: error: implicit declaration of function ââŹËdelayMicrosecondsââŹâ˘; did you mean ââŹËbcm2835_delayMicrosecondsââŹâ˘? [-Wimplicit-function-declaration] 531 | delayMicroseconds(10); | ^~~~~~~~~~~~~~~~~ | bcm2835_delayMicroseconds bcm2835.c: In function ââŹËbcm2835_initââŹâ˘: bcm2835.c:1314:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1314 | bcm2835_peripherals_base = (uint32_t *)(buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3] << 0); | ^ bcm2835.c:1334:75: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] 1334 | bcm2835_peripherals = mapmem(âgpioâ, bcm2835_peripherals_size, memfd, (uint32_t)bcm2835_peripherals_base); | ^ make[2]: *** [Makefile:549: bcm2835.o] Error 1 make[2]: Leaving directory â/home/wscadmin/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835/srcâ make[1]: *** [Makefile:352: all-recursive] Error 1 make[1]: Leaving directory â/home/wscadmin/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835â make: *** [Makefile:292: all] Error 2
I made a new install of Raspi but Iâm still struggeling trying to install the driver:
pi@womomon:~/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835 $ chmod +x configure && ./configure && sudo make && sudo make install
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
/home/pi/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835/missing: Unknown `--is-lightweight' option
Try `/home/pi/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for clock_gettime in -lrt... yes
checking for doxygen... no
configure: WARNING: Doxygen not found - continuing without Doxygen support
checking for ranlib... ranlib
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating doc/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
make all-recursive
make[1]: Entering directory '/home/pi/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835'
Making all in src
make[2]: Entering directory '/home/pi/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835/src'
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT bcm2835.o -MD -MP -MF .deps/bcm2835.Tpo -c -o bcm2835.o bcm2835.c
bcm2835.c: In function ââŹËbcm2835_peri_readââŹâ˘:
bcm2835.c:115:51: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
115 | printf("bcm2835_peri_read paddr %08X\n", (unsigned) paddr);
| ^
bcm2835.c: In function ââŹËbcm2835_peri_read_nbââŹâ˘:
bcm2835.c:155:54: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
155 | printf("bcm2835_peri_read_nb paddr %08X\n", (unsigned) paddr);
| ^
bcm2835.c: In function ââŹËbcm2835_peri_writeââŹâ˘:
bcm2835.c:171:63: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
171 | printf("bcm2835_peri_write paddr %08X, value %08X\n", (unsigned) paddr, value);
| ^
bcm2835.c: In function ââŹËbcm2835_peri_write_nbââŹâ˘:
bcm2835.c:202:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
202 | (unsigned) paddr, value);
| ^
bcm2835.c: In function ââŹËbcm2835_gpio_set_pudââŹâ˘:
bcm2835.c:531:5: error: implicit declaration of function ââŹËdelayMicrosecondsââŹâ˘; did you mean ââŹËbcm2835_delayMicrosecondsââŹâ˘? [-Wimplicit-function-declaration]
531 | delayMicroseconds(10);
| ^~~~~~~~~~~~~~~~~
| bcm2835_delayMicroseconds
bcm2835.c: In function ââŹËbcm2835_initââŹâ˘:
bcm2835.c:1314:38: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
1314 | bcm2835_peripherals_base = (uint32_t *)(buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3] << 0);
| ^
bcm2835.c:1334:75: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
1334 | bcm2835_peripherals = mapmem("gpio", bcm2835_peripherals_size, memfd, (uint32_t)bcm2835_peripherals_base);
| ^
make[2]: *** [Makefile:549: bcm2835.o] Error 1
make[2]: Leaving directory '/home/pi/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835/src'
make[1]: *** [Makefile:352: all-recursive] Error 1
make[1]: Leaving directory '/home/pi/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835'
make: *** [Makefile:292: all] Error 2
I realized that thereâs no /dev/ttyS0 or any ttySx.
I didnât get any error before running the make command. The jumpers are set correctly regarding the guide. and power is on on the board, NET is blinking
I think I have a solution for you, although it may be a little difficult to fix up. That error message is letting you know that a line in cd /home/pi/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835/src/bcm2835.c' is not functioning as expected.
I was able to fix this on a test setup by opening that file and modifying lines 531 and 533 so that instead of containing delayMicroseconds(10); they instead read bcm2835_delayMicroseconds(10);.
This file is massive so if you can open it using Geany or some other text editor that displays line numbers it will be much easier to find.
Step by step instructions:
Open a new terminal window
Navigate to the file directory using cd /home/pi/SIM7600X-4G-HAT-Demo/Raspberry/c/bcm2835
Open the file giving you errors using geany src/bcm2835.c
Navigate to lines 531 and 533 and change both lines from delayMicroseconds(10); to bcm2835_delayMicroseconds(10);
Save and exit this file
Finally run the command chmod +x configure && ./configure && sudo make && sudo make install
Let us know how this goes! This worked on my test setup using a Pi 4B, so hopefully itâs the same for you.
Glad to hear we are making progress. ttyS0 refers to the first serial port on your system and will absolutely be there on a Pi 5, but may not be configured to be accessible.
It may be worth repeating the steps to enable the serial port hardware in the config settings. This is explained in more detail in the guide, but for a quick summary of the steps:
Open a fresh terminal window on your Pi
Run the command sudo raspi-config to open up the config menu
Move down the list and hit enter on âInterface Optionsâ, then in the sub menu, âSerial Portâ
Select âNoâ on the first pop-up about making the login shell accessible over serial
Select âYesâ on the next pop-up asking if you want the serial port hardware to be available
Exit out of this terminal window and reboot your Pi (this part is required!)
Hopefully, this fixes this issue and allows you to access ttyS0. If not, let us know!
Hi, Iâm just starting with this HAT. I have a rpi 4B. Iâm following the instructions and have stopped at the point of editing rc.local because that file doe not exist in my etc folder. Any advice for me? TIA Joe
Hey @Joseph249014 and welcome to the forum, glad to have you here,
Looks like /etc/rc.local has been removed from autoinstall by Trixie OS.
Looks like weâre going to have to make it. Please try the following commands:
sudo nano /etc/rc.local
In the file that comes up enter the below, save the file, and exit:
#!/bin/bash
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
sh /home/pi/SIM7600X-4G-HAT-Demo/Raspberry/c/sim7600_4G_hat_init
exit 0