Registering Raspberry Pi with IBM Bluemix - raspberry-pi

I registered my Raspberry Pi with IBM Bluemix successfully . It has dht22 temp and humidity sensor connected to it and running.
Question: While building Internet of things starter app , do i need to code anything on Rpi to push that sensor data into Bluemix or simply providing the MAC address and the API will do the trick?
Note: I followed a recipe to configure my Raspberry Pi , registered with the MAC address. It is connected and sending messages when i check in the device.
Kindly let me know if i need to do any other configuration or coding to send specifically my dht22 sensor data to visualize in Bluemix and use it in Node-red.

By default Raspberry Pi recipe sends only the CPU temperature and CPU load. As there are no sensors present in Raspberry Pi by default, the recipe uses parameters like CPUTemp and CPULoad.
In your case, you will need to update the code to include dht22 temp and humidity parameters to be sent to IoTF(Bluemix). Please check the code in Github for the raspberry Pi recipe - https://github.com/ibm-messaging/iot-raspberrypi
Navigate to samples/c for the recipe code. You will have to gather the dht22 sensor data and convert them to JSON and send it to IoTF.
In the iot.h, update the json struct to include your sensor values. You can remove the cputtemp and cpuload parameters if you dont need them.
In iotmain.c, line 152 update the code with the code to gather the dht22 sensor values.
In jsonator.c, update the new sensor values based on your new struct.
Then follow the steps provided here to compile the code and install the new deb file. Now the iot service will send data with dht22 sensor values.

If the Bluemix IOT console is showing the that the device is connected and sending data then you should not need to do anything more on the Raspberry Pi.
You will need to bind the IOT service to your Node-RED instance (assuming you are running Node-RED on Bluemix) to access the data.

I believe the recipe you used was this one: https://developer.ibm.com/iot/recipes/raspberry-pi/
Per the readme in the source code, the events that are emitted in this sample are:
CPU temperature
CPU Load
Simulated Sine wave to demonstrate the different events can be pushed to IoT Portal and visualized.
If you are trying to capture other items such as humidity you may need to create additional code/logic.

I have an ansible role to register raspberrypi, fyr
https://github.com/reachlin/fangge/tree/master/ansible/roles/iot
You have to replace your credentials in file defaults/main.yml
ORG:xxx
TYPE:xxx
ID:xxx
AUTH:token
TOKEN:xxx

Related

How do I create a Near Edge computing system? (Send sensor data with Raspberry Pi/DHT11 sensor)

I am working on edge computing for IoT applications and expected to create a system that acts as a near edge computer with the use of a raspberry pi hooked up to a dht11 sensor. How do I send this data over to a computer that is at the edge? Ideally I want to use my PC as this device but I have no clue how to send this data over in real time.
So far I have created the circuit and can view the temperature and humidity readings on the raspberry pi in python. Unsure of what the next steps are - I don't want to send this data over to the cloud just yet.
Side note: I believe i may be missing knowledge regarding this but is the raspberry pi an edge device because it is hooked up to the sensor directly?
Any help is greatly appreciated.
You need to think this through a bit more. What will you do with the temperature and humidity data that you receive?
For example, if you're just experimenting and want to just see the readings in a console on your PC, you can use netcat to send the console output of your Python program from the RPi to PC. No SW development needed, they just have to be in the same network. Not particularly useful for anything else, either.
Otherwise you need to set up some client-server solution between the RPi and your PC. There's a ton of possible solutions, all depending on what you plan to do with the data. You can use MQTT, HTTP, a straight database connection (MySQL, PostgreSQL), etc. You have to supply both sides of the connection. The Python code on client side which connects and sends data; and the server side thing that accepts the samples and stores them somewhere. Plus all the networking, authentication etc.
Or you can just download the Python client libraries for your favourite cloud solution and set that up according to a tutorial. TBH, this sounds a lot less work to me.

How to model and simulate sensors that will send data to raspberry pi?

I am trying to establish communication between laptop and RPI. So far, I have used python and socket programming to do that. Now, instead of using actual sensors, I want to simulate sensor behavior by which sensor data can be sent from laptop to RPI.
So far I came across some options to do it:
Using IMB Bluemix IoT simulator or
Using simple python scripts to create sensor data or
Using simulink sensor models
Can anyone give me a better idea or any comment about these options please?

Alexa Skill - distinguish between the Users (in Lambda function) who invoked the Skill

After days of searching I decided to ask here for some help.
I want to publish an Alexa Skill which can controll some electric motors.
Current state:
- 1 User
- 1 Alexa
- 1 Local Network
- 1 Raspberry Pi
If the user invokes the skill which sends a json-request to a Lambda function. This functions sends a http-request (with a DDNS I "know" the IP address of the router which forwards the reqest to the Raspberry Pi) to the Raspberry Pi (on which a local webserver is running). This local webserver sends now instructions over the serial interface to the electric motors.
My Problem:
If I add a 2nd or 3rd or 1000th local network (see image), i cant differ anymore between these networks in the Lambda function.
How do I know which User belongs to which Raspberry Pi?
I'm about to implement openHAB, AWS IoT or Pubnub, so I dont have to worry about the communication between a specific Raspberry Pi and the Lambda Function. How ever after this implementaion the Lambda function still doesn't know which Raspberry Pi the User means?!
Ah and the User can only control his own Raspberry Pi which is in the same local network.
Basic Architecture
You can specify a unique user ID in the JSON request. Inside your Lambda Function, you can PubNub publish on a channel that is specific to an individual Raspberry Pi. Each of your Pis can PubNub Subscribe on their individual channel.
Get your forever free API keys here
PubNub Publish without an SDK:
GET request to:
http://pubsub.pubnub.com/publish/your_publish_key/your_subscribe_key/0/channel_name/0/{"your_json":"data_here"}

IBM Presence Insight RpiProx

i've been struggling lately with integrating Rasperry Pi and IBM Presence Insight
for wifi proximity detection
the official documentation describes raspberry pi as possible Wifi Proximity sensor, but there is no available documentation
someone tried it before ?
In order to use Raspberry Pi as a proximity sensor, you will need to:
Build a raspberry pi device with two different wifi adapters
Configure one wifi adapter to be an publicly visible endpoint
Write code to capture every time a mobile device tries to connect to the endpoint
Report that information back to Presence Insights.
Unfortunately, the chunk of code you need to write has not been open sourced, so you will need to do this on your own.
You could probably hack together a solution. It looks like there are a lot of resources out there online about "seeing who connects to my network [1], [2]" You could probably use one of these solutions and just feed the data into Presence Insights in the correct format (see the documentation about "proximity connectors.")
[1] http://www.howtogeek.com/204057/how-to-see-who%E2%80%99s-connected-to-your-wi-fi-network/
[2] https://github.com/tlhunter/node-wireless

CAN bus and SPI communication in Raspberry Pi

I am developing a prototype for adaptive cruise control using two raspberry pi's. I have tested SPI on pi and it works (checked it through loopback). Now i want to write this data to the cotroller. So, after referring to resources i found Socketcan should be used in order to interface can controller with the pi. So i request some one to explain how the communication happens like
1. After writing to spi how the can controller can take that data?
2. If socketcan be used to take data from spi , i need to know how?
Thanks