Install and setup OpenHAB 2.0 with Mosquitto and ESPEasy+HC-SR04

Yes the HCSR04 requires 5v. I have a voltage divider between the HCSR04 Echo pin and ESP GPIO14. Send me an email at markandcandyingle@gmail.com and I send you a picture of my breadboard setup. The trigger pin on the HCSR04 only requires 3.3v. I dont recall what the code is doing for setting the pin state. If I get a chance I will have look and let you know…hope this helps!

Also I reviewed my instructions above and realized I had the GPIO and board pins reversed. It has been corrected.

Hi Mark,
thanks for your thorough guide.
I have the same setup as you except I am using OH 1.8 .Just a question about the ESP Easy as I couldnt find the answer anywhere else… When you setup the sensor does the ESP Easy GUI show the sensor value in the device window? or the value only appears in OH?
I setup a Dallas DS18B20 last night following the instructions http://www.esp8266.nu/index.php/TemperatureSensor but the value on the ESP Easy GUI wasn’t changing (it was either nan or 0.0), hence I did not proceed to configuring OH for the sensor.
Thanks

Sam - I apologize for the very late reply. I have been busy with other projects and just checked in OpenHAB. ESP Easy does show the value in the device window but I think you need to refresh the page. I am sure you have probable moved on to your next project but let me know if you have any further questions.

Thank you Mark, this was a breakthrough for me. Really appreciate your contribution. Fantastic. Ton of applications here… presence, security… don’t you love the buzz after a break through… delusions of grandeur…
NOW to try and group these type of sensors together… PIR and hc sr04 to build in some sort of escalation… or hierarchy… i.e. Yes you are home (your cell phone has hit the wifi) and PIR/HC sr04 has detected movement… Astro binding says its dark so turn on the lights BUT not too many because its after 11 and we don’t want to wake people… wait the PIR/HCSR04 array has sensed another… who is that behind you…_sigh… I can dream…BIG

Alternative: arduino ide mashup sketch to help others…an alternative to pushing MQTT from sensors http://forum.arduino.cc/index.php?topic=408657.0

1 Like

Knowledge is power! Go improve the world with it!!! Thank you!!

When I do this, I don’t get such a config file (I assume on raspberry Pi/jessie it should be in the folder/etc/openhab2/services)

am I correct I can then create it myself, or does this mean I have another problem?

I think you have another problem. The mqtt.cfg file is part of the OpenHab install. Let me know if you need some help

also in Openhab2 on raspberry?

I relaunched :

wget -qO - ‘Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog’ | sudo apt-key add -

echo “deb http://dl.bintray.com/openhab/apt-repo2 testing main” | sudo tee /etc/apt/sources.list.d/openhab.list

sudo apt-get install openhab2-online

and still get the same result.

I am sorry but I am not familiar with the raspberry install of openhab.

I figure it out how it does work in Openhab2, the current stable release.

I created manually an mqtt.cfg file
I updated the addons.cfg and added mqtt to the binding part.

It’s my guess that selecting mqtt on openhab2 on a raspberry pi only installs the needed mqtt binaries yet no configuration files. (and thus also does not allow to update the mqtt binding setting in paperUI

Great! That makes sense…glad you got it worked out.

1 Like

Hi all, hate to post this here but am struggling at finding this on the web, believe it or not. I have even posted to other forums and no luck.

I am not a gpio guru but have worked with oh for awhile and love it. I have a wemos D1 R2 that is connected to my wifi just fine. I am running the espeasy and working nicely. I have mqtt setup in oh and will connect it all as i go along here. So to my question, i have four relays that i need to connect to the wemos. i can find the schematic but its really greek to me. i just need to know what pins to connect and where to connect the relays. i find tons of youtube videos but they dont show the connection details, just how the code works etc. i guess thats just the simple part that everyone should know but this is my first foray into the electronic side.

Can someone point me in the right direction or just help with some simple dummy information like, dude, just connect pin x to one relay, pin y to another and your good to go.

thanks!

and by the way, this thread is great!

Hello Clint! I can try to help. It’s been awhile so I may struggle a bit. Can you share a pics of your setup to get started?

Sure thing Mark! thanks!

so one pic shows just the wemos and the initial ssr. That ssr will then connect to another ssr then out to pumps. I have spent hours reading and that seemed to be the recommended setup but than again, maybe i dont need the ssr in the middle. in any case, i still dont know how best to connect the wemos to the relays. i have a 5v power supply that will connect to the wemos.

wemos with first ssr

wemos with second set of ssr’s

My working example is here.

SSR is wired to D4, VCC and GND. Note: my SSR is a “Low Level Trigger”.

@boilermanc I would suggest to eliminate intermediate SSRs and use a cheap buffering module like this.

Thanks andrew, this is the small ssr module that i am using.

sainsmart relay

specs are in there. if i am understanding it correctly, it should trigger anywhere from 2.5 - 20v. and then have enough output to trigger the next level ssr. at least that was the thought. the stepper that you sent, is that up or down? can’t really tell by the link.

The spec for the larger ssr would be:

Specification of the SSR
Input: 3V-32V DC
Control: 24V~380V AC
Current: 25A

So on the SSR board IN1, IN2, IN3, IN4 each need to be wired to a GPIO on the Wemos. GND from the Wemos needs to go to GND on the ssr board

How many volts and how much current will the second set of SSR carry?

I am not sure what you power source is for the wemos and ssr board so I want to make sure I understand

It seems I have exactly the same SSR on my module.
There is a schematics on the product page you published - your module seems to be “high level trigger”, so to activate the relay you will need to bring the corresponding NodeMCU output pin high. As a result you should be able to see the LED on the SSR board. Please test up to this step.
From the second picture you posted I’ve got a feeling that your wiring for power SSRs is incorrect. Please check with the manufacturer’s datasheet.
The module I mentioned is actually not a stepper, but “The ULN2003A is an array of seven NPN Darlington transistors capable of 500 mA, 50 V output” (wikipedia). It’s purpose is to protect and offload the NodeMCU outputs and provide enough current [from external source!] to the big SSR for example.

Some research on the control current:
The big SSR you have - Fotek SSR-10DA - has Trigger Current of 7.5ma per datasheet.
For ESP8266 I/O Imax is 12ma per datasheet.
So it looks like you can connect your big relays to your Wemos board directly without using the Sainsmart board. But to be on the safe side I would use something like ULN2003A as mentioned earlier.

Thanks to both for your insight. I will see if i can grab one of the steppers. First step might be to just get the first ssr to fire and that way i can test my code and connections. then worry about the next step of what is the line or not. so given that, which of the gpio’s should i use on the wemos to connect to that relay?

thanks!

It does not matter which GPIO as long as it digital. Is there a schematic for the wemos? I am not familiar with wemos so I need some help from you