In this project we will be using Arduino, Raspberry Pi and Alexa for a voice-controlled IoT plant monitoring device.
This system can measure the temperature and light intensity of the surrounding in this plant and give the values to anyone who accesses this skill.
The sensors are connected to the Arduino to read the analog values coming from the sensor. These sensor values are converted into digital values and are sent serially to the Raspberry Pi.
The Raspberry Pi has a server for Alexa running in it. The values are attached to the invoked indents user asks for.
Thus it solves for plant monitoring using voice commands.
This is a sample project and you can expand the project to connect any number of sensors to the Arduino or Raspberry Pi to solve your problem.
Let's get through the steps involved in the prototyping of the plant monitoring system.
Hardware Required1. Arduino UnoArduino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.
The Raspberry Pi 3 Model B is the third generation Raspberry Pi. It adds wireless LAN & Bluetooth connectivity making it the ideal solution for powerful connected designs.
Raspberry Pi 3 - Model B Features
- Now 10x Faster - Broadcom BCM2387 ARM Cortex-A53 Quad Core Processor powered Single Board Computer running at 1.2GHz!
- 1GB RAM so you can now run bigger and more powerful applications.
- Fully HAT compatible.
- 40pin extended GPIO to enhance your “real world” projects.
- Connect a Raspberry Pi camera and touch screen display (each sold separately)
- Stream and watch Hi-definition video output at 1080.
- Micro SD slot for storing information and loading your operating systems.
- 10/100 BaseT Ethernet socket to quickly connect the Raspberry Pi to the Internet.
LM35 is a precision IC temperature sensor with its output proportional to the temperature (in oC). The sensor circuitry is sealed and therefore it is not subjected to oxidation and other processes. With LM35, temperature can be measured more accurately than with a thermistor. It also possess low self heating and does not cause more than 0.1 oC temperature rise in still air. The operating temperature range is from -55°C to 150°C. The output voltage varies by 10mV in response to every oC rise/fall in ambient temperature, i.e., its scale factor is 0.01V/ oC.
A photoresistor (or light-dependent resistor, LDR, or photoconductivecell) is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity; in other words, it exhibits photoconductivity. A photoresistor can be applied in light-sensitive detector circuits, and light- and dark-activated switching circuits.
Let's see how a photo resistor react in light. Build the circuit above and notice how led brightness change.The resistance value becomes smaller when there is much light in the room. So in the dark the led remains off because the resistance has become very big.
LDR voltage dividerA light-dependent resistor (LDR) connects to a voltage divider circuit, also known as a potential divider (PD), for proper circuit operation. There are two configurations of the circuit depending upon the position of the LDR within the potential divider network.You can have a configuration where the voltage output (Vout) increases as light increases or one where the voltage output decreases as light increases. The following calculators and their respective formulas show how both configurations work.
I used a Raspberry Pi 3 and a fresh Raspbian Strech image downloaded from
https://www.raspberrypi.org/downloads/raspbian/
Two terminal sessions will be needed so using SSH to access the Pi is recommended. Once logged in, enter the following commands to install the required packages and python libraries:
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install python2.7-dev python-dev python-pip
sudo pip install Flask flask-ask
sudo apt-get install python-serial
Ngrok setup
Ngrok is a command-line program that opens a secure tunnel to localhost and exposes that tunnel behind an HTTPS endpoint. ngrok makes it so Alexa can talk to your code right away. Follow the next three steps to generate a public HTTPS endpoint to 127.0.0.1:5000.
Visit https://ngrok.com/download and get the latest Linux ARM release as a zip and unzip inside the home directory:
Next, run it from the command line with:
./ngrok http 5000
Your screen should look like the image above. Note the 'Forwarding' URL that starts with HTTPS, it will be used later. Note: Unfortunately the n grok URL changes every time the service is started so it is not a permanent solution if you are trying to run this full time. I'd recommend a service like Yaler or Page Kite if you need a more permanent URL to use with your new Skill.
After Ngrok, make a script (.py) program is given below copy and paste that code in your file.
ArduinoFor Arduino part code is given below copy that code and upload it. After uploading the code connect Arduino with RPi serially.
Amazon Website Configurations- 1. First create or login to your AWS Developer Account and open your list of Alexa skills.
- 2. Add new skill
- 3. Skill Information
Set the Skill Name to 'plant_monitor' and the Invocation Name to the word(s) you want to use to activate the skill. Click 'Next' to continue.
- 4. Interaction Model
Build the interaction model with the following indents mentioned in the image. This can help us to invoke the actions with respect to the commands as user says.
- Click on Add new intent, Name it light and add sample utterances which you want to use.
- Add new intent , temperature and sample utterances.
- Save model and built it.
Select 'HTTPS' as the Service Endpoint Type and select a region. Enter the ngrok URL and click 'Next'. The URL should be something like:
Select the 'My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority' option and click 'Next'.
Your skill is ready to work.
Interfacing of Arduio with RPi
Interfacing of LM35, LDR and Arduino
Vo is connected to Analog pin 1 and LM35 is connected to Analog 0.
TestingIf everything was setup correctly you should now see a screen similar to the first image above. The Skill is now enabled and can be accessed through any Amazon Echo device(or at http://echosim.io/) that is connected to your AWS Developer.
As far as I can tell there is nothing stopping someone from running this continuously in a 'development' mode for personal use though... My ultimate goal is to use this to integrate Alexa into my existing Raspberry Pi-based Smart Home setup so that everything can be controlled hands-free. This is my first project so any feedback is appreciated. If you have any questions or trouble setting this up I will do my best to help. Good luck!
SetupOutput Video
Comments