Balancing cart

My take on the classic inverted pendulum problem.

Video | Posted on by | 1 Comment

Arduino + Raspberry + Camera Board = Home Surveillance

Developing a home-surveillance system has interested me for some time, so I did some research on the best hardware for the job. The camera shields that I saw for the Arduino Uno were pretty pathetic, to be honest. They were expensive and/or lacked proper documentation. One particular Uno shield cost more than both the Raspberry Pi and its camera board combined, so I decided to just get those two instead. Turned out to be a great decision!

Although all programming was done myself, I’ve decided not to share the source; it’s important that a system like this be designed from scratch by the budding developer. I will, however, say a few things:

  1. If you’re using Parallax’s Ping))) sensor, be sure to insert a small delay immediately before taking a reading. It will help prevent against misreads, especially in certain environments. If you think your code is right and you’re still getting erroneous values, try placing it in a larger room. It works just fine outside, however.
  2. I used the Visual Micro debugger for Visual Studio to help me debug on the Arduino. There’s a video tutorial on YouTube for it; the video’s a bit lengthy, but very worthwhile to watch.
  3. The PIR sensor does not work well outside, since the ambient IR is constantly shifting.


At the end of the video, you’ll notice I don’t open the .jpgs that start appearing. Of course, I like to maintain some amount of privacy… Also, sorry about the camera position. You don’t actually get to see me, but I prefer it that way.

Posted in Uncategorized | Leave a comment

I2C + Raspberry Pi + Arduino Uno + RPi Camera Board

UPDATE: I’ve revised the circuit design. I no longer recommend connecting the Arduino Uno to the Raspberry Pi’s I2C pins together without the use of a logic level shifter. The revised design uses one from

As part of a larger project I’m doing right now I’ve connected an Arduino Uno, as an I2C slave, to the Raspberry Pi. The premise here is that if I press a button on the Arduino, it will trigger the Raspberry Pi to take a picture using the Camera Board and store it in a particular folder. The overall setup is as shown (minus the camera):

Uno to Pi camera

Hardware Connections

According to ELinux, the I2C pins on the RPi are connected to 3.3 V via internal pull-up 1.8 kΩ resistors. This means that, if the Uno is configured as a slave device, the necessary power will come from the RPi I2C pins themselves and that the Uno’s I2C pins can be directly connected to the RPi pins, right? A few websites’ tutorials show this configuration. However I’ve found that I2C communication is very flaky if the pins are directly connected. Again, I recommend using a logic level shifter. Adafruit sells one that is I2C compatible.


For the Uno, I used Arduino’s C++ and the Wire.h library. For the RPi I coded the software using Python, making use of three libraries:

  1. smbus
  2. GPIO 
  3. subprocess

Comments are included within the code to provide insight on how they are used. The files, and i2cslave.ino, are located here.

Edit: I’ve included a function that emails the picture taken to my GMail account. MitchTech has a great tutorial here:

Posted in Uncategorized | Leave a comment

Using both ownCloud and Adafruit’s WebIDE on the Raspberry Pi

Long story short, I installed both of the aforementioned programs on my Raspberry Pi but, in doing so, I was able to navigate to only ownCloud. After doing some digging around the internets, I found the solution.

As  smithg400 on Raspberry Pi’s forums pointed-out, both WebIDE and ownCloud listen for connections on port 80 of their local networks, and that the solution is to change one of them; in this case, the default port for WebIDE.

To do that, open a Terminal window and navigate to the config directory of the WebIDE installation folder by typing

cd /usr/share/adafruit/webide/config

Then type

sudo nano config.js

You’ll find that the file looks something like this:

change port

You want to change the port number to something else. In this case, I changed it from “80” to “8080”, like this:

changed port

Now press


to exit, then type 


to accept the changes. Now open a browser and log-in like you normally would to WebIDE. Just type in your RPi’s address followed by the port, like this:  192.168.xx.xx:8080

Posted in Uncategorized | Leave a comment

Raspberry Pi Cloud Server, using ownCloud

I just installed ownCloud on my Raspberry Pi after scouring the internets for the best set of directions. There’s quite a few tutorials out there, but only one of them worked for me, without much of a problem.

The best tute I found came from this blog:

There are two different ways to set up ownCloud using the script on the site. I had to go with Apache instead of NGiNX because NGiNX just didn’t work for some reason. But go ahead and check it out, it’s pretty nifty.

EDIT: The OS running on my RPi was Raspbian, installed using the NOOBS v1.2 .zip file found on

