Several users asked us to show a simple way to connect a Generic Sensor, device or application to a Karotz smart rabbit using Paraimpu. In a previous post in this blog we described how to connect your Karotz to Paraimpu and how to test it.
We remind you to that article for basic, preliminary steps.
Now, we want to connect a Generic Sensor, producing text messages, to Karotz in order to make the rabbit read the sent message through its text-to-speech feature.
The simplest way to do it with Paraimpu is the following.
1. Create the Generic Sensor
From the palette click on the generic sensor icon:
Click the Register Sensor button: in this way you've created a sensor which produces text messages named MySens.
2. Add the Karotz Actuator
Following the steps in the previous blog post, add your Karotz to your Paraimpu workspace, naming it, for example MyKarotz.
At this step, your Karotz should be properly configured and tested.
3. Connect the Generic Sensor to Karotz
In the workspace, connect the Generic Sensor to the rabbit using the connect button on the sensor:
and selecting the rabbit in the pop-up box.
4. Configure the Connection
Go to the created Connection page, clicking on the manage button
Here comes the funny part.
We need to instruct Paraimpu to act as follows:
WHEN a text message comes from MySens, THEN let MyKarotz read it.
To do that we need to create a mapping in the connection configuration page.
Thus, for our scenario, a mapping like the following defines the desired behavior (click to enlarge):
Important: don't forget to activate the connection!
5. Connect the created Paraimpu Sensor to your real object or application
For each sensor added, Paraimpu provides a well-defined API to connect the real physical object or application in order to send data to the system.
In our case, if you open the page for MySens object you will always find the API documentation as follows:
Thus, from your device or software application, making an HTTP POST to /data/new URL and sending a JSON with the right token (as specified in your sensor page) allows you to send data to the corresponding Generic Sensor in Paraimpu.
If all it's OK, then sent data will be automatically transformed and sent to Karotz according to the specified mapping(s).