How to model and simulate sensors that will send data to raspberry pi? - 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?

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.

Simulate serial-port communication

This semester I have a project where I need to send data from my microcontroller to my PC and read/interpret its data. We are doing this using an ftdi cable and using matlab to read the data.
I would like to know if there is a way that I can see if my matlab code works that doesn't involve me going to the lab to test it. That is, if there is a way to simulate receiving data in a USB port of my computer so that I can test if my code is working.
Thanks in advance

Registering Raspberry Pi with IBM Bluemix

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

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

arduino +odroid (linaru ubuntu with eclipse and opencv) + usb camera

I hope you can help me. I am trying to build a robot but I am kind of stuck. The Arduino Mega is controlling the stepper motors drivers of the robot. The odroid-x is a single board computer that has installed linaro ubuntu and eclipse c++. All the programming is done in C++ and OpenCV is an image processing library.
The odroid-x has only as input a color camera. Therefore, the information from the camera is received and is processed in eclipse. Then, according to the information that is received, the odroid-x should send different integers to the arduino. The arduino should have a program already uploaded in itself, so it will be waiting for an integer and that integer is going to determine what the arduino is going to send to the drivers.
My questions are the following:
How can I do a serial communication between the arduino and the odroid-x?
How can I send information from eclipse to the arduino with a serial connection?
Thanks so much for any guide you can give me
First, be very, very, very careful. The ODROID boards use 1.8V signalling, so hooking up your 3.3V or 5V Arduino to the pins that expect no more than 1.8V will give you a burnt ODROID-X. It is possible to hook these two boards together if you put a level converter between them, and Sparkfun and Adafruit have some of those converters available. There is even a 1.8V reference voltage pin available... one of the pins that go to the LCD panel RGB-to-LVDS converter board puts out a constant 1.8V.
You could use either the four pins of the little white connector, or UART1, as a serial port, or you can use some of the pins in the 50-pin GPIO block as UART4. There are board schematics available on Hardkernel's website. These two UARTs show up as /dev/ttySAC0 (UART1) and /dev/ttySAC3 (UART4).
I don't know how to talk to those UARTs from a program, personally, but I know there are serial communications libraries available for python from watching threads pop up on the ODROID forums.