{"id":18565579,"url":"https://github.com/leech001/sim800mqtt","last_synced_at":"2025-07-23T04:33:45.804Z","repository":{"id":56008208,"uuid":"232058344","full_name":"leech001/SIM800MQTT","owner":"leech001","description":"STM32 HAL library for SIM800 release MQTT client over AT command","archived":false,"fork":false,"pushed_at":"2021-10-28T03:48:40.000Z","size":1008,"stargazers_count":137,"open_issues_count":0,"forks_count":48,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T19:04:59.062Z","etag":null,"topics":["at","at-command","bluepill","gprs","gprssim800","hal","mqtt","mqtt-client","sim800","stm32"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leech001.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-01-06T08:37:34.000Z","updated_at":"2024-11-07T14:07:27.000Z","dependencies_parsed_at":"2022-08-15T11:20:17.816Z","dependency_job_id":null,"html_url":"https://github.com/leech001/SIM800MQTT","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/leech001/SIM800MQTT","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leech001%2FSIM800MQTT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leech001%2FSIM800MQTT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leech001%2FSIM800MQTT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leech001%2FSIM800MQTT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leech001","download_url":"https://codeload.github.com/leech001/SIM800MQTT/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leech001%2FSIM800MQTT/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266618800,"owners_count":23957273,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["at","at-command","bluepill","gprs","gprssim800","hal","mqtt","mqtt-client","sim800","stm32"],"created_at":"2024-11-06T22:19:27.311Z","updated_at":"2025-07-23T04:33:45.779Z","avatar_url":"https://github.com/leech001.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# STM32 HAL library for SIM800 (GPRS) release MQTT client  over AT command\n\nSimple C library (STM32 HAL) for working with the MQTT protocol through AT commands of the SIM800 (GPRS) module\nhttps://aliexpress.ru/item/32284560394.html?spm=a2g0s.9042311.0.0.34a833edF2cSsx\n\nConfigure STM32CubeMX by setting \"General peripheral Initalizion as a pair of '.c / .h' file per peripheral\" in the project settings.\n![photo](https://raw.githubusercontent.com/leech001/SIM800MQTT/master/img/ch_pair.png)\nRemember to enable global interrupts for your UART.\n![photo](https://raw.githubusercontent.com/leech001/SIM800MQTT/master/img/nvic.png)\nCopy the library header and source file to the appropriate project directories (Inc, Src).\nConfigure the UART port where your module is connected in the MQTTSim800.h file.\n```\n#define UART_SIM800 \u0026huart2\n#define FREERTOS 0\n#define CMD_DELAY 2000\n```\nIn the head file of your project (main.c), include the header file\n```\n/ * USER CODE BEGIN Includes * /\n#include \"MQTTSim800.h\"\n/ * USER CODE END Includes * /\n```\nIn the head file of your project (main.c), create SIM800 structure\n```\n/* USER CODE BEGIN PV */\nSIM800_t SIM800;\n/* USER CODE END PV */\n```\nadd function call Sim800_RxCallBack () to interrupt UART\n```\n/ * USER CODE BEGIN 0 * /\nvoid HAL_UART_RxCpltCallback(UART_HandleTypeDef * huart) {\n    if (huart == UART_SIM800) {\n        Sim800_RxCallBack();\n    }\n}\n/ * USER CODE END 0 * /\n```\nFill structure in the main (void) function section\n```\n/* USER CODE BEGIN 2 */\n    SIM800.sim.apn = \"internet\";\n    SIM800.sim.apn_user = \"\";\n    SIM800.sim.apn_pass = \"\";\n    SIM800.mqttServer.host = \"mqtt.mqtt.ru\";\n    SIM800.mqttServer.port = 1883;\n    SIM800.mqttClient.username = \"user\";\n    SIM800.mqttClient.pass = \"pass\";\n    SIM800.mqttClient.clientID = \"TestSub\";\n    SIM800.mqttClient.keepAliveInterval = 120;\n/* USER CODE END 2 */\n```\nadd the module initialization code in the main (void) function section\n```\n/ * USER CODE BEGIN 2 * /\n    MQTT_Init();\n/ * USER CODE END 2 * /\n```\nadd Subscription status\n```\n/ * USER CODE BEGIN 2 * /\n    uint8_t sub = 0;\n/ * USER CODE END 2 * /\n```\nadd a send topic \"STM32\" and value \"test\" to the server in an infinite while (1) loop, for example every 1 seconds.\nadd subscribe to topic \"test\" \n```\n /* Infinite loop */\n /* USER CODE BEGIN WHILE */\n while (1) {\n     if (SIM800.mqttServer.connect == 0) {\n         MQTT_Init();\n         sub = 0;\n     }\n     if (SIM800.mqttServer.connect == 1) {\n         if(sub == 0){\n             MQTT_Sub(\"test\");\n             sub = 1;\n         }\n         MQTT_Pub(\"STM32\", \"test\");\n\n         if(SIM800.mqttReceive.newEvent) {\n             unsigned char *topic = SIM800.mqttReceive.topic;\n             int payload = atoi(SIM800.mqttReceive.payload);\n             SIM800.mqttReceive.newEvent = 0;\n         }\n     }\n     HAL_Delay(1000);\n     /* USER CODE END WHILE */\n```\nThis completes the setup.\nCheck in loop SIM800.mqttReceive.newEvent for new publish events. Set to 0 (zero) while use new data.\n\nThe library also supports sending zero messages to the server to maintain a connection.\n```\nMQTT_PingReq();\n```\nThe library is implemented based on the code for generating MQTT packages of the project https://github.com/eclipse/paho.mqtt.embedded-c/tree/master/MQTTPacket\n\nThe library testing with https://github.com/r2axz/bluepill-serial-monster","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleech001%2Fsim800mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleech001%2Fsim800mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleech001%2Fsim800mqtt/lists"}