Getting Started - Tutorial - Creating First Program
Tuesday, July 31 2018

Video Version of this Tutorial

For certain things, directly controlling an LED manually is enough for turning one or two things on and off, but, you might be wondering how to do more complex tasks such doing multiple things with one action.

The way that we accomplish this with NodifyMe is through Programs.

In short; programs are the way that you can combine nodes together, as building blocks, to do more interesting and complex things.

We are going to start simple and build on what we've done in a pervious tutorial in which we used NodifyMe on a Raspberry Pi and got an LED to blink.

We are going to use a common premade Relay Board that is can be found on eBay, Amazon, Alibaba etc... You can get one here: 8 Channel Relay

We are going to hook this up as follows:

  • Raspberry Pi 5V -> Relay JD-VCC
  • Raspberry Pi 3.3V -> Relay VCC
  • Raspberry Pi GND -> Relay GNC
  • Raspberry Pi - pin 0 -> Relay In1

We are going to open NodifyMe Studio and connect to our Raspberry Pi so that we can use this relay board now.

Let's go ahead and find the DigitalWriter node that we used in the last video and rename it to Relay 1 and click save.

Now we can go to the view and start to control the relay.

You may notice that this board works a little differently than you might expect as you send an off or false signal to the relay that you want to engage and a true or on signal to disengage. As you can see, it is not always safe to assume that a signal does what you think.

For GPIO pins on a Raspberry Pi, we can compensate for this by using the invert property on the Digital Writer nodes, in this case, "Relay 1", so that the switch and the Relay behaves as expected.

This invert property is not always available but luckily there is another way. We can also perform this same inversion for any boolean signal by connecting another node before this that will invert the signal.

To demonstrate this, let's go ahead and disable the Invert property before moving on to the next step.

This is where Programs come into play. Programs allow you to string nodes together and have data flow between them. In this way you can create interesting automations from simple (and sometimes not so simple) building blocks.

To get started with programs, you'll need to make sure the Nav Panel is open and then select the Programs item under your Raspberry PI hub in the NavPanel.

Once we are on the Programs List view, we are need to click on the Add button. This will take us to a new program and program canvas in which we can drag-n-drop Nodes that we have already created onto and connect them together.

Let's go ahead and drag-n-drop our Relay 1 node that we created in our last video onto the canvas.

You can see that we have a block representation of our node with inputs and outputs on the sides.

It's kind of lonely here so let's another Service with some Nodes that will allow us to do slightly more interesting things with on and off values. Let's grab the boolean service from under the Services Tab.

We will go ahead and add it to the Hub just like we did previously with the RPiDigital service.

Now that we have our Bool service, let's start it and make sure that the light beside the on/off switch turns to green. If it does not, you can cycle the service host by turning it on and off. This usually clears up an issues.

Now let's start adding boolean Nodes. We'll just need to drag one Not Gate and one Bool Source (Dynamic) to the Active Nodes list in the Boolean Service.

Turn both of the Nodes 'On' or 'Enabled' to make sure that they are not muted when we used them.

Now let's head back to the program and add these two nodes to our program canvas. Let's drag each of them onto the canvas now.

The Boolean Source Dynamic is useful for generating a boolean signal that is later modified by other nodes downstream. In this case the chain ends with a single GPIO pin on the Raspberry Pi that we are sending these boolean signals to.

The Not Gate reverses that generated true or on signal to be a false or off signal (and vice-a-versa) so that our Relay board again behaves as expected.

Wire these nodes together like you see I've done here to complete this first part of the program.

Then open the Bool Source node's view by right clicking on the Node and then clicking 'Popout Edge View'. This is a live view of what is going on in the Node that you can also directly affect.

Go ahead and change the state of the Value pin to switch between true and false and notice that the Relay is again behaving with true turning the Relay on. You can see here that the boolean signal is being modified by the Not Gate node to invert the signal.

To further demonstrate this and to also show multiple dispatch, we are going to hook up one more relay to the Raspberry Pi.

In this case, I am hooking up the Raspberry Pi, wiring Pi pin 1, up to Relay In2.

Now we need to add the node that represents this GPIO pin and relay in NodifyMe Studio.

To do this we are going to add another Digital Writer node in the RPi Digital service like we did before. Don't forget to set the pin number property, in this case to 1, and be sure to click save. Also rename the node to Relay 2 so that we can keep track of which is which.

Now going back to the Program, we are going to drag the Relay 2 Node from Available Nodes onto the Program Canvas.

Let's wire this Relay Node directly to the Bool Source node.

Now when you flip the switch in the Bool Source node view, you will see that the two relays are always going to be inverted from each other.

This demonstrates wiring as well as the multiple dispatch taking place from one mouse click.

That is all for this tutorial. I hope you found it useful!