This project is submitted for

Description

This system is a low cost weather station that uses Raspberry Pi B+ and Texas Instruments Sensor Tag CC2650 to compare outside weather with internal conditions. Using Node Red and Freeboard , a dashboard can be created to visualize the data. Good for green houses. feral cat shelters, dog shelters, barns or even bee hives. Keeping our companion animals safe. I have also added a voice command system to play music for enclosed animals. I will also be including the Enocean Pi and a Reed Sensor to trigger a node red if a door has been opened or closed.

Details

There is a growing number of groups and individuals working to improve the conditions of factory farms, zoos and other captive animal enclosures. This project is a starting point to provide a real time dashboard to monitor weather conditions inside and outside. And to top it off – live streaming from a Raspberry Pi Camera.

The general weather can include humidly, precipitation and sunlight. Climate also refers to ambient things such as noise, artificial light and vibration. Housing an animals in a poorly build enclosure may cause chronic stress and possible death.

Humidity

I live in a province where we experience moderate summers. When we do have a day with high humidity it is uncomfortable and causes us to seek a cooler place. On factory farms higher humidity causes issues with feces and urine that linger and increase the chance of bacterial infection. Wet bedding will also need to be changed more frequently. If the humidity is too low than bedding can be too dry and cause more dust. The increase in dust can cause irritation and respiratory infections. High humidity contributes to stress.

Temperature

Every animal has a “thermoneutral zone”. This is where the metabolism works most efficiently. Once outside this zone it becomes a source of stress.

Light

Light Intensity is the third crucial factor to any captive animal’s welfare. Light Intensity and duration can have profound effects on behavior and body chemistry. This happens on Factory Farms where animals are not exposed to natural light. These animals require an appropriate number of hours of light each day. Exposing any animals to light 24 hours a day can destroy their circadian rhythm. This can lead to a refusal of food, inability to sleep and possible death.

Wikipedia defines circadian rhythm as:

A circadian rhythm is any biological process that displays an endogenous, entrainable oscillation of about 24 hours. These 24-hour rhythms are driven by a circadian clock, and they have been widely observed in plants, animals, fungi, and cyanobacteria.

I have decided on the final model for the weather station. In order to improve the automation , I have extended the use of Alexa voice control using the Skills Set. I have decided on using two Raspberry Pi computers. I also want to thank those who have shown interest and support for the project. I have learned a lot about the Internet of Things and deployment of data to the Cloud. This project has made me a better programmer !

Worker Pi

This Raspberry Pi is connected to IBM Bluemix and I have documented the steps to install the software to deploy the sensor data to the cloud. I will be testing extending the sensor network using Xbee in the near future so will leave the project open. I am using a slightly different version of Freeboard that works with Node Red in Bluemix. This will allow anyone to visualize the data delivered by the sensor tag on any internet connected device. I'm using the Raspberry Pi B. I also am using a USB hub.

Commander Pi

The Commander Pi can be placed at any location with a network connection. So if the Worker is in the barn the Commander may be in the house or at the office. As long as there is a network connection, it will be communicating with the Worker Pi using the Bluemix cloud and Amazon cloud. The Commander allows you to ask about the temperature, humidity and lux settings within the enclosure. You can still view the dashboard but this is a powerful way to quickly check the status of indoor weather conditions using voice commands. I have documented setting up Alexa on the Raspberry Pi but this time I will be using Skills to enhance the use of voice control. I'm using the Raspberry Pi 2.

The beauty of the model is its flexibility and low cost.

Let's get started !

Alexa Skills for Weather Station

Once you have Alexa set up on your Raspberry Pi (see log ) you can customize commands . I have demonstrated some basic commands in the video but the sky is the limit as to what you can do with the skills kit.

Node Red

For this final stage I am using the Bluemix Node Red rather than a local install on the Raspberry Pi. The setup includes nodes to connect Alexa to my FoxTracker project on Bluemix. I will just be focusing on temperature for now because of the deadline . I created a short video to show the properties of the nodes. I used two sessions of Putty to get this working.

Fire Up the Worker Pi to connect to Bluemix.

