Arduino, Programming

Arduino + DS1307 RTC

Another demo for interfacing an Arduino with the DS1307 Real Time Clock. The board I used (see here) also has an integrated 24C32 32K EEPROM which we won’t worry about in this demo.

Here’s a picture of my setup:

IMG_20151121_202254

Materials Used:

  • Arduino Uno R3
  • 16×2 LCD Shield
  • DS1307 board (I used this one) but you could use this one too
  • CR2032 button cell

Wiring details:

(NOTE: If you’re using the same board as me then wire to the side of the board with the pins SQ, DS, SCL, SDA, VCC, GND & BAT)

  1. Uno’s 5V (via LCD Shield) to RTC’s 5V
  2. Uno’s GND (via LCD Shield) to RTC’s GND
  3. Uno’s Analog Pin 4 (via LCD Shield) to RTC’s SDA
  4. Uno’s Analog Pin 5 (via LCD Shield) to RTC’s SCL
  5. Leave the other pins unconnected
  6. Put the button cell in!

You can find the code here. And voila! 🙂

Advertisements
Arduino, Programming

Arduino + HR-SR04 Ultrasonic

I wanted to try an Ultrasonic sensor so I bought the cheapest one I could find, the HR-SR04. I used this tutorial to learn about the ultrasonic. Basically I thought the Ultrasonic would provide an analog signal with the distance…well I was wrong. Distance is calculated based on the time taken for an echo signal to be sent and received.

Here’s a picture of my setup.

IMG_20151121_160922

Materials used:

Wiring is easy:

  1. Uno’s 5V (via LCD Shield) to sensor’s 5V
  2. Uno’s GND (via LCD Shield) to sensor’s GND
  3. Uno’s Digital Pin 0 (via LCD Shield) to sensor’s ECHO
  4. Uno’s Digital Pin 1 (via LCD Shield) to sensor’s TRIG

You can find the code here. And voila! 🙂

Arduino, Programming

Arduino IDE Alternatives

Ok the original Arduino IDE is good but not great. It’s pretty basic as it’s intended to be. I needed something better, something advanced. I didn’t try every alternative out there. I tried using Eclipse (it’s actually an eclipse plugin, see here) but I couldn’t get it work. I believe it didn’t work because I needed 32 bit Java. Anyways, I tried Visual Micro. This is something I liked. It’s also a plugin for Visual Studio. (FYI Visual Studio now comes in a free community edition, see here) Two things I didn’t like:
1) Creates too many files, that’s just how Visual Studio works. It creates several folders and files which I don’t need.
2) Some of the compilation errors didn’t show up. I was pulling my hair trying to figure out the cause of the error. I eventually figured out it after I compiled it using the original Arduino IDE.

The other “problem” for me was that I’m using a PC and laptop (it’s one of those convertible tablet/laptop) for development. I wanted to same the software on both systems. I didn’t want to install a big IDE like Visual Studio (with Visual Micro) on my laptop (it doesn’t have much space).

So I have decided to use Notepad++ for development and then use the original Arduino IDE with the “External editor” option activated.

Uncategorized

Freematics Telematics Kit #1 – Not so cool!?!?!

It was working for a while. I decided to tidy it up and use a breadboard. After plugging into the breadboard I tried to download a different program into the Nano, which worked. At some point the Nano’s driver in Windows stopped working. So I installed this http://www.ftdichip.com/Drivers/CDM/CDM%20v2.12.06%20WHQL%20Certified.zip. This also worked for a while. The next day it wouldn’t connect 😦

Everytime I tried to upload it would fail with “…avrdud…not in sync resp=0xca”. I eventually found this http://forum.arduino.cc/index.php?topic=73748.0 which provides instructions to test the board by performing a loopback test. I did that and the return from loopback test was “NON GENUINE DEVICE FOUND!”. Just great 😦

Update 1:
Here are the steps to fix it:
1) Follow http://electropit.com/index.php/2015/09/06/arduino-nano-v3-0-clones/. When it talks about burning the bootloader then follow http://www.instructables.com/id/How-To-Burn-a-Bootloader-to-Clone-Arduino-Nano-30/?ALLSTEPS
2) Install the Arduino USB drivers from C:\Program Files (x86)\Arduino\drivers\

And it works again! 🙂

The moral of the story? Buy genuine or buy compatible boards from a reputable source such as Core Electronics.

Uncategorized

Freematics Telematics Kit #1 – Cool!

I bought one of these recently: http://freematics.com/pages/products/arduino-telematics-kit-1/

It’s an Arduino based OBD interface device. The kit comes with:

  • OBD II Adapter (Arduino powered)
  • Arduino Nano
  • I2C OLED screen (128×64)

They even provide a sample Arduino program for the Nano and it works!

Here’s my guide to setting it up:

  1. Go to https://github.com/stanleyhuangyc/ArduinoOBD and download the zip file
  2. Extract the zip file to “ArduinoOBD-master” and browse to the “libraries” folder
  3. Copy “MicroLCD”, “MPU6050” and “OBD” from the “libraries” folder to the Arduino libraries folder (located in ..\Documents\Arduino IDE\libraries)
  4. Go back to the “ArduinoOBD-master” folder and open “nanologger”
  5. Open “nanologger.ino”
  6. When you compile it you will receive an error about the sketch being too big. If you haven’t installed the microSD card breakout then you don’t need the data logging features. Go to “config.h”, line 8 where it “#define ENABLE_DATA_LOG 1” and change it to “#define ENABLE_DATA_LOG 0”
  7. Make sure you disconnect the OBD adapter wires from the Nano otherwise you won’t be able to download it
  8. Now you can compile and upload!
  9. Connect the wires as per http://freematics.com/pages/products/arduino-telematics-kit-1/
  10. Connect to your car and voila! 🙂