How to access Arduino Dock A0 from terminal
-
Hi!
I would like to run a simple script in the Onion terminal in order to read Analog value on A0, is this possible?
Thank you
Kind Regards
-
I would be interested as well, even better, use it with python
-
I've got that to work. Here's the story:
The only communication between the Omega and the Arduino is on I2C. And as it stands that was set up to cause a reset on a particular write to do the flash procedure and also to control a neopixel string. Unfortunately that precludes using that channel for anything else, which is a real pain.
You can connect the Arduino serial RX/TX to the Omega RX/TX but that would take over the Omega console, so its not ideal.So what I did was to strip out the Neopixel code from the Omega Library and replace it with a modified library that allows a user program to register handlers for i2c receive and request. It preserves the 0xdead to 0x08 processing that is needed to automatically flash a new project but allows a number of user routines to be added. This makes the Arduino look like an I2C slave device with a set of registers that can be read or written from the Onion side. I also create an ONION pseudo device to simplify the setup.
Here's my current test application - it controls a single neopixel (on address 1) and also reads from A0 on request from address 2.
Note - this is just an experiment at this point. If there is interest I'll post my library code.#include <Wire.h>
#include <Onion2.h>
#include <Adafruit_NeoPixel.h>#define LED 13
#define LED2 A1
#define NEO 8Adafruit_NeoPixel rgb(1, NEO);
void recvEvent() {
byte data;
byte r=0, g=0, b=0;
if (Wire.available()) r = Wire.read();
if (Wire.available()) g = Wire.read();
if (Wire.available()) b = Wire.read();
rgb.setPixelColor(0, r, g, b);
rgb.show();
}byte reqEvent() {
return analogRead(A0);
}void setup() {
pinMode(LED, OUTPUT);
// pinMode(LED2, OUTPUT);
Serial.begin(115200);
rgb.begin();
rgb.clear();
rgb.show();ONION.registerRcvHandler(1, &recvEvent);
ONION.registerReqHandler(2, &reqEvent);// digitalWrite(LED2, LOW);
}void loop() {
Serial.println("Hello2");
digitalWrite(LED, 1);
delay(1000);
digitalWrite(LED, 0);
delay(1000);}
-
@Maurice-Marks Cool Would be useful if this could eventually be generalised to some sort of bridge code between the Omega and the Arduino dock.
I would be most interested in seeing your code when it is done and ready
-
Just a heads-up, we're hard at work on bridging the ATmega on the Arduino Dock and the Omega.
Expect something in the coming months.
-
I don't want to preempt any official Onion work. You folks have done a great job with the hardware and software. But if anyone is interested in my experimental library I've put it up on Github:
https://github.com/mpmarks/Onion2
-
@Lazar-Demin Hey. Is there any update on bridging the arduino and the omega? I need to read from a analogue pin, (which is why I'm using the dock), but it seems that getting the omega to be able to access the data is going to be a massive pain? Or am I missing something?
-
@Craig-OShannessy Unfortunately there is currently no code to do what you want.
It requires two code components that are not currently available:- Omega code to use I2C to access the Arduino to control the Arduino pins in a general manner
- Arduino library that responds to appropriate Omega I2C communications and performs the required pin actions (returning any appropriate information)
I am currently working on some general code to do this and will publish it when it is available. This code will provide access by the Omega to ALL standard Arduino pin operations including control of the analog pins
Currently the only available code for Omega<-->Arduino communications is for control of Arduino NeoPixels from the Omega
-
@Craig-OShannessy Take a look in case you missed the post that I did on this library.
-
@Will-Kostelecky said in How to access Arduino Dock A0 from terminal:
@Craig-OShannessy Take a look in case you missed the post that I did on this library.
How was this missed it should have been posted somewhere predominantly reviewed @Will-Kostelecky he put some work into this and it deserves to be seen. Maybe along with a video section with links to great videos a related page for this kind of post created by @Will-Kostelecky .
He has a video as well.... https://youtu.be/XNXW-DNVqi0
-
@Guest I did only just post it recently but thanks for the shout-out!