Posted in Uncategorized | Leave a comment

Arduino library for the Parallax PIR and Ping))) Sensors

pir ping

I’m currently working on something that involves the Parallax PIR and Ping sensors. The main platform for this one is an Arduino Uno. Right now, Arduino has code on their website for both of these sensors, here and here. Since I thought that they’re both kinda messy, I wrote a library for each one, by just organizing the existing code. Credit goes to the original authors.

Here’s the link to the repository where they’re kept. If you’re not familiar with git, check out this link.

Posted in Uncategorized | Leave a comment

DIY: Temperature Monitoring and Regulation for HomeBrew

Beer brewing is a fun hobby, whether you wanna just brew something easy from a kit, or take the time to fine-tune your preferred style. With every batch, there are always two things that weigh heavy on a brewer’s mind: risk of contamination or, depending on where you live, extreme temperatures. I live in an area where the temperature often dips below 60° F during the winter, which is too cold for the yeast to thrive. Using a space heater wastes a ton of energy, and I’ll still have to turn it off manually. I decided to tackle this problem.

At the very least, I knew I would need a heating belt, a temperature sensor, and an AC power source that can be activated/deactivated. Generally speaking, heating belts don’t come with any sort of feedback control, and an off-the-shelf regulator costs far more than I’m willing to pay. After a bit of research, I decided that I needed the following:

  1. 1 x Arduino micro-controller
  2. 1 x DS18B20 waterproof temperature sensor
  3. 1 x character LCD
  4. 1 x 10 kΩ trimmer, to adjust the LCD contrast
  5. 2 x 330 Ω, 1/4 W resistor
  6. 1 x 100 Ω, 1W resistor
  7. 1 x IR sensor
  8. 1 x 2N6344G TRIAC
  9. 1 x MOC3023 optoisolator
  10. 1 x 2N2222 NPN
  11. 1 x DIP IC socket
  12. 1 x 250 VAC, 0.5 A, 1.25″ x 0.25″ fuse
  13. 1 x  fuse holder for 1.25″ x 0.25″ fuse
  14. 1 x Brew Belt
  15. some wires

I started off the project by doing a bit of programming on the Arduino to display the temperature read by the sensor on the LCD, and the IR sensor to trigger the LCD backlight (via the Arduino). Once that all worked, I was left with a dilemma: I could use either an electromechanical relay or a solid state relay, like a TRIAC. Since I had no experience in using one, I went with the TRIAC.

For those of you unfamiliar with TRIACs (triode for AC), here’s a little background info: they are 3-pin transistors. When a current is injected into the gate terminal, it allows for current to pass through the other two terminals, just like it would for a BJT. The great thing about TRAICs is that they can conduct both ways, making this a great switch for AC applications. If you open a light dimmer-switch, you’re likely to find a TRIAC inside. For safety’s sake, TRIACs should be driven by optocouplers (a.k.a. optoisolators), which in turn are driven by a controlling signal. TRIAC/isolator combinations are, in my opinion, better than electromechanical relays because they are cheaper and require less space. The optocoupler’s datasheet provides example circuit diagrams for different kinds of loads. I picked the one for resistive loads and tested it. After testing, the circuit was soldered onto a PCB. As you can see, the IC socket is soldered-on, and the isolator simply inserted. That way, if it stops working, it will be easier to pinpoint the problem.


An extension cord was stripped on the female side and the leads soldered as shown in my schematic, then thrown into an outlet box. Finally, I threw together everything as shown in the schematic:


Update: I soldered the stuff seen in the video onto a protoshield, and added a few things.


Final thoughts:

  • I’ve tested this circuit with a couple different “sensitive gate” TRIACs, and a normal (sometimes advertised as a “snubberless”) one, and they all work similarly in my experience. There are texts out there saying to avoid the sensitive gate TRIACs because of their tendency to turn-on as soon as AC voltage is applied to M1 and M2. Personally, I’ve not had that experience. But it’s better to be safe than sorry.
  • The datasheet of the 2N3364 seems to infer that the TRIAC cannot be turned-on in Quadrant IV; in other words, it would be on for only half a cycle. Testing proved this to be untrue. Maybe I read it wrong.
  • Don’t wrap the heating belt around a glass carboy. I’ve been told that the belts cause the glass to crack. Use a bucket instead.
  • That enclosure is ugly as sin. I sure would like a 3D printer…

After my tests are all said and done, it’ll be time to start brewing. How can one better kick-off the summer than with homemade Stout and Honey Wheat?

Posted in Uncategorized | Leave a comment