Make projects via Micropython using just A9G board | GSM, GPRS, GPS, MQTT and lot more....

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
So if you clicked on this video there are high  chances that you already know what A9G board   is and are here to learn how to use A9G board  without AT commands and without any external   microcontroller using micropython firmware and  well it was it so you are on the correct video as   in this video I'll be sharing you some micropython  scripts for A9G board using which you'll be easily   able to write and read data onto the A9G board's  GPIO pin, you'll be able to send the SMS from A9G   board, you'll be able to get the GPS coordinates  on it and not only that we are also going to write   a script about making communication with the  cloud MQTT broker to send and receive data via   GPRS connectivity using micropython so after  watching this video you'll easily be able to   make your own IOT projects by just using the A9G  board Standalone so let's quickly get started   this video is sponsored by Alitum and they came  up with an amazing product called as Alitum   365. so Altium 365 is an Electronics product  design platform that unites PCB design MCAD   data management and teamwork so with Alitum 365  you can do the PCB designing task you can share   your projects over web for review purposes it do  cover sharing your PCB file to Mechanical team   so that they can create the mechanical product  package based on your PCB then it also provides   the centralized cloud storage so you don't need to  rely on one single computer for your files it also   helps you with managing your components and get  real-time supply chain data for your components   it also allows multiple people to work on single  project and in the end it also helps you with   sending your design to final manufacturing  units so Altium 365 takes care of all other   tasks so you put more time and effort in making  something creative and useful and the good part   is you can try out its free version as well  I'll leave its free trial version link down   in the description of this video so do check  that out and now let's start with this video. Okay so here is the A9G board and now if you  want to buy this board while we are selling   it at an amazing price through our website whose  purchase link is down in the description of this   video so by default the A9G board comes with the  AT commands firmware built in and now if you want   to change its firmware to micro python well you  should watch out my previous video in which I have   shown the step-by-step process about changing the  A9G firmware to micropython its link is down in   the description of this video so after changing  its firmware to micro python we are ready to   install the micropython scripts in it but before  that we need to do the programming connections yes   you can't program A9G board directly with the  built-in micro USB port rather you will need a   TTL converter so here I'm using the smallest  TTL programmer made by team techiesms which   is set to 5 V logic level if you want to buy this  programmer well it's purchase link you can easily   find in the description of this video so we made  the connection between the programmer and the A9G   board according to this connection diagram so  after that I'll connect the programmer with my   computer and I'll press and hold the power button  on the A9G board for two to three seconds to power   up this board now we are ready to jump onto  our computer and install the scripts onto the   A9G board okay so here is the thonny IDE so the  first step which you need to do after connecting   this A9G board with your computer is you just need  to go to run click on configure interpreter here   just select micropython generic and here just  select the com port on which your A9G board   is connected via programmer after that just  click on OK and just click on this stop button   and here you should be able to see this  micropython version uh whichever version   you have installed with A9G module if this  appears then you are good to go to write your   Python scripts and you can test it out here as  well if I type here as a print hello world and   if I press enter as you can see the hello world is  printed that means the micropython is successfully   running onto this particular board okay now we  are ready to install the script so first let's   try to install the LED blink example script okay  so here is the script for blinking LED on our A9G   board so let me explain you the script so first  of all we imported two packages now packages are   nothing but the libraries that we used to install  or include in our Arduino sketches similarly here   in micropython we used to include the packages so  first is the machine package which is responsible   for interacting with the gpio pins of the  board and second is the time package which   is responsible for providing the delay inside the  script after that we have declared one variable   LED which is nothing but the PIN 27 acting as an  output now here 27 GPIO is that pin on with the   built-in LED of A9G board is connected with and  we will be you know toggling the built-in LEDs   that's why here we have declared as pin 27 after  that by default value of the variable value is   set to 1 and straight after that we have defined  while one which is nothing but the infinite Loop   so this is same as uh we used to write void Loop  inside the Arduino IDE so inside the wild one what   we are doing is we are setting the value of LED  pin as value which is nothing but one so we are   turning on the LED after that we are providing  the delay of one second using the time using the   time dot slip function after that we are toggling  the value okay so this time the value will become   0 and after that it will again jump onto this  line and it will turn off the LEDs so this is how   we are you know toggling the LED at an interval  of one second okay now to test this script what   need to do is you need to click on file click on  save as select micropython device here and here   you need to save this script with the name called  as main.py now why main.py? well as soon as this   micro python device boots up it will run main.py  script by default so if you save it with this name   and if you power up A9G board separately it will  by default run main.py script automatically that's   why you should say with the main.py name okay I'll  click on OK and it installs that script inside the   A9G board I'll turn on the secondary camera to  show you uh whether this the script works or not   okay so here is the A9G board as of now as you  can see no LED is not at all blinking on this   board well to test that out you can just click  on the play button okay and as you can see the   LED on board started blinking at the interval of  one second okay and this will work if you power up   energy board separately as well so this was first  script to write data to GPIO pin now let's just   write a script to read the data from GPIO pin and  do some task way so what I'll do is I'll write a   script for you know turning on this led based upon  the status of the push button connected with the   A9G board okay so here is the script for turning  on and off the LED using button so what changes we   made here is we declared one more variable called  as button which is nothing but the GPIO 26 PIN   acting as the input so we'll be attaching a push  button at GPIO 26 pin and what we are doing next   is we are reading the button status by typing  the command button dot value and if the button   status is one we are turning on the LED else we  are turning it off a very simple script but this   will help you to control the uh you know things  with the help of a push button okay so similarly   we are doing the same thing here uh which is  we'll be saving this file uh with the name main.py   inside the micropython device I'll select this  click on OK it will overwrite its click on yes   and we have successfully installed the script  I'll again start the secondary camera okay so   now click on the play button here and yeah as you  can see the LED on the board is turned off so now   if I press the button as you can see the LED got  turned off and if I release the button the LED got   turned off so it is working based upon the status  of the button so we are successfully able to read   the data from the GPIO pin and write the data to  GPIO pins and this is how you can interact with   your energy board using micropython now let's just  move one step more ahead and let's just try to you   know send SMS using A9G board okay so here is the  script for sending the SMS but before that what   I did is I have inserted the VI SIM card onto  my A9G board okay now here one thing you need   to make sure that this A9G board supports the SIM  card with only 2G connectivity it won't work with   the 3G and 4G network match so make sure if you're  using any SIM card uh let's cross check that your   network provided provides the 2G connectivity okay  so after insert in the SIM card let's just move on   to understanding the script for sending the SMS  so here we need to you know import one important   package called as cellular now the cellular  package is responsible for all the cellular   activity like sending receiving SMS and calls and  GPRS and everything okay and after that we have   declared the or imported the time package again  for providing the delay okay now here what we did   is we have defined one uh you know user defined  function called as smshandler which is responsible   for receiving the SMS and sending the SMS as  well unfortunately this receiving SMS function   or the command is not working that will see while  running this script I don't know why and how but   yeah it is not working but we are successfully  able to send the sms okay so after defining the   custom uh SMS Handler function you need to provide  the name of the function here inside the command   cellular dot on SMS after that by typing cellular  dot SMS you need to provide the mobile number on   which you need to send the SMS with the country  code and after that you need to type the message   which you want to send in my case I am sending  Hello from A9G and .send function now this line   will help you to send the SMS to the dedicated  mobile number okay after that it will be inside   the while loop forever as it will be waiting for  SMS reception but we won't be able to do that and   after doing everything it will just print as done  once it comes out from the while loop okay so now   I'll save this inside the micropython device with  the same name called as main.py click on yes and   yeah it got successfully saved and now I'll click  on the Run script button and let's just wait for   the SMS to be received on this mobile okay here  it says SMS sent and here in my phone as you can   see let me turn on the screen recording on the  smartphone and here inside all messages as you   can see I got the message called as Hello From  A9G so yeah we were successful for sending the   SMS from the A9G board to the mobile phone and if  I send the message from here like from the mobile   phone to the A9G board let's see what happens  inside this shell as you can see it says that   module object don't have any attribute called as  SMS received which is this okay so it is unable to   find this particular attribute inside the package  you can see and for that reason we are not able to   receive any SMS well I took this script from one  GitHub repository by pulkin and majority of the   microPython scripts which I use in this video are  based upon this repository so I'll leave the link   for this report as well down in the description  of this video so you can check out other examples   as well okay so we are successfully able to send  SMS unfortunately not receive SMS but anyone you   are few watching this video may know the solution  about how we can receive the SMS well do drop your   suggestions and solutions down in the comments  of the video and after learning about the SMS   now let's just take one more step ahead and let's  just try the GPRS connectivity over MQTT okay so   I'll show you the example code about how to send  and receive data over MQTT over GPRS okay so here   is this script for Adafruit MQTT so I've made  this script particularly for Adafruit MQTT so   if you are using Adafruit well you can follow  the script and if you're using any other MQTT   broker you need to provide the credentials like  the username password server name everything here   okay let me take you this whole script and let  me uh let me like teach you how the script works   okay so first of all including the important  package is pretty common after that here is   one new command or function you can say which is  cellular.GPRS and here we need to provide the APN   name of your network provided to make successful  GPRS connectivity okay in my case I'm using the   Vodafone idea SIM card and its APN name is www  in your case it may be different so you need to   search for it and you need to provide that APN  name here okay after that I have declared two   topic one is Led topic and second is the sensor  topic now those who have used MQTT before must   be knowing what a topic actually is okay so  here the LED topic is uh relay1 and the sensor   topic is temperature okay in your case it will be  different for sure that you need to provide here   after that what we are doing is we are declared  One LED variable which is nothing but the PIN 27   as output so the built-in LED is declared as an  output in this particular line after that here we   have to provide a time period like now this is the  time period for sending the data to the server so   here I'm sending the data after every 6 second  if you want to increase or decrease the number   you can change the number here after that here  this particular function will try to install the   umqtt package in case your uh micropython device  doesn't have that package if it is having it   won't install it but if it doesn't have it will  just install that by running this command pretty   convenient right ? so after that here again  we declared a user defined function called as   cb which is nothing but the Callback function  so whenever we receive any data from the MQTT   server this particular function will be called  and based upon the data received if the data   received is 0 we are turning off the LED and if  the data received is 1 we are turning on the LEDs   that we are doing here okay now let's just see  how we are sending the data but before that we   need to provide couple of more credentials like  the name the name of the device which can be a   random name but it should be unique for all the  devices connected to the same broker after that   we need to provide a server name in my case it  is io.adafruit.com port number in my case it is   1883 username in my case is this and password  is nothing but the AIO key of adafruit MQTT   broker which is this These kind of credentials  you want to provide for an MQTT broker after   that we are plotting all the credentials inside  this function and using this particular line we   are establishing the MQTT connection okay after  that we are providing the Callback function as cb   and we are subscribing to the LED topic which is  nothing but the relay1 and inside the while loop   what we are doing is we are just checking if there  is incoming messages from the Adafruit MQTT broker   if is it so it will simply call the Callback  function and if there is no message coming in   what would it will call the send sensor function  which is defined here which is nothing but it is   sending the data to sensor topic and the data  is fixed as of now which is 25 but here you can   also attach a sensor and send the sensors data  well I try to attach the DHT11 sensor with the   micropython device or A9G board particularly but I  didn't find a particular package that supports the   DHT11 sensor in it hence I was unable to attach  that sensor but again if you know how to attach   that if you know proper package of the DHT11 for  A9G you can definitely let me know here so as I   was not able to attach the DHT11 sensor I am just  sending the data 25 but let's just change the data   to 100 okay so I'm sending the data 100 it to the  sensor topic which is nothing but the temperature   okay and this is sand after interval of every 6  second and this is the simple mqtt uh script uh   in micropython for A9G board okay so now what I'll  do is I'll just click on the stop button first and   I will save this script inside my micropython  device with the same name called as main.py   I'll overwrite it and it got successfully written  now in the browser I'll open my Adafruit account   so this is my adafruit account and I'll click on  the play button here now let's just see if we are   getting the data or not so here we should be able  to see the data 100 let's just wait and as you   can see so earlier this data was 25 but now it's  changed to 100 so our A9G board successfully sent   the data over GPRS over MQTT to our MQTT broker  and now let's test this led button but before   that I'll turn on the smartphones camera to show  you the live uh you know working of this project   so here's the A9G board and if I turn on the LED  okay as you can see the A9G board like the onboard   LED turned on if I turn it off the LED got turned  off so it is working in real time with a very low   latency and in the meantime we are also able to  send the data which is shown here in the inside   this shell okay so we are able to you know work  over MQTT with GPRS using A9G board Standalone   via micropython how awesome it is right with this  you can make a lot of IOT projects for sure now   let's just uh do one more thing which is let's  just test out the GPS connectivity let's try to   get the GPS coordinates on the A9G board and let's  just see the script for it but before that we need   to move to some window location so that this A9G  board can get the proper GPS connectivity okay so   right now I'm sitting near to the window location  where I have put the A9G board outside the window   so that it can get some uh you know GPS satellite  connectivity okay now let's jump on to the script   and let's just understand how we can get the GPS  coordinate using micro python so first of all two   packages are included one is for GPS and another  is for providing the time delay inside the script   after that by just writing this single line  command you can turn on the GPS inside A9G and   in the while true that is the infinite Loop what  we are doing is we are just printing the location   like the latitude and longitude data and after  that we are also printing printing the number   of tracked and visible satellites uh connected  or like uh you know recognized by this A9G board   and we are printing everything at an interval of  1 second that's a pretty simple script and now   what we'll do is I'll click on the stop button  first of all and I will save this script inside   the micropython device with the same name main.py  I'll overwrite it and I will just click on the Run   button and let's see if we are getting the data or  not so here inside the shell it started printing   the latitude longitude but as you can see the  number of satellite tracked and visible are 0   that means it is not connected to satellite yet  but still it is printing the latitude longitude   data how well the great feature provided by  this micropython script is it can print the   previously recorded GPS location even if there  is no satellite connectivity so the last location   is stored and is printing the last location only  and once it gets the uh satellite connectivity it   will give us the real time location okay so let's  just wait for the satellite connectivity okay so   now it got connected to the satellites and now we  are getting the real time latitude longitude data   so what I'll do is I'll simply I'll first of all  click on the stop button okay I'll copy this data   of latitude and longitude and I'll open my web  browser in a new tab I'll open maps.google.com and here if I paste this coordinate  and let's just see what we are getting okay so we are got we are getting the location  somewhere here and as you can see it is pretty   close to the studio so here is my studio and  here is the uh like this is the location which   we got from the A9G board which is pretty close  and once we take this A9G board outside an open   environment where it can get the maximum satellite  connectivity we can get more accurate GPS location   and yeah this is working Standalone without any  external microcontroller so we can now make our   own GPS tracker by just using A9G because it can  get the GPS data and you can send that over MQTT   so I'll definitely try to make a GPS tracker  the smallest GPS tracker using A9G board only   soon on my channel so make sure to subscribe  the channel if you don't want to miss out that   Amazing Project coming up on our Channel and  yeah that was all about getting started with   in A9G board using micropython I know I haven't  covered all the different uh you know example   codes about micropython but still I'll leave  the link for that GitHub repository on which   they do have a couple of more example codes down  in the description of this video so you can check   it out so what I did here is I just covered the  important things like sending the SMS and sending   the data over MQTT getting the GPS coordinates  so I just got the important stuff so that you uh   you know get quickly start with your IOT projects  using A9G board okay and whatever problem I faced   uh while using it I already you know told in this  video so if any one of you watching this video   has a solution for all the problems I discussed  well do reach me out through the comments that   will be a great help for me and yeah that was  it about this video do click the LIKE button if   you appreciate our hard work and if you got to  learn something new from this video well make   sure you hit the like button also let me know  your suggestions feedback anything regarding   this video in the comments of the video and yeah  that being said I'm just ending this video here   and now just wait for my next video till then  explore learn share with me techieSMS [Music]   foreign
Info
Channel: techiesms
Views: 35,171
Rating: undefined out of 5
Keywords: techiesms, electronics, electronics projects, A9G, A9G board, A9G Micropython, A9G MQTT, GPS Tracker project, A9G without AT Commands
Id: kJ-0dBrX2P4
Channel Id: undefined
Length: 20min 54sec (1254 seconds)
Published: Sat Mar 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.