(Edison) 2x Arduino Serial Communication

I’m trying to communicate between two arduinos, Mega 2560 to Edison Kit for Arduino. I’m reading rfid tags on Mega and then transmitting them to Edison. I can’t read any data from Serial at Edison. I’ve wired Mega TX with Edison RX, Mega RX with Edison TX. Also grounds are wired together.

Mega code:

#include <SPI.h>
#include <MFRC522.h>

constexpr uint8_t RST_PIN = 5;     // Configurable, see typical pin layout above
constexpr uint8_t SS_PIN = 53;     // Configurable, see typical pin layout above
 
MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class

MFRC522::MIFARE_Key key; 

// Init array that will store new NUID 
byte nuidPICC[4];

void setup() { 
  Serial.begin(9600);
  Serial1.begin(9600);
  SPI.begin(); // Init SPI bus
  rfid.PCD_Init(); // Init MFRC522 
  pinMode(19, INPUT);
  pinMode(18, OUTPUT);

  for (byte i = 0; i < 6; i++) {
    key.keyByte[i] = 0xFF;
  }
}
 
void loop() {

  // Look for new cards
  if ( ! rfid.PICC_IsNewCardPresent())
    return;

  // Verify if the NUID has been readed
  if ( ! rfid.PICC_ReadCardSerial())
    return;

   if (rfid.uid.uidByte[0] != nuidPICC[0] || 
    rfid.uid.uidByte[1] != nuidPICC[1] || 
    rfid.uid.uidByte[2] != nuidPICC[2] || 
    rfid.uid.uidByte[3] != nuidPICC[3] ) {

    // Store NUID into nuidPICC array
    for (byte i = 0; i < 4; i++) {
      nuidPICC[i] = rfid.uid.uidByte[i];
    }
   
    printHex(rfid.uid.uidByte, 1);
      }
  else return;

  // Halt PICC
  rfid.PICC_HaltA();

  // Stop encryption on PCD
  rfid.PCD_StopCrypto1();
}


/**
 * Helper routine to dump a byte array as hex values to Serial. 
 */
void printHex(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i]);
    Serial.write(buffer[i]);
  }
}

Edison code:

#define przekaznik 9
#define darlington 10
#define czujka 11
#define poten 14
#define fotoRes 15
#define therm 16
#define rx 0
#define tx 1

#include <Wire.h>
#include <rgb_lcd.h> 
rgb_lcd lcd;

//MW 
bool menustart=true; 
//MW

//MS
float Rsensor;            

double temps() {
 double Temp;
 int RawADC = analogRead(therm);
 Temp = log(10000.0*((1024.0/RawADC-1)));
//         =log(10000.0/(1024.0/RawADC-1)) // for pull-up configuration
 Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
 Temp = Temp - 273.15;            // Convert Kelvin to Celcius
 return Temp;
}
float lux() {
  int sensorValue = analogRead(fotoRes); 
  Rsensor=(float)(1023-sensorValue)*10/sensorValue;
  int lx = map(Rsensor, 0, 1023, 50, 1000);
  return lx;
}
//MS

//MW
void Menu() {
     int pot = analogRead(poten);
     pot = map(pot, 0, 1023, 0, 4);  
        switch(pot)
        {
        case 0:
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Temperatura: ");
        lcd.print(temps());
        lcd.setCursor(0, 1);
        lcd.print("Jasnosc: ");
        lcd.print(lux());
        break;
        case 1:
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Grubas: ");
        lcd.setCursor(0, 1);
        lcd.print("Start ");
        break;  
        case 2:
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print(":::>");
        lcd.setCursor(0, 1);
        lcd.print("Herezja");
        break; 
        case 3:
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Maslo do ciecia");
        lcd.setCursor(0, 1);
        lcd.print("Pierogi z miesem");
        break; 
        }
    delay(1);
}


//MW

int x = 0;

void setup() {
   pinMode(czujka, INPUT);
   Serial.begin(9600);
   pinMode(14, INPUT);
   pinMode(15, INPUT);
   pinMode(16, INPUT);
   pinMode(tx, OUTPUT);
   pinMode(rx, INPUT);
   
   lcd.begin(16, 2); 
   lcd.setRGB(60, 60, 200);                   
   lcd.setCursor(0, 0);                
   lcd.print("ok.");
   delay(500);  
}

void loop() {
  Menu();
  delay(500);
  if (Serial.available() > 0)
  {
    x = Serial.read();
    Serial.print("Odebrano: ");
    Serial.println(x);
  }
}

