Wednesday, April 20, 2016

Upcoming Projects

I've had very little spare time lately, but I do have a few projects very near completion! My biggest dilemma in all of these projects is the housing for the controllers, as I want to make them all permanent (likely to be 3D printed!)

Peaceful Fountain

The fountain will have a 12v silent pump, trickling water down on the rocks. I picked up a few bamboo sticks from my local farmers market which will grow in the water of the fountain! The water pump is not submersible, so it will be mounted outside the tank, and connected through clear piping I picked up at home depot, The defining factor of this project is the startup, which will be Arduino controlled, when motion is detected on the IR motion detector.

Smart Fishtank

This is a two in one project. Years ago I decided to get into the aquarium scene and set up a cute fish tank with a heater, an aerator, and tetra fish. That tank was a twenty gallon, which through various situations ended up in my mother's basement (with the fish still). Now, my aunt gave me a thirty gallon fish tank which she received from a friend, and it had everything I would need to set up another tank. I set the goal to make both of these into smart fish tanks. I currently have everything I need to set up these tanks, except the time to do it. However, the key features of this project are:
  • Motion sensor to turn on lights and aerator
  • Temperature sensor to kick on heaters
  • Water level warning
  • Warning to feed fish
  • Warning to change filter
  • Warning to clean tank
This will be accomplished with relays controlling a junction box with each device plugged in. The wires from the relays will run to an Arduino. The Arduino will also have three buttons for reset of the feed, filter, and cleaning timers. The back of the tank will have a string of LEDs to display the current conditions.


**UPDATE
I have designed and ordered the controller housing! I designed it in solidworks and ordered it from Shapeways. Hopefully it isn't terriblely deformed!

 

JeepMate

This project is still far in the future. My jeep doesn't have a clock in it, which was the initial spark for this project, and it has reflected in my previous projects. However, upon the arrival of my 20x4 LCD I decided I could display a whole lot more of information. The information it will display is:
  • Time
  • Heading (NSEW)
  • Temperature
  • Tilt (forward/backward and left/right)
The time will be controlled by the DS3231 from my previous examples. This module is also capable of displaying temperature. The heading will be controlled by a 3 axis gyro, which will also control the tilt. The final piece of this project, which came about last week when a PT cruiser tried to ram into me, is a dash cam. This will save 800x600 images to an SD card, which will be easily removable from the side. The entire ensemble will be encased in a 3d printed box, carefully mounted to ensure trail survival, and the box screwed in right above my windshield. The biggest speed bump of this project is the car's 12v battery, which I will need to convert to Arduino voltages, preferably without creating too much current!

Touch Screen Car Stereo

This project is far in the future and is by far my most ambition project. My mother's Toyota stereo has been loosing functionality on the past few years (CD player skipping, cassette player broke). I see this as a wonderful opportunity. My roommate loves to work with car stereos and audio equipment, which, combined with his excellent programming and raspi knowledge should prove to be a project well within our capability. His friend is proficient in coding with Codi on the rasberry pi, which should be extremely helpful. I intent to use Andrei Istodorescu's guide and interface for the program. My goal is to include:

  • Cd/Radio
  • Gps/Navigation
  • Backup Camera
This project will hopefully be complete by the end of summer!


So that is where I am, I know its a bad habit of DIYers to take on too many projects, but I am prioritizing the best I can in my free time, and hopefully will be ready soon!

Thanks for reading, and as always, check your wiring!

Wednesday, April 13, 2016

I2C LCD Display Problems

I hope this post can be a rescue ring for anyone struggling with this problem. I purchased several lcd displays on eBay from a seller named 'Frentaly.' Now the seller was fantastic, located in the US so shipping was fast and the build quality was very good, however, I couldn't find a library that would work with it. I contacted Frentaly and they didn't know what the problem was, but offered me a refund, which I declined because I was certain I was doing something wrong (how could three lcds be defective?!).

I became an expert on these lcd screens. I used every library and sketch I from every how-to video and blog out there, but nothing seemed to get the display to show text. I could flash the back light, read the device's address, but I couldn't see the text I was sending it. I gave up for a week in frustration, and finally reproached it yesterday at work when I found a page on i2c lcd displays (not the solution, but still a great resource). I thought maybe I had found the right library, because that page says some lcds have different wiring. I got home, ran it, and it wasn't fixed. Undeterred I scoured the net looking for customer reviews, hopeful someone else would share this problem. I finally found a useful review on amazon (no link because I can't find it again, but thank you amazon reviewer!).

The lcd I bought came with a pre-soldered 'backpack' on it, which would make it possible to use only I2C wiring, instead of several i/o pins. On this backpack is a small blue box with an adjustment knob on it, can you guess what that knob does?


Contrast, Bingo! Turn it until you can see the text on your screen, and voila! Miraculously, my screen works now. If your display doesn't have one of these backpacks you can pick one up on ebay for 99 cents, and it'll make your life a whole lot easier!


Thanks for reading, and as always, check your wiring!

Monday, April 4, 2016

Sensor Communication (I2C)


