Difference between revisions of "MakaPython A9G"

From MakerFabsWiki
Jump to: navigation, search
(Introduction)
(Project_2: Display SMS message on OLED display)
 
(50 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
  
 
+
MakePython A9G is an IOT for GPRS / GSM + GPS module, users can use MicroPython to program it, which is very easy, especially for non-programmers. There is also a user guide to learn how to use the board to create the first IOT project, which allows beginners to quickly learn hardware and programming skills.<br>
 
 
  
 
With this board, you will easy to add text, SMS and data to your project. It is good for your smart home project or GPS tracker and so on.<br>
 
With this board, you will easy to add text, SMS and data to your project. It is good for your smart home project or GPS tracker and so on.<br>
  
 
'''Model: [https://www.makerfabs.com/maduino-zero-a9g.html OAC010A9G]'''<br>
 
'''Model: [https://www.makerfabs.com/maduino-zero-a9g.html OAC010A9G]'''<br>
[[File:MakePython_A9G_1.jpg|500px]]<br>
+
[[File:MakePython_0_A9G.jpg|500px]]<br>
  
 
== Features ==
 
== Features ==
*BAT Input Voltage: 3.4-4.2V
 
*ATSAMD21G18, 32-Bit ARM Cortex M0+
 
 
*Micro SIM connector
 
*Micro SIM connector
*Integrated Power Control System
 
 
*Support AT Command
 
*Support AT Command
 
*Quad-band: 850/900/1800/1900Mz
 
*Quad-band: 850/900/1800/1900Mz
Line 19: Line 15:
 
*Support GPRS data traffic, the maximum data rate, download 85.6Kbps, upload 42.8Kbps
 
*Support GPRS data traffic, the maximum data rate, download 85.6Kbps, upload 42.8Kbps
 
*Support SMS text messaging
 
*Support SMS text messaging
*Support USB power charge
 
 
*Support Micro SD Card
 
*Support Micro SD Card
*Interface: I2C/SPI/UART/18*GPIO
 
*Arduino compatible
 
 
*Working Temperature: -40 – 85℃
 
*Working Temperature: -40 – 85℃
*Default baud rate: 115200
+
*Size: 70*32.6mm
*Size: 40*55mm
 
  
 
== Interface Function ==
 
== Interface Function ==
[[File:Maduino Zero A9G 3V3_1.JPG|700px]]<br>
+
[[File:MakePython_A9G_2.JPG|700px]]<br>
①Micro USB: 5V power input, USB to serial communication<br>
+
①BAT: 3.7V Lipo battery connector<br>
②CHG: 5V power input, can connect the solar panel to charge the lipo battery<br>
+
②CHRG: 5V power input<br>
③VBAT: 3.7V Lipo battery connector<br>
+
③Micro SD Card Holder<br>
④SW1:Switch on/off<br>  
+
④Micro SIM Card Holder<br>
⑤PWR: Power indicate<br>
+
⑤A9G Module<br>
⑥CHG: Charge indicate<br>
+
⑥GSM: GSM Antenna IPX Interface<br>
⑦GSM: GSM Antenna IPX Interface<br>
+
⑦GPS: GPS Antenna IPX Interface<br>
⑧Reserved Interface for A9 or A9G module<br>
 
⑨STA: A9G GPS status indicate<br>
 
⑩NET: A9G Network indicate<br>
 
⑪GPS: GPS Antenna IPX Interface<br>
 
⑫J3:I2C Interface<br>
 
⑬SWD: Bootloader downloading<br>
 
⑭RESET: Reset button for ATSAMD21G18<br>
 
⑮MCU: Atmel ATSAMD21G18<br>
 
⑯A9 or A9G Module<br>
 
 
 
[[File:Maduino Zero A9G 3V3_2.JPG|700px]]<br>
 
 
 
①Micro SIM Card Holder<br>
 
②Micro SD Card Holder<br>
 
 
 
Note: Maduino Zero A9G v3.3 either the battery or the microUSB can be used for power supply. While microUSB connected, the board will be powered by microUSB first, while microUSB removed, it will switch to battery automaticly.
 
  
 
==Usage==
 
==Usage==
 
Warning: Don't operate when in power supply on (That is, don’t plug or unplug the Antenna ,SIM Cars, SD Card , in case of short-circuit that may burn the IC down.)<br>
 
Warning: Don't operate when in power supply on (That is, don’t plug or unplug the Antenna ,SIM Cars, SD Card , in case of short-circuit that may burn the IC down.)<br>
Note After [https://www.arduino.cc/en/Guide/HomePage a Arduino IDE] installed, there is no package to support Maduino Zero(Arduino Zero ), we need to install the Arduino Zero package in Arduino IDE to continue.
 
 
===Install Software for the Arduino/Genuino Zero===
 
The following steps show how to install software for the Maduino(Arduino/Genuino) Zero boards in the Arduino IDE.<br> 
 
1.1. Open the Boards Manager From the top Arduino IDE menu, select Tools-> Board-> Boards Manager… to open the Boards Manager dialog box.<br> 
 
That is, install Arduino SAMD Boards(32-bits ARM Cortex-M0+)<br>
 
 
[[File:Maduino Zero A9G 3V3_3.JPG|700px]]<br>
 
[[File:Maduino Zero A9G 3V3_4.JPG|700px]]<br>
 
 
1.2. Select Arduino SAMD Boards and install in the Boards Manager dialog box, type Arduino Zero into the search field to easily find the Arduino SAMD package for 32-bits ARM Cortex-M0+ boards as shown in the image below. Install it.<br>
 
[[File:Maduino Zero A9G 3V3_5.JPG|700px]]<br>
 
 
1.3. Find the Arduino Zero Boards on the Arduino IDE Menu After the software package has been installed, the new Arduino boards can be seen on the Arduino IDE Board menu found under Tools →Board as shown in the image below.<br>
 
[[File:Maduino Zero A9G 3V3_6.JPG|700px]]<br>
 
 
A new section called Arduino SAMD (32-bits ARM Cortex-M0+) Boards can be seen on the Board menu which contains Arduino M0, M0 Pro, Zero, MKR boards and others. This means the right package has been installed and Maduino ready to go.]<br>
 
  
===Hardware Connection===
+
===Related instructions===
• Plug a MicroSIM card.<br>
+
<pre>
• Plug a GPS Antenna to designator which shows GPS.<br>
+
AT+GPS=1  #1:Turn the GPS on, 0:Turn the GPS off
• Plug a GSM Antenna to designator which shows GSM.<br>
+
AT+CCID   #Query SIM, unique serial number, can be used to judge whether the card is normal
• Plug a Micro USB Cable to Maduino Zero A9/A9G.<br>
+
AT+CREG?  #Check the registration status of the network
• (Optional in v3.3)Plug a 3.7V lithium battery to J6<br>
+
AT+CSQ   #Query signal strength, the first parameter is the signal strength value
Note1: A 3.7V lithium battery normal voltage is 3.7V, but the range voltage often from 3.4V to 4.2V<br>
+
AT+CGATT=1  #Attach to the network, if you need to access the Internet, this command is mandatory
Note2: It can be powered by battery or the MicroUSB<br>
+
AT+CGDCONT=1,”IP”,”CMNET” #Set PDP parameters
Note3: Both the battery or the MicroUSB can be used for power supply. While MicroUSB connected, the board will be powered by MicroUSB, while MicroUSB removed, it will switch to battery automaticly.<br>
+
AT+CGACT=1,1   #Activate PDP, you can go online after activation
 +
AT+GPSRD=N   #N is a number indicating that a NEMA message is read every N seconds
 +
AT+GPSRD=0   #Stop reporting
 +
AT+LOCATION=2  #Get the address information of GPS, as long as the GPS can see the satellite before returning, otherwise it will return GPS NOT FIX NOW
 +
AT+CPMS="SM","SM","SM"  #Set up SMS storage unit
 +
AT+CMGF=0/1 #Set the SMS format, 1 for text format reading, 0 for pud format reading
 +
AT+CMGR=x #Read SMS content, x is the number of SMS
 +
AT+CMGL=4/"ALL"   #View the SMS list. The reading parameter in PUD format is 4, and the reading parameter in txt format is "ALL"
 +
AT+CMGD=1 #Delete the text message. If you use AT + CMGD = 1,4 then delete all SMS
 +
</pre>
  
===Program the Maduino Zero===
+
===Project_1: Shows the GPS location on OLED display===
After open the IDE and turn the board on, select the desired Arduino/Genuino Zero(Native USB port) board from the Arduino IDE Board menu<br>
 
 
 
[[File:Maduino Zero A9G 3V3_7.JPG|700px]]<br>
 
 
 
Then select the correct Port number from the menu item below Board on the Tools Menu. The Maduino board can now be programmed in the usual manner like Arduino.<br>
 
 
 
[[File:Maduino Zero A9G 3V3_8.JPG|700px]]<br>
 
 
 
Note: It may show different Serial number in your PC.<br>
 
Select Arduino/Genuino Zero(Native USB port) Open our first programming code [https://github.com/Makerfabs/Maduino-Zero-A9G A9G_AT_Commands_Test.ino]<br> 
 
Click Verify button to compile it.<br>
 
 
 
[[File:Maduino Zero A9G 3V3_9.JPG|700px]]<br>
 
 
 
If there is no any errors, it will show Done compiling.<br>
 
[[File:Maduino Zero A9G 3V3_10.JPG|700px]]<br>
 
 
 
Click Upload button to upload firmware to the Maduino Zero A9/A9g board.<br>
 
[[File:Maduino Zero A9G 3V3_11.JPG|700px]]<br>
 
 
 
After done uploading, it will show the programming OK, as below:<br>
 
 
 
[[File:Maduino Zero A9G 3V3_12.JPG|700px]]<br>
 
 
 
From the top Arduino IDE menu, select Tools → Serial Monitor… to open the Serial Monitor dialog box.<br>
 
[[File:Maduino Zero A9G 3V3_13.JPG|700px]]<br>
 
 
 
Select “Both NL & CR”, and baud rate 115200, it will show the board begin to work:<br>
 
[[File:Maduino Zero A9G 3V3_14.JPG|700px]]<br>
 
 
 
Click Send button after input AT and it will response OK. Now you can input other AT Commands refer to AT Command Set,Such as AT+CCID to show CCID, AT+CSQ to report GSM/GPRS signal quality and so on. Thus you can learn much about A9/A9G Module that will be a great helpful to your next program.<br>
 
 
 
===How to get GPS Location information?===
 
A9G Module is a GPRS/GSM+ GPS Quad-band module, with this board, we can use it as a GPS tracker, data acquisition, remote control and a lot of IOT project or smart home project. This example show you how to get GPS location.<br>
 
 
Attention: To get GPS location, please ensure you are outdoor, and plug the GPS Antenna. Indoor may get the incorrect location or no location information.<br>
 
Attention: To get GPS location, please ensure you are outdoor, and plug the GPS Antenna. Indoor may get the incorrect location or no location information.<br>
 +
<br>
 +
The example uses MicroPython programming, very simple and easy to understand.<br>
 +
This MakePython A9G can do nothing. It needs a microcontroller like ESP32 to drive it. The following two routines are implemented by A9G with MakePython ESP32, they can be directly combined to achieve various functions.<br>
 +
[[File:MakePython_A9G_3.JPG|700px]]<br>
 +
You can get MakePython ESP32 from here:
 +
https://www.makerfabs.com/makepython-esp32.html<br>
 +
Step:<br>
 +
1. Plug in the GPS antenna<br>
 +
2. Plug to MakePython ESP32, connect the USB to the PC.<br>
 +
[[File:MakePython_A9G_4.JPG|700px]]<br>
 +
3. Sample code, or you can get it from here: [https://github.com/Makerfabs/MakePython-A9G A9G_GPS.py]<br>
 +
<pre>
 +
from machine import UART,Pin,I2C
 +
import machine
 +
import ssd1306
 +
import utime
  
1. Turn on GPS, using the AT command “AT+GPS=1” to turn the GPS on:<br>
+
uart = UART(2, baudrate=115200, rx=21, tx=22,timeout=10)
[[File:Maduino_Zero_A9G_3V3_16.JPG|700px]]<br>
+
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)      #Init i2c
Note: The AT command “AT+GPS=0” to turn the GPS off.<br>
+
lcd=ssd1306.SSD1306_I2C(128,64,i2c)         
 +
lcd.text('Hello, Makerfabs',0,0)
 +
lcd.text('waiting...',0,8)
 +
lcd.show()
  
2. The AT command “AT+GPSRD=10” to read NEMA information every 10 seconds<br>
+
A9G_RESET_PIN = Pin(33, Pin.OUT)
[[File:Maduino_Zero_A9G_3V3_17.JPG|700px]]<br>
+
A9G_RESET_PIN.value(0)            #set pin to low
Note: It may take a while to report the location. Sometimes it should be outdoor, sky visible.<br>
 
  
3. AT+GPSRD=0 to stop the report and input AT+LOCATION=2 to get GPS address<br>
+
utime.sleep_ms(2000)
[[File:Maduino_Zero_A9G_3V3_18.JPG|700px]]<br>
+
A9G_PWR_KEY = Pin(27, Pin.OUT)
 +
A9G_PWR_KEY.value(0)
 +
utime.sleep_ms(2000)
 +
A9G_PWR_KEY.value(1)
 +
utime.sleep_ms(20000)
  
We can show our location where we are in https://www.gps-coordinates.net/<br>
+
#Display line wrap
[[File:Maduino_Zero_A9G_3V3_19.JPG|700px]]<br>
+
p=0
 +
def text(string,c=0,r=0):
 +
    global p
 +
    if p>80:  
 +
        p=0
 +
        lcd.fill(0)
 +
    colum=int(len(string)/15)+2
 +
    i=0
 +
    for a in range(0,colum):
 +
        lcd.text(string[i:i+15],c,a*8)
 +
        i=i+15
 +
    lcd.show()
  
===Maduino Zero A9G GPS Tracker Projects===
+
if True:
Project_1: Shows the GPS location on OLED display <br>
+
  lcd.fill(0)
 
+
  uart.write('AT+GPS=1\r\n')#1: turn on GPS  0:Turn off GPS
We need a 0.96"I2C OLED 128x64 at:<br>
+
  utime.sleep_ms(1000)
https://www.makerfabs.com/0.96-inch-i2c-oled-128x64-blue.html
+
  uart.write('AT+GPSRD=10\r\n')
 +
  utime.sleep_ms(1000)
 +
  uart.write('AT+LOCATION=2\r\n')
 +
  utime.sleep_ms(1000)
 +
  while True:     
 +
    if uart.any():
 +
      uart.write('AT+LOCATION=2\r\n') #Get GPS address
 +
      bin_data = uart.readline()
 +
      msg = len(bin_data)
 +
      print(bin_data)
 +
      mystr = str(bin_data[0:msg-2],'utf-8')
 +
      lcd.fill(0)
 +
      text(mystr,0,0) 
 +
      lcd.show()
 +
    utime.sleep_ms(2000)
 +
</pre>
 +
4. The screen displays NEMA message.<br>
 +
[[File:MakePython_A9G_5.JPG|700px]]<br>
 +
<br>
 +
5. The screen displays GPS address.<br>
 +
[[File:MakePython_A9G_20.JPG|700px]]<br>
 +
*Location information may not be received indoors, and GPS NOT FIX NOW will be displayed on the screen if reception fails.<br>
 +
<br>
 +
6. We can show our location where we are in https://www.gps-coordinates.net/.<br>
 +
[[File:MakePython_A9G_21.JPG|900px]]<br>
  
[[File:Maduino_Zero_A9G_3V3_30.JPG|700px]]<br>
+
===Project_2: Display SMS message on OLED display===
Check the Pin J3 on Maduino Zero A9G v3.3 (GND/3V3/SCL/SDA), as the pins definition compatible, plug the OLED directly on J3.<br>
+
Please note that each text message may require some fees depending on your local GSM operator, make sure the SIM card is active, and leave enough money for this application.<br>
[[File:Maduino_Zero_A9G_3V3_21.JPG|700px]]<br>
 
And install the SSD1306 OLED driver library<br>
 
[[File:Maduino_Zero_A9G_3V3_22.JPG|700px]]<br>
 
[[File:Maduino_Zero_A9G_3V3_23.JPG|700px]]<br>
 
 
 
And then upload our example ([https://github.com/Makerfabs/Maduino-Zero-A9G A9G_GPS_OLED.ino]) to Maduino board, the result shows the location on the OLED screen:<br>
 
[[File:Maduino_Zero_A9G_3V3_24.JPG|700px]]<br>
 
And we can show the humidity and temperature on OLED screen too, Follow me to finish it.<br>
 
Install DHT library.<br>
 
[[File:Maduino_Zero_A9G_3V3_25.JPG|700px]]<br>
 
 
 
Hardware Connection:<br>
 
Connect the simple sensor to Maduino boards as following:<br>
 
{| cellspacing="0" cellpadding="5" border="1"
 
|-
 
| align="center" width="150" | '''Sensor'''
 
| align="center" width="200" | '''Maduino Pins'''
 
 
 
|- style="font-size: 90%"
 
| align="center" | Sensor's GND
 
| align="center" | Maduino's GND
 
|- style="font-size: 90%"
 
| align="center" | Sensor's DATA
 
| align="center" | Maduino's D6
 
|- style="font-size: 90%"
 
| align="center" | Sensor's Vcc
 
| align="center" | Maduino's Vcc
 
|}
 
 
 
[[File:Maduino_Zero_A9G_3V3_26.JPG|700px]]<br>
 
Insert the I2C SSD1306 OLED:<br>
 
[[File:Maduino_Zero_A9G_3V3_27.JPG|700px]]<br>
 
 
 
Upload the code [https://github.com/Makerfabs/Maduino-Zero-A9G A9G_DHT11_OLED.ino] to the board. We can see the humidity and temperature on the screen.<br>
 
[[File:Maduino_Zero_A9G_3V3_28.JPG|700px]]<br>
 
 
<br>
 
<br>
Project_2: A Simple IOT Project- SMS Remote Control<br>
+
This example also uses MakePython ESP32 for MicroPython programming.<br>
 
+
Step:<br>
Note that some fee maybe needed for each SMS depends on your local GSM Operator, make sure that the SIM Card is active, support SMS and enough money left for this application.<br>  
+
1. Plug in the GSM antenna<br>
1. Hardware connection<br>
+
2. Insert a mini SIM card(GPS does work without a SIM)<br>
Connect the LED to Maduino boards as following:<br>
+
[[File:MakePython_A9G_6.JPG|700px]]<br>
{| cellspacing="0" cellpadding="5" border="1"
+
3. Plug to MakePython ESP32, connect the USB to the PC.<br>
|-
+
4. Sample code, or you can get it from here: [https://github.com/Makerfabs/MakePython-A9G A9G_GSM.py]<br>
| align="center" width="150" | '''LED'''
+
<pre>
| align="center" width="200" | '''Maduino Pins'''
+
from machine import UART,Pin,I2C
 
+
import machine
|- style="font-size: 90%"
+
import ssd1306
| align="center" | Red PIN
+
import utime
| align="center" | Maduino's D2
+
uart = UART(2, baudrate=115200, rx=21, tx=22,timeout=10)
|- style="font-size: 90%"
+
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)      #Init i2c
| align="center" | Green PIN
+
lcd=ssd1306.SSD1306_I2C(128,64,i2c)         
| align="center" | Maduino's D3
+
A9G_RESET_PIN = Pin(33, Pin.OUT)
|- style="font-size: 90%"
+
A9G_RESET_PIN.value(0)           
| align="center" | Blue PIN
+
utime.sleep_ms(2000)
| align="center" | Maduino's D4
+
A9G_PWR_KEY = Pin(27, Pin.OUT)
|- style="font-size: 90%"
+
A9G_PWR_KEY.value(0)
| align="center" | Sensor's Vcc
+
utime.sleep_ms(2000)
| align="center" | 3V3
+
A9G_PWR_KEY.value(1)
|}
+
utime.sleep_ms(20000)
 
+
p=0
[[File:Maduino_Zero_A9G_3V3_29.JPG|700px]]<br>
+
def text(string,c=0,r=0):  
 
+
    global p
2. Upload [https://github.com/Makerfabs/Maduino-Zero-A9G A9G_SMS_Control.ino] to the board. Using your phone send a message to the SIM card you insert in board for turning on or turning off the led, such as ‘onr’ to turn the red led on, ‘offr’ to turn the red led off.<br>
+
    if p>80:
[[File:Maduino_Zero_A9G_3V3_45.JPG|700px]]<br>
+
        p=0
 
+
        lcd.fill(0)
Supported messages in the code.<br>
+
    colum=int(len(string)/15)+2
{| cellspacing="0" cellpadding="5" border="1"
+
    i=0
|-
+
    for a in range(0,colum):
| align="center" width="150" | '''Message'''
+
        lcd.text(string[i:i+15],c,a*8)
| align="center" width="200" | '''Result'''
+
        i=i+15
 
+
    lcd.show()
|- style="font-size: 90%"
+
if True:
| align="center" | onr
+
    uart.write('AT+GPS=0\r\n')#1: turn on GPS  0:Turn off GPS
| align="center" | turn the red led on
+
    utime.sleep_ms(1000)
|- style="font-size: 90%"
+
    uart.write('AT+CCID\r\n')
| align="center" | ong
+
    utime.sleep_ms(1000)
| align="center" | turn the green led on
+
    uart.write('AT+CREG?\r\n')
|- style="font-size: 90%"
+
    utime.sleep_ms(1000)
| align="center" | onb
+
    uart.write('AT+CGATT=1\r\n')
| align="center" | turn the blue led on
+
    utime.sleep_ms(1000)
|- style="font-size: 90%"
+
    uart.write('AT+CGACT=1,1\r\n')
| align="center" | offr
+
    utime.sleep_ms(1000)
| align="center" | turn the red led off
+
    uart.write('AT+CGDCONT=1,\"IP\",\"CMNET\"\r\n')
|- style="font-size: 90%"
+
    utime.sleep_ms(1000)
| align="center" | offg
+
    uart.write('AT+CSQ\r\n')
| align="center" | turn the green led off
+
    utime.sleep_ms(1000)
|- style="font-size: 90%"
+
    uart.write('AT+CPMS="SM","SM","SM"\r\n')
| align="center" | offb
+
    utime.sleep_ms(1000)
| align="center" | turn the blue led off
+
    uart.write('AT+CMGF=1\r\n')
|}
+
    utime.sleep_ms(1000)
 
+
    #uart.write('AT+CMGL="ALL"\r\n')
Then we can see the related LED on or off<br>
+
    #utime.sleep_ms(1000)
[[File:Maduino_Zero_A9G_3V3_32.JPG|700px]]<br>
+
    while True:    
 
+
      if uart.any():
Also, We can see the serial monitor shows the log when operate. That we can make sure the SIM card received a message.<br>
+
        lcd.fill(0)
[[File:Maduino_Zero_A9G_3V3_33.JPG|700px]]<br>
+
        uart.write('AT+CMGR=1\r\n')
 
+
        utime.sleep_ms(1000)
Project_3: A Simple IOT Project- Environment Remote<br>
+
        bin_data = uart.readline()
 
+
        print(bin_data)
Monitor<br>
+
        text(bin_data,0,0)
A9 or A9G Module is a GPRS/GSM+ GPS Quad-band module, with this board, we can use it as a GPS tracker, data acquisition, remote control and a lot of IOT project or smart home project. In this project, we will detect the humidity/temperature of our soldering lab, and reports it to internet thingspeak(https://thingspeak.com/channels/920821), so we can monitor the lab/home/office/farm environment remotely.<br>
+
        lcd.show()
We use the humidity /temperature sensor at:<br> 
+
      utime.sleep_ms(2000)
https://www.makerfabs.com/dht11-temperature-humidity-module.html
+
</pre>
 
+
4. The screen displays the phone number, time and information for sending SMS.<br>
1. Sensor Connection
+
[[File:MakePython_A9G_7.JPG|500px]]<br>
Connect the simple sensor to Maduino boards as following:
+
*Mobile phone to send SMS.<br>
{| cellspacing="0" cellpadding="5" border="1"
+
[[File:MakePython_A9G_8.JPG|700px]]<br>
|-
+
*Display the phone number and time of sending SMS<br>
| align="center" width="150" | '''Sensor'''  
+
[[File:MakePython_A9G_10.JPG|700px]]<br>
| align="center" width="200" | '''Maduino Pins'''  
+
*Show received content
 
 
|- style="font-size: 90%"
 
| align="center" | Sensor's GND
 
| align="center" | Maduino's GND
 
|- style="font-size: 90%"
 
| align="center" | Sensor's DATA
 
| align="center" | Maduino's D6
 
|- style="font-size: 90%"
 
| align="center" | Sensor's Vcc
 
| align="center" | Maduino's Vcc
 
|}
 
[[File:Maduino_Zero_A9G_3V3_34.JPG|700px]]<br>
 
2. Insert a Micro SIM card and GSM antenna, power the Maduino with battery or MicroUSB. The Maduino Zero A9/A9G board uses the micro SIM card that is widely used in Android phone, install the Micro SIM card to the holder as below picture, and also the GSM antenna.<br>
 
[[File:Maduino_Zero_A9G_3V3_35.JPG|700px]]<br>
 
Note that some fee maybe needed for each SMS or GPRS depends on your local GSM Operator, make sure that the SIM Card is active and enough money left for this application.<br>
 
3.Programming<br>
 
3.1 Sign up an account in https://thingspeak.com/ . If you already have one, sign in directly.<br>
 
3.2 Click New Channel to create a new ThingSpeak channel.<br>
 
[[File:Maduino_Zero_A9G_3V3_36.JPG|700px]]<br>
 
3.3 Input name, Description, Select Field 1, Field 2, Field3, Field4.<br>
 
[[File:Maduino_Zero_A9G_3V3_37.JPG|700px]]<br>
 
Note: Field 3 and Field4 are reserved for other application.<br>
 
Then save channel on the bottom.<br>
 
[[File:Maduino_Zero_A9G_3V3_38.JPG|700px]]<br>
 
 
 
3.4 Copy your API Key, we will instead it in the code [https://github.com/Makerfabs/Maduino-Zero-A9G A9G_DHT_GSM.ino]<br>
 
[[File:Maduino_Zero_A9G_3V3_39.JPG|700px]]<br>
 
[[File:Maduino_Zero_A9G_3V3_40.JPG|700px]]<br>
 
Below are some ways to use the API, what we used is Write A Channel Feed<br>
 
[[File:Maduino_Zero_A9G_3V3_41.JPG|700px]]<br>
 
Select the right port and Arduino board: Arduino Zero(Native USB Port) to upload the code([https://github.com/Makerfabs/Maduino-Zero-A9G A9G_DHT_GSM.ino]) to Maduino Zero A9/A9G board<br>
 
[[File:Maduino_Zero_A9G_3V3_42.JPG|700px]]<br>
 
If demo code run successful, you could refresh your cannel on thingspeak.com to see the result.<br>
 
https://thingspeak.com/channels/920821<br>
 
[[File:Maduino_Zero_A9G_3V3_43.JPG|700px]]<br>
 
Have fun in making Maduino!<br>
 
You can get the code from our [https://github.com/Makerfabs/Maduino-Zero-A9G Github.]<br>
 
  
 
== FAQ  ==
 
== FAQ  ==
Line 295: Line 214:
 
== Resources ==
 
== Resources ==
 
*[https://www.makerfabs.com/wiki/images/a/a0/Gprs_series_module_at_instruction_set_v1.0%28A9_A9G%29.pdf AT Command Set]
 
*[https://www.makerfabs.com/wiki/images/a/a0/Gprs_series_module_at_instruction_set_v1.0%28A9_A9G%29.pdf AT Command Set]
*[https://makerfabs.com/wiki/images/0/02/Maduino_Zero_A9G_v1.0.pdf v1.0 Schematic]
+
*[https://www.makerfabs.com/wiki/images/2/22/MakePython_A9G_GPS_Tracker_V1.0.pdf V1.0 Schematic]
*[https://makerfabs.com/wiki/images/2/28/Maduino_Zero_A9G_v3.3.pdf v3.3 Schematic]
 

Latest revision as of 08:07, 9 June 2020

Introduction

MakePython A9G is an IOT for GPRS / GSM + GPS module, users can use MicroPython to program it, which is very easy, especially for non-programmers. There is also a user guide to learn how to use the board to create the first IOT project, which allows beginners to quickly learn hardware and programming skills.

With this board, you will easy to add text, SMS and data to your project. It is good for your smart home project or GPS tracker and so on.

Model: OAC010A9G
MakePython 0 A9G.jpg

Features

  • Micro SIM connector
  • Support AT Command
  • Quad-band: 850/900/1800/1900Mz
  • Support GPS
  • Support GPRS data traffic, the maximum data rate, download 85.6Kbps, upload 42.8Kbps
  • Support SMS text messaging
  • Support Micro SD Card
  • Working Temperature: -40 – 85℃
  • Size: 70*32.6mm

Interface Function

MakePython A9G 2.JPG
①BAT: 3.7V Lipo battery connector
②CHRG: 5V power input
③Micro SD Card Holder
④Micro SIM Card Holder
⑤A9G Module
⑥GSM: GSM Antenna IPX Interface
⑦GPS: GPS Antenna IPX Interface

Usage

Warning: Don't operate when in power supply on (That is, don’t plug or unplug the Antenna ,SIM Cars, SD Card , in case of short-circuit that may burn the IC down.)

Related instructions

AT+GPS=1   #1:Turn the GPS on, 0:Turn the GPS off
AT+CCID	   #Query SIM, unique serial number, can be used to judge whether the card is normal
AT+CREG?   #Check the registration status of the network
AT+CSQ	   #Query signal strength, the first parameter is the signal strength value
AT+CGATT=1  #Attach to the network, if you need to access the Internet, this command is mandatory
AT+CGDCONT=1,”IP”,”CMNET”	#Set PDP parameters
AT+CGACT=1,1	  #Activate PDP, you can go online after activation
AT+GPSRD=N	  #N is a number indicating that a NEMA message is read every N seconds
AT+GPSRD=0	  #Stop reporting
AT+LOCATION=2   #Get the address information of GPS, as long as the GPS can see the satellite before returning, otherwise it will return GPS NOT FIX NOW
AT+CPMS="SM","SM","SM"   #Set up SMS storage unit
AT+CMGF=0/1		 #Set the SMS format, 1 for text format reading, 0 for pud format reading
AT+CMGR=x		 #Read SMS content, x is the number of SMS
AT+CMGL=4/"ALL"	  #View the SMS list. The reading parameter in PUD format is 4, and the reading parameter in txt format is "ALL"
AT+CMGD=1		#Delete the text message. If you use AT + CMGD = 1,4 then delete all SMS

Project_1: Shows the GPS location on OLED display

Attention: To get GPS location, please ensure you are outdoor, and plug the GPS Antenna. Indoor may get the incorrect location or no location information.

The example uses MicroPython programming, very simple and easy to understand.
This MakePython A9G can do nothing. It needs a microcontroller like ESP32 to drive it. The following two routines are implemented by A9G with MakePython ESP32, they can be directly combined to achieve various functions.
MakePython A9G 3.JPG
You can get MakePython ESP32 from here: https://www.makerfabs.com/makepython-esp32.html
Step:
1. Plug in the GPS antenna
2. Plug to MakePython ESP32, connect the USB to the PC.
MakePython A9G 4.JPG
3. Sample code, or you can get it from here: A9G_GPS.py

from machine import UART,Pin,I2C
import machine
import ssd1306	
import utime

uart = UART(2, baudrate=115200, rx=21, tx=22,timeout=10)
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)      #Init i2c
lcd=ssd1306.SSD1306_I2C(128,64,i2c)           
lcd.text('Hello, Makerfabs',0,0)
lcd.text('waiting...',0,8)
lcd.show() 

A9G_RESET_PIN = Pin(33, Pin.OUT) 
A9G_RESET_PIN.value(0)             #set pin to low

utime.sleep_ms(2000)
A9G_PWR_KEY = Pin(27, Pin.OUT) 
A9G_PWR_KEY.value(0)
utime.sleep_ms(2000)
A9G_PWR_KEY.value(1)
utime.sleep_ms(20000)

#Display line wrap
p=0 
def text(string,c=0,r=0): 
    global p 
    if p>80: 
        p=0
        lcd.fill(0) 
    colum=int(len(string)/15)+2 
    i=0
    for a in range(0,colum):
        lcd.text(string[i:i+15],c,a*8)
        i=i+15 
    lcd.show() 

if True:
  lcd.fill(0)
  uart.write('AT+GPS=1\r\n')#1: turn on GPS  0:Turn off GPS
  utime.sleep_ms(1000)
  uart.write('AT+GPSRD=10\r\n')
  utime.sleep_ms(1000)
  uart.write('AT+LOCATION=2\r\n')
  utime.sleep_ms(1000)
  while True:      
    if uart.any():
      uart.write('AT+LOCATION=2\r\n') #Get GPS address
      bin_data = uart.readline()
      msg = len(bin_data)
      print(bin_data)
      mystr = str(bin_data[0:msg-2],'utf-8')
      lcd.fill(0)
      text(mystr,0,0)  
      lcd.show() 
    utime.sleep_ms(2000)

4. The screen displays NEMA message.
MakePython A9G 5.JPG

5. The screen displays GPS address.
MakePython A9G 20.JPG

  • Location information may not be received indoors, and GPS NOT FIX NOW will be displayed on the screen if reception fails.


6. We can show our location where we are in https://www.gps-coordinates.net/.
MakePython A9G 21.JPG

Project_2: Display SMS message on OLED display

Please note that each text message may require some fees depending on your local GSM operator, make sure the SIM card is active, and leave enough money for this application.

This example also uses MakePython ESP32 for MicroPython programming.
Step:
1. Plug in the GSM antenna
2. Insert a mini SIM card(GPS does work without a SIM)
MakePython A9G 6.JPG
3. Plug to MakePython ESP32, connect the USB to the PC.
4. Sample code, or you can get it from here: A9G_GSM.py

from machine import UART,Pin,I2C
import machine
import ssd1306
import utime
uart = UART(2, baudrate=115200, rx=21, tx=22,timeout=10)
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)      #Init i2c
lcd=ssd1306.SSD1306_I2C(128,64,i2c)           
A9G_RESET_PIN = Pin(33, Pin.OUT) 
A9G_RESET_PIN.value(0)             
utime.sleep_ms(2000)
A9G_PWR_KEY = Pin(27, Pin.OUT) 
A9G_PWR_KEY.value(0)
utime.sleep_ms(2000)
A9G_PWR_KEY.value(1)
utime.sleep_ms(20000)
p=0 
def text(string,c=0,r=0): 
    global p 
    if p>80: 
        p=0
        lcd.fill(0) 
    colum=int(len(string)/15)+2 
    i=0
    for a in range(0,colum):
        lcd.text(string[i:i+15],c,a*8)
        i=i+15 
    lcd.show() 
if True:
    uart.write('AT+GPS=0\r\n')#1: turn on GPS  0:Turn off GPS
    utime.sleep_ms(1000)
    uart.write('AT+CCID\r\n')
    utime.sleep_ms(1000)
    uart.write('AT+CREG?\r\n')
    utime.sleep_ms(1000)
    uart.write('AT+CGATT=1\r\n')
    utime.sleep_ms(1000)
    uart.write('AT+CGACT=1,1\r\n')
    utime.sleep_ms(1000)
    uart.write('AT+CGDCONT=1,\"IP\",\"CMNET\"\r\n')
    utime.sleep_ms(1000)
    uart.write('AT+CSQ\r\n')
    utime.sleep_ms(1000)
    uart.write('AT+CPMS="SM","SM","SM"\r\n')
    utime.sleep_ms(1000)
    uart.write('AT+CMGF=1\r\n')
    utime.sleep_ms(1000)
    #uart.write('AT+CMGL="ALL"\r\n')
    #utime.sleep_ms(1000)
    while True:      
      if uart.any():
        lcd.fill(0)
        uart.write('AT+CMGR=1\r\n')
        utime.sleep_ms(1000)
        bin_data = uart.readline()
        print(bin_data)
        text(bin_data,0,0)
        lcd.show() 
      utime.sleep_ms(2000)

4. The screen displays the phone number, time and information for sending SMS.
MakePython A9G 7.JPG

  • Mobile phone to send SMS.

MakePython A9G 8.JPG

  • Display the phone number and time of sending SMS

MakePython A9G 10.JPG

  • Show received content

FAQ

You can list your questions here or contact with support@makerfabs.com for technology support.

Resources