Community
cancel
Showing results for 
Search instead for 
Did you mean: 
EEste1
Novice
1,155 Views

Communication between Arduino and Nodejs programs in Intel Galileo Gen 1

Hi, I am trying to make two programs that communicate with each other in Intel Galileo Gen1. The first program I am programming in Node.js, while the other program with the Ide Arduino. But I can not get them to communicate with each other, I want them to function as a client-server. So I wanted to consult, how I can do a program with the Ide Arduino that transfers data to another in Node.js, both running in Galileo?

From already thank you very much

Tags (1)
0 Kudos
3 Replies
idata
Community Manager
88 Views

Hello Esteban,

 

 

I would recommend you to read this article https://software.intel.com/en-us/blogs/2015/05/05/efficient-data-sharing-using-interrupts-on-intel-e.... Even though it was written for the Edison, the basic principles and the programming can be applied to your Galileo.

 

 

Also, you can check this site http://node-ardx.org/, which provides several examples related to the node.js – Arduino IDE communication within an Arduino based board.

 

 

Regards,

 

Andres

 

EEste1
Novice
88 Views

Thank you very much Andres for the answer. But finally the communication between Ide Arduino and Node.js has been able to do so via UDP socket. For that reason I leave the code that I used to carry out the communication between the two programs, in case anyone it serves.

  • Arduino Code

# include

# include

# include

byte arduinoMac[] = { 0x40, 0x25, 0xC2, 0x11, 0x30, 0x78 };

IPAddress arduinoIP(127, 0, 0, 1); // desired IP for Arduino

unsigned int arduinoPort = 8888; // port of Arduino

IPAddress receiverIP(127, 0, 0, 1); // IP of udp packets receiver

unsigned int receiverPort = 6000; // port to listen on my PC

EthernetUDP Udp;

void setup()

{

Ethernet.begin(arduinoMac,arduinoIP);

Udp.begin(arduinoPort);

}

void loop()

{

Udp.beginPacket(receiverIP, receiverPort); //start udp packet

Udp.write("Funciona!!"); //write sensor data to udp packet

Udp.endPacket(); // end packet

delay(1000);

}

  • Node.js Code

var dgram = require("dgram");

var server = dgram.createSocket("udp4");

server.on("message", function (msg, rinfo)

{ //every time new data arrives do this:

console.log("Se recibe de la IP: "+ rinfo.address + ":" + rinfo.port); // you can comment this line out

console.log("llego msj:"+msg);

});

server.on("listening", function ()

{

var address = server.address();

console.log("server listening " + address.address + ":" + address.port);

});

server.bind(6000); //listen to udp traffic on port 6000

Thank you very much for everything

Andres_V_Intel
Employee
88 Views

Hello Esteban,

I'm glad you found a way to perform the communication between your programs, and thank you for sharing that information with the community.

Regards,

Andres

Reply