What we use
Tasmota on wemos D1 with ultra Sonic sensor
MQTT broker running on a Raspberry Pi 3+
Running Domoticz on this Pi
First we have to setup our Tasmota module, if you don't have Tasmotizer you can get it on github
https://github.com/tasmota/tasmotizer
Be sure to use the Tasmota-sensors.bin
First time you use Tasmotizer ? After flasshing your esp you'll find a new wifi network connect you comuter to is and you see a screen to fil in your wifi acces. Once this is done you need to reconnect to you own wifi network.
You'll need to find the IP of you Tasmota device. Mostly you'll do this by you config of your router.
i' ve based my project by this link
You need to create 3 dummy devices in Domoticz
Now you have to create 3 "Virtual Sensors"
if you have created them go to "devices"
IDX index very important for programming and tasmota
go to you config from tasmota
Save this configuration and go back to Domoticz
and if al went ok, you'll see your distance senor in Domoticz
Now come's the hard part adding some events to calculate the water volume.
This is the code for Lua
Based on this ink
---------------------------------------------------------------------------
depth_sensor = 'water tank sensor'
-- Output devices: Percentage full, volume.
pct_sensor = 'water tank'
pct_sensor_id = 30
--idx in domoticz =30
volume_sensor = 'water'
volume_sensor_id = 31
--idx in domoticz =31
--you should look for you settings in your domoticz devices
-- Tank dimensions
tank_height = 165
tank_area = 98 * 98 * 3.14
--tank_area = tank radius =98 cm
-- if you have a square tank W * D
-----------------------------------------------------------------------------------
commandArray = {}
if (devicechanged[depth_sensor] or devicechanged[tank_temp_sensor]) then
-- Use otherdevices_svalues[] because devicechanged[foo_Utility] is not
-- present when the value is zero
depth = otherdevices_svalues[depth_sensor]-35
-- -35 cm =distance to top level from water
-- Calculate percentage and volume
pct = (tank_height - depth) / tank_height * 100
volume = (tank_height - depth) * tank_area / 1000
commandArray[1] = {['UpdateDevice'] = pct_sensor_id .. "|0|" .. pct}
commandArray[2] = {['UpdateDevice'] = volume_sensor_id .. "|0|" .. volume}
end
return commandArray
----------------------------------------------------------------------------------------------------------------------
when you past this code it should look like this.
if you did everything ok you should get this result.
I use this sensors
The test project !
The sensor on the watertank
Hope you like what you see, grtz Spike
Geen opmerkingen:
Een reactie posten