{"id":20186629,"url":"https://github.com/zimbora/esp32-freertos2","last_synced_at":"2025-03-03T06:46:15.959Z","repository":{"id":162040889,"uuid":"578142589","full_name":"zimbora/esp32-freeRTOS2","owner":"zimbora","description":"base firmware running on esp32 to accelerate IoT deployment for any device","archived":false,"fork":false,"pushed_at":"2025-02-13T11:50:16.000Z","size":13364,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T12:35:11.586Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/zimbora.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-14T11:05:03.000Z","updated_at":"2025-02-13T11:50:20.000Z","dependencies_parsed_at":"2024-12-14T18:35:04.043Z","dependency_job_id":"4df2b3c6-3603-40a0-856f-dd98f25e54bc","html_url":"https://github.com/zimbora/esp32-freeRTOS2","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zimbora%2Fesp32-freeRTOS2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zimbora%2Fesp32-freeRTOS2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zimbora%2Fesp32-freeRTOS2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zimbora%2Fesp32-freeRTOS2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zimbora","download_url":"https://codeload.github.com/zimbora/esp32-freeRTOS2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241622594,"owners_count":19992502,"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-11-14T03:18:01.917Z","updated_at":"2025-03-03T06:46:15.932Z","avatar_url":"https://github.com/zimbora.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# freeRTOS2\n\n## IMPORTANT\n  !! now() method cannot be called outside main process\n\n## How to use source code\n  - Fork the repository\n  - Edit FW_MODEL in src/app/user/app_package.h file\n  - Edit credentials.h file according to your needs\n  - Use app.cpp and app.h to write your own code\n  - If new changes are available sync it with main repo\nNote: all changes are made outside src/app folder\n\n## Build\n  \n### Linux and MacOs\n  \u003e\u003e ./deploy.sh\n\n### Using docker\n  \u003e\u003e ./docker.sh\n\n### Arduino\n  - Update your esp32 board manager version\n  - Install dependent libraries from your Arduino libraries manager  \n  - Compile code. Check for correct output\n\n### Github Actions\n  - Change .github/workflows/docker-image.yml\n  - Add your GITHUB_TOKEN to secrets\n  - Push commit to a new branch or create a new Tag\n  - Check generated files on Actions/Artifacts or release\n\n## package.h\n  \n  !! Do not edit this file. Use app_package.h file\n\n## src/app/user/app_package.h\n  \n  Edit the available macros\n\n### Connection\n  - ENABLE_LTE - Uses BG95 modem\n  - ENABLE_BLE - Uses BLE to set wifi credentials\n  - ENABLE_AP - Launches Access Point and http server on IP 192.168.4.1 to set wifi credentials otherwise try to connect to default wifi credentials and credentials stored on sysfile at each 30s. \n      Default ssid and password defined on src/app/user/credentials.h file\n\n### TASKS\n  select just one option:\n  - FAST_APP // App runing on main thread\n  - THREAD_APP // 1 dedicated thread for app\n  - SYNCHED_APP // App running on core thread\n\n#### Configurations\n  NETWORK_CORE_TASK_SIZE 2048*8\n  NETWORK_CORE_TASK_PRIORITY 3\n\n  NETWORK_LTE_TASK_SIZE 2048*4\n  NETWORK_LTE_TASK_PRIORITY 2\n\n  NETWORK_APP_TASK_SIZE 2048*4\n  NETWORK_APP_TASK_PRIORITY 1\n\n### Features\n  - ENABLE_JS // JavaScript for user runtime code\n  - EXT_SERIAL_COMM // uart2 assigned to Serial1\n  - ENABLE_RS485 // enable rs485 module on Serial1\n  - DIGITAL_COUNTERS\n\n### Ios\n  Edit or add your IOs according to your needs\n\n## src/app/user/credentials.h\n\n### Default credentials\n'''\n  #define FW_AR_FILENAME \"/etc/settings/ar.txt\"\n  #define FW_ALARM_FILENAME \"/etc/settings/alarm.txt\"\n  #define FW_JS_FILENAME \"/etc/settings/js.txt\"\n\n  #define APP_PATH_SETTINGS \"/home/app/settings\"\n  #define APP_SETTINGS_FILENAME \"/home/app/settings/app.txt\"\n  #define APP_PATH_RECORDS \"/home/app/records\"\n  #define APP_CALIB_FILENAME \"/home/app/calib.txt\"\n  #define APP_ACCUM_FILENAME \"/home/app/accum.txt\"\n  #define APP_ACCUM_TP_FILENAME \"/home/app/accumtp.txt\"\n\n  #define WIFI_SSID \"inlocAP\"\n  #define WIFI_PASSWORD \"inlocAPpwd\"\n\n  #define MQTT_HOST_1 \"devices.dev.inloc.cloud\" // mac OS broker\n  #define MQTT_PORT_1 1883\n  #define MQTT_USER_1 \"device\"\n  #define MQTT_PASSWORD_1 \"device\"\n\n  #define MQTT_HOST_2 \"\" // mac OS broker\n  #define MQTT_PORT_2 1883\n  #define MQTT_USER_2 \"\"\n  #define MQTT_PASSWORD_2 \"\"\n  #define MQTT_ACTIVE_2 false\n\n  // CANNOT be changed after being set\n  #define MQTT_PROJECT \"freeRTOS2\"\n  #define MQTT_UID_PREFIX \"uid:\"\n  #define MQTT_WILL_SUBTOPIC \"/status\"\n  #define MQTT_WILL_PAYLOAD \"offline\"\n  #define MQTT_PATH_RECORDS \"/records\"\n\n  #define LOG_ACTIVE true\n  #define LOG_LEVEL 5\n\n  #define KEEPALIVE_ACTIVE true\n  #define KEEPALIVE_PERIOD 15\n\n  // also used for RS485\n  #define UART2_ACTIVE true\n  #define UART2_BAUDRATE 115200\n  #define UART2_CONFIG SERIAL_8N1\n'''\n\n## SYSFILE\n\n  On startup 3 directories are created:\n  - /etc/settings\n  - /home/app/settings\n  - /home/app/records\n\n#### /etc/settings\n\n  Stores system configuration\n\n#### /app/settings\n\n  Can be used by user to store app configurations\\\n  Use sysfile.write_file() method to store data\\\n  and sysfile.read_file() to read data\n\n#### /app/records\n\n  Use this directory to store data that should be sent to mqtt broker\\\n  An autonomous service will be checking for new files and always that is possible it will send to mqtt broker\n\n## Commands\n\n  Commands are passed through MQTT with topic prefix/fw/#\\\n  The following commands are available\n\n  On receive (topic:payload):\n  - :prefix/status (update clock)\n  - :prefix/fw/reboot/set : 1 (reboots system)\n  - :prefix/fw/reset/set : 1 (reset memory)\n  - :prefix/fw/clean/records/set : 1 (clean records in memory)\n  - :prefix/fw/fota/update/set : {\"url\":\"\"} (updates fw)\n\n## Configurations\n\n  Configurations are done through MQTT with topic :prefix/fw/#\\\n  The following commands are available\n\n  On receive\n  - :prefix/fw/settings/modem/set : {\"apn\":\"\",\"pwd\":\"\",\"user\":\"\",\"band\":(uint8_t),\"cops\":(uint16_t)} (updates modem settings)\n  - :prefix/fw/settings/wifi/set : {\"ssid\":\"\",\"pwd\":\"\"} (updates wifi settings)\n  - :prefix/fw/settings/mqtt/set : {\"host\":\"\",\"user\":\"\",\"pass\":\"\",\"active\":(bool)} (configure 2nd mqtt) connection)\n  - :prefix/fw/settings/keepalive/set : {\"active\":(bool),\"period\":(seconds)}\n  - :prefix/fw/settings/log/set : {\"active\":(bool),\"level\":(0-disabled;1-verbose;2-debug;3-info;4-warn;5-error)}\n  - :prefix/fw/ar/set : {}\n  - :prefix/fw/alarm/set : {}\n  - :prefix/fw/js/code/set : (file)\n\n## MQTT\n\n  Device can have one or two connections\\\n  The first connection will be always enabled\\\n  A second one can be activated and in that case all publish messages in app directory will\\\n  be redirected for this second connection\n\n### Prefix\n\n  Prefix identifies device in MQTT broker and it is composed by project + uid\\\n  prefix = MQTT_PROJECT+\"/\"+uid\n\n  MQTT_PROJECT is defined in credentials file\\\n\n  uid = MQTT_UID_PREFIX+macAddress\n  MQTT_UID_PREFIX is also defined in credentials file\\\n\n\n### Subscriptions\n\n  Device subscribes the following topics:\n   - prefix/status\n   - prefix/fw/#\n   - prefix/app/#\n\n  #/fw/# topic is reserved for device configurations\n\n### On Connection\n\nsends the following topics:\n  - /status - online\n  - /model - FW_MODEL\n  - /version - FW_VERSION\n  - /uptime\n  - /reboot_cause_cpu0\n  - /reboot_cause_cpu1\n\n### Running\n\nsends the following topics with keepalive period:\n  - /uptime\n  - /rssi\n  - /tech\n\n### Clocksync\n  Clock is synched when a ':prefix/status' msg is received\n\n### Available Topics\n\n- [/fw/get] (#fw_)\n- [/fw/reboot/set] (#fw_reboot_)\n- [/fw/reset/set] (#fw_reset_)\n- [/fw/info/get] (#fw_info_)\n- [/fw/clean/records/set] (#fw_info_)\n- [/fw/fota/update/set] (#fw_fota_update_)\n- [/fw/js_program/set] (#fw_js_code_)\n- [/fw/settings/wifi/set] (#fw_wifi_)\n- [/fw/settings/modem/set] (#fw_modem_)\n- [/fw/settings/mqtt/set] (#fw_mqtt_)\n- [/fw/settings/log/set] (#fw_log_)\n- [/fw/settings/keepalive/set] (#fw_keepalive_)\n- [/fw/settings/serial/set] (#fw_serial_)\n- [/fw/ar/set] (#fw_ar_)\n- [/fw/alarm/set] (#fw_alarm_)\n- [/fw/serial/read/get] (#fw_serial_read_)\n- [/fw/serial/write/get] (#fw_serial_write_)\n\n## Autorequests\n  Use mqtt topic \"#/fw/ar/set\" to configure autorequests\n\n  The available sensors depends on your hardware and can be:\n  - rs485\n  - ...\n\n\n  The following format is available for rs485:\n\n  ```\n  {\n    \"autorequests\":\n    {\n      \"rs485\": [\n        {\n          \"ref\": \"Itemp\",\n          \"modbus\": [1,3,834,2],\n          \"type\": \"UINT32BE\",\n          \"period\":60\n        },\n        {\n          \"ref\": \"Ipress\",\n          \"modbus\": [1,3,836,2],\n          \"type\": \"UINT16BE\",\n          \"period\":60\n        },\n        {\n          \"ref\": \"Ivb\",\n          \"modbus\": [1,3,806,4],\n          \"type\": \"INT16BE\",\n          \"period\":60\n        },\n        {\n          \"ref\": \"Ivc\",\n          \"modbus\": [1,3,810,4],\n          \"type\": \"FLOATBE\",\n          \"period\":60\n        }]\n    }\n  }\n  ```\n\n  All autorequests with `app` key will be managed by app module. So, when a sensor with ref `asd` is configured, the program will call app.getValue method to request the value of `asd` sensor.\n  It's up to you provide code to return `asd` value\n\n  ```\n  {\n    \"autorequests\": {\n      \"app\": [\n        {\n          \"ref\": \"asd\",\n          \"type\": \"FLOATBE\",\n          \"period\": 60\n        }\n      ]\n    }\n  }\n  ```\n\n## Alarms\n  Use mqtt topic \"#/fw/alarm/set\" to configure alarms\\\n  Alarms will use ref field to get configured sensor from autorequests.\\\n  The following format is available:\n\n  ```\n  {\n    \"alarms\": [\n      {\n        \"ref\": \"Itemp\",\n        \"min_value\":15,\n        \"max_value\":30,\n        \"period\":15\n      },\n      {\n        \"ref\": \"Ipress\",\n        \"min_value\":1.1,\n        \"period\":15\n      },\n      {\n        \"ref\": \"Ivb\",\n        \"diff\":1,\n        \"max_value\":10,\n        \"period\":15\n      },\n      {\n        \"ref\": \"Ivc\",\n        \"period\":15\n      }\n    ]\n  }\n  ```\n\n  Such as autorequests, alarms with `app` key will also be managed by app module. So, when a sensor with ref `asd` is configured, the program will call app.getValue method to request the value of `asd` sensor.\\\n  It's up to you provide code to return `asd` value\n\n  ```\n  {\n    \"alarms\": [\n      {\n        \"ref\": \"asd\",\n        \"period\": 15,\n        \"max_value\": 150,\n        \"min_value\": 130\n      }\n    ]\n  }\n  ```\n\n##JS\n\n[Check this page to further info](https://github.com/zimbora/esp32-freeRTOS2/blob/main/Javascript.md)\n\n## External Dependencies\n\n### External libraries:\n- Board esp32 by Espressif Systems 3.0.7\n- WiFi.h v1.2.7\n- HTTPClient v2.2.0\n- TimeLib v1.6.1\n- ESP32httpUpdate v2.1.145\n- ArduinoJson.h v6.19.4 - deprecated\n\n### Own Libraries:\n- EspMQTTClientFork v1.13.3 [EspMQTTClientFork](https://github.com/zimbora/EspMQTTClient)\n- autorequest v1.0.1 [autorequest](https://github.com/zimbora/esp32-autorequest)\n- alarm v1.0.1[alarm](https://github.com/zimbora/esp32-alarm)\n- modbus-rtu v1.0.1 [modbus-rtu](https://github.com/zimbora/esp32-ModbusRTU)\n- modem-freeRTOS v1.0.4 [modem-freeRTOS](https://github.com/zimbora/esp32-modem-freeRTOS)\n- esp32-BG95 v1.0.6 [esp32-BG95](https://github.com/zimbora/esp32-BG95)\n- sysfile v1.0.2 [sysfile](https://github.com/zimbora/esp32-sysfile)\n- ESP32Logger2 v1.0.3 [esp32-logger](https://github.com/zimbora/ESP32Logger2)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzimbora%2Fesp32-freertos2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzimbora%2Fesp32-freertos2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzimbora%2Fesp32-freertos2/lists"}