my name is jasir im telling about my friend project
This project uses a Raspberry Pi B+ attached to 2 temperature sensors and sends data to an Azure data source that can be used to create charts.
A bunch of my code for accessing the temperature sensors came from the Adafruit tutorial Adafruit's Raspberry Pi Lesson 11. DS18B20 Temperature Sensing
Step 1: Build the Sensor DeviceThis project uses 2 DS18B20 1-wire temperature sensors. The sensors can be connected in parallel with only one 4.7K resistor.
The red wire is connected to the 3.3v pin, the blue wire is connected to ground, and the green wire is connected to pin#4 for data. The 4.7K resistor goes from data to 3.3V
The Python program prints out the temperature in degrees C every 5 seconds
code session click>> "prints out the temperature"
The program starts by running the 'modprobe' commands, they are needed to start the interface for reading the one wire protocol sensors.
The next three lines, identify the file where the messages can be read. The function read_temp_raw reads the raw data from the interface. The read_temp function parses the data and returns the temperature value.
The main loop of the program reads the temperature and prints it out every 5 seconds.
You can start an editor window and enter the code by typing
[nano sender.py]
Once you've entered the code you can run the code using
[sudo python sender.py]
Step 3: Configure Azure Event Hub
Log into your Azure management portal and create a Service Bus Name Space.
Click the Plus to create a new Service Bus name space. Give the Name Space a name then click the check mark to create.
Within the Service Bus Name Space just created, create an Event Hub. Click the Plus, then Choose Quick Create and give the Event Hub and name then click Create.
In the Event Hub page, click on the configuration tab. Create a policy called Receive Rule with permissions to Manage, Send and Listen. Then policy name and key will be needed later on.
I use an Azure SQL database table here, but you can use other types or data sources like: table store, blob storage, or export directly to PowerBI.
Using SQL Server Management Studio, or some other database management tool to connect to the database and create a table. You can use the following script:
click code sessions <<"step4 code"
Step 5: Configure the Azure Stream Analytics JobClick New to create a new Stream Analytics job, Give it a name and also specify the New Storage Account name, then click Create.
Open the Stream Analytics Job in the Azure Protal (https://portal.azure.com)
Then add and configure an Input. You'll need to specify the Service Bus Name Space, Event hub name. Also enter the policy and key we specified in the previous step. The Event serialization format should be JSON and Encoding should be UTF-8.
Install the Azure API and other prerequisite libraries by executing the following commands within a terminal window on your Pi.
click code session >>"step 6"
Call the Azure API from Python code
This code has been edited to import the Azure library and a call to the sbs.send_event at the end of each loop.
click step6.1
thanks for read the project ,i belive you understand ,more about contact me
Comments