See my log entry for details on installing and running the program. You should see the following if the program did run successfully on Putty.

Fire Up the Commander Pi to connect to Alexa

See my log entry for installing and running the program.

Setting up the Skill Sets

Log into Bluemix and select FoxTracker

FoxTracker Dash Board includes the url for Routes. We are going to be using this as an endpoint in Alexa. My route is FoxTracker.mybluemix.net. Later I will use this url and the url I set up for the http node.

Log into Amazon Developer website and select Alexa Skills Set.

Name your skill and choose a Invocation Name. I simply called mine "the barn". So in this demo I will be saying "Alexa ask the barn what is the temperature ?"

Set up the Intent Schema. This is flexible. I set up the parameters I wish to test.

Set up Utterances for your Intents. I only included one for each intent but you can include a number of variations as to what someone may ask. i.e How's the temperature ?

Its been some time since I added a new log. I have been mulling over how to bring this all together. At first I thought this phase might be a new project. But I think it can be incorporated nicely to Clouds Happen. I will be sending the Sensor Tag motion data to IBM Bluemix Cloud .

Sending Sensor Data to IBM Bluemix

I used this excellent video by Ryan Baxter exclusively to achieve the deployment of sensor motion data to Bluemix The video was made in Nov 12, 2014 and Bluemix has changed. His video can be found here: . He was using a Beaglebone Black as a gateway and I am using a Raspberry Pi B. I had to make some modification to his code to accommodate the changes to Bluemix which I have documented. The screenshots in the video have changed so if you do follow the video than you may have to improvise to get where you need to be. Basically all you are doing is connecting a device and than creating a service. Then you can create a APP. You also need to sign up for a free trial from IBM. If I missed a step please let me know

Move to the publish directory and execute the command npm install – You may see some warnings but as long as they are not errors it should be okay.

Now lets set up our Raspberry Pi in Bluemix ;

Console for IBM. Click on Catalog.

Select Internet of Things on the left. Now select Internet of Things

Under Connect you device – click on Launch dashboard

Select Create Device Type

Select Create device type:

Name your Device. Add the MAC address for the Pi. The MAC address can be found using ifconfig. All other fields are not mandatory

Generate you credentials . This is where I had to modify the code. During the setup you have to create a config.properties to store you credentials generated by Bluemix. This screen shot shows what I copied from Bluemix to Notepad. I changed the field names to match his code. My credentials have changed so I'm not concerned about showing them. The device.cfg shows one set of credentials modified to work in the program. If you view his video the syntax has changed to the example in Notepad. Use sudo nano within the publish directory to copy your credentials to that was generated by Bluemix.

Now we can start the program from the publish directory.

Node sensor-tag.js

Make sure your sensor tag is connected and you should see this in Putty.

Lets go back to Bluemix. Connected to fox tracker

Sensor data coming in !

I have created an app for the Fox Tracker .

Click on view App. I also imported a node red flow from the git repository.

I am using Enocean Pi to sense if a door has been opened or closed. I decided to use the Raspberry Pi B and Raspbian as the operating system. I also installed FHEM for testing. Changes to Jessie seems to have altered the serial port for the Raspberry Pi. The serial port /dev/ttyAMA0 is missing in the update. This is the third component to my project. The actuator is a reed or contact sensor. No batteries required or wiring for Enocean sensors.

I clicked on the learning button on the contact sensor and now have a room called Enocean. The contact sensor is given a unique ID. When I bring the magnet close to the contact sensor and then move it away that state will change.The idea is to provide an inexpensive way of providing alerts if a door or window has been opened. Looks like every thing is configured correctly so I install Node Red.

I added an Indicator Light to the dashboard to warn if the door is open.

Now install Dweetio Node:

cd ~/.node-red

npm install node-red-node-dweetio

I noticed that the datasource for the Enocean Pi was not updating in real time. As I moved the magnet close to the sensor nothing happened. Once I started to send the msg.payload to my Dweet then it worked. The Open State means the magnet is away from the sensor so the Door is open. The Closed State means the magnet is close to the sensor so the Door is closed. Here's a short video of testing the sensor:

