The hardware setup was made to detect when the bottle opened/closed, environmental readings(temperature), and estimate the level of pills remaining in the bottle. To do this we created a force sensor using a sheet of adafruit's Velostat. This material's resistance has an inverse correlation with force applied.
The software is setup according to this masterpiece of a drawing:
Sensor data is logged by our Particle Photon and send to Azure IoT Hub. Our IoT Hub then keeps this data in an Azure database. Our Flutter app is then able to display this data and set alarms in the database through a connected NodeJS server.