Sourdough Sensor (ESP8266)

Introduction: Sourdough Sensor (ESP8266)

I'm still out there to try to measure the fermentation of my sourdough starter and I wanted to try this solution with a Sharp sensor.The sensor will measure the distance to the surface of the preparation. The higher it goes, the more fermented the preparation is. The increase in height is due to the bacteries and yeast eating the flour and producing carbon dioxyde. This gas will be trapped in the preparation and inflate it.

This is using a simple ESP8266 to transmit the measures to a MQTT broker. I printed the cover to integrate the components in the container cap so that it doesn't move too easily.


  • ESP8266 - I took a NodeMCU v3 from aliexpress
  • Sharp Sensor GP2Y0A41SK0F - the one I use is good for 4cm to 30cm which is gonna be a good match in that case.
  • MQTT Server - the one I use is handled by my home assistant software, any will do
  • One glass jar
  • Some sourdough starter
  • USB powerbank or power adapter with micro USB output

Step 1: Print the Jar Cover

I designed the cover with Fusion 360, sliced with Cura and printed on my Creality 3D CR10S. I left some holes for ventilation so that there is no condensation on the sharp sensor.

I found some good design for the nodemcu on grabcad. As well as for the sharp sensor. Much easier to design the holes for the mounting. I used some spacers from my arduino boards mounting pieces to adjust the height of the component above the cover top. (not the same but close enough for the holes fitting)

I stuck a little bit of double side tape to make the cover stay in place on top of the jar.

Step 2: Cabling

First we have to wire the nodemcu to the sharp sensor. This is quite straightforward.

  1. The Sharp sensor will take 5 volts as an input so we can plug it into VU (VUSB) on the nodemcu.
  2. Then sharp sensor ground to any nodemcu ground pin.
  3. And finally the V0 from the sharp sensor goes to the A0 (analog input) on the ESP.
  4. Fortunately the output of the sharp sensor is maximum 3.1 volts. It would be higher we would have issues with the ESP than runs on 3.3 volts and would not appreciate higher voltages on its input pin.

Then I use a standard USB powerbank with micro USB plug or a wall plug to power the nodemcu. This has to be done since we want to have a valid VUSB at 5 volts. The sensor will take only between 4.5 to 5.5 volts. nodemcu typically runs at 3.3v which is insufficient.

Step 3: Coding

This code is using Arduino IDE language to program the ESP8266. You will have to install the ESP8266 board to be able to program it from this IDE.

Search and replace the keyword "REPLACE" with your own values.

There is a calibration phase for the sharp sensor. You will see the formula to convert analog reading to centimeters, this can be modified after calibration. Typical calibration is to perform a serie of measurements with the sensor and use excel to compute the coefficients for the formula. This will improve accuracy of the measures.

Some examples of calibration process

The code contains a connection to any wifi station you have. Thanks to this wifi connection, the ESP can send the values to the configured MQTT server.

Step 4: Check MQTT

Once plugged, the esp will start sending values to the MQTT. Then I use home assistant ( to read the queue and display the result.

Then you are left with adding your soudough starter, some flour and water and then wait for the sensor to measure the level of the surface in the glass jar. This will hopefully indicate the level of fermentation of the sourdough so we know when the peak is reached.

I attached the graph of the first time I used the sensor. I transferred the sensor readings back to InfluxDB and this graph is from Grafana so you can see a nice evolution of the measurements over time.

I hope you liked this tutorial, please me know if you need more details on some of the steps!

Be the First to Share


    • Backyard Contest

      Backyard Contest
    • Make it Fly Challenge

      Make it Fly Challenge
    • Metal Contest

      Metal Contest