Introduction: TwitterPlant

Welcome to our twitter plant project and our first instructable. We hope you like it and try to make your own twittera plant. If you need our help and experience we will be happy to help you.

First of all we introduce ourselves, we are a group of three students of ‘Creative Electronics’, a Beng Electronic Engineering 4th year module at the University of Malaga, School of Telecommunication (http://etsit.uma.es/).

Our project was born of our desire to do something fun using electronics, in addition we had read about the BotaniCalls[1] project so we decided to make our plant smart.

[1] https://www.botanicalls.com/

Step 1: Material's List

You must make a list of the components needed. We made that already, all the things we needed to build this plant are:

1 RaspberryPi 3

1 Arduino Leonardo ( You can also create your own arduino as we have done https://github.com/fmalpartida/SAV-MAKER-I)

1 Humidity sensor

1 Temperature sensor, DHT11

1 Photoresistor

1 Resistor 10k

1 Micro USB to USB Cable

1 Junction box

1 Stripboard

Step 2: Programming With Python 3 in RaspberryPi

Your Pi ships with IDLE – a Python development environment – that allows you to input commands. It includes a handy help() command that can help you with your syntax, and also comes with its own built-in text editor, with colour-coded syntax and automatic placing of indents, to help with your programming.

You can to use Arduino from another OS, but if you use Arduino from Raspberry Pi, open a terminal window and enter the following command:

sudo apt –get install arduino

Now, you can to program with Arduino in your Raspberry Pi.

Be careful if you work from OS of Raspberry Pi because you should always close the arduino before running the Python program because there may be conflict on the port.

Step 3: Twitter Account

Picture of Twitter Account

If you don't already have a Twitter account, you'll need to create one at twitter.com

Step 4: Connect to Twitter From Python Using Twython

Picture of  Connect to Twitter From Python Using Twython

To access the Twitter account from Python using the Twitter API:

  1. Go to apps.twitter.com and click the Create New App button:
  2. Complete the application details form.
  3. Modify your app permissions from Read only to Read and write.
  4. Click the 'Keys and Access Tokens' tab and create an access token. Refresh the page and you'll see a new section with your access token details.
  5. You should now be able to see your Consumer key, Consumer secret, Access token, and Access token secret.
  6. Very important, check that the system time of your raspberry Pi is correct, because otherwise Python Will not connect to Twitter.

Open a terminal window and enter the following command:

sudo raspi-config

If the date/time is still wrong, enter with the current time and date:

sudo date -s "2 Feb 2017 00:00:00"

Step 5: Connect to Twitter From Python

Now Open Python 3, create a new file and paste your API keys:

consumer_key = ''

consumer_secret = ''

access_token = ''

access_token_secret = ''


Save the file as auth.py, create another new file:

from twython import Twython

from auth import (

consumer_key,

consumer_secret,

access_token,

access_token_secret

)

twitter = Twython(

consumer_key,

consumer_secret,

access_token,

access_token_secret

)

Now, you can to send a tweet:

message = "Hello!"

twitter.update_status(status=message)


Save the file as tuit.py and run From Python text editor or from the terminal window.

Step 6: Board

As you can see in the list of materials we have used a board with arduino, in particular we have used the SAV-MAKER-I based on the popular vinciDuino board, predecessor of Arduino's Leonardo board and fully compatible with it.

We encourage you to make your own board but if not, you can use an Arduino's Leonardo board.

Then we leave the link to be able to make your own SAV-MAKER-I.

https://github.com/fmalpartida/SAV-MAKER-I

This board will be connected to the Raspberry Pi using a micro-USB cable, the sensor connections to Arduino are detailed below.

Step 7: Temperature Sensor

Picture of Temperature Sensor

We used a DHT family sensor, specifically the DHT11 model. This sensor is able to provide us digital data of temperature and air humidity. In the project we only measured temperature, but it is interesting for the care of a plant to know the humidity of the air. In the future as we have this sensor we can add this feature to our intelligent plant.

For the programming of this sensor we used the arduino library DHT11. You will need to add the DHT11 library to your Arduino library folder. We include the library for download.

We show a schematic of the sensor connection to the arduino board.

Step 8: Humidity Sensor

Picture of Humidity Sensor

To measure soil humidity we have used a soil hygrometer (FC-28).

The FC-28 is a simple sensor that measures soil humidity varying its conductivity. Does not have enough accuracy to make an absolute measurement of soil humidity, but it is enough for our Project.

The FC-28 is distributed with a standard measuring board that allows to obtain the measurement as an analogue value or as a digital output, activated when the humidity exceeds a certain threshold.

We have used the analog output, the values obtained range from 0 submerged in water, to 1023 in the air (or in very dry soil). A moist soil would give typical values of 600-700. A dry soil will have values of 800-1023.

These values depend of on the plant we have to irrigate, A cactus is not the same as a Calla lily, for most plants these values are valid. We have obtained information from the plant we have used (A thought) and we have used another range most appropriate values.

We show a schematic of the sensor connection to the arduino board.

Step 9: Light Sensor

Picture of Light Sensor

The light sensor has been manufactured by us. To do this we only need a resistance of 10k Ohms and a photoresistance.

The connection of the sensor to arduino is shown in the following image.

Our plant does not need special care of luminosity. We only use these data when the sun goes to the plant, in this case an output greater than 900 is obtained.

Step 10: Getting the Raspberry Pi to Talk to Arduino

You needed to establish serial communication between a Raspberry Pi an Arduino.

Firstly, I needed to install pyserial library in your Raspberry Pi. Open a terminal window and enter the following command:

sudo apt-get install python-serial

Now, you can read the information sent by Arduino from Python.

In your file tuit.py:

import serial

import serial.tools.list_ports

ports=list(serial.tools.list_ports.comports())

port_no = ports[0][0]

arduino = serial.Serial(port_no, 9600,timeout=1)

while True:

read_serial=arduino.readline()

Step 11: Run Your Program Automatically When You Start the Raspberry

Open a terminal window and enter the following command:

sudo nano /etc/init.d/tuit-init

Your copy this content:

#--------------------------------------------------------------------------------------------------------------

#! /bin/sh
# /etc/init.d/tuit-init

### BEGIN INIT INFO

# Provides: tuit-init

# Required-Start: $all

# Required-Stop: $remote_fs $syslog

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: Script de ejemplo de arranque automático

# Description: Script para arrancar el programa

### END INIT INFO

# Dependiendo de los parámetros que se le pasen al programa se usa una opción u otra

case "$1" in

start)

echo "Arrancando tuit-init"

# Aquí hay que poner el programa que quieras arrancar automáticamente

/usr/bin/python3 /home/pi/tuit.py

;;

stop)

echo "Deteniendo tuit-init"

;;

*)

echo "Modo de uso: /etc/init.d/tuit-init {start|stop}"

exit 1

;;

esac

exit 0

#------------------------------------------------------------------------------------------------------

Now, we make the Exe file:

sudo chmod 755 /etc/init.d/tuit-init

We verify that everything runs correctly:

sudo /etc/init.d/tuit-init start

Finally activated the automatic start:

sudo update-rc.d tuit-init defaults

When we start Raspberry Pi, we can check okey:

ps aux | grep "tuit.py"

Step 12: Good Job

Picture of Good Job

We have soldered the sensors on a Stripboard.

Finally, we have to find the best way to equip our plant. We use a junction box to put together the two boards and sensors, in addition, we prepared the box to be able to hang it in our plant.

In this link is our code:

https://github.com/SmartGreenUMA/TwitterPlant.git

Comments

About This Instructable

1,453views

16favorites

License:

More by SmartGreenUMA:TwitterPlant
Add instructable to: