element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog Blog entry #2: Setting up the I2C
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: sjsfastcar2017
  • Date Created: 18 Apr 2017 3:53 PM Date Created
  • Views 544 views
  • Likes 3 likes
  • Comments 1 comment
  • tockman
  • upcycled_tockman
Related
Recommended

Blog entry #2: Setting up the I2C

sjsfastcar2017
sjsfastcar2017
18 Apr 2017

Now that we have pretty much disassembled the clock, we’re working on rewiring it so each system in the clock functions before reassembly. We had a few problems with publishing this blog due to some unexpected delays(and lack of communication due to traveling/sicknesses) but hope to be able to maintain a more consistent pace over the next few weeks.

 

Progress summary:

  • Finished creation of button + potentiometer interface that will be affixed to the top of the clock
  • Got I2C to work with Arduino so we can send and receive messages using a slave
  • Implemented time synchronization and random music shuffling (see code below)


Current Goals:

  • Modify master so it can be an Edison instead of an Arduino
  • Create the foam (or 3-D printed) pieces that will connect the potentiometers to the metal bells
  • Redo audio connections
  • Implement Edison once it is received

 

These potentiometers are affixed to tactile buttons, and will be attached to the top of the clock to serve as interfaces. The button caps are removable and we will swap these caps which are connected to the potentiometers with the ones currently on the clock. As mentioned before, these will play a role in controlling audio functions such as volume. Hopefully, we will be able to connect these to the slave Arduino and use I2C communication with the Edison.

803111464_10186678099586322812.jpg

As seen below we’ve encountered trouble with our current soldering iron We will have to buy a better one(Weller  WLC100WLC100 to complete connections if we plan to use this mic

image

 

The master and slave Arduinos running. Although the circuitry is a bit messy, we basically connected the A4/A5 and ground pins for I2C communication and added a potentiometer and button. Currently, we are not very concerned with space, but pending on future designs may be forced to use an arduino nano.

image

Code:

Slave code:

 

#include<Wire.h>

void setup() {

Wire.begin(8);                // join i2c bus with address #8

  Wire.onReceive(receiveEvent); // register event

  Serial.begin(9600);

  Wire.onRequest(requestEvent);// start serial for output

}

 

void loop() {

  delay(100);

 

}

 

// function that executes whenever data is received from master

// this function is registered as an event, see setup()

void requestEvent(){

Wire.write("hello "); /* I couldn’t get it to give a sensor value might have to do with timing? If I replace it with giving the current value for a potentiometer it does work. Might have something to do with button states */

  }

 

void receiveEvent(int howMany) {

  while (1 < Wire.available()) { // loop through all but the last

    char c = Wire.read(); // receive byte as a character

    Serial.print(c);        

  }

  int x = Wire.read();    // receive byte as an integer; checking to make sure the sent value equals original

  Serial.println(x);        /*May be turned into a stability system, so we say that if two values are more than 5 values apart, we say they aren’t measured(as in the slave sends back the number received and the master sends a new number to check against the first. This is necessary because we noticed the potentiometer values during movement could greatly vary) */

}



Master Code: (Won’t be used as this will be done with an Edison)

 

#include <Wire.h>

 

void setup() {

  Wire.begin();

Serial.begin(9600);

}

 

byte x = 0;

 

void loop() {

 

  Wire.beginTransmission(8); // transmit to device #8

x=analogRead(2);

  Wire.write("x is ");       

  Wire.write(x);          

  Wire.endTransmission();   

Wire.requestFrom(8, 6);    // request 6 bytes from slave device #8

 

  while (Wire.available()) { // slave may send less than requested

    char c = Wire.read();

    Serial.print(c);         // print the character

  }

 

  delay(500);

}

 

Time synchronization / shuffling order of playing music:

 

timedatectl set-ntp 1

 

while :; do find ./songs -print0 | shuf -z | xargs -0 -n1 $MUSIC_PLAYER; done

 

Expected Challenges of Continuation:

Trying to get the errors out of our I2C code will definitely allow us to make the project go more smoothly as most other stuff would be either hardware or simple input/output stuff. Hopefully by next week, we will have the Edison so we can begin figuring that stuff out.

 

Created by:

Roosh Bhosale

Clyde Johnson

Dhilan Lahoti

Andy Tockman

Joshua Tsai

Ishan Kamat

  • Sign in to reply
  • Workshopshed
    Workshopshed over 8 years ago

    There's some notes on I2C on the Edison here:

     

    Exploring Edison - I2C Bus

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube