Tutorial ESPEasy / OpenHAB problem

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
NietGiftig
Normal user
Posts: 103
Joined: 16 Sep 2015, 20:32

Tutorial ESPEasy / OpenHAB problem

#1 Post by NietGiftig » 18 Sep 2015, 23:57

I am having a test setup with Raspi2, TP-link wifi router, ESP8266-12, OpenHAB, Mosquitto and of course ESPEasy

I'm using the router as a dedicated home automation wifi.
It has no Internet connection,just using it as switch

I have connected the Raspi with a wifi stick to the router.
The Ethernet from the raspi goes to my home network so I can manage the raspi also from there.
The serial from the ESP8266-12 is also connected to my work PC
I have connected a laptop to the Home Automation wifi so I can communicate to the ESP8266-12 via the webinterface

I have installed OpenHAB and Mosquitto MQTT on the raspi with the demo site from OpenHAB.

Then I used the EasyESP tutorial for OpenHAB (LED on/off)
I'm using ESPEasy build 20 from Github

I can reach the ESP8266-12 with the webinterface and have it configured for my home automation wifi, I called it "TestESP"
I have managed to let OpenHAB speak to MQTT following the tutorial, I've monitored the MQTT messages to /TestESP/gpio/2 and it is sending 0 and 1 as expected.

The only thing that does not happen is that the LED on gpio 2 responds :cry:

Is there somebody out there who has this tutorial working?
Or somebody who has an advice how to trace/tackle the problem?

Martinus

Re: Tutorial ESPEasy / OpenHAB problem

#2 Post by Martinus » 19 Sep 2015, 16:48

Hello,

Nice to see that someone is actually trying to use the openhab with ESP Easy. We did a test some time ago and it did work at that time (R16). But maybe later development did break something here.

Do you get this message on serial out when the ESP starts:

Code: Select all

MQTT : Connected to broker
I checked the code, but the debugging part has been commented out. Have to improve this in some newer release. You might be able to enable this yourself for time being. If you navigate to the "controller" tab and find lines 387 & 388, should look like this:

Code: Select all

  //for (byte x = 0; x <= count; x++)
    //Serial.println(topicSplit[x]);
and change it to:

Code: Select all

  for (byte x = 0; x <= count; x++)
    Serial.println(topicSplit[x]);
Upload to ESP and see if it shows the received MQTT topic split into separate lines.

NietGiftig
Normal user
Posts: 103
Joined: 16 Sep 2015, 20:32

Re: Tutorial ESPEasy / OpenHAB problem

#3 Post by NietGiftig » 21 Sep 2015, 13:56

Martinus wrote: Nice to see that someone is actually trying to use the openhab with ESP Easy
Yes and no, I want to work with OpenHab and Mosquitto.
I think this problem has to do with the interface Mosquitto <> ESP8266
Martinus wrote: Do you get this message on serial out when the ESP starts:

Code: Select all

MQTT : Connected to broker
Yes it is there
I have uncommented the lines for the debug print, but no result in the serial terminal.

In the sketch i see that the MQTT port is hardcoded (1883).
I do not think thats correct, it can have another one if configured in Mosquitto, (not in this case).
Maybe that there is a mixup in names/ip's and ports for the use with Domoticz

I have also problems with the AP key / Sta key and the initializing of ESPEasy in espeasy.ino
I cannot get my finger behind this at the moment.
It looks like the login code of the ESP is persistant between new flashes, if true then it's probably by design ;) .
I think that there is a problem in the logins, usernames, passwords, ports.
But that's not for this thread, i will open another one for that (once I can describe the problem.)

I continue the search ;)

Martinus

Re: Tutorial ESPEasy / OpenHAB problem

#4 Post by Martinus » 21 Sep 2015, 16:00

NietGiftig wrote:
Martinus wrote: Nice to see that someone is actually trying to use the openhab with ESP Easy
Yes and no, I want to work with OpenHab and Mosquitto.
Now you have me confused. You do have an ESP buy you're not going to use it with openhab/ESPEasy :?
Would have been nice... We need more people to help testing/debugging/etc.
NietGiftig wrote:In the sketch i see that the MQTT port is hardcoded (1883).
You're right about the hardcoded portnumber. That's a bug, but it should still work if you're using the default port on Mosquitto.
It's fixed it R21.

I've had a chance to boot up the openhab testlab and tested against ESPEasy R20. Still works in my testlab (can blink the blue led on/off), so we haven't broken things since R16. Your unit connects anyway or you would not see the "connected to broker message"

So what's wrong in your environment?

In case of OpenHab we decided to have the ESP listen to all topics address to it's name

Code: Select all

/<espname>/#
If I use the MQTTfx tool, everything I publish on that channel is shown on the serial console of the ESP if I use R21.
R21 is available now on github. Maybe you can use this version, so we know that we're using the same sketch...

This is my serial log:

Code: Select all

INIT : I2C
MQTT : Connected to broker
Subscribed to: /openhabdemo/#
INIT : Boot OK
Boot
0
normal boot
MQTT : Topic /openhabdemo/gpio/2
gpio,2,1
And the led is on...

NietGiftig
Normal user
Posts: 103
Joined: 16 Sep 2015, 20:32

Re: Tutorial ESPEasy / OpenHAB problem

#5 Post by NietGiftig » 22 Sep 2015, 14:46

Martinus wrote: Now you have me confused. You do have an ESP buy you're not going to use it with openhab/ESPEasy :?
Would have been nice... We need more people to help testing/debugging/etc.
Sorry, my fault, of course I want to use ESPEasy otherwise I would not be here.
Martinus wrote: I've had a chance to boot up the openhab testlab and tested against ESPEasy R20. Still works in my testlab (can blink the blue led on/off), so we haven't broken things since R16. Your unit connects anyway or you would not see the "connected to broker message"

So what's wrong in your environment?
In case of OpenHab we decided to have the ESP listen to all topics address to it's name

Code: Select all

/<espname>/#
Not good at RTFM
I had called my lovely little ESP8266 E12 "ESPTestboard", because it is sitting in my testboard.
After setting the serial debug to level 4, i did see some lines more in the serial monitor.
(Advice for everybody, set the level high)
That's when I saw the problem, because in the openhabdemo it has a different name, and so a different message topic in Mosquitto.
Martinus wrote: R21 is available now on github. Maybe you can use this version, so we know that we're using the same sketch...
I have, problem has been solved
Th next one is comming, but not ESPEasy.
When I change the buttonstate in OpenHAB a couple of times quick, mosquitto stops responding for a few seconds.
When I do the same in the Raspi terminal console it keeps working.

Code: Select all

 mosquitto_pub -d -t /ESPTestboard/gpio/2 -m "1" 
 mosquitto_pub -d -t /ESPTestboard/gpio/2 -m "0"
 
But that has nothing to do with ESPEasy

xbmcnut
Normal user
Posts: 49
Joined: 17 Mar 2016, 08:49
Location: Auckland, NZ
Contact:

Re: Tutorial ESPEasy / OpenHAB problem

#6 Post by xbmcnut » 17 Mar 2016, 08:56

Hi guys. I too have set this demo up today with R78. I am using MQTT.fx to get status updates from the ESP every 60s on the channel /PetesESP8266/# and this works flawlessly. Tonight I wanted to try publishing to turn the internal blue LED on but when I publish this

Code: Select all

/PetesESP8266/gpio/2
, the blue LED turns on (no payload sent) and I cannot turn it off without hitting reset on the board.

The MQTT server is running on my Synology NAS and the ESP can see it.

Am I doing something wrong?

P.S I'm still learning OH2 so wanted to get familiar with MQTT before delving deeper into OH.
Numerous Sonoff's and Shelly's, Home Assistant on Intel NUC i3, Aeotec Z-Stick (Gen 5), deCONZ Zigbee Stick, 3 x Echo Dot's and 5 x Google Home

dabe5
New user
Posts: 6
Joined: 28 Feb 2016, 20:17

