stm32f1/README.md

6.2 KiB

This is the firmware for the elevainitor, a sourdough starter (aka. levain) elevator.

project

summary

The purpose is to grow and train a yeast culture in a sourdough started. The yeast will multiply on its own, but the optimum temperature is 30 - 35 °C. A heater will keep the temperature around 32.5 °C. This will also allow to have similar condition to measure the yeast's efficiency over time. The device with also monitor the sourdough starter rising under the activity of the yeast.

technology

A small glass (e.g. 350 mL) is used to make a sourdough starter.

To make a starter:

  1. mix 50 g of flour and 50g of water (whole wheat flour contains generally more yeast and bacteria since there is more of the grain's shell)
  2. leave it in the glass for 24h
  3. mix 50 g of this starter with 50 g of flour and 50 g of water
  4. repeat from step 2 until the starter is rising twice its original size after a couple of hours
  5. mix 10 g of this starter with 50 g of flour and 50 g of water
  6. leave it for a couple of hours until it's falling back in
  7. you can keep it in the fridge for a couple of days (maximum until a gray liquid layer is forming)
  8. repeat from step 5

A heater is used to keep the glass above 30 °C. The heater is made out of a lid fitting the glass, so the glass fits perfectly on top of it. A 5 Ohm 10 W ceramic resistor is epoxy glued in the lid. A DS18B20 sensor is placed next to it to monitor it's temperature. The thermometer is used to prevent the lid from over-heating.

The top lid of the glass if equipped with the following:

  • a 10 kOhm thermistor in a stainless steel tube, to measure the starter's temperature once plunged into it
  • a HC-SR04 ultrasonic range sensor, to measure the starter's rising
  • a n-channel MOSFET, to power the power resistor in the heater
  • a SSD1306 0.96 inch OLED display, to show the starter's temperature and growth
  • a STM32F401-based WeAct MiniF4 development board, to control all peripherals

The top lid also used to have a MLX90614 IR-thermometer, but the reading were wrong (24 °C instead of 29 °C). This might be because of the high humidity when heating up, and droplets are forming on the sensor. It can maybe corrected by changing the emissivity, but a thermistor is just the easier solution.

To use the yeast raiser:

  1. put the lid on the empty glass
  2. power the board, through the USB-C, USB micro-B, or OD 5.5 mm/ID 2.1 mm barrel jack, using a 5 V 1 A power supply
  3. the screen should display a message
  4. press on the button, which will measure the height of the glass
  5. prepare the sourdough starter in the glass
  6. put back the lid on, inserting the thermistor in the starter
  7. press on the button, which will measure the height of the initial started
  8. the yeast raiser will continuously monitor and display the height and temperature of the sourdough starter
  9. it will heat the starter to 30 - 35 °C, until it falls back
  10. it will show when, and how high the starter was when it reached its peak

connections

Connect the peripherals the following way.

button (if not already present on the development board):

  1. ground
  2. PA0

power n-channel MOSFET:

  1. gate: PB12, pulled up by 100 kO resistor to 5V
  2. drain: power resistor for heated bed
  3. source: ground

HC-SR04 ultrasonic range sensor:

  1. ground
  2. echo: PB9
  3. trigger: PB8
  4. VCC: 5V

DS18B20 1-Wire temperature sensor:

  1. ground
  2. 1-Wire: PB10, pulled up by 1 kO resistor to 5V
  3. VCC: 5V

SSD1306 OLED display module:

  1. gound
  2. VDD: 3.3V
  3. SCK: PB6/I2C1_SCL, pulled up by 10-47 kO resistor to 3.3V
  4. SDA: PB7/I2C1_SDA, pulled up by 10-47 kO resistor to 3.3V

10 kOhm NTC thermistor:

  1. ground
  2. PA6, pulled to to 3.3V by 10 kOhm resistor

All pins are configured using defines in the corresponding source code.

code

dependencies

The source code uses the libopencm3 library. The projects is already a git submodules. It will be initialized when compiling the firmware. Alternatively you can run once: git submodule init and git submodule update.

firmware

To compile the firmware run rake.

documentation

To generate doxygen documentation run rake doc.

flash

There are two firmware images: bootloader and application. The bootloader image allows to flash the application over USB using the DFU protocol. The bootloader is started first and immediately jumps to the application if it is valid and the DFU mode is not forced (i.e. by pressing the user button on the board or requesting a DFU detach in the application). The application image is the main application and is implemented in application.c. It is up to the application to advertise USB DFU support (i.e. as does the provided USB CDC ACM example).

The simplest way do flash the bootloader image is using the embedded bootloader. By pressing the BOOT0 button (setting the pin low) while powering or resetting the device, the micro-controller boot its embedded UART/USB DFU bootloader. Connect a USB cable and run rake dfu_bootloader.

Once the bootloader is flashed, it is possible to flash the application over USB using the DFU protocol by running rake flash (equivalent to rake dfu_application. To force the bootloader to start the DFU mode press the user button or short a pin, depending on the board. Note: I use my own DFU bootloader instead of the embedded bootloader because I was not able to start the embedded USB DFU bootloader from the application.

The images can also be flash using SWD (Serial Wire Debug) in case the firmware gets stuck and does not provide USB functionalities. For that you need an SWD adapter. The Makefile uses a ST-Link V2 programmer along OpenOCD software (default), or Black Magic Probe. To flash the booltoader using SWD run rake swd_booloader (this will also erase the application). To flash the application using SWD run rake swd_aplication (or rake swd). To erase all memory and unlock read/write protection, run rake remove_protection.

debug

SWD also allows to debug the code running on the micro-controller using GDB. To start the debugging session run rake debug.

USB

The firmware offers serial communication over USART1 and USB (using the CDC ACM device class).