Any help?

You have not told us how you have the two boards connected.

I'm guessing that you want to use Serial1 on the Mega to send data to the Edison. But you have no code in the Mega that uses Serial1 to send anything.

I am not familiar with the Edison so I won't comment specifically about it.

When I send serial data between two Arduinos I use the 3rd example in Serial Input Basics

Make sure you have a GND connection between the two boards.

...R

Mitnick:
I've wired Mega TX with Edison RX, Mega RX with Edison TX. Also grounds are wired together.

Serial1 is leftover from attempt to use it, no effect.

I'll try your third example later.

Anyway, even with this code, as I think, I should receive something, right?

Mitnick:
Anyway, even with this code, as I think, I should receive something, right?

As you have not told me how you have connected the two boards how can I tell?

And neither have told me anything about the capabilities of the Edison

...R

I don't quite understand what do you mean by "how do I have connected the two boards". Could you explain?

Edison kit for Arduino is just an Uno with Intel Quark 100MHz microcontroller (i686 architecture). Pin layout is the same but different architecture prohibits use of non-i686 libraries, such as SoftwareSerial. Basic libraries work and Intel provides some libraries for Edison like: Wire, TimerOne, OneWire, EEPROM and a few more. Usage is the same as for standard Arduino libraries.

I think what he's looking for is what serial you have hooked up between the boards and do you have a ground connection between the two

Mitnick:
I don't quite understand what do you mean by "how do I have connected the two boards". Could you explain?

Very simple. What pins on the Mega are connected to what pins on the Edison. And also provide a link to the pinout diagram for the Edison as I am not familiar with it.

...R

Oh. Sorry for that.

Connection:

|TX0->RX0|
Mega|RX0->TX0|Edison
|GND–GND|

There is the Hardware Guide that Intel provides.

Could this be a 3.3V Vs 5V problem?

It would make a lot more sense to use the Tx1 and Rx1 (pins 18 and 19) and Serial1 on the Mega as that will leave Serial free for uploading programs and debug messages to the Serial Monitor.

I am completely unfamiliar with the Edison and the document you linked to confuses me. I thought an Edison was a standalone device that was somewhat compatible with an Uno. But the document refers to "Intel® Edison Kit for Arduino" as though it is something you attach to an Arduino. Is that what you are doing?

Can you post a photo of the Edison thing that you have?

None of which is intended to distract from @PaulRB's very sensible question.

...R

It is compatible with an Uno. I'm using Edison kit for Arduino. It's microcomputer Intel Edison mounted on Edison Kit for Arduino. Edison alone has 2 core processor @ 500MHz (linux part) and an microcontroller 100MHz (i686 architecture, arduino part), which is used instead of Atmega 328p. Pinout for board is almost the same as for Uno. One difference is that you can choose 4 pins with PWM active by jumper on board (pins 3,5,6,9,10,11).
You can write program for it on standard Arduino IDE but also on Linux using MRAA library and utilize on-board pins by calling GPIO's.

I'm using Intel Edison Kit for Arduino, not Intel Edison and Arduino Breakout Board.

I can choose operating voltage for pins 0-13 by changing jumper position but I checked it and surely it's on 5V position.

Edit:
Could this be different clock speeds? Uno has 16MHz clock, Edison 100MHz. If so, how I can sync those clocks? If you don't know how to do it for Edison, post how to do it on normal Uno or Mega2560, I'll try to figure out the rest.

Link to Arduino site with Edison

The micro clocks won't be a factor, but the Serial port baud rate must be set to the same value.

When you have trouble getting 2 devices to talk together using a UART serial link, set both devices to 9600 baud. Also make sure the other settings are the same, typically 8N1 (8 bits, no parity bit, 1 stop bit) Once it is working then you can try faster baud rates. Sometimes there are limitations on how fast a device can operate and bit timing issues can occur, thought a modern UART will correct for bit timing.

Can you send and receive messages to the Arduino using a serial monitor? can you do the same with the Edison? If both can communicate with the a serial monitor using the same baud rate and settings then they can talk to each other assuming the connections and voltages are correct.

Load the second example from Serial Input Basics onto the Edison and see can you send data to it from the Arduino Serial Monitor.

If that works then it should be possible to send data from the Mega.

If it does not work then you will have to wait for an expert on the Edison to come along. Your Thread title does not mention an Edison so how will the experts know? You can change the title if you edit your Original Post.

...R