Sending integers/Strings/Char Arrays from Esplora to Arduino Uno by USB

I would like to send some integers from an Esplora to my Arduino Uno (and back) by USB. I have an USB host shield R3 and thought it wouldn't be a problem. But I can't get it to work and can't find way's to do this on this forum or on Google.

When I tried to sent integers over a serial connection I found that it had to be a String in a Char* and that was no problem. I can also get them back to integers but I don't know how to get a serial connection between the Esplora and Arduino Uno.

I read something about an ISP connection between the Arduino and the USB shield. I also tried something with it but coudn't tell it that worked. (it didn't give me an output to the Esplora)

I noticed I didn't really ask a question, so my question would be:

Is it possible to get a serial connection between the Uno and Esplora? If possible: How do I do it? And if not: Is there another way to do it?

I'm not familiar with the Esplora but it seems to be similar to a Leonardo (which I do have).

If the Esplora has a Serial1 connection that can be used for communication with an Uno. But you will probably need to use SoftwareSerial on the Uno to create an extra serial port if you want to use the Uno's USB connection for communication with your PC and for programming the Uno.

SPI would be another option.

...R

Robin2, thank you for the answer.

Sounds right, I´ve tried but couldn´t get it to work.

I need to know a RX and TX pin but can´t find those. I´ve tried a couple pins but nothing seems to work.

I used the SoftwareSerialExample on the uno and a bit of code to take the serial input on the Esplora and display it on the screen:

Uno:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(11, 12); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  Serial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Eplora:

#include <TFT.h>

#include <Esplora.h>

String A = " ";
char* a = " ";

void setup() {
  Serial.begin(9600);
  EsploraTFT.begin();
  EsploraTFT.background(255,255,255);
  EsploraTFT.setTextSize(3);
}

void loop() {
  A = Serial.read();
  A.toCharArray(a,5);   //I know this doesn't work perfectly, but I get something on the screen
  EsploraTFT.stroke(0,0,0);
  EsploraTFT.text(a,0,0);
  delay(1000);
  EsploraTFT.stroke(255,255,255);
  EsploraTFT.text(a,0,0);
  A = " ";
  a = " ";
}

I've tried different sets of numbers for the RX and TX(10,11;11,12;12,13;) and 0,1 but those were used by the serial connection to the pc so that interfered but also didn't give an output to the Esplora.

Are there pins I can use? And if not, is there a way to tell the USB shield it has to send the information from a serial connection over two pins to the USB? Or to tell it to send the information given to it through the ICSP to the USB?

...R

As I said, I don't have an Esplora. Somebody else may be able to help.

Have you tried SPI ?

And, if you are content with 9600 baud or thereabouts you could try SoftwareSerial.

...R

Yes, I 've tried SPI but couldn't get it to work. I don't know what I did wrong but it didn't seem to work. (I don't know how it works but tried with some help from Google).

Thanks for your help and I hope someone else can help me further.

...RP

Post the code you tried with SPI and a diagram of how you connected everything.

...R

I've only tried to get an SPI connection between the Uno and USB shield. I hoped it would send something by USB but it didn't seem to work.

I deleted the code when I tried the serial connection again.

Since I will need a long cable from the Esplora to the Uno (between 18 and 20 meters), I thought it would be better to get a USB connection than loose cables. But I could always connect the cables to some other cable with multiple threads.

Anyway, I hope I can find a good way to connect them and send a good signal between them.

RP

(When I searched the internet at first, I thought a lot of people would have tried it but I can't find anyone who did.)

I don't think USB would work over that distance - 5 or 6 metres maybe.

RS485 is often used for longer connections - but that needs serial connections on the Arduinos.

...R