Re: Tutorial ESPEasy / OpenHAB problem

#7 Post by dabe5 » 19 Mar 2016, 10:21

xbmcnut wrote:when I publish this

Code: Select all

/PetesESP8266/gpio/2
, the blue LED turns on (no payload sent)
So what do you expect when you send no payload? I wouldn't even expect that it switches on.

Try to send payload 1 for on and payload 0 for off

I have it running for dimming a RGB LED String and it works well. I can see everything in MQTTfx and Mosquitto and OpenHAB is running on my Synology.

xbmcnut
Normal user
Posts: 49
Joined: 17 Mar 2016, 08:49
Location: Auckland, NZ
Contact:

Re: Tutorial ESPEasy / OpenHAB problem

#8 Post by xbmcnut » 19 Mar 2016, 11:24

@dabe5 Yes, that is why I'm puzzled. When I publish

Code: Select all

/PetesESP8266/gpio/2
without anything else, the internal blue LED turns on. Sending 0 or 1 in the payload makes no difference and I have to reset the board to get the LED to turn off.
Numerous Sonoff's and Shelly's, Home Assistant on Intel NUC i3, Aeotec Z-Stick (Gen 5), deCONZ Zigbee Stick, 3 x Echo Dot's and 5 x Google Home

dabe5
New user
Posts: 6
Joined: 28 Feb 2016, 20:17

Re: Tutorial ESPEasy / OpenHAB problem

#9 Post by dabe5 » 19 Mar 2016, 23:12

I have no problems to switch the gpio on/off with

Code: Select all

/ESP-OG01/gpio/14
and payload 0 / 1

or

Code: Select all

/ESP-OG01/pwm/14
and payload from 0 to 1000 for dimming the LED

but I never tried with GPIO 2.
I use GPIO 12, 13 and 14

xbmcnut
Normal user
Posts: 49
Joined: 17 Mar 2016, 08:49
Location: Auckland, NZ
Contact:

Re: Tutorial ESPEasy / OpenHAB problem

#10 Post by xbmcnut » 20 Mar 2016, 10:33

Thanks for the advice. I'll try that tomorrow.
Numerous Sonoff's and Shelly's, Home Assistant on Intel NUC i3, Aeotec Z-Stick (Gen 5), deCONZ Zigbee Stick, 3 x Echo Dot's and 5 x Google Home

timsson
Normal user
Posts: 77
Joined: 25 Mar 2016, 22:00

Re: Tutorial ESPEasy / OpenHAB problem

#11 Post by timsson » 29 Mar 2016, 16:54

Hi,
something is wrong in R93 or me...
I set gpio15 at ON, 1 or 255 via openhab/mgtt -> it works
but after reboot ESP, gpio15 starts with 0 -> and goes not to ON, 1 or 255.

I would like the same state before reboot...
How can i fix that?
should i set gpio15 as switch?
Thanks

Code: Select all

Mar 29 16:45:58 10.1.1.181 ESP Unit: 1 : MQTT : Topic: /ESP_01/gpio/15
Mar 29 16:45:58 10.1.1.181 ESP Unit: 1 : MQTT : Payload: 255
Mar 29 16:45:58 10.1.1.181 ESP Unit: 1 : SW   : GPIO 15 Set to 255
Mar 29 16:46:00 10.1.1.181 ESP Unit: 1 : MQTT : Topic: /ESP_01/gpio/12
Mar 29 16:46:00 10.1.1.181 ESP Unit: 1 : MQTT : Payload: 155
Mar 29 16:46:00 10.1.1.181 ESP Unit: 1 : SW   : GPIO 12 Set to 155
Mar 29 16:46:01 10.1.1.181 ESP Unit: 1 : MQTT : Topic: /ESP_01/gpio/13
Mar 29 16:46:01 10.1.1.181 ESP Unit: 1 : MQTT : Payload: 155
Mar 29 16:46:01 10.1.1.181 ESP Unit: 1 : SW   : GPIO 13 Set to 155

