Smart Shutter | Bluetooth Communication Between Android and Arduino using Processing

So, once you get processing for android all installed, if you’re like me the first thing you’ll want to do is get your phone talking with an Arduino over bluetooth. Well maybe not first thing but you get the Idea. Below is two pieces of code that I’ve used for this project. It’s very specific for this project, but it may help somebody and will likely help myself in the future so there you go.

Ardiuno Code:

Processing Code:

Let me know if you ever use this!

Smart Shutter | Installing Processing For Android (With Pictures!)

This was a horrible (!) experience. I ran in to a slew of errors from the “Android Mode” menu not showing up, to having to adjust my PATH variable. Hopefully this guide helps somebody. Most of this is taken from this guide from processing, but a lot of the errors I ran into I resolved using various forums.

First things first, download the Android SDK for an existing API.

From there, you need to install the SDK as well as some pretty specific packages using the SDK manager. [Android SDK Platform-tools], [Android 2.3.3 (API 10) > SDK Platform] and [Google USB Driver under Extras]. My setup worked once I hit “deselect all”. Note the location of the SDK.

The install of Processing is very simple. Please note that the “modes” folder inside the folder is NOT the folder you manually install modes in. Please note the location of your sketchbook folder from the preferences inside of processing.

Next, you need to download and install Java’s JDK here.

So this is where stuff started to go south. For some unknown reason, when I installed processing, “Android Mode” didn’t appear in the modes box in the top right corner.

I had to manually install AndroidMode. To do that, you must download and uncompress it into the modes folder IN your sketchbook folder.

Once you can see “Android Mode” you will need to locate the SDK.

Once I got this working, upon compiling a demo app with my phone connected resulted in errors!

You must edit the “Path” variable by adding a semicolon with the location of your JDK’s bin folder.

And there you go. Everything should be working now.

In order to connect your phone and upload your apps to it, you need to set your phone to developer mode, which is very simple. Look here for instructions.

Smart Shutter | Setting up a BlueSMiRF with Software Serial and Arduino

I was recently accepted into a beta test for MIT dealing with a prototype Arduino board and their website. I’ll create a final post showcasing the completed project, but for step by step updates check out their website here, and my personal project page here. Now on to the tutorial.


I always reset my module after I dust it off for use, jussttt in case:

Because I know I’ll need to do this again, I’ve decided to take the time writing a post explaining how to get communication going between an Arduino and a PC using serial over bluetooth in windows 8.

First thing’s first, connect to your device, as stated in the title, I’m using a BlueSMiRF Silver from Sparkfun.

Pairing is very easy. From there, upload the following code to your Arduino and connect your board as dictated by the code.

 

NOTE: IN ORDER TO USE DIFFERENT SERIAL SPEEDS, YOU WILL NEED TO MANUALLY CHANGE THE BAUD RATE USING THE DEBUG MODE IN THE BLUESMIRF.

https://learn.sparkfun.com/tutorials/using-the-bluesmirf

Then open your device manager and see how the bluetooth configuration went and how the ports were assigned:

 

For some reason, the lower COM port number is the correct one, I have no idea why. I’ll be using Putty to connect to the bluetooth COM port, the config is very simple:

<a href=”http://imgur.com/lXBc69L”><img src=”http://i.imgur.com/lXBc69L.png?1″ title=”Hosted by imgur.com” /></a>

From there, start typing in either console and it should all work!

Thanks for reading!

PiPlanter 2 | Moving again

I bought a wire rack from walmart and put the PiPlanter back inside my house. Hopefully the plants will live longer than they did last year so while I’m at college I can continue to develop on this model. Images below.

PiPlanter 2 | Solving Broken Pipe Errors [Errno 32] in Tweepy

If I haven’t mentioned it already, https://twitter.com/piplanter_bot IS the new twitter account for PiPlanter. Like last time, I’m using the tweepy library for python to handle all things twitter for the project. What I’m NOT using this time is Flickr. From a design point of view, it wasn’t worth it. It was too complicated and had too many things that could go wrong for me to continue using it. Twitter is more than capable of hosting images, and tweepy has a very simple method of passing these images to twitter. Recently I moved the whole setup indoors and mounted it all onto a shelf seen here and it came with a set of strange problems.

Long story short, what I think happened was that since I moved them to a different location, the complexity of the images increased, causing an increase in the size of the images themselves. A broken pipe error implies that the entirety of the package sent to twitter wasn’t sent, causing the tweet not to go through. I first started to suspect this problem after seeing this:

 

The graphs were going through just fine, but images were seeming to have a hard time. You can’t tell from this photo, but those tweets are hours apart as opposed to the 20 minutes they are supposed to be. Once I started having this problem, I bit the bullet and integrated logging into my project which produced this log:

Hours and hours of failed tweets due to “[Errno 32] Broken pipe”. I tried a lot of things, I figured out that it was the size of the images after seeing this:

Photos that were simple in nature had no problem being sent. After scaling the image size down, I’ve had absolutely no problem sending tweets.


If you are tweeting images with tweepy in python and getting intermediate Broken pipe errors, decrease the size of your image.
Thanks for reading.

