esp easy and node-red

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Peterj
New user
Posts: 9
Joined: 20 Mar 2017, 23:41

esp easy and node-red

#1 Post by Peterj » 27 Mar 2017, 11:41

Hi all
I have flashed a sonoff using esp easy and using some http commands i can easily get the relay to switch on or off, . I decided to try using node-red, it a big fat fail, I think it has something to do with the address node red is using, it being 127.0.0.1, I don't know how to get node-red to use an address within the range of my network(192.168.1.?), what am i doing wrong?

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

Re: esp easy and node-red

#2 Post by NietGiftig » 27 Mar 2017, 13:13

You have to install a MQTT messagebroker
Mosquitto MQTT is a a good working one.
Google a bit with node-red & MQTT

Peterj
New user
Posts: 9
Joined: 20 Mar 2017, 23:41

Re: esp easy and node-red

#3 Post by Peterj » 31 Mar 2017, 20:45

thanks mate that might just be where I am going wrong.
:idea:

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: esp easy and node-red

#4 Post by JR01 » 01 Apr 2017, 10:30

Or tou could control esp from node red vihytp controls
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

Peterj
New user
Posts: 9
Joined: 20 Mar 2017, 23:41

Re: esp easy and node-red

#5 Post by Peterj » 08 Apr 2017, 15:37

Thanks all, I have mostly abandoned this project I can just not get node red to connect. like i say I have put in some rules and I can switch them remotely by typing commands in the browser link bar which works for me locally, just not as nice looking as node-red though.

User avatar
lucaberta
Normal user
Posts: 59
Joined: 09 May 2016, 11:26
Location: Lausanne, Switzerland
Contact:

Re: esp easy and node-red

#6 Post by lucaberta » 20 Apr 2017, 01:33

Running an MQTT broker such as Mosquitto together with Node-RED on a simple device such as a Raspberry Pi is not that complicated after all.

Andreas Spiess, who has a great YouTube channel with lots of good tips on IoT and ESP8266-based projects, did it recently on a Raspberry Pi Zero, here is the video:

https://www.youtube.com/watch?v=QU24kMqpFdY

Peter Scargill, another very active blogger on IoT, has put together a very useful script which configures a fresh install of Raspbian or Diet Pi to include MQTT, Node-RED, and a few other useful utilities to play with, I highly recommend "The Script" in order to kickstart your MQTT and Node-RED experiments:

http://tech.scargill.net/a-christmas-script/

Hope this help!

Bye, Luca

Peterj
New user
Posts: 9
Joined: 20 Mar 2017, 23:41

Re: esp easy and node-red

#7 Post by Peterj » 02 May 2017, 00:17

thanks all, I am revisiting the node red thing, with some success.
what I have noticed is when I put sonff 1/# in the input node topic section it selects all the data that is in the system info on the esp chip is there any way to only select the uptime ?
thanks

User avatar
lucaberta
Normal user
Posts: 59
Joined: 09 May 2016, 11:26
Location: Lausanne, Switzerland
Contact:

Re: esp easy and node-red

#8 Post by lucaberta » 02 May 2017, 01:10

Peterj wrote: 02 May 2017, 00:17 thanks all, I am revisiting the node red thing, with some success.
what I have noticed is when I put sonff 1/# in the input node topic section it selects all the data that is in the system info on the esp chip is there any way to only select the uptime ?
that's good news, great!

To answer your question, when you use # in your subscription topic, you are telling your MQTT client to send you *all* the data sent within the topic with the label you have before the "/#" part.

You can narrow down your subscription and, if your sonoff1 topic includes sonoff1/uptime, then you should see the value posted to your MQTT broker.

Mind you, that data is not sent by default, you need to configure a system device in the devices tab, and select uptime and the rest of configuration data. Uptime is an integer value, so of course put 0 for the number of decimals.

Hope this helps.

Bye, Luca

Peterj
New user
Posts: 9
Joined: 20 Mar 2017, 23:41

Re: esp easy and node-red

#9 Post by Peterj » 02 May 2017, 10:45

thanks i will try a few strings of text I am not sure of the syntax for this filter.
when i use "sonoff 1/#" I get all the system data, uptime, wifi, and ram.
when I change the script to "sonoff 1/uptime" I get nothing,
is there a way of grabbing the data directly from the devices list on my sonoff 1?
thanks

User avatar
lucaberta
Normal user
Posts: 59
Joined: 09 May 2016, 11:26
Location: Lausanne, Switzerland
Contact:

Re: esp easy and node-red

#10 Post by lucaberta » 03 May 2017, 08:59

Peterj wrote: 02 May 2017, 10:45 thanks i will try a few strings of text I am not sure of the syntax for this filter.
when i use "sonoff 1/#" I get all the system data, uptime, wifi, and ram.
when I change the script to "sonoff 1/uptime" I get nothing,
are you sure you are running ESPEasy on your Sonoff device?

Could it be that you are running ESPurna instead, maybe?

Do have a space between "sonoff" and the number 1 in the topic?

ESPurna by default sends out system data in a format such as:

device-name/uptime
device-name/vcc

and other parameters.

In ESPEasy these parameters are not sent by default, they rather have to be configured specifically as a "system" device in the devices configuration tab.
is there a way of grabbing the data directly from the devices list on my sonoff 1?
I am not sure I understand what you mean there, can you explain?

Luca

Peterj
New user
Posts: 9
Joined: 20 Mar 2017, 23:41

Re: esp easy and node-red

#11 Post by Peterj » 03 May 2017, 09:50

Thanks for your help and encouragement
another small step forward the syntax for the capture of data is "/sonoff 1/wifi/" the third forward slash is the charm.
I need to work on getting the relay now to switch,
i have configured the node server to "mosquitto@127.0.0.1:1883" ?
I have in the topic"/newdevice/gpio 12/".
when I send a 1 or a 0 the sonoff goes offline for a second.
I have noticed when I set the server to "node-red@127.0.0.1:1883" I still get system data.
my node-red is on 127.0.0.1:1880, could this be a problem?
I am using espeasy 120.
thanks

User avatar
lucaberta
Normal user
Posts: 59
Joined: 09 May 2016, 11:26
Location: Lausanne, Switzerland
Contact:

Re: esp easy and node-red

#12 Post by lucaberta » 03 May 2017, 09:59

Node-RED is on port 1880, while MQTT is on port 1883. They work together but are not the same thing, so don't worry about that.

To have the Sonoff relay switch you need to do something different.

You need to publish a message to the "/sonoff 1/cmd" topic with content:

gpio,12,1

to turn on GPIO-12, and

gpio,12,0

to turn it off.

You could then create appropriate nodes in Node-RED to control this from the graphic UI via a web browser, which is precisely what I do too.

Luca

Peterj
New user
Posts: 9
Joined: 20 Mar 2017, 23:41

Re: esp easy and node-red

#13 Post by Peterj » 03 May 2017, 19:20

thats great I can easly do that I think I understand now.

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests