Ключевое ?лово

vk

Добро пожаловать, Гость
Логин: Пароль: Запомнить меня
Железо для умного дома

ТЕМА: ESP8266+MQTT+OpenHab

ESP8266+MQTT+OpenHab 07 Апр 2015 23:22 #3169

  • igorvin
  • igorvin аватар
  • Не в сети
  • Захожу иногда
  • Сообщений: 50
  • Спасибо получено: 15
  • Репутация: 1
Hi Everybody,

I want to share you how I configured an ESP8266 module with firmware 0.1.1 PRO version in OpenHab server.

Purpose:
Create sensore for outside with the following functionality:
Scheme:






Configuration:

Firmware settings:
Main


Sensors


GPIO


Servers
IP-192.168.1.148- My OpenHAB Server



Debug data
To see if your system is receiving data by protocol MQTT from the sensor,
Please run this command on Raspberry pi console:
mosquitto_sub -h localhost -v -t '#'
and you should see the following output:
/esp8266/gpio/input/15 1
/esp8266/gpio/output/15 1
/esp8266/gpio/output/14 1
/esp8266/gpio/output/16 0
/esp8266/sensors/dhtt1 24.5
/esp8266/sensors/dhth1 39.0
/esp8266/sensors/freemem 21928
/esp8266/sensors/uptime 76635


OpenHab My Home interface






OpenHab installation

I'm using OpenHab installed on RaspBerry PI with MQTT support
I'm not going to explain how to install OpenHab server
I'm sure that anybody can find a good documentation in Internet - OpenHab Installation

OpenHab Configuration
  1. Edit file openhab.cfg
    You can find this file in directory /etc/openhab/configurations/openhab.cfg
    In Transport configurations section add the following
    mqtt:mymosquitto.url=tcp://localhost:1883
    mqtt:mymosquitto.qos=0
    mqtt:mymosquitto.retain=true
    mqtt:mymosquitto.async=true
  2. Create file myhome.item in /etc/openhab/configuration/items/
    Group	All
    Group	WH	(All)	
    Group	Uber	""	(All)	
    Group	gGF	(All)	
    Group	gFF	(All)	
    Group	gC	(All)	
    Group	gVR	(All)	
    Group	Shutters	(All)	
    Group	Weather	(All)	
    Group	Status	(All)	
    Group	Hardware	""	<network>	(All)	
    Group	all
    
    Rollershutter	Roof_Switch	"Verandah Roof [(%d)]"	<rollershutter>
    Switch	ESP8266_Status	"ESP8266 Module Helth"	(Hardware)		{ nh="192.168.1.149" }
    
    DateTime	Date	"Date [%1$tA, %1$td.%1$tm.%1$tY]"	<calendar>	{ ntp="Asia/Jerusalem:ru_RU" }
    
    Switch	esp_relay_up  "Roof_UP"	(all,gVR)		{ mqtt=">[mymosquitto:/esp8266/gpio/output/15:command:ON:0],>[mymosquitto:/esp8266/gpio/output/15:command:OFF:1],<[mymosquitto:/esp8266/gpio/output/15:state:default]" }
    Switch  esp_relay_down  "Roof_Relay_DOWN"   (all,gVR)	{ mqtt=">[mymosquitto:/esp8266/gpio/output/14:command:ON:0],>[mymosquitto:/esp8266/gpio/output/14:command:OFF:1],<[mymosquitto:/esp8266/gpio/output/14:state:default]" }
    Switch  esp_Rain	"Rain status [%s]"	(all,gVR)	{ mqtt="<[mymosquitto:/esp8266/gpio/input/0:state:MAP(0on1off.map)]" }
    
    Number  esp_temp       "Temp [%.1f °C]"	(all,gVR)	{ mqtt="<[mymosquitto:/esp8266/sensors/dhtt1:state:default]" }
    Number  esp_humid      "Humid [%.1f %%]"	(all,gVR)	{ mqtt="<[mymosquitto:/esp8266/sensors/dhth1:state:default]" }
    
  3. Create file myhome.sitemap in /etc/openhab/configuration/sitemaps/
    sitemap myhome label="My Home"
    {
    	Frame label="Rooms" {
    		Group item=gVR label="Verandah" icon="terrace" {
    			Text item=esp_Rain label="Rain Status [%s]" icon="light"			
    			Text item=esp_temp label="Temp. [%s]" icon="temperature"			
    			Text item=esp_humid label="Humid. [%s]" icon="climate"			
    			Switch item=Roof_Switch label="Roof"			
    		}		
    	}	
    	Frame label="Date" {
    		Text item=Date		
    	}	
    	Frame label="Devices" {
    		Group item=Hardware label="Status" icon="heating" {
    			Switch item=ESP8266_Status			
    		}		
    	}	
    }

  4. Create file myhome.rules in /etc/openhab/configuration/rules/
    I created three rules:
    1. Open roof from the button.
    2. Close roof from the button.
    3 When sensor is detecting a rain, the system automatically close a roof.
    Each rule working with timer, if you open, close a roof from the button or by rain sensor , the system is waiting one minute and then stop both relay.
    import org.openhab.core.persistence.* 
    import org.openhab.model.script.actions.*
    import org.openhab.core.library.types.* 
    
    var Timer timer=null
    var Timer2 timer2=null
    var Timer3 timer3=null
    var Timer4 timer4=null
    
    
     rule "Roof Stop"
     		when
     			Item Roof_Switch received command STOP
     		then
     		sendCommand(esp_relay_up, OFF)
     		sendCommand(esp_relay_down, OFF)
     end
     rule "Roof UP"
     		when
     			Item Roof_Switch received command UP
     		then
     			sendCommand(esp_relay_down, OFF)
     			sendCommand(esp_relay_up, ON)
     		timer = createTimer(now.plusMinutes(1)) [|  
    			sendCommand(esp_relay_up, OFF)
     		]
     end
     			
    rule "Roof DOWN"
     		when
     			Item Roof_Switch received command DOWN
     		then
     			sendCommand(esp_relay_up, OFF)
     			sendCommand(esp_relay_down, ON)
     		timer2 = createTimer(now.plusMinutes(1)) [|  
    			sendCommand(esp_relay_down, OFF)
     		]
     end
    
    rule "Rain"
    		when
    			Item esp_Rain received update ON   
     		then
    			sendCommand(esp_relay_down, ON)
     		timer3 = createTimer(now.plusMinutes(1)) [|
               	sendCommand(esp_relay_down, OFF)
               	]
    end
    