Yes I have left my previous attempt for Voice Commands behind. I installed Alexa from Amazon on the raspberry pi 2. If you want to add voice command to your project then you should try this out. There is no cost and you do not have to give out credit card info. It performs better than what I expected. Alexa is chatty but does provide detailed info from my questions. My only issue remaining is extending WIFI. Okay have another week for that.

STEP 1 VNC SERVER

Install VNC Server

VNC is a graphical desktop sharing system that will allow you to remotely control the desktop interface of your Raspberry Pi from another computer. This will come in very handy as you get rid of the external monitor connected to your Pi. Type:

sudo apt-get install tightvncserver

Start VNC Server

To start VNC Server, type:

tightvncserver

You'll be asked to set a password to access the Pi. The password is maximum 8 characters,

Run VNCServer at Startup

You want to make sure the VNC Server runs automatically after the Raspberry Pi reboots, so you don’t have to manually start it each time with the command tightvncserver through SSH. To do that, type the following in the terminal:

cd /home/pi

cd .config

Note the '.' at the start of the folder name. This makes it a hidden folder that will not show up when you type 'ls'.

During installation you'll be offered the choice of Typical, Custom or Complete. You only need the VNC client and not the server, so choose Custom. Then select TightVNC Server and choose Entire feature will be unavailable. Click Next. Uncheck the option about Windows Firewall and click Next again, then Install.

Once the installation is complete you should find TightVNC Viewer under the start menu. When you run it you'll be presented with the dialog below. You will need to enter the IP address of the Raspberry Pi followed by the screen number (:0 or :1). For example: 192.168.0.6:1

Click on connect and you should see your raspberry pi desktop

STEP 2 : VLC

Install VLC

Get VLC media player by typing:

sudo apt-get install vlc-nox vlc-data

NOTE: If you already have VLC installed, you will need to remove two conflicting libraries by running the following commands:

sudo apt-get remove --purge vlc-plugin-notify

sudo rm /usr/lib/vlc/plugins/codec/libsdl_image_plugin.so

Unable to fetch errors If you run into some "Unable to fetch" errors while trying to install VLC, try the following:

I spent Sunday improving the Dashboard. I was still interested in streaming live from You Tube. I also wanted to test everything out. So the test subject was me in a motel room with no air conditioning. Its hot and humid and very uncomfortable. I found out that yes you can live stream from the Raspberry Pi camera and after some tweeking had a nice green healthy stream. Below is my live stream from my room. Not too much happening !

You cannot live stream ddirectly from the FreeBoard pane but you can capture the video from your live stream.

This contains a summary and links to 7 studies on how music can impact the lives of animals. Music can reduce agitation, promote sleep, and improve mood, and lower stress and anxiety. Dogs prefer classical over heavy metal. Apparently cats are more pick and there has been research on music that appeals to them. You can hear a sample at this link.

So I will be expanding on this before the end of the contest. The best Voice Command software was PiAUISuite that was developed in 2013. I watch the video and knew this is what I wanted. But with changes since the first build, it was a challenge to get this running on the Raspberry Pi. After reading countless forums I found the following steps worked. After I post this, I will reproduce the setup on a different SD card for a final test.

Step 1: Setting up and testing the Microphone:

I have budget constraints and chose the low cost Logitech c170 webcam with a microphone included. I paid $22 CND for it and it works like a charm. When I first tested this with aplay I received just static noise. So I had to configure my microphone for the raspberry pi. First you need to load the drivers.

sudo modprobe snd_bcm2835

sudo nano /etc/modprobe.d/alsa-base.cong

options snd-usb-audio index=1

To save it you need to CTL+X. If the module is blank just add the code, Same for the next step.

During the install a number of questions will be asked for the commands.conf file. General consensus instructs us to say yes to all the questions. To get this all to work I did a manual rather than an automatic setup for VoiceCommand so said no. .My threshold was different than the default. An once I had the correct threshold I could see the recording as mono and signed. I'll post my .commands.conf file in the log.

Step 4: Replace the tts file:

We have to replace the tts (Text to Speech) with this: The file is in the VoiceCommand folder.