Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9880 Discussions

Send data to Mac

VMeno
Novice
1,032 Views

Hello. Sorry for the basic question, but what is the easiest way to stream data from the Edison (i.e. real-time sensor values or analogIn values) to a Mac, using Python? EDIT: I would need to be able to access this sent data in either Matlab or Python running on a Mac

I want to perform mathematical operations on sensor data but on my Mac and not on the Edison (for several reasons).

Thanks!

1 Solution
Pedro_M_Intel
Employee
162 Views

Hello menonv,

You may be able to do it by sending serial data throught the Edison's Serial0 port (the one used for the Arduino IDE) which is directly connected to the micro-USB port next to the micro-switch. You can do this by making system calls that send data to ttyGS0. On your computer's side you will have to read this data from the serial port in order to use it as you wish. Here's a quick example on how to send data to Serial0:

from subprocess import call

import time

while True:

call('echo Your_Message > /dev/ttyGS0', shell=True)

time.sleep(0.2)

call('echo Another_Message > /dev/ttyGS0', shell=True)

time.sleep(0.2)

Peter.

View solution in original post

2 Replies
Pedro_M_Intel
Employee
163 Views

Hello menonv,

You may be able to do it by sending serial data throught the Edison's Serial0 port (the one used for the Arduino IDE) which is directly connected to the micro-USB port next to the micro-switch. You can do this by making system calls that send data to ttyGS0. On your computer's side you will have to read this data from the serial port in order to use it as you wish. Here's a quick example on how to send data to Serial0:

from subprocess import call

import time

while True:

call('echo Your_Message > /dev/ttyGS0', shell=True)

time.sleep(0.2)

call('echo Another_Message > /dev/ttyGS0', shell=True)

time.sleep(0.2)

Peter.

idata
Community Manager
162 Views

If you want to avoid cabling, and use the Wifi network, consider MQTT. Just host a mosquitto broker on your MAC, and run a subscriber.

You can publish data from the Edison. Here is an untested snippet... This is basically how it works...

import paho.mqtt.client as mqtt

import time

def on_connect(client, userdata, flags, rc):

print("Connected with result code "+str(rc))

print("Connected to " + BROKER_ADDR) # BROKER is your MAC

def main():

client.connect(BROKER_ADDR)

client.loop_start()

while True:

client.publish("edison/test", "Hello Edison!!")

time.sleep(.5)

Reply