This Waveshare 4G HAT has a SIM7600G-H Module onboard which enables the 4G/3G/2G communication and GNSS positioning. This module supports LTE CAT4 connection up to 150Mbps for downlink data transfer.

Transcript

Today we're tapping in to our mobile communication networks with our Raspberry Pi.

Hey Gang, Tim here at Core Electronics and we're going to set up this Wave Share 4G HAT with a Raspberry Pi single board computer. This will dramatically increase your sphere of connectivity, providing you the ability to control your projects from the other side of the world. So, let's crack on in!

With this HAT installed on your Raspberry Pi single board computer, it's going to be able to connect to 4G, 3G, 2G, NB-IoT, or CAT-M1 mobile networks. You will need an activated SIM card to be able to do this. This HAT also unlocks global navigation satellite system positioning, so our Raspberry Pi is going to be able to pinpoint its GPS location no matter where it is in this big wide world. This module supports LTE-CAT4 connection with 150 megabits per second for downlink data transfer.

After setting up this system, we will first send text messages and ring mobile phones with our Raspberry Pi single board computer. Then, we will pinpoint our device's location using GPS and send that location data in an SMS message to a mobile phone. Finally, we're going to activate GPIO connected hardware via an SMS sent to our Raspberry Pi.

Performing on the table is everything you need to set up your 4G Pi system. Naturally, you're going to need the Wave Share 4G HAT and a Raspberry Pi. We're using a Raspberry Pi 4 Model B 2 Gigabyte here. You're going to need an activated standard size SIM card that works on 4G networks. If you want to forego phone calls, the Hologram Global IoT SIM card could be the perfect solution for you. There are also size adapters, so if you have a small SIM card, that is no issue. You're also going to need everything to run this Raspberry Pi as a desktop computer. That means you're going to need a microSD card flashed with the Raspberry Pi operating system, a power supply, and a monitor. caps to the d3 and d4 pins

Latest Raspberry Pi OS, a micro HDMI to HDMI cord to connect the system to a monitor, and a Raspberry Pi power supply, mouse, and keyboard are all included. A USB microphone and audio headphones are optional extras if you want to use your Raspberry Pi as a legit phone.

Just to be clear, everything to the left of this antenna comes with the 4G hat. Preferably, you're going to want a case that can hold up the 4G antenna in the upright position. I have a 3D printed one here and the STL file is in the full written up guide, so just check the description if you want to print one too.

Start by installing your activated SIM card to the Wave Share 4G hat. Be aware that you need to slide back the mechanism to unlock it, then it will be able to swing open. No major force is required in any step of this. Slip in the SIM card into the cradle and be careful that the SIM card does not fall out or shuffle around during installation.

Connect the wires from the GPS antenna and the 4G mobile network antenna to the UFL adapter connectors like so. Once complete, connect the other side of the two UFL connectors to the top of the hat. Connect the GNSS port to the GPS antenna and the main port for the mobile network antenna. Line them up over the top of the connection and push down firmly and with commitment. It will then pop firmly into place. These connections are not easy to remove, so double check the location you're attaching them to.

Now be aware not to toggle accidentally pull off the antennas when you're moving around the setup. Once you have them connected, having a case that holds the antenna upright securely and nearby is definitely advantageous.

Now turn your attention to the yellow jumper caps on the top of the Wave Share 4G hat. Set the yellow jumper cap between power and the D6 pins. Also, if you need to arrange the pair of yellow jumper caps to the D3 and D4 pins. press enter again and select yes then press enter again to confirm

We can now mount the 4G Wave Share Hat to the Raspberry Pi board as we would any other HAT using the included hardware. Make sure the GPIO pins line up correctly and press the two boards firmly together. Then plug in USB micro power to the bottom USB 3.0 port of the Raspberry Pi. From here, just set up the Raspberry Pi as you would a desktop computer. I will also include a USB microphone which can be plugged directly into the USB 2.0 port and we'll add some headphones to the auxiliary port of the Wave Share 4G Hat. I 3D printed a mount to set everything onto it securely and make sure that the 4G antenna stands upright. If you want one of these, the print files are in the description.

