{"id":13801710,"url":"https://github.com/JiekangHuang/MicroPython-AM7020","last_synced_at":"2025-05-13T11:31:44.318Z","repository":{"id":57441477,"uuid":"348234782","full_name":"JiekangHuang/MicroPython-AM7020","owner":"JiekangHuang","description":"MicroPython-AM7020","archived":false,"fork":false,"pushed_at":"2021-03-29T09:01:43.000Z","size":2519,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T06:41:14.743Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JiekangHuang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-16T06:13:54.000Z","updated_at":"2023-08-11T08:19:37.000Z","dependencies_parsed_at":"2022-09-06T02:01:34.106Z","dependency_job_id":null,"html_url":"https://github.com/JiekangHuang/MicroPython-AM7020","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiekangHuang%2FMicroPython-AM7020","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiekangHuang%2FMicroPython-AM7020/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiekangHuang%2FMicroPython-AM7020/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiekangHuang%2FMicroPython-AM7020/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JiekangHuang","download_url":"https://codeload.github.com/JiekangHuang/MicroPython-AM7020/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253553949,"owners_count":21926606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:26.194Z","updated_at":"2025-05-13T11:31:39.304Z","avatar_url":"https://github.com/JiekangHuang.png","language":"Python","readme":"# AM7020 MicroPython 範例程式碼\n [AM7020](https://atticedu.com/index.php/am7020.html) (SIMCOM SIM7020E) 窄頻物聯網(NBIoT)模組 MicroPython 範例程式碼\n \n  ![AM7020](images/am7020_front.jpg)\n\n Installation\n ------------\n\n To install am7020:\n\n ```python\n import upip\n upip.install('micropython-am7020')\n ```\n or\n ```console\n $ ampy -p COMX put am7020\n ```\n ## MQTT 教學說明\n Declare nb and mqtt client instance using:\n ```Python\n nb = AM7020NB(uart_num=0, baudrate=115200, tx_pin=16, rx_pin=17, reset_pin=5, dump_at_cmd=False)\n mqtt = AM7020MQTT(nb)\n ```\n Initialize nb and connect to NBIOT base station:\n ```Python\n while((not nb.init() or (not nb.nbiotConnect(apn, band)))):\n     print(\".\")\n \n while(not nb.waitForNetwork()):\n     print(\".\")\n     sleep(5)\n ```\n Check MQTT connection status and connect to Broker:\n ```Python\n if(not mqtt.chkConnBroker()):\n     mqtt.connBroker(MQTT_BROKER, 1883, mqtt_id=\"MY_AM7020_TEST_MQTTID\")\n ```\n Publish and subscribe:\n ```Python\n mqtt.publish(TEST_TOPIC, \"Hello MQTT\")\n \n def callback1(msg):\n     print(TEST_TOPIC, \":\", msg)\n mqtt.subscribe(TEST_TOPIC, callback1)\n ```\n Listen for messages from the broker:\n ```Python\n mqtt.procSubs()\n ```\n ## HTTP 教學說明\n Declare nb and http client instance using:\n ```Python\n nb = AM7020NB(uart_num=0, baudrate=115200, tx_pin=16, rx_pin=17, reset_pin=5, dump_at_cmd=False)\n http = AM7020HTTP(nb, HTTP_SERVER)\n ```\n Initialize nb and connect to NBIOT base station:\n ```Python\n while((not nb.init() or (not nb.nbiotConnect(apn, band)))):\n     print(\".\")\n \n while(not nb.waitForNetwork()):\n     print(\".\")\n     sleep(5)\n ```\n HTTP GET and POST:\n ```Python\n http.get(HTTP_GET_API)\n state_code = http.responseStatusCode()\n body = http.responseBody()\n \n http.post(HTTP_POST_API, content_type=\"application/json\", body=\"{\\\"value\\\": \\\"POST\\\"}\")\n state_code = http.responseStatusCode()\n body = http.responseBody()\n ```\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJiekangHuang%2FMicroPython-AM7020","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJiekangHuang%2FMicroPython-AM7020","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJiekangHuang%2FMicroPython-AM7020/lists"}