[SOLVED] Arduino Dock 2: Onion Library still required for Omega2(+) ?
-
Hi,
I am using an Omega2+ with the Arduino Dock 2.
I would like to communicate with the ATmega via I2C.
While reading the docs I stumbled upon this article:
Using I2C in a Sketch
Right now the Onion Library joins the I2C bus with an address of 0x08 and listens for a write of 0xde 0xad (get it? 'dead' ha ha ha) when resetting. If you need a Sketch to use I2C, make sure to build this functionality into your I2C handling to comply with the Arduino Dock flashing procedure.
https://wiki.onion.io/Tutorials/Arduino-Dock/Using-the-Arduino-DockDoes this still apply to the new Omega2 and Arduino Dock 2 ?
I can't find anything related in the Omega2 docs:
https://docs.onion.io/omega2-docs/arduino-dock-2.htmlOnion Arduino Library:
https://github.com/OnionIoT/Onion-Arduino-Library/tree/master/Onion
-
Hi @canochordo,
You don't need to use the Onion Library for the Omega2 and Arduino Dock2.
The most simple way to communicate through I2C:
- On the Omega2 side use the i2cget or i2cset command for I2C port 0 and ATmega address 0x08. For example,
i2cget -y 0 0x08 (reading from ATmega)
i2cset -y 0 0x08 0x01 (sending 0x01 to ATmega)
- On the Atmega side, flash the chip wirelessly using the following guide and use the wire library:
https://docs.onion.io/omega2-docs/flash-arduino-dock-wirelessly.html
-
Another method from the Omega side is to install python and use the I2C python module:
https://wiki.onion.io/Documentation/Libraries/I2C-Python-Module
-
Thanks @Michael-Xie48 for your quick response
I am now able to switch the build-in LED on / off via I2C:
Arduino / ATmega
#include <Wire.h>
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);Wire.begin(0x08);
Wire.onReceive(i2c_on_receive_handler);
}void loop() {
}void i2c_on_receive_handler(int bytes_num) {
digitalWrite(LED_BUILTIN, Wire.read());
}Omega2
root@Omega:~# i2cset -y 0 0x08 0x01 # switch on
root@Omega:~# i2cset -y 0 0x08 0x00 # switch off