Sunteți pe pagina 1din 4

technology

workshop

living

food

play

outside

Arduino Control/Integrate Aftermarket Accessories via the CAN-BUS


by mviljoen2 on March 9, 2015

Table of Contents
Arduino Control/Integrate Aftermarket Accessories via the CAN-BUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Intro: Arduino Control/Integrate Aftermarket Accessories via the CAN-BUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 1: Another Example of its use. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 2: See this instructable in action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

http://www.instructables.com/id/Arduino-ControlIntegrate-Aftermarket-Accessories-v/

Intro: Arduino Control/Integrate Aftermarket Accessories via the CAN-BUS


If you wanted to control aftermarket accessories using the existing controls in your vehicle you would have to connect a relay to end where an existing factory accessory
is connected to.
For an example:
You have a 4x4 and want to add aftermarket spot lights, So you need to then connect a relay to an existing light, which will click the relay and let more power through to
the aftermarket lights. This means you have to splice and cut into the existing factory wiring of your vehicle.
With this instructable you can tap into the can bus (in my case the can bus wires at the back of the radio)
The radio has a can-bus because its controllable via other accessories such as the steering wheel buttons, so instead of cutting into it you can buy a female-to-make
connector and then tap into the connector.
You need the following.
Arduino UNO.
SeeedStudio CAN-BUS Shield.
Arduino IDE with the SeeedStudio CAN-BUS Library.
Relay Shield, can be a single channel, but I used an 8 channel relay board.
The Arduino Code (At the end of this instructable)

Step 1: Another Example of its use.


See the picture.
Some vehicles knows how much power the factory bulbs in the Blinkers,Brakes and headlights are supposed to consume, anything under and over it will shutdown the
circuit.
So If you wanted to add a trailer , you also need to by the wiring harness which basically does exactly this, and they are very pricey!

http://www.instructables.com/id/Arduino-ControlIntegrate-Aftermarket-Accessories-v/

Step 2: See this instructable in action


Ive created an example prototype on youtube of this.
It monitors the CAN-BUS for the message that turns on the lights, and then DigitalWrite to the pin of your choice.
The Arduino's IO pin is connected to an 8Channel Relay board which can be used to turn on accessories.
In the video i'm controlling the relay by turning on the main beams.
Enjoy! Happy CAN-BUS Hacking!
More Information about this project can be viewed in this forum thread on techtinker.co.za
http://techtinker.co.za/forum/viewtopic.php?f=14&t...
The Arduino Code.
#include
#include "mcp_can.h"
INT32U canId = 0x000;
unsigned char len = 0;
unsigned char buf[8];
char str[20];
String CanMessage="";
int HeadLightsDetected=0;
int RelayCHN01=7;
void setup()
{
//INIT RELAY PIN
pinMode(RelayCHN01, OUTPUT);
//TEST RELAY PIN
TESTRElay();
Serial.begin(115200);
START_INIT:
if(CAN_OK == CAN.begin(CAN_125KBPS))
{
Serial.println("CAN BUS Shield init ok!");
}
else
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
}
void loop()
{
if(CAN_MSGAVAIL == CAN.checkReceive())
{
CAN.readMsgBuf(&en, buf);
CanMessage="";
canId = CAN.getCanId();
//Detect Main Beam HeadLisghts
if (canId==680)
{
//Build Complete Message Without CAN ID From BUS
for(int i = 0; i
void TESTRElay()
{
digitalWrite(RelayCHN01,
delay(200);
digitalWrite(RelayCHN01,
delay(200);
digitalWrite(RelayCHN01,
delay(200);
digitalWrite(RelayCHN01,
delay(200);
digitalWrite(RelayCHN01,
delay(200);
digitalWrite(RelayCHN01,
delay(200);
digitalWrite(RelayCHN01,
delay(200);
digitalWrite(RelayCHN01,
delay(200);

HIGH);
LOW);
HIGH);
LOW);
HIGH);
LOW);
HIGH);
LOW);

http://www.instructables.com/id/Arduino-ControlIntegrate-Aftermarket-Accessories-v/

Related Instructables

How to analysze
a vehicle's CANBUS using an
Arduino
attached to a
CAN-BUS
Shield and free
software. by
mviljoen2

Arduino OBD2
Simulator by
mviljoen2

How to connect
Hack your
Arduino and
vehicle CANRFID by
BUS with
otaviousp
Arduino and
Seeed CAN-BUS
Shield by
mviljoen2

Seeed Pet by
jimbo.we

Car to Arduino
Communication:
CAN Bus
Sniffing and
Broadcasting
with Arduino by
stvmac11

Advertisements

Comments
1 comments

Add Comment

petestrash says:
Very good, thanks for sharing.
I did find a small typo at the beginning "buy a female-to-make connector"

http://www.instructables.com/id/Arduino-ControlIntegrate-Aftermarket-Accessories-v/

Mar 12, 2015. 7:25 PM REPLY

S-ar putea să vă placă și