Difference between revisions of "Template:Pico-SIM868-Manual"

From Waveshare Wiki
Jump to: navigation, search
Line 44: Line 44:
  
 
====Expected result====
 
====Expected result====
[[File:SIM868 PICO GPS.png|500px]]
+
[[File:SIM868 PICO GPS.png|1000px]]
 +
 
 
===Taking calls===
 
===Taking calls===
 
This example mainly demonstrates the phone call test. The module has an onboard microphone so that calls can be made directly to each other, and speakers are needed to hear the sound.<br>
 
This example mainly demonstrates the phone call test. The module has an onboard microphone so that calls can be made directly to each other, and speakers are needed to hear the sound.<br>

Revision as of 03:01, 11 May 2022

Hardware connection

  • Pico-SIM868-GSM/GPRS/GNSS x 1 (Pin header should be soldered)
  • Raspberry Pi Pico x 1
  • SIM卡 x 1 (Support supports 2G service)
  • Micro USB cable x 1

Pico-SIM868-GSM-GPRS-GNSS-5.jpg

Description:

If you need to use audio, you need to connect a speaker.
When in use, it is recommended to connect to the lithium battery: when there is no additional USB power supply, turn on the USB to turn off the lithium battery power supply, switch to VBAT to use the lithium battery power supply; When connected to USB power, the USB can be used to charge the lithium battery, power the Pico or write firmware and programs.

Python Examples

Use in Windows

  • 1. Press and hold the BOOTSET button on the Pico board, connect the pico to the USB port of the computer through the Micro USB cable, and release the button after the computer recognizes a removable hard disk (RPI-RP2).
  • 2. Copy the pico_micropython_xxxxxxxx.uf2 file in the python directory to the recognized removable disk (RPI-RP2)
  • 3. Open Thonny IDE (note: use the latest version of Thonny, otherwise there is no Pico support package, the latest version under Windows is v3.3.3)
  • 4. Click Tools->Settings->Interpreter, select Pico and the corresponding port as shown in the figure

Pythonwin.png
5.File->Open->main.py, click to run, as shown below:
Main.png
This demo provides a simple program...

Use in Raspberry Pi environment

  • 1. The process of flashing the firmware is the same as that on Windows, you can choose to copy the pico_micropython_xxxxxxxx.uf2 file into pico on PC or Raspberry Pi.
  • 2. Open Thonny IDE on the Raspberry Pi Mountain (click the Raspberry logo -> Programming -> Thonny Python IDE ), you can check the version information in Help->About Thonny

To make sure your version has Pico support package, you can also click Tools -> Options... -> Interpreter to select MicroPython (Raspberry Pi Pico and ttyACM0 port
as the picture shows:
Inter.png
If your current Thonny version does not have the pico support package, enter the following command to update the Thonny IDE

sudo apt upgrade thonny

3. Click File->Open...->python/main.py to run the script


AT Test

This demo is mainly to facilitate the user can through the Thony software, directly test and verify the AT instruction transceiving module. The main program will start the module directly first and then check the network condition. After that, it will check the AT instructions entered by the user, send them to the module through the serial port, and then send the AT instructions back to the Pico serial port for printing.
For more details of AT commands, please check the manual:File:SIM800 Series_AT Command Manual_V1.11.pdf

Expected result

SIM868 AT Test.png

GPS Positioning

This example mainly demonstrates GPS positioning-related tests. To perform this example, the GPS antenna receiver must be placed outside (or in a window where the sky can be seen), and the GPS location cannot be obtained on rainy days。
For more details of AT commands, please check the manual:File:SIM868 Series_GNSS_Application Note_V1.02.pdf

Expected result

SIM868 PICO GPS.png

Taking calls

This example mainly demonstrates the phone call test. The module has an onboard microphone so that calls can be made directly to each other, and speakers are needed to hear the sound.
For more details of AT commands, please check the manual:File:SIM800 Series_AT Command Manual_V1.11.pdf

Expected result

SIM868 Phone call.png

HTTP

Description

In this example, Raspberry Pico is connected to the Internet through NB-IoT and gets the weather information from the weather website through HTTP GET. Meanwhile, the temperature information on Pico is pushed to the server through HTTP POST.
Users can access the website and view the data uploaded in real-time. The software schematic is as follows:
Pico-SIM7020-HTTP-demo-diagram.png

Server Web Page Deployment

User http://pico.wiki/esp-chart.php as example.
Pico-SIM7020-HTTP-Demo-2.png
1、Server setup PHP, mysql and other environment, create database files. For example:

  • Database:example_esp_data
  • Password:your_password
  • user name:your_username
  • Create database table:
CREATE TABLE Sensor (
   id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
   value1 VARCHAR(10),
   value2 VARCHAR(10),
   value3 VARCHAR(10),
   reading_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)

2、Example PHP files on the server are post-data.php and esp-chart.php

  • post-data.php: HTTP POST API that the SIM7080G module can call to POST data to the server.
  • esp-chart.php: The latest data uploaded by SIM7080G can be obtained from a web page accessed by the client and displayed in a graph.

Pico software setup

Download python example:Demo codes ,Part of the HTTP codes:

  • HTTP GET:
# HTTP GET TEST
def http_get():
   send_at('AT+HTTPINIT', 'OK')
   send_at('AT+HTTPPARA=\"CID\",1', 'OK')
   send_at('AT+HTTPPARA=\"URL\",\"'+http_get_server[0]+http_get_server[1]+'\"', 'OK')
   if send_at('AT+HTTPACTION=0', '200', 5000):
       uart.write(bytearray(b'AT+HTTPREAD\r\n'))
       rec_buff = wait_resp_info(8000)
       print("resp is :", rec_buff.decode())
   else:
       print("Get HTTP failed, please check and try again\n")
   send_at('AT+HTTPTERM', 'OK')
  • HTTP POST:
  1. HTTP POST TEST
def http_post():
   send_at('AT+HTTPINIT', 'OK')
   send_at('AT+HTTPPARA=\"CID\",1', 'OK')
   send_at('AT+HTTPPARA=\"URL\",\"'+http_post_server[0]+http_post_server[1]+'\"', 'OK')
   send_at('AT+HTTPPARA=\"CONTENT\",\"' + http_content_type + '\"', 'OK')
   if send_at('AT+HTTPDATA=62,8000', 'DOWNLOAD', 3000):
       uart.write(bytearray(http_post_tmp))
       utime.sleep(5)
       rec_buff = wait_resp_info()
       if 'OK' in rec_buff.decode():
           print("UART data is read!\n")
       if send_at('AT+HTTPACTION=1', '200', 8000):
           print("POST successfully!\n")
       else:
           print("POST failed\n")
       send_at('AT+HTTPTERM', 'OK')
   else:
       print("HTTP Post failed,please try again!\n")

Expected result



Results of web page access on the server:http://pico.wiki/esp-chart.php

SIM868 HTTP POST Result mark.png