Sensor data acquisition and visualization for plant growth with Intel Edison and Python

I used Intel Edison and Python to acquire and visualize sensor data for growing plants. Even a beginner like me who doesn't understand the circuit can easily get the value just by writing the code if there is a Base Shield and a sensor, which is fun. There are few things written using Python in Edison, so I decided to write it. It doesn't look like IoT because it doesn't work with the server.

What I did this time

edison setup Get sensor value by python ・ Save csv file Visualization with nvd3.js

Intel Edison settings

This was set with reference to the following. Arduino board http://nonnoise.github.io/Edison/

sensor

I used the following sensors.

Grove - Temperature Sensor Grove - Light Sensor Grove - Moisture Sensor http://www.seeedstudio.com/wiki/Grove_-Temperature_Sensor http://www.seeedstudio.com/wiki/Grove-Light_Sensor http://www.seeedstudio.com/wiki/Grove-_Moisture_Sensor

I bought a kit because I'm a beginner and I don't understand the circuit too much. http://www.sengoku.co.jp/mod/sgk_cart/detail.php?code=EEHD-4KNG

Also, I thought it would be interesting to talk, so I attached an LCD monitor. http://www.seeedstudio.com/wiki/Grove_-_LCD_RGB_Backlight

The completed system looks like this. Grow peppermint.

sensor.jpg

It is interesting that you can easily get data just by inserting it in the pin.

program

This time, the date, temperature, light intensity, and water content in the soil are saved in csv format every 10 minutes. Import the mraa module and read the value of the pinned sensor. It seems that lcd can be controlled by mraa, but pyupm_i2lcd was easier, so I used this.

sensor.py


#!/usr/bin/python

import datetime
import mraa
import csv
import time
import math
import pyupm_i2clcd as lcd

# definition of Pin
light = mraa.Aio(0)
temperature = mraa.Aio(1)
moisture = mraa.Aio(2)
lcdDis = lcd.Jhd1313m1(0, 0x3E, 0x62)

B = 3975
t = 0
OUT_FILE = "20150426_30.csv"
HOUR = 3600 * 30

with open(OUT_FILE,"wb")as f:
    writer = csv.writer(f)
    writer.writerow(["datetime","temperature","light","moisture"])

while t < HOUR:
    if t % 600 == 0:
        #read the value
        light_val = light.read()
        tem_val = temperature.read()
        moi = moisture.read()

        #calc temperature
        resistance = (1023.0 - tem_val) * 10000 /tem_val
        tem_last = round(1/(math.log(resistance /10000) / B+1 / 298.15) - 273.15,2)

        #calc light
        rsensor = round((1023.0 - light_val)*10 / light_val,2)

        #calc today
        d = datetime.datetime.today()

        #calc moisture
        moi_per = round(moi / 10.0,2)

        strtime = d.strftime("%Y-%m-%d %H:%M:%S")

        with open(OUT_FILE,"ab")as f:
            writer = csv.writer(f)
            writer.writerow([strtime,tem_last,rsensor,moi_per])
        print "Now:",strtime,"," , "Temperature:",tem_last,"," , "Light:",rsensor,",","Moisture:",moi_per 

        #Check Moisture and Change LCD Display
        if moi_per < 10.0:
            lcdDis.write("                ")
            lcdDis.setColor(128,0,128)
            lcdDis.setCursor(0,0)
            lcdDis.write("I am thirsty :(")
        else:
            lcdDis.write("                ")
            lcdDis.setColor(255,255,0)
            lcdDis.setCursor(0,0)
            lcdDis.write("Iam fine :)")

    time.sleep(1)
    t += 1

The value obtained by this is saved in csv format.

Visualization of sensor data

The acquired sensor data was visualized using nvd3.js. http://nvd3.org/

It looks like this. Since it was placed indoors, the temperature did not fluctuate significantly. Is it within the margin of error that the water in the soil is rising? Or is it because it sucked up the water in the saucer? When the light is bright, the value is low, and when it is dark, the value is high. You can see that it is a night-time human being.

スクリーンショット 2015-04-26 12.49.04.png

Reflection

・ The training environment is bad (laughs) I tried it in the room this time, but the growth rate is much better if I grow it on the balcony (laugh) When I moved the pot to the balcony, it was growing steadily. I think you can get more interesting data if you put it outdoors.

・ Not IoT This time I didn't go to the point of sending the value to the server, so Next time I would like to send it to the server and make a prediction based on the sent data

Future plans

· Send values directly to the server ・ Predict when watering is needed from there ・ I want to make an automatic watering device ・ I want to grow vegetables

Recommended Posts

Sensor data acquisition and visualization for plant growth with Intel Edison and Python
Easy data visualization with Python seaborn.
Data analysis starting with python (data visualization 1)
Data analysis starting with python (data visualization 2)
Data pipeline construction with Python and Luigi
Python visualization tool for data analysis work
Recommendation of Altair! Data visualization with Python
[In-Database Python Analysis Tutorial with SQL Server 2017] Step 3: Data Exploration and Visualization
Data acquisition from analytics API with Google API Client for python Part 2 Web application
Beautiful graph drawing with python -seaborn makes data analysis and visualization easier Part 1
Implement "Data Visualization Design # 3" with pandas and matplotlib
Beautiful graph drawing with python -seaborn makes data analysis and visualization easier Part 2
Test python models and functions deployed online with Cloud Pack for Data with form-formatted input data
Data analysis for improving POG 1 ~ Web scraping with Python ~
List of Python libraries for data scientists and data engineers
Benchmark for C, Java and Python with prime factorization
Overview and tips of seaborn with statistical data visualization
Investigate Java and python data exchange with Apache Arrow
Data analysis with python 2
Data visualization with pandas
Data analysis with Python
Logistics visualization with Python
Have Google Text-to-Speech create audio data (narration) for video material (with C # and Python samples)
[High School Information Department Information I] Teaching materials for teacher training: Data format and visualization (python)
Visualize plant activity from space using satellite data and Python
Using Python with SPSS Modeler extension nodes ① Setup and visualization
Get rid of dirty data with Python and regular expressions
Analyze stocks with python and look for favorable trading phases
Solve the spiral book (algorithm and data structure) with python!
Web crawling, web scraping, character acquisition and image saving with python
Stylish technique for pasting CSV data into Excel with Python
Get data from analytics API with Google API Client for python
Library for specifying a name server and dig with python
Get additional data to LDAP with python (Writer and Reader)
This and that for using Step Functions with CDK + Python
Sample data created with python
Encryption and decryption with Python
Python and hardware-Using RS232C with Python-
Python for Data Analysis Chapter 4
Get Youtube data with python
Python for Data Analysis Chapter 2
python with pyenv and venv
Works with Python and R
Python for Data Analysis Chapter 3
Read json data with python
Create a striped illusion with gamma correction for Python3 and openCV3
Automatic acquisition of gene expression level data by python and R
Get data from MySQL on a VPS with Python 3 and SQLAlchemy
[Pandas] I tried to analyze sales data with Python [For beginners]
Move data to LDAP with python Change / Delete (Writer and Reader)
Create a USB boot Ubuntu with a Python environment for data analysis
[Concept] A strategy to analyze data with python and aim for a decline after shareholder benefits to make a profit