This 4G Wave Share Hat is a very clever bit of technology but it does require some software setup so it can communicate effectively and function with a Raspberry Pi single board computer. With our Raspberry Pi connected as a desktop computer and powered, it will boot up to Raspberry Pi OS. Once here, we're going to open up a new terminal window by pressing the black button on the top left of the screen. In this terminal window, type and enter the following: sudo raspy config. As soon as you press enter, it's going to open up the configuration menu. Use the arrow keys to navigate to interface options and press enter. This is going to take you into a deeper menu. In this menu, we want to enable serial port communication. This is how the Raspberry Pi and the Wave Share 4G Hat are going to communicate. Use the arrow keys to navigate down to serial port. Once there, press enter. This will open up a new menu page asking the question: would you like a login shell to be accessible? Press enter again and select yes, then press enter again to confirm.

The other jumper cap arrangements configure the HAT to work with other boards like the Arduino microcontrollers. that save the file by pressing ctrl x and then y and then enter

Over serial, navigate to 'No' and type 'Enter' on 'No'. It will then open up another menu asking another question: 'Would you like the serial port hardware to be enabled?'. Navigate to 'Yes' and type the 'Enter' key. With that complete, navigate to 'Finish' and type 'Enter' when the prompt asks you to reboot. Do so, with the system rebooted and back to the desktop.

We will now install Minicom to our Raspberry Pi system. Minicom is a serial communication program. Once again, open up a terminal window and type and enter the following into this new terminal window: 'sudo apt-get install minicom'. If ever prompted with 'Do you want to continue? Y/N', press 'Y' and then the 'Enter' key to continue the process.

Next, to install the demo codes and board drivers, we're going to open up a new terminal window using that same black button and we're going to type and enter the following 'wget' command. It's easier to copy and paste it from the full article, like I'm doing here. This should only take a couple of minutes to complete.

When it finishes, use the same terminal window to type and enter each following command that you can find in the full written up article. The first line is going to install 7-zip software which we can use to unzip the downloaded file. The second line will unzip our downloaded file into a specific location. The third line will provide permissions so that the Raspberry Pi OS doesn't block the WaveShare 4G HAT from functioning. The final will open up the rc.local file which we will edit.

So, as you can see, that last line when entered opened up a new page - the rc.local file that you can navigate around by using the arrow keys on your keyboard. You will need to add this command from the full write-up inside the rc.local file. We're going to copy and paste it into exactly the same location as I'm doing here. Having done that, save the file by pressing 'Ctrl+X', then 'Y' and then 'Enter'. the script is set to hang up after that time

We can now set up the Wave Share 4G Hat to work with the Raspberry Pi Single Ball Computer. To do this, press Ctrl + X + Y and then the Enter key to lock in and save these changes. Completing this task will mean that the Wave Share 4G Hat drivers will start on the boot up of the Raspberry Pi Single Ball Computer.

Finally, open up one more new terminal window. Copy and paste these two last commands one by one. The first one is going to direct focus to the downloaded bcm2835 folder which has the Wave Share 4G driver inside. The second command will give access permissions and initialize the driver.

With that complete, we have some great example Python scripts that we can jump into and start exploring. So let's start by calling up a mobile phone using the Raspberry Pi system that we've set up. Open up the location of the script phone call.py, which can be found in the directory /home/pi/sim7600x-4g-hat-demo/raspberry/python/phone call. We're going to right click this file and select open with Thonny IDE. Thonny IDE is just a Python interpreter software and you can use any that takes your preference.

With this file open, adjust the default phone number to the one you want to call. Also double check that the line here looks the same on your system. TTYS0 is the user UART connection port of this Raspberry Pi 4 Model B. That number at the end is the default baud rate of the Hat. The baud rate is the rate at which information is transferred in a communication channel.

With that complete, press save and then press the big green run button on the script. Give it a second or two to initialize and boom, your target phone should be receiving a phone call from your Raspberry Pi. If you choose to pick up the call, it's going to last less than 20 seconds as the script is set to hang up after that time. network and the gps antenna we can start to build some really cool projects

Decided in the Python script, great success! An excellent confirmation that the Waveshare 4G HAT has connected correctly to the mobile network. So now let's get our Raspberry Pi to pinpoint its exact location. A great example script that we can dive our toes into this world with is called GPS.py which you can find in the directory here. This script will activate and utilize the GPS antenna. With the script open, click the green run button and allow it a couple of minutes to figure out where in the world the Raspberry Pi is. If you're running into issues with connecting, place the GPS receiver stick aside face down and put it outside. Also note that it can have connectivity issues in particularly rainy weather. It took about four minutes for me to receive the positioning signal after running this for the first time.