PiPlanter 2 | Progress Update

I’m almost done with a very stable version of the Python code running the PiPlanter. There are many specific differences between this version of the python code and the version I wrote and implemented last summer, but the main one is that I tried to write functions for pretty much every task I wanted to do, and made each routine much more modular instead of one long line after line block to do each day. This took significantly longer to do (thus the lack of updates, sorry) but is much more expandable going forward. Below is the new version of the code, but by no means am I an expert programmer. The following code seems to work very well for what I want it to do.

Note the distinct lack of comments. I will put out a much more polished version of the code when it’s done. Before I move onto things like a web UI etc, I would like to do a few more things with this standalone version. The above version renders videos into time lapses, I would like to be able to upload those videos somewhere, hopefully youtube. I would also like to be able to email the log file to the user daily, which should be easier than uploading videos to youtube.

The script that renders the MySQL data into a graph is the following, it on the other hand has not changed much at all since last year and is still the best method to render graphs like I want to:

Here are some photos of the current setup, it hasn’t changed much since last time:

Thank you very much for reading.

PiPlanter 2 | New Code Version / Temporary Setup

Hello! Here are some images of the new grow setup:

and here is the working version of the code:

I’ll do a much more thorough post when the project is further along. For those playing along at home, you can see that I’ve totally re-written the code for this new version. So far, it has much less functionality but much more stability and flexibility.

My Raspberry Pi Networked Media/NAS Server Setup

I have come to a very good place with my media server setup using my Raspberry Pi. The whole thing is accessible using the network, over a wide range of devices which is ideal for me and the other people living in my house.

If you don’t need to see any of the installation, the following software is running on the server: Samba, Minidlna, Deluge & Deluge-Web and NTFS-3G.

The combination of all of this software allows me to access my media and files on pretty much any device I would want to. This is a great combination of software to run on your Pi if you’re not doing anything with it.

So let’s begin with the install!


I’m using the latest build of Raspian, the download and install of that is pretty simple, instructions here.

Unless you can hold your media on the SD card your Pi’s OS is installed on, you’ll need some kind of external storage. In my case, I’m using a 3TB external HDD.

We’ll need to mount this drive, I’ve already written a post on how to do this, check that out here.


Now we should involve Samba. Again, it’s a pretty simple install.

Once it installs you should already see signs of it working. If you’re on windows, make sure network sharing is on, and browse to the “network” folder. It should show up as “RASPBERRYPI” as seen in this image:

The only real tricky part is configuring it. Here is an untouched version of the samba config file. On your pi, it is found at:

You can edit it like you would any config file. This is the configuration following is the configuration I am running on my Pi, if you want a configuration that will work with no problems without any modifications, replace the existing /etc/samba/smb.conf with this version.

There are only a few differences between the standard version and the version I’m using. The biggest one being the actual “Share” being used seen here:

Basically, this shares the external HDD you just mounted to the network. You can insert this share anywhere in your document and it will work. Once you update your config file, you have to add your user to samba. If you haven’t done anything but install raspbian, your username on the pi should still be “pi” so the following should do the following:

Enter your new samba password twice and then you’re good to go after restarting samba.

In windows you can go to “network” option in My Computer and see your share.

If you’re like me though, you’re going to want multiple users for multiple shares. Samba only can only have users that are members of the system, so in order to add a new user to samba, you have to add a user to the Raspberry Pi. For example, let’s add the user ‘testuser’:

I have written a bash script to do this automatically.

On the share level, the line of valid users = should be set to whichever user you want to be able to use the share.

That’s pretty much it for Samba. I’m probably going to do a guide on accessing your shares via SSH tunneling when the need for me to do so arises. I’ll link that here if it ever happens. Now on to minidlna.


MiniDLNA is a very lightweight DLNA server. DLNA is a protocal specifically for streaming media to a huge array of devices from computers to iOS devices or gaming consoles or smart TV’s. I have spent quite a bit of time using minidlna, and have reached a configuration that works extremely well with the raspberry pi. The install is very easy, much like samba, it’s the configuration that is tricky.

The config file i’m using is found here. There Pi actually handles the streaming really really well, and there only a few things you need to change in the config file, and they are mostly aesthetic. The following lines are examples of media locations for each type of file.

And changing this line will change the name of the DLNA server on the network:

That’s pretty much all there is to it.

You can stream the files all over the place, the following images show it being used on my kindle and another computer. I stream files to my xbox 360 all the time.

The last major component of this media server is Deluge, let’s proceed with that install.


Deluge is a torrent client for linux servers. The coolest part is it has a very good web based GUI for control. The install isn’t too straightforward, but there is no real specific configuration. The following commands will get things up and running.

And there you go! You can now torrent files directly into your Samba shares which is hugely useful and more secure, the following is me doing just that:


The last thing that needs to be done is run a few commands at boot, particularly mount the HDD and start deluge-web. The easiest way to do this crontab. First run:

Then add the following two lines:

So it looks like this:

And everything will start working upon boot!


Thank you very much for reading. If you have any questions, please leave a comment.