I wanted to spend a few minutes explaining this for my own sake. I spent an entire frustrating day this weekend trying to get two sensors working simultaneously. In the end I realized I had wired my board incorrectly (hence, 'Check your wiring'), but I did learn some interesting information.

So lets get down to it, disclaimer: the fundamentals of this communication method have very little consequence to an arduino programmer, you could use libraries all day long and cannibalize code until your eyes bleed, but to really understand what you are doing this is important knowledge.

I2C ("I sqaured C) stands for Inter-Integrated Circuit (which means nothing to me). You may have connected pins A4 and A5 on your board to a sensor before, these are the serial pins. If you haven't, don't get confused, we're just getting started! These pins connect to the SDA and SCL wires on your sensor. The connection of these wires allows for communication between the devices.

The SDA line is your data line, this line actually transfers the data in bits/bytes (never can keep them straight). The SCL line is the clock line, which keeps the data organized and decides the speed of the transfer. What makes this type of communication unique is that instead of using different pins for each one of your sensors, each device has its own address, and when the master devices sends the address request down the I2C lines, only the requested device answers. There are two modes for this communications, 7-bit, which can communicate with a little over 120 different addresses, and 10-bit, which is a slightly slower communication, but allows for over 1000 unique addresses.

The are tons of different devices you can connect. The arduino itself is called a master, and you can have more than one master communicating. The sensors (without a processor) are called slaves. You might have heard of this in other computer applications. The slaves can be anything from a thermostat, to a clock, to a gyroscope. I mentioned before that each device has its own address that it responds to. This address is permanently engraved on the device by the manufacturer. For example the TC74 digital serial thermal sensor can be give the address of TC74A0-TC74A7, and if you have two TC74A1's they will interfere with one another. An interesting work around for this would be to power one down while reading the other, but hopefully you'll never have to do that! (as a side note I should mention that the address is in hex, so the addresses will look more like 0x1E)

One of the main benefits of I2C communication is how few pins it requires. You can run tons of sensors with only two serial wires. The fascinating part of this is that each of the devices are connected in parallel, and only the device requested responds to input, all of it happening instantly. Its truly a brilliant form of communication!

Click here for more information!

I hope you enjoyed the read, and remember, check your wiring!

Friday, April 1, 2016

4 Digit 7 Segment Clock with DS3231



Earlier this weekend I found out what a shift register was and managed to get a 4 digit 7 segment display (4D7SD) to show counting milliseconds using Kristian BlĂ„sol's videos here: Shift Register4D7SD. These two videos are fantastic and really show you how to work with these concepts, please watch them if you are interested in getting this wired up, I will only be covering my modifications to his setup. In my code you'll notice I used a cheat at the end instead of figuring out how the cathode call numbers worked.

Now I really wanted to take this a step further. My goal was to build a display that would show the current time (hh:mm) with the 4D7SD. Naturally, to do this I would need a clock (and not the millis like I used in my last post). Enter the DS3231. This is a nifty little device, I bought several on ebay (about 1.5$ for 2). They have a battery to keep time even when the board is turned off.

I used this instructable for wiring. The library linked in this will get you going with pretty much all you need with the DS3231. However, the functions in the library use pointers which, for the uninitiated, are a *****. I am not qualified to explain a pointer, but my understanding is it basically is a variable that 'points' to somewhere else. My guess in this application would be the pointer runs a functions to grab the time from the DS3231.

Anyway, the problem with the pointers is, you can't convert them to a different value. What this means for you is that the value your library takes from the DS is a 'char' not an 'int'. The end result is you have to jump through a bunch of hoops (as you'll see in my code) to get it to do what you want. You can't compare characters to integers, and a bunch of other things I can't think of right now.

Hello World! (Dog feeding timer)

This will be my very first blog post ever, so exciting! To celebrate my very first blog post ever I will present you with my very first Arduino project ever! So grab yourself a glass of wine, some wires, and sit on back!

The problem: my roommate and I have a dog (Illyah) that we both take care of. Frequently we would either both feed the dog, or neither of us.
The solution: a timer that resets when the dog is fed.



I don't quite remember all the steps I took to build this project (it several months ago), but I’ll give you the best breakdown I can! This project was very basic, originally I built in on a Uno, but when my nano arrived I switched it over to that.

Wiring:

The code is the most fun part of this project for me. Originally I had the LED flashing quite long and simply (which is probably fine for your application). However, in our little flat the LED would flash so brightly I could see it in my room and it would keep me up at night! So this code is designed with that in mind.

Code

The simplest way for me to write this function was to pull on the Arduino’s integrated millisecond counter and converts it to hours. When we feed Illyah we reset the board.  The flashing LED uses the hours to determines how frequently to flash. When the timer is first reset the green LED flashes so rarely that you probably won’t see it unless you stare at the setup. Then, after eight hours, the flashing switches to yellow and flashes more frequently and stays on slightly longer, although the duration of the flash is still quite insignificant at this point. Finally, once twelve hours has passed, the buzzer sounds, the color switches to red, and LED flashing and duration increase. As hours pass after the twelve hour mark, the light and buzzer become incessant to remind you to feed the dog. And, viola! Never forget to feed the dog again!