element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
Save The Bees Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Save The Bees Design Challenge
  • More
  • Cancel
Save The Bees Design Challenge
Blog ZinnBee Blog#05: I2C Bus Between Arduino Nicla Vision Module and MKR1310
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Save The Bees Design Challenge to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: flyingbean
  • Date Created: 21 Apr 2023 4:51 AM Date Created
  • Views 686 views
  • Likes 5 likes
  • Comments 0 comments
  • save the bees
  • nicla vision
  • mkr1310
Related
Recommended

ZinnBee Blog#05: I2C Bus Between Arduino Nicla Vision Module and MKR1310

flyingbean
flyingbean
21 Apr 2023

After the Spring break activities finished here, I updated my schedule for ZinnBee Lego-lab ML testing report, which will be posted by end of this week. I jumped to communication testing between Arduino Nicla Vision module and MKR 1310 module now.

I connected Arduino Nicla Vision module J5(I2C bus) with MKR 1310 QWIIC JST connector as Fig 1.

image

 Fig 1: MKR 1310 QWIIC JST Connector

The hardware bench testing was set up as Fig 2.

image

Fig 2: I2C Bench Testing Setup Between Nicla Vision Module and MKR1310

The source code of Nicla Vision I2C master was modified from OpenMV example I2C codes as below:

# I2C Control
#
# This example shows how to use the i2c bus on your OpenMV Cam by dumping the
# contents on a standard EEPROM. To run this example either connect the
# Thermopile Shield to your OpenMV Cam or an I2C EEPROM to your OpenMV Cam.

from machine import I2C
i2c = I2C(1,freq=100000)
print(i2c)
#print(i2c.scan())

#address =i2c.scan()[0]
address = 14

print(address)
data = i2c.readfrom(address, 7)
print(data)

i2c.writeto(address,b'000')

I used fixed I2C slave address 14 here in order to simply my I2C bus decode work on the oscilloscope.

The I2C slave source code used Arduino Wire library with very generic

/*
  MKR1310 I2C Slave Demo
  i2c-slave-test.ino 
*/
 
// Include Arduino Wire library for I2C
#include <Wire.h>
 
// Define Slave I2C Address
#define SLAVE_ADDR 14
 
// Define Slave answer size
#define ANSWERSIZE 7
 
// Define string with response to Master
String answer = "MKR1310";
 
void setup() {
 
  // Initialize I2C communications as Slave
  Wire.begin(SLAVE_ADDR);
  
  // Function to run when data requested from master
  Wire.onRequest(requestEvent); 
  
  // Function to run when data received from master
  Wire.onReceive(receiveEvent);
  
  // Setup Serial Monitor 
  Serial.begin(9600);
  Serial.println("I2C Slave from MKR1310");
}
 
void receiveEvent(int data) {
 
  // Read while data received
  Serial.println("Receive data: ");
  while (0 < Wire.available()) {
    data  = Wire.read();
  Serial.print(data);
  }
  Serial.println("\n");
   
 
}
 
void requestEvent() {
 
  // Setup byte variable in the correct size
  byte response[ANSWERSIZE];
  
  // Format answer as array
  for (byte i=0;i<ANSWERSIZE;i++) {
    response[i] = (byte)answer.charAt(i);
  }
  
  // Send response back to Master
  Wire.write(response,sizeof(response));
  
  // Print to Serial Monitor
  Serial.println("Request event");
  Serial.println("\n");
}
 
void loop() {
 
  // Time delay in loop
  delay(500);
}
 bus control commands.

The bench testing results are presented as below.

1.  Nicla Vision I2C bus got proper response from I2C slave as Fig 3: printing out messages received from I2C slave: 'MKR1310' by using I2C slave address 14.

image

Fig 3: Nicla Vision Working as I2C Master

2. MKR 1310 received message from I2C master as Fig 4: data package was 484848(in Decimal), which is ASCII code for b'000.

image

Fig 4: MKR1310 as I2C Slave Received Data from I2C Master

Here is the waveform of I2C bus from the oscilloscope.

image

Fig 5: I2C Bus Waveform at 100KHz Speed

From this bench testing, I found my Rigol MSO5074 might not decode I2C bus address at a proper way. The address decoded from my Rigol MSO5074 was 1C, which was not 14 as I defined. Nicla Vision module can use I2C slave address 14 without any issues. I will make time to figure out why my Rigol MSO5074 can not decode I2C bus 100%. However, my Rigol MSO5074 was still capable to decode data package in ASCII code properly, which was a plus.

ZinnBee Blogs as below:

ZinnBee Blog#01: Introduction of the Project

ZinnBee Blog#02: Initial Project Structure

ZinnBee Blog#03: LoRa WAN Communication Framework

ZinnBee Blog#04: First Impression of Arduino Nicla Vision Machine Learning Process

  • Sign in to reply
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