Now this default Python script is fantastic however it provides the location details in NMEA format. NMEA is a standard data format supported by all GPS manufacturers but it isn't very human readable. I created another script called GPSHuman-Readable.py to fix this. You can download it from the written article along with all scripts utilized in this guide. Opening and running this script in the same way as before is going to result in two values, latitude and longitude given in decimal degree format. Decimal degree format is a notation for expressing latitude and longitude geographic coordinates as a decimal fraction of a degree. Here are our latitude and longitude results. These are nice as we can just copy and paste the results directly into Google Maps search bar. It will refresh the web page to exactly where your Raspberry Pi device believes it is located and here we are in God's land, Newcastle.

So now that we know that our Raspberry Pi Single-Board Computer is connected to both the mobile network and the GPS antenna, we can start to build some really cool projects. behind the gsm module and the GPIO pins on the raspberry pi

Network and the GPS, specifically the GLONASS system, let's use both. I created a script that figures out the device's GPS location and then sends an SMS from our Raspberry Pi with that location data as the contents of the message. This SMS is written in a very human readable language. To do this, open up the script, "Find GPS then SMS Final.py" by right clicking like before and opening it with Sony IDE. This Python script was created by combining the two demo scripts talked about before.

You will need to customize the Python script by adding your target phone number right here. Then, with that done, save it and press the green run button. As soon as you do, it will start the GPS session and pinpoint its location in latitude and longitude formatted in decimal degrees. Once it finds the GPS location, it's going to swap to SMS mode, as you can see here, and send the message through to your target phone. Ahaha, and there it is, we got our text.

That's how that is done. This Python script could be easily scheduled to run on boot or at a certain point each day, so long as you have constant power to your Raspberry Pi system. It would make for a perfectly capable do-it-yourself GPS tracking system for fleet management applications.

And it's not just GPS that you could send. If you had a particular sensor installed, you could send the results of their measurements to your mobile phone in a very similar manner. So let's take advantage of this and now use the SMS receiving capabilities of our system to control the hardware attached to the GPIO pins. For today, we're going to control a GPIO connected LED to turn on for a couple of seconds when a new text message, which has the correct keyword inside, is received by the device.

This table shows the default relationship between the SIM 7600 control pins, which is the brain behind the GSM module, and the GPIO pins on the Raspberry Pi. Raspberry Pi to do things with a simple text message

Box on top of the WaveShare 4G HAT and the Raspberry Pi's I/O is important to know before attaching extra hardware to any GPIO pins. You won't be able to connect to GPIO pins that already have communication or powering tasks to perform. If you want a labelled GPIO pin out guide for Raspberry Pi single board computers, check the description.

Now that we know what GPIO pins are free, let's set up our LED and connect it to our Raspberry Pi's GPIO. Attach the negative side to the ground pin 39 and the positive side to the GPIO21 pin 40 on the Raspberry Pi. Be aware that this LED is a placeholder for whatever hardware you want to use, via the servo, solenoid engine, or your garage door, just as some examples.

Turning our attention now to the GPIO LED control via text.py script, we're going to open it up and we're going to run it. This is a combination of the demo SMS receive code and a simple LED turn on or off script. When run, this is going to constantly update each couple of seconds looking for new SMS messages. When it gets a new one, it's going to open it up, print all the details of the SMS message to the shell, and scan the contents for the keyword "red". If it finds that keyword, the LED turns on briefly. So let's send it a message right now: "Hello Raspberry Pi, I love you. Please turn on the red LED." We're going to send it through right now, just like that, the LED's turned on.

If you want to change this keyword, you can find it down here in the script. It is part of this if statement. Recording buff is shorthand for the recording buffer. This is the method used here to read the serial output of the HAT as it talks to the Raspberry Pi. This keyword can be altered to anything that you desire, so long as we're within mobile connectivity, which is darn near everywhere, except for when you need it. We can now get our Raspberry Pi to do things with a simple text message.

Raspberry Pi can be used to start, stop, and control almost any electronics. Hopefully, this base will serve you well. That's it for today. If you have any questions, write me a message below. We are full-time makers and we're here to help. With my Wave Share 4G HAT functioning exactly how I want it to, and you with all the information to do the same, until next time, stay cozy.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.