application: remove MLX90614 because of errounous readings
This commit is contained in:
parent
bef5cf299f
commit
991921ed99
11
README.md
11
README.md
|
@ -38,11 +38,14 @@ 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 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 HC-SR04 ultrasonic range sensor, to measure the starter's rising
|
||||||
- a MLX90614 infra-red thermometer, to measure the starter's temperature without contact, as alternative to the thermocouple
|
|
||||||
- a n-channel MOSFET, to power the power resistor in the heater
|
- 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 SSD1306 0.96 inch OLED display, to show the starter's temperature and growth
|
||||||
- a STM32F401-based [WeAct MiniF4](https://github.com/WeActTC/MiniF4-STM32F4x1) development board, to control all peripherals
|
- a STM32F401-based [WeAct MiniF4](https://github.com/WeActTC/MiniF4-STM32F4x1) 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:
|
To use the yeast raiser:
|
||||||
|
|
||||||
1. put the lid on the empty glass
|
1. put the lid on the empty glass
|
||||||
|
@ -91,12 +94,6 @@ SSD1306 OLED display module:
|
||||||
1. ground
|
1. ground
|
||||||
2. PA6, pulled to to 3.3V by 10 kOhm resistor
|
2. PA6, pulled to to 3.3V by 10 kOhm resistor
|
||||||
|
|
||||||
MLX90614 IR-thermometer:
|
|
||||||
1. VIN: 3.3V
|
|
||||||
2. GND: ground
|
|
||||||
3. SCL: PA8/I2C3_SCL
|
|
||||||
4. SDA: PB4/I2C3_SDA
|
|
||||||
|
|
||||||
All pins are configured using `define`s in the corresponding source code.
|
All pins are configured using `define`s in the corresponding source code.
|
||||||
|
|
||||||
code
|
code
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "sensor_sr04.h" // range measurement utilities
|
#include "sensor_sr04.h" // range measurement utilities
|
||||||
#include "sensor_ds18b20.h" // 1-Wire temperature sensor utilities
|
#include "sensor_ds18b20.h" // 1-Wire temperature sensor utilities
|
||||||
#include "oled_text.h" // OLED display utilities
|
#include "oled_text.h" // OLED display utilities
|
||||||
#include "sensor_mlx90614.h" // MLX90614 infra-red thermometer utilities
|
|
||||||
|
|
||||||
/** watchdog period in ms */
|
/** watchdog period in ms */
|
||||||
#define WATCHDOG_PERIOD 10000
|
#define WATCHDOG_PERIOD 10000
|
||||||
|
@ -64,7 +63,6 @@ static uint8_t starter_height = 0; /**< how height the yeast/sour dough starter
|
||||||
static uint8_t max_height = 0; /**< the maximum height the yeast reached */
|
static uint8_t max_height = 0; /**< the maximum height the yeast reached */
|
||||||
static float heater_temp = NAN; /**< heater temperature */
|
static float heater_temp = NAN; /**< heater temperature */
|
||||||
static float yeast_temp = NAN; /**< yeast/sour dough starter temperature */
|
static float yeast_temp = NAN; /**< yeast/sour dough starter temperature */
|
||||||
static float ir_temp = NAN; /**< yeast/sour dough starter temperature as measured by the IR thermometer */
|
|
||||||
|
|
||||||
/** heater control pin
|
/** heater control pin
|
||||||
* @note connected to power nMOS gate, pulled up to 5V
|
* @note connected to power nMOS gate, pulled up to 5V
|
||||||
|
@ -351,7 +349,6 @@ static void command_state(void* argument)
|
||||||
height = ((container_height && current_height) ? (container_height - current_height) : 0);
|
height = ((container_height && current_height) ? (container_height - current_height) : 0);
|
||||||
printf("current height: %u mm\n", height);
|
printf("current height: %u mm\n", height);
|
||||||
printf("sourdough temperature: %.02f °C\n", yeast_temp);
|
printf("sourdough temperature: %.02f °C\n", yeast_temp);
|
||||||
printf("IR temperature: %.02f °C\n", ir_temp);
|
|
||||||
printf("heater temperature: %.02f °C\n", heater_temp);
|
printf("heater temperature: %.02f °C\n", heater_temp);
|
||||||
puts("heater: ");
|
puts("heater: ");
|
||||||
puts(gpio_get(GPIO_PORT(HEATER_PIN), GPIO_PIN(HEATER_PIN)) ? "on\n" : "off\n");
|
puts(gpio_get(GPIO_PORT(HEATER_PIN), GPIO_PIN(HEATER_PIN)) ? "on\n" : "off\n");
|
||||||
|
@ -638,14 +635,6 @@ void main(void)
|
||||||
puts("KO\n");
|
puts("KO\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
puts("setup MLX90614 IR-thermometer: ");
|
|
||||||
const bool sensor_mlx90614_ok = sensor_mlx90614_setup(0xff); // setup sensor
|
|
||||||
if (sensor_mlx90614_ok) {
|
|
||||||
puts("OK\n");
|
|
||||||
} else {
|
|
||||||
puts("KO\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
puts("setup SSD1306 OLED display: ");
|
puts("setup SSD1306 OLED display: ");
|
||||||
const bool oled_text_ok = oled_text_setup(); // setup display
|
const bool oled_text_ok = oled_text_setup(); // setup display
|
||||||
if (oled_text_ok) {
|
if (oled_text_ok) {
|
||||||
|
@ -658,7 +647,7 @@ void main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// show status
|
// show status
|
||||||
const bool all_ok = heater_ok && sensor_sr04_ok && sensor_ds18b20_present && thermsitor_ok && sensor_mlx90614_ok && oled_text_ok;
|
const bool all_ok = heater_ok && sensor_sr04_ok && sensor_ds18b20_present && thermsitor_ok && oled_text_ok;
|
||||||
if (oled_text_ok) {
|
if (oled_text_ok) {
|
||||||
if (all_ok) {
|
if (all_ok) {
|
||||||
oled_text_line("press button", 1);
|
oled_text_line("press button", 1);
|
||||||
|
@ -674,8 +663,6 @@ void main(void)
|
||||||
oled_text_line("heater thermo.", 2);
|
oled_text_line("heater thermo.", 2);
|
||||||
} else if (!thermsitor_ok) {
|
} else if (!thermsitor_ok) {
|
||||||
oled_text_line("thermistor", 2);
|
oled_text_line("thermistor", 2);
|
||||||
} else if (!sensor_mlx90614_ok) {
|
|
||||||
oled_text_line("IR thermo.", 2);
|
|
||||||
} else {
|
} else {
|
||||||
oled_text_line("unknown", 2);
|
oled_text_line("unknown", 2);
|
||||||
}
|
}
|
||||||
|
@ -779,10 +766,6 @@ void main(void)
|
||||||
if (thermsitor_ok) {
|
if (thermsitor_ok) {
|
||||||
yeast_temp = thermistor_temperature(); // get temperature
|
yeast_temp = thermistor_temperature(); // get temperature
|
||||||
}
|
}
|
||||||
// show IR temperature
|
|
||||||
if (sensor_mlx90614_ok) {
|
|
||||||
ir_temp = sensor_mlx90614_temperature_object(); // get temperature
|
|
||||||
}
|
|
||||||
// update uptime
|
// update uptime
|
||||||
if (yeast_time) {
|
if (yeast_time) {
|
||||||
const uint32_t uptime = rtc_to_seconds() - yeast_time; // get time from internal RTC
|
const uint32_t uptime = rtc_to_seconds() - yeast_time; // get time from internal RTC
|
||||||
|
|
|
@ -1,86 +0,0 @@
|
||||||
/** library to communicate with MLX90614 infra-red thermometer
|
|
||||||
* @file
|
|
||||||
* @author King Kévin <kingkevin@cuvoodoo.info>
|
|
||||||
* @copyright SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
* @date 2020
|
|
||||||
* @note peripherals used: GPIO @ref sensor_mlx90614_gpio, I2C @ref i2c_master_i2c
|
|
||||||
* @note this library only uses the I²C interface, not the PWM output
|
|
||||||
*/
|
|
||||||
/* standard libraries */
|
|
||||||
#include <stdint.h> // standard integer types
|
|
||||||
#include <stdbool.h> // boolean type
|
|
||||||
#include <stdlib.h> // general utilities
|
|
||||||
#include <math.h> // NaN definition
|
|
||||||
|
|
||||||
/* STM32 (including CM3) libraries */
|
|
||||||
#include <libopencm3/stm32/rcc.h> // real-time control clock library
|
|
||||||
#include <libopencm3/stm32/gpio.h> // general purpose input output library
|
|
||||||
#include <libopencm3/stm32/i2c.h> // I²C library
|
|
||||||
|
|
||||||
/* own libraries */
|
|
||||||
#include "global.h" // global utilities
|
|
||||||
#include "sensor_mlx90614.h" // own definitions
|
|
||||||
#include "smbus_master.h" // SMBus utilities
|
|
||||||
|
|
||||||
/** @defgroup sensor_mlx90614_gpio GPIO pin used to control the MLX90614
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define SENSOR_MLX90614_SCL PA8 /**< GPIO pin for SMBus SCL, use to send request condition to switch mode from PWM to SMBus (must be the same as used for SMBus communication) */
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/** MLX90614 I²C slave address */
|
|
||||||
static uint8_t sensor_mlx90614_slave_addr = 0x5a;
|
|
||||||
|
|
||||||
bool sensor_mlx90614_setup(uint8_t slave_addr)
|
|
||||||
{
|
|
||||||
if (!smbus_master_check_signals()) { // check if there are pull-ups to operate I²C
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// send request condition to switch to I²C mode
|
|
||||||
rcc_periph_clock_enable(GPIO_RCC(SENSOR_MLX90614_SCL)); // enable clock for GPIO port domain
|
|
||||||
gpio_mode_setup(GPIO_PORT(SENSOR_MLX90614_SCL), GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN(SENSOR_MLX90614_SCL)); // set pin as output
|
|
||||||
gpio_set_output_options(GPIO_PORT(SENSOR_MLX90614_SCL), GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, GPIO_PIN(SENSOR_MLX90614_SCL)); // set pin output as open-drain (should be pulled up by external resistors required for I²C communication
|
|
||||||
gpio_clear(GPIO_PORT(SENSOR_MLX90614_SCL), GPIO_PIN(SENSOR_MLX90614_SCL)); // set low to send request condition
|
|
||||||
sleep_us(1024 + 500); // SMBus Request is min. 1.024 ms
|
|
||||||
gpio_set(GPIO_PORT(SENSOR_MLX90614_SCL), GPIO_PIN(SENSOR_MLX90614_SCL)); // set back high to end request condition
|
|
||||||
|
|
||||||
if (slave_addr < 0x80) { // only the least 7-bit are valid (use default address else)
|
|
||||||
sensor_mlx90614_slave_addr = slave_addr; // save I²C slave address of MLX90614
|
|
||||||
}
|
|
||||||
smbus_master_setup(100, true); // setup SMBus with PEC
|
|
||||||
uint8_t response[2]; // response is always 2 bytes
|
|
||||||
// test if the device is present
|
|
||||||
smbus_master_command_read(sensor_mlx90614_slave_addr, 0x20 | 0x0e, response, LENGTH(response)); // I don't know whey, but the PEC for the first transfer is erroneous, maybe because it has some old bits in the calculation buffer
|
|
||||||
const enum smbus_master_rc rc = smbus_master_command_read(sensor_mlx90614_slave_addr, 0x20 | 0x0e, response, LENGTH(response)); // read its own slave address
|
|
||||||
if (SMBUS_MASTER_RC_NONE != rc) { // read failed
|
|
||||||
return false; // could not read from SMBus device
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sensor_mlx90614_slave_addr != response[0]) { // the used slave address does not match the one in the ROM
|
|
||||||
return false; // this is probably not a MLX90614
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
float sensor_mlx90614_temperature_ambient(void)
|
|
||||||
{
|
|
||||||
uint8_t response[2]; // response is always 2 bytes
|
|
||||||
const enum smbus_master_rc rc = smbus_master_command_read(sensor_mlx90614_slave_addr, 0x00 | 0x06, response, LENGTH(response)); // read Ta from RAM
|
|
||||||
if (SMBUS_MASTER_RC_NONE != rc) { // read failed
|
|
||||||
return NAN;
|
|
||||||
}
|
|
||||||
const uint16_t temp = response[0] + (response[1] << 8); // low byte is transferred first
|
|
||||||
return temp * 0.02 - 273.15; // calculated temperature according to specification 7.7.1
|
|
||||||
}
|
|
||||||
|
|
||||||
float sensor_mlx90614_temperature_object(void)
|
|
||||||
{
|
|
||||||
uint8_t response[2]; // response is always 2 bytes
|
|
||||||
const enum smbus_master_rc rc = smbus_master_command_read(sensor_mlx90614_slave_addr, 0x00 | 0x07, response, LENGTH(response)); // read Tobj1 from RAM
|
|
||||||
if (SMBUS_MASTER_RC_NONE != rc) { // read failed
|
|
||||||
return NAN;
|
|
||||||
}
|
|
||||||
const uint16_t temp = response[0] + (response[1] << 8); // low byte is transferred first
|
|
||||||
return temp * 0.02 - 273.15; // calculated temperature according to specification 7.7.1
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
/** library to communicate with MLX90614 infra-red thermometer
|
|
||||||
* @file
|
|
||||||
* @author King Kévin <kingkevin@cuvoodoo.info>
|
|
||||||
* @copyright SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
* @date 2020
|
|
||||||
* @note peripherals used: GPIO @ref sensor_mlx90614_gpio, I2C @ref i2c_master_i2c
|
|
||||||
* @note this library only uses the I²C interface, not the PWM output
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/** setup I²C bus to communicated with MLX90614 Infra-Red thermometer
|
|
||||||
* @param[in] slave_addr I²C slave address of MLX90614 device (least significant 7-bit, 0xff for default)
|
|
||||||
* @return if the display setup is successful, else the display is probably not on the I²C bus
|
|
||||||
* @warning only one display on the I²C bus is currently supported
|
|
||||||
* @note I²C frequency is 100 kHz
|
|
||||||
*/
|
|
||||||
bool sensor_mlx90614_setup(uint8_t slave_addr);
|
|
||||||
/** get ambient temperature of sensor
|
|
||||||
* @return ambient temperature in °C
|
|
||||||
* @note uses internal thermistor
|
|
||||||
*/
|
|
||||||
float sensor_mlx90614_temperature_ambient(void);
|
|
||||||
/** get measured object temperature
|
|
||||||
* @return object temperature in °C
|
|
||||||
* @note uses IR sensor
|
|
||||||
*/
|
|
||||||
float sensor_mlx90614_temperature_object(void);
|
|
Loading…
Reference in New Issue