Pill Consumption Tracking

The hardware platform was based on an ESP32 board. The ESP32 boardqueries the existing system through a SPI base command interface, andmakes the data available over JSON-RPC interface. The mobile application runing on iPhone / Android mobile, queries the data periodically over the JSON-RPC interface, and displays it on themobile application interface, in a format that is convenient for the user.

Introduction

The firmware on the ESP32 was implemented using Arduino framework, and the ESP Async Webserver was used to implement the JSON-RPC interface. A network manager was implemented on the ESP32 to configure the WiFi interface of the ESP32, and to connect to the configured AP.

The mobile app was designed to be cross-platform across Android andiOS. The mobile application was written in Python using the Kivy framework, and the WebSocket interface was built using Async IO and aio-http framework. The mobile application can be configured to monitor multiple machines, with any one machine active at a given instant. The wireless AP to connect to and the IP parameters of the ESP32, can be configured remotely from the mobile application, as well.

Design Highlights

Cross Platform Mobile Application

The choice of Python and Kivy for building the mobile application allowed to use a single code-base across both the platforms. While there were other contenders for a cross-platform solution like React Native, Python and Kivy proved to be a simple and maintainablealternative that suited the requirement at hand.

Remote Device Management

The application and the firmware had all the features necessary to manage the device remotely. Remote upgrade capability was built into the firmware, and the wireless network was remotely configurable from the mobile application. The ESP32 is available in AP mode, as a fallback option, and can be used to re-configure the ESP32 to connect to different wireless AP.

Automated Testing

Automated testing was used to weed out bugs both in the JSON-RPC interface and the UI. The UI was automated using Telenium, to exercise and test the UI for extreme input cases. The JSON-RPC interface was fuzzed with out of range values, to ensure that the network interface was robust, and was protected from buggy clients and deliberate attacks.