I don't know how can I get temperature and humidity value on Arduino Yun Linux can you share about that? I want to send sensor value on sns or Email by python
can you show me your python code?
I've not used that sensor, so I have no finished code to show you. But I can describe the general idea.
The Linux side is powerful, and has a lot of capabilities, but it has no access to the shield connector pins, so it can't access any sensors directly (unless they are plugged into the host USB port.) the Arduino sketch processor is much more limited when compared to the Linux processor, but it has excellent sensor control ability. They each have their strengths and weaknesses, but they work very well together. The key is to use the Arduino side to do the talking to the sensor, and the Linux side to do the heavy processing and communications.
The way I like to do it is to write a sketch that collects the sensor data. I try to keep it simple - just read the data and write it to the Serial port. Make sure that sketch is running properly, and printing the data you expect and that the data looks correct. Make the output format simple.
Next, write the Python script that does the processing and communications work. Actually, this can be any language that the Linux side supports, but Python is easy. Write it so that it reads input data from the keyboard, parses and process that data, and does whatever it is you want done with it (store it in a database, write to SD card, send an Email, etc.) Test that by running it from the SSH command line, and manually typing data into it using the keyboard, giving it data in the same format as is written out by the sketch. Make sure the Python script works the way you want it to work. The Python script should have an infinite loop, such that once started, it keeps going back and looking for more input, forever.
Now, this is an important step: while logged into an SSH session, change to a different directory, and run your Python script again by typing the full path to the script. Does it still work? If not, the script may be referencing some files, assuming that they will be in the current directory. Use full path names when referencing any files, as you cannot make any assumptions about what will be the current directory when it comes to the next step.
Finally, when you know the sketch is working properly, and the Python script is working properly, it's time to tie them together. Doing this step last makes the debugging easy. If you try to do it all at once, it can be hard to determine where a bug may be. But if you get each side working properly first, and they don't work together, then you can be pretty sure the problem has something to do with the way they are connected.
To get them to work together, I use the Process class from the Bridge Library. In setup(), use the Process class to start your Python script (give it the full pathname to your script, don't assume anything about the current directory. Use the runAsynchronously() function to start the process, so that the sketch can continue running while the Python runs at the same time.
Now, the sketch is running, and the Python script is running, it's time for the sketch to send the data to the Python script. Both the Serial class and the Process class derive from the Stream class, so the functions you used to print data out the Serial port will also work with the Process class. Go through and change all of your Serial print statement to print to your Process object instead (or just change the ones that send the data, in case you have other debugging print statements.) For example, if you named your Process object proc
, and you are currently printing your sensor data by using Serial.println(sensorValue);
, you can send that instead to the Python process by changing it to proc.println(sensorValue);
Now, when the sketch runs, it starts the Python script, and sends it the sensor data. The Python script reads that data and does whatever it is that needs to be done. You can also easily send data from the Python script to the Arduino sketch: whatever the Python script prints out (that which normally is printed to the screen when you run it from the SSH command line) will be sent up to the sketch's Process object. You can read that data from the Process object in exactly the same way that you read from the Serial port - for example, using .available() and .read().