How to calibrate a DIY Soil Moisture Sensor - Zigbee2mqtt with Domoticz

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

Post Reply
Bram81
Posts: 22
Joined: Saturday 02 May 2015 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Utrecht, NL
Contact:

How to calibrate a DIY Soil Moisture Sensor - Zigbee2mqtt with Domoticz

Post by Bram81 »

Hi,

I'm running Zigbee2mqtt with Domoticz and I've made a soil moisture sensor using a CC2530 and a capacitive sensor, inspired by this example https://community.home-assistant.io/t/d ... sor/251031
The board is flashed with the ptvo firmware and the device is recognized in Domoticz by the auto discovery plugin. using this external coverter:

Code: Select all

const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters');

const exposes = zigbeeHerdsmanConverters.exposes;
const ea = exposes.access;
const e = exposes.presets;
const fz = zigbeeHerdsmanConverters.fromZigbeeConverters;
const tz = zigbeeHerdsmanConverters.toZigbeeConverters;

const ptvo_switch = zigbeeHerdsmanConverters.findByDevice({modelID: 'ptvo.switch'});
fz.legacy = ptvo_switch.meta.tuyaThermostatPreset;

const device = {
zigbeeModel: ['Bodemvochtigheid'],
model: 'Bodemvochtigheid',
vendor: 'Custom devices (DiY)',
description: 'Configurable firmware',
fromZigbee: [fz.ignore_basic_report, fz.ptvo_switch_analog_input,],
toZigbee: [tz.ptvo_switch_trigger, tz.ptvo_switch_analog_input,],
exposes: [e.voltage().withAccess(ea.STATE).withValueMin(0).withValueMax(3.3).withEndpoint('l1'),
],
meta: {
multiEndpoint: true,

},
endpoint: (device) => {
    return {
        l1: 1,
    };
},
};

module.exports = device;
Now I need to calibrate the raw value with some kind of calculation pointing value x is 0% and value y is 100%. In Domoticz I don't have the option to add a specific template the way that can be done with HA. I've tried to calculate the l1 value in the external converter, but since I'm not sure about the possibilities and the syntax most of the time zigbee2mqtt fails to start after most of my tries and therefore I don't have a log available for debugging.

Is there anyone who can help me or point me in the right direction..?
All help is much appreciated!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest