Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ble Plant sensor chip TLSR8250 #3

Open
finipini opened this issue Dec 7, 2023 · 6 comments
Open

Ble Plant sensor chip TLSR8250 #3

finipini opened this issue Dec 7, 2023 · 6 comments

Comments

@finipini
Copy link

finipini commented Dec 7, 2023

Hi i have a ble Plant sensor ( a bit like Xiaomi mi flora ) that have the chip TLSR8250, i wonder if this could be compatible with zigbee and what i could do to test it.

IMG_20231207_173318
IMG_20231207_174517

@pvvx
Copy link
Owner

pvvx commented Dec 7, 2023

TLSR8250 can work in Zigbee.
But this sensor uses an additional circuit, which is not very optimal for measuring soil moisture and has a high battery consumption.
I try to avoid sensors with sub-optimal battery consumption due to further numerous user complaints.

@finipini
Copy link
Author

finipini commented Dec 7, 2023

TLSR8250 can work in Zigbee. But this sensor uses an additional circuit, which is not very optimal for measuring soil moisture and has a high battery consumption.

Oh ok. One good thing about the sensor os that uses 2 AAA batteries that is easy to have rechargable ones. Never really use it in plants yet, but if it is not reliable maybe should forget this.

@pvvx
Copy link
Owner

pvvx commented Dec 7, 2023

The most commonly used scheme is similar to:
image

https://tlfong01.blog/2020/09/26/moisture-sensor-notes-2/

@pvvx
Copy link
Owner

pvvx commented Dec 7, 2023

For operation, the required frequency must be in the region of several MHz.
The signal should not be rectangular, it should have different half-cycles to bias the diode.
No external 555 timer is required. TLSR825x has more advanced built-in PWM controllers.
An acceptable TLSR825x circuit contains one resistor, one capacitor and one RF diode.
The measurement time ranges from 5 to 16 ms, depending on the size (capacity) of the sensor itself. The total current consumption of the entire device when measured does not exceed 3 mA.
No one will remake the purchased sensors. And I am not in the commercial or household goods business.

@pvvx
Copy link
Owner

pvvx commented Dec 7, 2023

From my archive:

image

The duty cycle of the PWM is tuned for the DC component of the voltage drop across the diode.

For real example (Soc:TLSR8253), set the PWM parameters to 1/12. Those. cycle = 12 periods 24 MHz, of which 1 period is an impulse. Total frequency over the period - 2 MHz. Pulse envelope - 12 MHz.
R=7.5к, C=100nF.

image

The final sensitivity on the probe is less than 1 pF.
A piece of wires in a couple of cm is a sensor for bringing the hand to the case (checking for XiaomiLYWSD03MMC through its case). The voltage with the hand drops to 350 mV and below. Without - more than 405 mV. Test without setting the duty cycle and duration of PWM. Automatic adjustment of PWM parameters for any sensors is possible and uncomplicated.

At C=10 nF, the measurement time is up to 2 ms.

Measurement in this case takes up to 2 ms with current consumption up to (!) 5 mA.
If measurements are made every minute, then the consumption per measurement will be:
(0.002sec*0.005A)/60sec = 0.000000167A = 0.167uA
It is necessary to add to it the sleep current (power on: SRAM and RTC) of the SoC - 1.8 uA.
When advertising is broadcast every 3 seconds, the average SoC consumption is 5..7 uA. Depends on the transmission encoding.
The data is given and consistent with the real test on SoC TLSR8253.

/*
 * rh.c
 *
 *  Created on: 05.04.2022
 *      Author: pvvx
 */
#include <stdint.h>
#include "tl_common.h"
#include "drivers.h"
#include "battery.h"

// R = 7.5 kOm, BAV99, C 10..100 nF

/*********************************************************************************
    PWM0   :  PA2.  PC1.  PC2.	PD5
    PWM1   :  PA3.  PC3.
    PWM2   :  PA4.  PC4.
    PWM3   :  PB0.  PD2.
    PWM4   :  PB1.  PB4.
    PWM5   :  PB2.  PB5.
    PWM0_N :  PA0.  PB3.  PC4	PD5
    PWM1_N :  PC1.  PD3.
    PWM2_N :  PD4.
    PWM3_N :  PC5.
    PWM4_N :  PC0.  PC6.
    PWM5_N :  PC7.
 *********************************************************************************/

#define PWM_PIN		GPIO_PB5
#define AS_PWMx		AS_PWM5
#define PWM_ID		PWM5_ID

static void pwm_init(void) {
	reg_clk_en0 |= FLD_CLK0_PWM_EN;
	reg_pwm_clk = 0; // = CLOCK_SYS_CLOCK_HZ 24Mhz
	pwm_set_mode(PWM_ID, PWM_NORMAL_MODE);
	pwm_set_phase(PWM_ID, 0);   //no phase at pwm beginning
	pwm_set_cycle_and_duty(PWM_ID, 12, 1);
	pwm_start(PWM_ID);
	gpio_set_func(PWM_PIN, AS_PWMx);
}

extern void adc_channel_init(ADC_InputPchTypeDef p_ain);

uint16_t get_adc_rh_mv(uint32_t p_ain) { // ADC_InputPchTypeDef
	gpio_setup_up_down_resistor(GPIO_ADC1, PM_PIN_UP_DOWN_FLOAT);
	pwm_init();
#if 0
	u32 t0 = clock_time();
	while (!clock_time_exceed(t0, 10000));
#else
	pm_wait_us(16000);
#endif
#if 1
	uint16_t mv = get_adc_mv(p_ain);
	pwm_stop(PWM_ID);
	gpio_setup_up_down_resistor(GPIO_ADC1, PM_PIN_PULLDOWN_100K);
	return mv;
#else
#define ADC_BUF_COUNT	8
	volatile unsigned int adc_dat_buf[ADC_BUF_COUNT];
	adc_channel_init(VBAT);
	adc_power_on_sar_adc(1); // + 0.4 mA
	adc_reset_adc_module();
	adc_set_ain_chn_misc(p_ain, GND);
	pm_wait_us(200);
	adc_config_misc_channel_buf((uint16_t *) adc_dat_buf, sizeof(adc_dat_buf));
	adc_dat_buf[ADC_BUF_COUNT-1]=0;
	dfifo_enable_dfifo2();
	pm_wait_us(100);
	pwm_stop(PWM_ID);
	while(adc_dat_buf[ADC_BUF_COUNT-1]==0);
	dfifo_disable_dfifo2();
	gpio_setup_up_down_resistor(GPIO_PB7, PM_PIN_PULLDOWN_100K);
	adc_power_on_sar_adc(0); // - 0.4 mA
	u32 adc_average = 0;
	int i;
	for (i = 0; i < ADC_BUF_COUNT; i++)
			adc_average += ((uint16_t) adc_dat_buf[i] & 0x3FFF);
	return (adc_average * adc_vref_cfg.adc_vref) >> (10 + 3);
#endif
}

Similarly, it is possible to build a completely isolated water leak sensor.

@olafschmidt1984
Copy link

Hi,

Is it possible to change the BLE protocol to zigbee.
There is a firmware on your website:
https://pvvx.github.io/PLANT-MON/

Think you in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants