Vadim Tabakman

Python to REST Nintex Workflow Cloud External 

Python to REST Nintex Workflow Cloud External

Although this post is specifically about the Raspberry Pi, I'm putting it in here, because this is going to be my start into writing some Python code to make a REST call.  Now it doesn't haven't to be Nintex Workflow Cloud, but since I do a lot of work around Nintex, this was the easiest thing for me to do.  Since I didn't have to go and build a REST service.  Instead, I build a workflow in Nintex Workflow Cloud that had an external start (REST end point).

I also wanted to see if I could write the Python script in the simplest possible way so that it's easy for everyone to understand.

Nintex Workflow Cloud

I know some of you may not know what Nintex or Nintex Workflow Cloud is.  Check it out.  It's quite amazing in letting you automate business processes with an easy to use drag and drop designer.  In this example, I created a simple workflow and configured it have an External Start with two parameters.

This is what the External Start settings look like :

Notice the two parameters, EventName and EventAmount.  These are going to be two JSON parameters we will be able to set from the Python script.

Next, we have a simple Send an Email action:

Finally, once you publish this workflow, you get all the REST information you need to then plug into the Python script.

 

Here are the minimum requirements I had.

  • REST Url
  • JSON data (payload)
  • Headers

# This is what the Python looks like.

import requests

url = 'https://........'

data = '{\

   "startData": {\

      "se_event_amount1": 20.4,\

      "se_event_name1": "Intruder alert"\

   },\

   "options": {\

      "callbackUrl": ""\

   }\

}'

headers = {'content-type': 'application/json'}

response = requests.post(url, data=data, headers=header)

print response.text

Now I saved this file as "nwcStart.py" and I was able to easily run this to make sure it works, using "python nwcStart.py".

Conclusion

This is just the beginning.  I wanted to see how easy it was to make a REST call from Python, since the aim will be for this type of script to be run when a sensor on the Raspberry Pi, senses something we are interested in.

I hope this helps.  If you have any questions, let me know.

Posted by Vadim Tabakman Wednesday, January 4, 2017 10:56:00 AM Categories: Nintex Nintex Workflow Cloud Python Raspberry PI REST

Getting an LED to Light Up 

Getting an LED to Light Up

I'll be the first to admit that it's been many many many years since I've done anything to do with electronics and I can't read the simplest electronics diagram if my life depended on it.  This is actually one of the reasons I'm messing around with the Raspberry Pi.  I want to keep my brain active since learning another language (spoken.. not programming) is beyond my limitations.  "Limitations are the shackles we bind to ourselves".  Who said that??? - I'm showing my grandpa'dness.

Last night I was googling around all over the place to get my head around how to get a simple LED to light up using the Raspberry Pi.  It doesn't sound hard, and it's probably the first thing you should do.  It's like the Hello World of electronics.

Firstly, I should tell you what my set up is.

  • Raspberry Pi 2
  • Breadboard
  • T-Type GPIO expansion board
  • Ribbon cable to connect the expansion board to the Raspberry Pi.
  • Red LED
  • 470ohm Resistor
  • 3 jumper leads (red, white an black)