Mar 29 16:46:06 10.1.1.181 ESP Unit: 1 :      : Rebooting...
Mar 29 16:46:11 10.1.1.181 ESP Unit: 1 : WIFI : Connected!
Mar 29 16:46:11 10.1.1.181 ESP Unit: 1 : MQTT : Connected to broker
Mar 29 16:46:11 10.1.1.181 ESP Unit: 1 : Subscribed to: /ESP_01/#
Mar 29 16:46:11 10.1.1.181 ESP Unit: 1 : UDP  : Send Sysinfo message
Mar 29 16:46:12 10.1.1.181 ESP Unit: 1 : INIT : Boot OK
Mar 29 16:46:12 10.1.1.181 ESP Unit: 1 : INIT : Normal boot
Mar 29 16:46:12 10.1.1.181 ESP Unit: 1 : EVENT: System#Boot
Mar 29 16:46:13 10.1.1.181 ESP Unit: 1 : MQTT : Topic: /ESP_01/gpio/13
Mar 29 16:46:13 10.1.1.181 ESP Unit: 1 : MQTT : Payload: 0
Mar 29 16:46:13 10.1.1.181 ESP Unit: 1 : SW   : GPIO 13 Set to 0
Mar 29 16:46:13 10.1.1.181 ESP Unit: 1 : MQTT : Topic: /ESP_01/gpio/12
Mar 29 16:46:13 10.1.1.181 ESP Unit: 1 : MQTT : Payload: 0
Mar 29 16:46:13 10.1.1.181 ESP Unit: 1 : SW   : GPIO 12 Set to 0
Mar 29 16:46:13 10.1.1.181 ESP Unit: 1 : MQTT : Topic: /ESP_01/gpio/15
Mar 29 16:46:13 10.1.1.181 ESP Unit: 1 : MQTT : Payload: 0
Mar 29 16:46:13 10.1.1.181 ESP Unit: 1 : SW   : GPIO 15 Set to 0

gpio15.jpg
gpio15.jpg (58.92 KiB) Viewed 10592 times

xbmcnut
Normal user
Posts: 49
Joined: 17 Mar 2016, 08:49
Location: Auckland, NZ
Contact:

Re: Tutorial ESPEasy / OpenHAB problem

#12 Post by xbmcnut » 01 Apr 2016, 03:30

dabe5 wrote:I have no problems to switch the gpio on/off with

Code: Select all

/ESP-OG01/gpio/14
and payload 0 / 1

or

Code: Select all

/ESP-OG01/pwm/14
and payload from 0 to 1000 for dimming the LED

but I never tried with GPIO 2.
I use GPIO 12, 13 and 14
Thanks for your help. Works flawlessly now.
Numerous Sonoff's and Shelly's, Home Assistant on Intel NUC i3, Aeotec Z-Stick (Gen 5), deCONZ Zigbee Stick, 3 x Echo Dot's and 5 x Google Home

azure
New user
Posts: 2
Joined: 28 May 2016, 07:33
Location: Tamilnadu, India
Contact:

Re: Tutorial ESPEasy / OpenHAB problem

#13 Post by azure » 28 May 2016, 08:36

am using esp and openhab with mosquitto. it is working fine...

Setup
Esp GPIO pin 12 is connected to relay

My ESPeasy Config
----------------------
Name = sonoff
Controller = OpenHabMQTT
IP=192.168.0.8



My OpenHab Setup
----------------------
default.items
-----------------
Switch LED3W "Ceiling" <light> (FF_Corridor) { mqtt=">[azurebroker:/sonoff/gpio/12:command:ON:1],>[azurebroker:/sonoff/gpio/12:command:OFF:0],<[azurebroker:/sonoff/relay/switch:state:default" }

openhab.cfg
----------------
mqtt:azurebroker.url=tcp://192.168.0.8:1883
mqtt:azurebroker.clientId=openHAB


this setup is working fine
P.Kannan
Whatsapp: +91-9488557777
HAM CallSign: KD0NER
Echolink: KD0NER

Post Reply

Who is online

Users browsing this forum: No registered users and 122 guests