We decided on implementing Sparkfun’s ESP32 Thing microcontroller in our project for several reasons. First, for its small size — one of our main project objectives. Second, for its built-in Bluetooth capabilities that would allow us to more easily setup and communicate over Bluetooth LE. And third, for its ability to work with the Arduino IDE that we were already comfortable with.
For the Analog-to-Digital Converter (A/D or ADC) in our design, we selected the Adafruit ADS1115 which is a 4-channel, 16-bit I2C ADC. This device is very small, low cost, and has enough bit precision for the scope of the project. Because it can communicate over I2C, data is able to be transferred easily between it and the microcontroller.
The sensors we are implementing act as variable resistors — in our case, when the pressure applied to the sensor changes, the resistance changes as well. We can easily calculate the resistance of the sensor by using the measured voltage drop across the sensor, the supply voltage (3.3V), and the resistance of the potentiometer in this equation:
Resistance to Pressure
Once we have the sensor resistance, the microcontroller converts it to a sensor reading, using the resistance-reading curve for that particular sensor. For example the FSR402 force sensor has the following resistance-pressure curve (as measured by Prof Wang’s lab):
The microcontroller was programmed using the Arduino IDE. The basic function of the code is to read the voltage drop across the sensor from the ADC using I2C protocol, convert to a resistance, convert the resistance to a pressure, and send out that pressure reading using BLE.