Yes, support for another smart object such as openPICUS has come into Paraimpu!
Following this tutorial you will be able to connect an openPICUS Device in the Web of Things, getting and posting data from/to Paraimpu.
Here we're going to give you just some hints, and hope this will excite some interest or curiosity, at least...
N.B. The Windows O.S. requisite is relative only to OpenPICUS IDE.
Paraimpu is multi-platform and supports and works on the major operating systems and environments.
First of all, be sure to match the following basic requisites, in order to have your device full-working:
- Your Starter Kit: openPICUS Device + FlyPort module.
- A WiFi Infrastructured Network (supporting 802.11b mode), connected to the Internet.
- A Microsoft Windows O.S.
- A little programming competence in the C language.
- The openPICUS IDE
From openPICUS "Get Started" web page, download and install into your machine:
- Microsoft .NET Framework (if not already installed)
- C30 Microchip Compiler
- openPICUS IDE
- The VCP Driver
From the FTDI web site, in the VCP Driver section, download and install into your machine the proper VCP (Virtual COM Port) Driver, depending on your OS.
This is required to connect your openPICUS Device to a PC via USB Nest.
- And... a great interest in the Internet of Things/Web of Things!
Setup your environment
- Plug your openPICUS Device via USB cable into your PC, and let Windows search for the port drivers.
- Go to the Windows Control Panel, browse to the "Device Manager", and expand the section "Ports (COM & LPT)".
There should be an entry called (probably) "USB Serial Port (COMx)".
- Double click this entry, and the "Properties" window will appear. Here go to the "Port Settings" tab.
- From the menu "Bits per second" select the value 19200.
- Then, click on "Advanced" button. In the "Miscellaneous Options" check the "Set RTS On Close" box.
- Click OK on all opened windows to save the configuration.
Pins not available
We have assumed a particular configuration for the following subset of the pins, for both of the modes.
- OUT5: OUTPUT (digital). It is internally connected to the "D1" red led in the FlyPort. Don't use it!
This led will signal the status of the WiFi connection.
When the connection is (re)extablished, the led turns on; if the connection is lost, the led turns off.
- OUT4: OUTPUT (digital). It is internally connected to the "D2" red led in the FlyPort. Don't use it!
This led will signal the status of the Paraimpu routine, so it will be periodically blinking.
When an HTTP request is in progress, this led will turns on. During timeout periods it will stay off.
- OUT1: OUTPUT (digital). It should be connected to an external led. No problem if you leave it floating.
The led will signal the status of the Paraimpu routine: ON (active) or OFF (suspended).
- IN2: INPUT (digital), internally wired to a pull-down resistor. It should be connected to an external momentary switch-button.
The switch-button should put (temporarily) a HIGH value in input, to suspend or re-enable the Paraimpu routine.
Consequently, the led connected to OUT1 will change ON→OFF or OFF→ON.
If you leave it floating, the input value will be tied to GND, and everything will work (routine permanently enabled).
Note that it's not possible to change the status while a request to Paraimpu is going on (you will know looking at the "D2" red led).
Pins available for openPICUS-based Sensors
- Analog Input: AI1, AI2, AI3, AI4
- Digital Input: OUT2, OUT3, IN5, IN4, IN3, IN1
Pins available for openPICUS-based Actuators
- Digital Output: OUT2, OUT3, IN5, IN4, IN3, IN1
Create an empty project in openPICUS IDE
- Launch the IDE, and create a new empty project (from a "Blank template" on IDE 2.0 or from "Basic no webserver" on IDE 2.1), choosing a comfortable location in your disk.
| Create a new project on openPICUS IDE 2.0|
|Create a new project on openPICUS IDE 2.1|
- There will be displayed some files. The most important for us is the first one:
|Default workspace on openPICUS IDE 2.0|
|Default workspace on openPICUS IDE 2.1|
- Close the project, just for now... we'll need it when you download the Paraimpu-based routine.
OpenPICUS device as a Paraimpu Sensor
To create a new openPICUS Sensor instance, on the Sensor palette, click on the icon equal to the image below.
On the page details of the just created sensor, you can set the routine before downloading. You can choose its mode between:
- Reader. All the input values are periodically sent to Paraimpu
- Trigger. Inputs are coupled with a trigger condition. When all trigger conditions are satisfied, their values are sent to Paraimpu. Conditions are evaluated according AND logical operator.
Last example image shows, on analog input
AI1we set just one trigger-condition: 600 ≤ value ≤ 1023. In this way, data will be sent to Paraimpu ONLY when the input value lays in the range between 600 and 102
This means that the analog input should exceed the value given by:
600·2mV = 1.2 Volts.
Note: You should not leave any pin floating, because read values could be unpredictable.
Filled the widget data, you must click blue button to download the your routine. The original file name is
OpenPICUS device as a Paraimpu Actuator
To create a new openPICUS Actuator instance, on the Actuator palette, click on the icon equal to the image below.
Then, you move to the details page of this newly created Actuator instance.
To download the related
taskFlyport.cjust click on the blue button (like the one showed on next image).
Configure and Upload on your openPICUS device the Paraimpu-based routine task
Independently you are playing with a sensor or and actuator, we downloaded the Paraimpu-based routine task. If you didn't change its name, it's called
- Move the downloaded
taskFlyport.cto the directory of the just created openPICUS project overwritting the default
- Re-open the project. The downloaded file will be shown in place of the old blank one.
- For security and privacy reasons, you edit some parameters.
Only 1 parameter is compulsory:
#define my_SSID "___"
the SSID of your WiFi Network
taskFlyport.c.Anyway, they are:
#define my_SECURITY "___"
The type of security of your WiFi Network (WPA, WEP40, WEP104, or OPEN)
#define my_IPaddress "___"
A valid free IP Address
#define my_PASSWORD "___"
The password for your WiFi Network (ignore for OPEN Networks)
#define my_WEPindex "___"
The key-index of your password (only for WEP Networks)
#define my_TIMEOUT "___"
The Timeout between subsequent requests to Paraimpu
- We pre-set the primary e secondary DNS Server addresses with 2 OpenDNS server, you can modify them DNS more comfortable for you. The variable to modify are:
#define my_primaryDNS "___"
#define my_secondaryDNS "___"
- You'd better "Recompile All" the whole project.
No additional configuration is needed: the default one will be OK for the routine to work.
- As final act, "Download Firmware" into your openPICUS Device.
- Once the firmware has been downloaded into your openPICUS device, it will begin getting/posting data from/to the corresponding Paraimpu actuator/sensor instance.
Testing if your Actuator is working fine
After downloading and uploading, it's the time to test if the actuator is working fine.
Connect the 6 output pins to 6 different LEDs.
The OpenPICUS device lets 2 tipologies of output signals:
- LOGICAL DC value:
- PWM wave: a 3.3 Volts peak value, with the specified
OUT3(with the "observable" 1 Hz Frequency, and a 50% Duty-Cycle).
For the other outputs
IN1, we choose just a HIGH value.
In order to simulate the arrival of this data, press the "POST Data" button.
You will see the two leds (connected to
OUT3) blinking every half second, and all the others just turning ON.
Using a Phidget Sensor to verify if your Sensor is working fine
Let's consider for example a Force/Pressure Phidget as a "trigger" input for our OpenPICUS device.
Unlike the 5 Volts recommended for the Phidget, we power it to 3V from the 3V3 openPICUS, in order to produce values inside the acceptable input voltage range.
Now, plug the force sensor as showed in image below.
As soon as you'll press the Phidget button, the openPICUS will post the values to Paraimpu according the mode of your sensor. You can verify data sent on the sensor details page.
You are encouraged to make connections with this openPICUS Sensor, so that data can flow to some Actuator instance.