ESP-01 / Openhab challenges [solved]

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bennybubble
Normal user
Posts: 44
Joined: 31 Jan 2016, 21:05

ESP-01 / Openhab challenges [solved]

#1 Post by bennybubble » 31 Jan 2016, 21:33

Dear all,

Recently I tried to connect some ESP-01 modules to connect to my Openhab 1.80.
OpenHab is running fine with some (software) bindings like weather etc.
Now it was time to connect some hardware and choose the ESP-01 with ESPEasy to control some stuff around the house.

After some struggling (installing broker (mosquitto) and programming the ESP-01), I was able to control a led via Openhab on the ESP-01.

So far so good but I also want to monitor some pir (motion) sensors using the 'switch' functionality in ESPEasy and that's where the problems begins.
I tried almost everything in OpenHab and ESPEasy but cannot get the thing to work, I searched the internet but cannot find a good (working) example on how to do this.

Is there anyone who can help me setting up a motion sensor using ESPEAsy (R78) and OpenHab (1.80) ?
OS = Windows 7 ENG

In .sitemap I have :

Code: Select all

	Frame label="MQTT Test"{
 		Switch item=MQTTLED 
 		Text item=MotionBackyard 	
	}
In .items :

Code: Select all

Switch MQTTLED {mqtt=">[mybroker:/device180/gpio/2:command:ON:1],>[mybroker:/device180/gpio/2:command:OFF:0]"}
Contact MotionBackyard "Motion Backyard [%d]"  {mqtt="<[mybroker:/device180/gpio/0/state:state:default]"}
Image

This is the startup code from ESPEasy :

Code: Select all

>reboot

 ets Jan  8 2013,rst cause:1, boot mode:(3,7)

load 0x4010f000, len 1264, room 16 
tail 0
chksum 0x42
csum 0x42
~ld
ªU
INIT : Booting Build nr:76
mode : sta(18:fe:34:9c:c8:06) + softAP(1a:fe:34:9c:c8:06)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
bcn 0
del if1
mode : sta(18:fe:34:9c:c8:06)
IP   : Static IP :192.168.2.xxx
WIFI : Connecting... 1
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
pm open phy_2,type:2 0 0
cnt 

connected with xxxxxxxxxxxxx, channel 12
ip:192.168.2.xxx,mask:255.255.255.0,gw:192.168.2.xxx
WIFI : Connected!
MQTT : Connected to broker
Subscribed to: /device180/#
INIT : Boot OK
INIT : Normal boot
MQTT : Topic: /device180/gpio/2
MQTT : Payload: 1
SW   : State 1
MQTT : Topic: /device180//Switch
MQTT : Payload: 1.00
SW   : State 0
MQTT : Topic: /device180//Switch
MQTT : Payload: 0.00
WD   : Uptime 0 ConnectFailures 0 FreeMem 26456
In the LOG file of ESPEasy (and serial output window) I see that the state of GPIO-0 changes from 0 --> 1 and vice versa when motion is detected BUT I cannot get it detect it in OpenHab !
The LED is connected to GPIO-2 and the PIR sensor to GPIO-0.

Anyone any idea what could be wrong ? Any help greatly appreciated !

-ben
Last edited by bennybubble on 02 Feb 2016, 18:53, edited 1 time in total.

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: ESP-01 / Openhab challenges

#2 Post by costo » 01 Feb 2016, 02:09

I think you should try to fill in a number other than 0 or 1 in the IDX/Var field.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: ESP-01 / Openhab challenges

#3 Post by tozett » 01 Feb 2016, 08:11

i struggled about this, too.
maybe you put first a real switch on the GPIO, see if it sends via MQTT to openhab and than change to the PIR-sensor ?..

bennybubble
Normal user
Posts: 44
Joined: 31 Jan 2016, 21:05

Re: ESP-01 / Openhab challenges

#4 Post by bennybubble » 01 Feb 2016, 08:22

tozett wrote:i struggled about this, too.
maybe you put first a real switch on the GPIO, see if it sends via MQTT to openhab and than change to the PIR-sensor ?..
Thanks for your reply, tried with forcing it hi (+3.3v) and lo (0v), no luck...

-ben

bennybubble
Normal user
Posts: 44
Joined: 31 Jan 2016, 21:05

Re: ESP-01 / Openhab challenges

#5 Post by bennybubble » 02 Feb 2016, 10:25

Problem solved !

Had to change Contact to String in .items file, now working fine.
Also mosquitto_sub tool was a great help in debugging !

-ben

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: ESP-01 / Openhab challenges

#6 Post by tozett » 02 Feb 2016, 13:31

as i am no admin, newly just looking around at lot in this forum,
i myself would find it helpful to see solved problems renamed in the Thread-Subject to "SOLVED:..."
by the threadstarter. i makes the overview in big forums a lot easier...
:P

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests