1. Welcome to Tacoma World!

    You are currently viewing as a guest! To get full-access, you need to register for a FREE account.

    As a registered member, you’ll be able to:
    • Participate in all Tacoma discussion topics
    • Communicate privately with other Tacoma owners from around the world
    • Post your own photos in our Members Gallery
    • Access all special features of the site

Arduino and the Tacoma

Discussion in '2nd Gen. Tacomas (2005-2015)' started by Erll, Mar 16, 2012.

  1. Mar 16, 2012 at 6:03 AM
    #1
    Erll

    Erll [OP] Well-Known Member

    Joined:
    Feb 8, 2011
    Member:
    #50752
    Messages:
    153
    Gender:
    Male
    First Name:
    My Name is Erll
    Des Moines, Iowa
    Vehicle:
    Speedway Blue
    Check my sig
    This is where I will be putting my Arduino code and documenting my projects.
     
    digitaLbraVo likes this.
  2. Mar 16, 2012 at 6:06 AM
    #2
    Erll

    Erll [OP] Well-Known Member

    Joined:
    Feb 8, 2011
    Member:
    #50752
    Messages:
    153
    Gender:
    Male
    First Name:
    My Name is Erll
    Des Moines, Iowa
    Vehicle:
    Speedway Blue
    Check my sig
    For those not familiar with the Arduino, check out Arduino.cc and read up on it. It's super simple to program and very powerful for its size/price.
    I get most of my parts on sparkfun.com.
     
  3. Mar 16, 2012 at 8:28 AM
    #3
    Erll

    Erll [OP] Well-Known Member

    Joined:
    Feb 8, 2011
    Member:
    #50752
    Messages:
    153
    Gender:
    Male
    First Name:
    My Name is Erll
    Des Moines, Iowa
    Vehicle:
    Speedway Blue
    Check my sig
    #include <SoftwareSerial.h>
    #include <Wire.h>
    SoftwareSerial mySerial(2, 3);
    int HMC6352Address = 0x42;
    // This is calculated in the setup() function
    int slaveAddress;
    byte headingData[2];
    int i, headingValue;


    //TMP36 Pin Variables
    int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is Connected to
    //the resolution is 10 mV / degree centigrade with a
    //500 mV offset to allow for negative temperatures

    /*
    * setup() - this function runs once when you turn your Arduino on
    * We initialize the serial connection with the computer
    */
    void setup()
    {
    Serial.begin(9600); //Start the serial connection with the computer
    //to view the result open the serial monitor
    mySerial.begin(9600);
    Wire.begin();
    clearLCD();
    mySerial.write(0x7C); //command flag for backlight stuff
    mySerial.write(157); //light level.
    delay(10);
    pinMode(5,OUTPUT);
    pinMode(6,OUTPUT);
    analogWrite(5,230); //green
    analogWrite(6,255); //blue
    slaveAddress = HMC6352Address >> 1;
    }

    void loop() // run over and over again
    {
    //**************************************Heading - Compass Section**************************************

    // Send a "A" command to the HMC6352 HMC6352 is hooked to A4 and A5
    // This requests the current heading data
    Wire.beginTransmission(slaveAddress);
    Wire.write("A"); // The "Get Data" command
    Wire.endTransmission();
    delay(10); // The HMC6352 needs at least a 70us (microsecond) delay
    // after this command. Using 10ms just makes it safe
    // Read the 2 heading bytes, MSB first
    // The resulting 16bit word is the compass heading in 10th's of a degree
    // For example: a heading of 1345 would be 134.5 degrees
    Wire.requestFrom(slaveAddress, 2); // Request the 2 byte heading (MSB comes first)
    i = 0;
    while(Wire.available() && i < 2)
    {
    headingData = Wire.read();
    i++;
    }
    headingValue = headingData[0]*256 + headingData[1]; // Put the MSB and LSB together


    //Convert headingValue to float to compare to ranges for Human readable directions
    String headingString ;
    float headingFloat = (headingValue / 10.00);

    if (headingFloat>337.5 || headingFloat<22.5)
    headingString = "N ";
    if (headingFloat>22.5 && headingFloat<67.5)
    headingString = "NE";
    if (headingFloat>67.5 && headingFloat<112.5)
    headingString = "E ";
    if (headingFloat>112.5 && headingFloat<157.5)
    headingString = "SE";
    if (headingFloat>157.5 && headingFloat<202.5)
    headingString = "S ";
    if (headingFloat>202.5 && headingFloat<247.5)
    headingString = "SW";
    if (headingFloat>247.5 && headingFloat<292.5)
    headingString = "W ";
    if (headingFloat>292.5 && headingFloat<337.5)
    headingString = "NW";

    //Send heading and direction to LCD
    mySerial.write(0xFE); //command flag
    mySerial.write(131); //position
    delay(10);
    mySerial.print("Heading ");
    mySerial.print(headingString);

    //*************************** Tempature Section************************************

    //getting the voltage reading from the temperature sensor
    int reading = analogRead(sensorPin);

    // converting that reading to voltage, for 3.3v arduino use 3.3
    float voltage = reading * 5.0;
    voltage /= 1024.0;


    //Convert to Centigrade
    float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
    // now convert to Fahrenheight
    mySerial.write(0xFE); //command flag
    mySerial.write(194); //position
    delay(10);
    float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
    mySerial.print("Temp F ");
    mySerial.print(temperatureF); //Use this for Farenheight
    //mySerial.print(temperatureC); //Use this for Centigrade

    delay(1000); //waiting a second

    }

    void selectLineOne(){ //puts the cursor at line 0 char 0.
    mySerial.write(0xFE); //command flag
    mySerial.write(128); //position
    delay(10);
    }
    void selectLineTwo(){ //puts the cursor at line 0 char 0.
    mySerial.write(0xFE); //command flag
    mySerial.write(192); //position
    delay(10);
    }
    void clearLCD(){
    mySerial.write(0xFE); //command flag
    mySerial.write(0x01); //clear command.
    delay(10);
    }
    void backlightOn(){ //turns on the backlight
    mySerial.write(0x7C); //command flag for backlight stuff
    mySerial.write(140); //light level.
    delay(10);
    }
    void backlightOff(){ //turns off the backlight
    mySerial.write(0x7C); //command flag for backlight stuff
    mySerial.write(128); //light level for off.
    delay(10);
    }
    void serCommand(){ //a general function to call the command flag for issuing all other commands
    mySerial.write(0xFE);
    }
     
  4. Mar 16, 2012 at 12:07 PM
    #4
    ckeck

    ckeck New Member

    Joined:
    Mar 16, 2012
    Member:
    #75011
    Messages:
    1
    Gender:
    Male
    Oh heck yeah -- thanks for sharing! Will be keeping an eye on this thread...
     
  5. Mar 16, 2012 at 12:56 PM
    #5
    MikeyLikesIt

    MikeyLikesIt Supercharged Mileage Master

    Joined:
    Jul 17, 2011
    Member:
    #60053
    Messages:
    342
    Gender:
    Male
    Very cool, I picked one up a few weeks ago but I haven't had a chance to play with it yet.
     
  6. Apr 1, 2012 at 8:28 PM
    #6
    Erll

    Erll [OP] Well-Known Member

    Joined:
    Feb 8, 2011
    Member:
    #50752
    Messages:
    153
    Gender:
    Male
    First Name:
    My Name is Erll
    Des Moines, Iowa
    Vehicle:
    Speedway Blue
    Check my sig
    OK here is the first prototype. I really need to figure out how to mount this thing. My nest step is to add inside the truck temp and to be able to control the windows.

    IMAG0484.jpg
     
  7. Apr 2, 2012 at 3:52 PM
    #7
    elykTacos

    elykTacos "Its all ball bearings nowadays"

    Joined:
    May 31, 2011
    Member:
    #57541
    Messages:
    234
    Gender:
    Male
    First Name:
    Kyle
    Salt Lake City, Utah
    Vehicle:
    2011, DBLCB , 4x4, Sport, Grey
    Custom sliders, Bilstien 5100s in front - 5100's + AAL + TSB in rear, dif drop, LED's in scoop, CB installed in console, flashlight mount, window tint, locking compartment in bed.
  8. Apr 2, 2012 at 4:19 PM
    #8
    D4D Hilux Dude

    D4D Hilux Dude Well-Known Member

    Joined:
    Aug 24, 2011
    Member:
    #62271
    Messages:
    177
    Gender:
    Male
    First Name:
    Darren
    Arvada, CO
    Vehicle:
    2011 4x4 Double Cab TRD Offroad
    TRD Supercharger TRD Catback Exhaust Ziebart Rust Proofing Additional Bed Ties 2012 Indicator side mirrors
    How difficult is this to get into?
     
  9. Apr 2, 2012 at 4:33 PM
    #9
    Erll

    Erll [OP] Well-Known Member

    Joined:
    Feb 8, 2011
    Member:
    #50752
    Messages:
    153
    Gender:
    Male
    First Name:
    My Name is Erll
    Des Moines, Iowa
    Vehicle:
    Speedway Blue
    Check my sig
    It's actually very easy. I am really not an electronics geek at all. It really only takes an Arduino uno r 3 and a pc. The software is all free, and there are tons of examples to cheat from
     
  10. Apr 2, 2012 at 4:34 PM
    #10
    Erll

    Erll [OP] Well-Known Member

    Joined:
    Feb 8, 2011
    Member:
    #50752
    Messages:
    153
    Gender:
    Male
    First Name:
    My Name is Erll
    Des Moines, Iowa
    Vehicle:
    Speedway Blue
    Check my sig
    I would be willing to put some examples up here if there is interest. Check out WWW.sparkfun.com
     
  11. Apr 2, 2012 at 5:23 PM
    #11
    MikeyLikesIt

    MikeyLikesIt Supercharged Mileage Master

    Joined:
    Jul 17, 2011
    Member:
    #60053
    Messages:
    342
    Gender:
    Male
    I use an Arduino UNO and I program it withe Visual Studio and the Visual Micro add in. I love the intellisence in Visual Studio and it makes programming a lot easier. I started off with the typical LED projects, but we are moving into actuators and servos. Very cool stuff, I can't wait to see what you come up with.
     
  12. Apr 2, 2012 at 5:33 PM
    #12
    Erll

    Erll [OP] Well-Known Member

    Joined:
    Feb 8, 2011
    Member:
    #50752
    Messages:
    153
    Gender:
    Male
    First Name:
    My Name is Erll
    Des Moines, Iowa
    Vehicle:
    Speedway Blue
    Check my sig
    I am beginning to think I my need to go to a mega. I keep thinking of things I can use this for. I just got a bunch of 5 v relays that I can use for windows, lights, air compressor, heated seats.
    I also found a single ic weather radio that I plan on putting into my aux port.
     
  13. Apr 6, 2012 at 6:42 PM
    #13
    Erll

    Erll [OP] Well-Known Member

    Joined:
    Feb 8, 2011
    Member:
    #50752
    Messages:
    153
    Gender:
    Male
    First Name:
    My Name is Erll
    Des Moines, Iowa
    Vehicle:
    Speedway Blue
    Check my sig
    I just picked up an RFID / NFC sensor for the Arduino, and also got some tags. I will be setting this up to unlock and lock the doors when the keys are out of the range of the vehicle. I will have to see what the real world range if the tag is, and what the code all involves. anyone with NFC experience ?
     
  14. May 2, 2012 at 6:26 PM
    #14
    Erll

    Erll [OP] Well-Known Member

    Joined:
    Feb 8, 2011
    Member:
    #50752
    Messages:
    153
    Gender:
    Male
    First Name:
    My Name is Erll
    Des Moines, Iowa
    Vehicle:
    Speedway Blue
    Check my sig
    I got a wild hair and decided that I want to add an integrated weather radio to this whole mess.

    OK I got the RTC module in today and the 16 channel relay module on order. I will be adding the RTC to the code tomorrow, and the compiling a list of things that i want to control with the Relay module. Any Ideas. I was thinking the following

    1 - anytime backup cam
    2 - air compressor for my riderites
    3 - Fog Lights
    4 - backup lights
    5 - Front windows based on interior temp and rain sensor
    6 - bed lights
    7 - ??
     
  15. Jul 17, 2012 at 12:12 PM
    #15
    Sandman614

    Sandman614 Ex-Snarky TWSS elf, Travis #hotsavannahdotcom

    Joined:
    Oct 26, 2010
    Member:
    #45273
    Messages:
    35,538
    Gender:
    Male
    First Name:
    Tim
    Garner, NC/Boone, NC
    Vehicle:
    '06 SR5 Off Road
    ARB Front Bumper, Projector Headlights w/Slimcubby 4300K HID's, Oznium LED's, LED taillights, DIY Washable Cabin Moose Filter, Sockmonkey SR5 Off Road, Aux Audio plug, OME 886x, OME Nitrochargers, Wheelers 3 Leaf Progressive AAL, ImMrYo Rear-View Mirror Lift Bracket, Dodge D-Rings
    Any progress?
     
  16. Jul 17, 2012 at 12:15 PM
    #16
    Taqoma

    Taqoma Well-Known Member

    Joined:
    Jan 9, 2012
    Member:
    #70332
    Messages:
    1,352
    Gender:
    Male
    First Name:
    Brennan
    Los Angeles
    Vehicle:
    2011 TRD Off-Road
    TRD Supercharger, TRD CAI, Camburg LT, Fox 2.5x8 coilovers, Fox 2.0 bumps, Deaver e30 leafs, Fox 3.0x18 triples, Avid sliders, Yaesu 2900R, Pro Comp 7089 16x8, DDM 55w HID Hella 500FF, DDM 35w HID headlights, Magnaflow 11255 muffler, PLX DM-100 OBDII, Autometer Ultra-Lite II Boost gauge, Flex Pod gauge mount, LSK tube bumper, McNeil fenders, Fiberwerx bedsides, 285/75/16 Toyo MT's
  17. Jul 17, 2012 at 12:30 PM
    #17
    ajwhlr04

    ajwhlr04 Well-Known Member

    Joined:
    Jan 4, 2012
    Member:
    #69957
    Messages:
    66
    Gender:
    Male
    First Name:
    Aaron
    Woodland Hills, CA
    Vehicle:
    2007 Tacoma 4x4 Double Cab 6MT
    sub'd

    I haven't played with an Arduino yet, but I always thought it would be cool to program a microcontroller to read and display data from the OBDII system on a vehicle. Possibly use the data to do some calculations to figure out optimal engine speed to get the best MPG, or any other useful calculation. To bad I don't have the time to figure it out. Maybe someone does!
     
  18. Jul 17, 2012 at 1:06 PM
    #18
    Schwinn

    Schwinn Well-Known Member

    Joined:
    Mar 27, 2012
    Member:
    #75761
    Messages:
    624
    Gender:
    Male
    First Name:
    Jamie
    Georgina, ON
    Vehicle:
    2012 TRD Sport with Trail Teams package
    Looks almost like Javascript!
     
  19. Jul 17, 2012 at 5:09 PM
    #19
    maineah

    maineah Well-Known Member

    Joined:
    Mar 24, 2011
    Member:
    #53641
    Messages:
    6,585
    Gender:
    Male
    First Name:
    Tim
    Maine
    Vehicle:
    4X4 SR5 V6 6spd
    C++
     
  20. Jul 17, 2012 at 5:11 PM
    #20
    maineah

    maineah Well-Known Member

    Joined:
    Mar 24, 2011
    Member:
    #53641
    Messages:
    6,585
    Gender:
    Male
    First Name:
    Tim
    Maine
    Vehicle:
    4X4 SR5 V6 6spd
    Radio Shack is selling the Arduino boards now.
     

Products Discussed in

To Top