Those are the minimum that I found was needed to get this to work.  I'm going to try to explain why it plugged in the way it is, but I want you to take note that I'm learning here.  So it's possible I'm doing something wrong (hopefully I won't electrocute myself).  If you see I'm doing something wrong or don't get it, let me know.  I'm keen to understand this stuff better.

Making sure there's Power and Ground to the Breadboard

I'm making this the first part of this post, because this is what I didn't know and I woke up this morning with an epiphany.

Feel free to click on the above image, to get a closer look.

Firstly, when you plug in the T-type expansion board into the breadboard (with the ribbon), I was under the wrong impression that somehow the left and right side of the board now had power and ground all connected up, under the covers.  That was a wrong assumption.

As you can see, I have a White jumper connected to Pin 1 (3v3 power) and it goes to the + (red) column.  That sends power down that column, so you can plug things into it now.

I also have a Red jumper that connects the Gnd (ground) pin to the - (blue) column. This is what I was missing as I thought I didn't need to do this.

LED

The LED you can pretty much put anywhere, as long as it's not on the same row.  The rows, being the number set of holes.  What I mean, is that your LED can't take up pins D35 and E35.  One row needs to be for the positive (anode) and the other for the negative(cathode).I've put my Red LED with the anode on E33 and the cathode on E34.  So now my row 34 is the negative (or ground) and row 33 is the positive (power).

For those who are learning, like me, the anode (+) is the long leg of an LED and the cathode (-) is the shorter leg.

Resistor

I've read a bunch about how you shouldn't plug the LED directly to the power with a resistor, because it will try to drag in as much power as possible and burn itself out.  I actually did connect it up without a resistor and it worked, but I don't recommend this as I did it while I had no idea what I was doing.  Which I still feel is the case :).

I took the 470 ohm resistor that came with my kit, but you can use a smaller one since we are just dealing with an LED.  One of the ends of the resistor is plugged in to the cathode row.  In the picture, it's plugged into A34.  The other end of the resistor is plugged into the - line (to ground it).

GPIO17 pin

The final electronics piece of the puzzle, is connecting the LED to one of the GPIO pins, because I want to write some code to talk to it.

In the image above, I have a Black Jumper connected to the anode part of the LED (pin C33.. it could also be A33, B3 or D33)  The other end of the jumper is connected to B6 which is the GPIO17 pin.

Code to turn the LED on and off

Since I'm running Raspbian (linux) on the Raspberry Pi, the simplest way to communicate with the pins is using Python.  Now I'm not a Python guru.  I'm learning it as I go, so it's not going to be pretty. 

Turning on the LED

import RPi.GPIO as GPIO

pinNum = 17

GPIO.setmode(GPIO.BCM)

GPIO.setwarning(False)

GPIO.setup(pinNum, GPIO.OUT)

GPIO.output(pinNum, GPIO.HIGH)

Turning off the LED

import RPi.GPIO as GPIO

pinNum = 17

GPIO.setmode(GPIO.BCM)

GPIO.setwarning(False)

GPIO.setup(pinNum, GPIO.OUT)

GPIO.output(pinNum, GPIO.LOW)

Conclusion

I don't think this is too complicated, but like I said, I'm still learning and I could be doing something wrong or describing it incorrectly.  Please let me know if either is true as I want to understand this stuff and I also want to put it in a way for other beginners/newbies like myself to learn it easily.

A little addon to this. I installed Ninja-IDE to write my Python.  It seems pretty good for my needs.  That way, I can write the Python code and it gives me an idea if I totally messed something up, like syntax.  Then I save the files, eg ledON.py and ledOFF.py and I can run them with something like this:

python ledON.py

and

python ledOFF.py

Posted by Vadim Tabakman Wednesday, January 4, 2017 7:58:00 AM Categories: Breadboard GPIO GPIO17 Jumpers LED Ninja-IDE Python Raspberry PI Resistor T-Type Expansion

Updating your Raspberry Pi 

Updating your Raspberry Pi

It's been a while since my Unix days, so I feel like I'm learning all over again.

Updating the Raspberry Pi is quite simple.

sudo apt-get update && sudo apt-get upgrade

That goes and downloads all the updates for what you have installed.  In some cases, it will stop and ask if you want to continue.  You just need to press Y and then <enter>

Posted by Vadim Tabakman Tuesday, January 3, 2017 8:16:00 PM Categories: apt-get Raspberry PI

Minimizing Hardware - Remote Desktop 

Minimizing Hardware - Remote Desktop

Keeping this a short and sweet blog post.  Mostly as a reminder to me for later so I don't forget and have to keep looking.

One of the important things to me around the Raspberry Pi, is that it's tiny and it doesn't take up a lot of real estate on my desk or in my office.  Once I have Raspbian installed on an SD card, the first thing I did was to get Remote Desktop working.

Why??  Because that means I don't need to worry about having a monitor, a keyboard and a mouse connected it.  It can be sitting in a corner somewhere and as long as it has power, it'll do what I tell it to do.

I looking online on how to get RDP (remote desktop) working, and installing xrdp almost worked, but I was having some issues after successful login.  Turns out I needed something else.

So here are the commands to run:

sudo apt-get install tightvncserver
sudo apt-get remove xrdp
sudo apt-get install xrdp

Notice that it removes xrdp and installs it again.  That assume you already installed it and are having issues.

This seemed to work for me and hopefully it helps others.

Posted by Vadim Tabakman Tuesday, January 3, 2017 8:09:00 AM Categories: Raspberry PI RDP Tightvncserver XRDP
Page 2 of 2 << < 1 2