The main thing I want you to get out of this project is this: upon completion you will have cellular data connected to your Internet of Things device! LoRa, Sigfox, Bluetooth and WiFi can't compete with cellular data for coverage, speed and data allowance. Many projects only become possible when using cellular data. Need to send pictures? Sure. Over the air updates? Yes. Real time streaming data? That too. Just imagine the possibilities!
Hi, I'm Chris from Core Electronics and today we're looking at the GPy from PyCom. This is the getting started guide, where we've got it all plugged in and code running, and I'll show you exactly what it's doing.
So, on the PC here, I'm just about to run the code, what I expect is that it's going to hook up to the Internet using cellular data and set the real-time clock inside and start telling me the correct time. So here we go I will hit run, initially the real-time clock is unset setting up the LTE modem, configuring, attaching, connecting and there we go the real-time clock was updated from au.pool.ntp.org and every five seconds now it's telling me the time, it's in a kind of a reverse, year, month, day, hour, minute, second, microsecond format and it's giving me the correct time.
No it's not five minutes past 1:00 in the morning this is GMT time from London because I haven't set a time zone, alrighty so let's have a look at the hardware that we're working with from my iPhone 6 which is an LTE phone, I've withdrawn the SIM card draw and just taken the SIM card from that I'll just disconnect now from the PC and take this apart and show you what's in it I'm just waiting for the program to stop running. Alright if I take the GPI off the expansion board you can see my SIM card is in the draw here, the orientation for the SIM card as it goes in is shown in the text for this tutorial, as well as many other details including firmware updates, so we need to correctly position that using the old LED end is at the USB end, snap those on, we also must use the LTE antenna the device can be damaged without the correct antenna attached, so that has to be there plug it back in now and we're ready to run again.
Alright so using LTE data is very different to using some of the other technologies that you can use to connect your Internet of Things devices to the Internet. If you have Wi-Fi obviously you have a broadband internet connection and you can do lots of things including, over the air software updates you could post live video or photos whatever you can do with the capacity of the Internet of Things device you're working on, but Wi-Fi isn't available everywhere you certainly can't go across city using the same Wi-Fi network. Bluetooth is very limited it's low-power and only about 10 meters worth of range if you want to use Sigfox or Lora those deployments are rolling out everywhere, there's coverage like crazy however they're very specific to how you are to use the service and mostly small messages sent very occasionally. So, if you wanted to do something that was a bit of a bandwidth hog or needed lots of data or needed to send data continuously, LTE is probably the best option if you're in an LTE coverage zone. So, I have checked as part of this project that my iPhone is LTE compatible that the sim card I have lets me use the LTE network, I have checked which LTE protocols my provider makes available, the two main ones now are Kat m1 and N b1 and the firmware that's on the devices you need to with your PyCom device decide in advance which of those two you're using and load the appropriate firmware.
So, while I'm on firmware there are three distinct levels of firmware here, the expansion board 3.0 has its own firmware and should be updated first, the GPy has its own firmware as well and there is a separate firmware as I mentioned for the LTE radio, so those are all linked in the documentation as is how to set up the Atom IDE and get the py maker extension running.
So, I'll just come back to the PC again for a moment, in setting this up I have had many problems, not because of PyCom but because these three lines here that I'm showing, are very critical to how the device runs, so depending on your location and the carrier you're using there will likely be several configuration lines that you must get exactly right to make your device work. Now that I have these correct every single time I want the internet connection it works a hundred percent of the time it's fabulous, however until I got these configuration lines correct it never worked 0% success. So, what I want to say is as you're about to try one of these projects you'll run into the case where you need to configure the device correctly for your network, if you're in Australia and use Telstra there you go it works, however, if you're on a different carrier or in a different country you will likely have to do some digging around to find the correct settings.
So, I'll just run to the bottom of the program here the main part of the code is here, we create a reference to the real-time clock device that's within the GPy and we use this get RTC function. If we scroll up the code a little bit the definition of the get RTC function, says only returns an RTC object that has already been synchronized, so it'll give you back a connection to the RTC device and make sure the time has been set before you get it. What happens is if it's not already synchronized it'll call another function called set RTC, so we run back up in the code again the function set RTC will of course get the LTE connection to set the real-time clock it needs to be connected to the Internet. So, we're in this kind of pattern where we expect that the clock is working if it's not working, we jump back and set it if we set it we need to jump back again and get an internet connection running so that we can set it. So, things are happening just as they're needed. If I now reconnect to my device and I run the program you can see that the real-time clock is unset, so it's connecting to the Internet to set the clock, the reason it's unset is that I've just unplugged it, now the time is being displayed again if I stop the program and I've just clicked the Run button again to stop the program and start it again the second time it says initially the real-time clock is set and the real-time clock says the date and time.
So this is a very basic example of connecting to the yet to set the clock but there's nothing to stop you downloading webpage posting to Twitter pushing data up and down from web services like AdafruitIO using MQTT, you could interact with rest web services, anything that you want to do on an internet connection is now possible because the cellular radio is connected, the only issue you'll have is if you run out of coverage.
So I hope that gives you a quick introduction to the GPy, the same sort of functionality is available on the Fipy, these two devices from PyCom both have the cellular radio, I'm looking forward to building some projects with this I'd like to have a low jacking bug for my ebike, so the fit if ever wanders off it'll tell me where it's gone, I'm hoping I can hide all the equipment in the frame somewhere and nobody will even know it's there.
All right as usual, the documentation is linked below, there's more detail there than I can pack into the video I hope you have some success with your cellular IOT projects. Thanks, see you.
SKU: CE04926 https://core-electronics.com.au/pycom-gpy.html