Последнее редактирование: 11 Апр 2015 18:51 от igorvin.
Администратор запретил публиковать записи гостям.

ESP8266+MQTT+OpenHab 08 Апр 2015 04:24 #3170

  • sergeipt
  • sergeipt аватар
  • Не в сети
  • Захожу иногда
  • Сообщений: 43
  • Спасибо получено: 3
  • Репутация: 3
igorvin пишет:
Hi Everybody,

I want to share you how I configured an ESP8266 module with firmware 0.1.1 in OpenHab server.

Purpose:
Create sensore for outside with the following functionality:
Configuration:

Firmware settings:
Main


Sensors


GPIO


Servers
IP-192.168.1.148- My OpenHAB Server




OpenHab installation

I'm using OpenHab installed on RaspBerry PI
I'm not going to explain how to install OpenHab server
I'm sure that anybody can find a good documentation in Internet - OpenHab Installation

OpenHab Configuration
  1. Edit file openhab.cfg
    You can find this file in directory /etc/openhab/configurations/openhab.cfg
    In Transport configurations section add the following
    mqtt:mymosquitto.url=tcp://localhost:1883
    mqtt:mymosquitto.qos=0
    mqtt:mymosquitto.retain=true
    mqtt:mymosquitto.async=true

To be continued.....
good day can connection diagram relay? How does the relay 5 to a power supply module 3.3?
Пользователь Majordomo
Администратор запретил публиковать записи гостям.

ESP8266+MQTT+OpenHab 08 Апр 2015 18:09 #3189

  • shaman1010
  • shaman1010 аватар
  • Не в сети
  • Живу я здесь
  • Сообщений: 605
  • Спасибо получено: 139
  • Репутация: 17
sergeipt пишет:
good day can connection diagram relay? How does the relay 5 to a power supply module 3.3?
5в реле подключать только к 5в источнику, естественно. С модуля - подавать напряжение управления (на мосфет или опторазвязку). Диаграмму думаю можно отрисовывать, метрика передается, дальше работа сервера.
p.s. для топикстартера - можешь писать на русском, мы его понимаем, а то SSID тебя сильно палит (ну и ник) :)
Администратор запретил публиковать записи гостям.

ESP8266+MQTT+OpenHab 09 Апр 2015 00:00 #3192

  • igorvin
  • igorvin аватар
  • Не в сети
  • Захожу иногда
  • Сообщений: 50
  • Спасибо получено: 15
  • Репутация: 1
Hi,

You absolutely right about power supply 5v and about my Russian
I'm sorry, I haven't a Russian keyboard (Translitom pisat' kak to ne seriozno :( )
In this weekend I'll try to finish this post

Have a good night
Последнее редактирование: 11 Апр 2015 10:59 от igorvin.
Администратор запретил публиковать записи гостям.

ESP8266+MQTT+OpenHab 11 Май 2015 10:41 #4132

  • User68
  • User68 аватар
  • Не в сети
  • Давно я тут
  • Сообщений: 99
  • Спасибо получено: 11
  • Репутация: 7
Интересная тема! Ждем продолжения!
Я сейчас использую цепочку:
ESP8266 <-> Бенукс <-> Openhab
По Вашему варианту должна получится более быстрая работа и меньшее потребление ресурсов....
В качестве минуса - сложность настройки, меньший функционал при работе "из коробки"...
Последнее редактирование: 11 Май 2015 10:42 от User68.
Администратор запретил публиковать записи гостям.

ESP8266+MQTT+OpenHab 15 Май 2015 23:16 #4244

  • odix
  • odix аватар
  • Не в сети
  • Новый участник
  • Сообщений: 1
  • Репутация: 0
Подключился к облачной CloudMQTT
Где можно посмотреть команды - чтобы например считывать датчики и управлять gpio?
Администратор запретил публиковать записи гостям.
Модераторы: FlyRouter
Время создания страницы: 0.139 секунд

Home`s Smart © 2013-2016. г.Киров.
Цитирование материалов возможно только со ссылкой на сайт. Использование фотоматериалов только с разрешения авторов.