**EDIT: I am receiving the following error message:* "Error retrieving accessibility bus address: or.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files"
I wrote code for the PC platform using Python and it works just fine. I was looking to have this program run on a rasberry pi connected to a monitor.
I installed Raspbian and all of the libraries for the above needed functions.
The code is as follows:
############################################################
# Visualizing data from the Arduino serial monotor #
# and creating a graph in a nice format. Later work will #
# look into outputting this to a Android device #
############################################################
############################################################
############################################################
############################################################
#Becuase we can always use more time
import time
#Inport the fancy plotting library
import matplotlib.pyplot as plt
#Inport the serial library
import serial
#We want to do array math so we need Numpy
import numpy
#We also want to draw things so we need drawnow and
#everything that comes with it
from drawnow import *
############################################################
############################################################
#Creating an array to hold data for plotting. See several
#lines below for more information
tempArray = []
pressureArray = []
altitudeArray = []
#The object that is created to interact with the Serial Port
arduinoSerialInput = serial.Serial('/dev/ttyACM0', 230400)
time.sleep(3)
#Here we set the definition oto look for interactive mode
#and plot live data
plt.ion()
############################################################
############################################################
clippingCounter = 0
#Here we define a function to make a plot, or figure of
#the data aquired
def plotTempData():
plt.ylim(150,320)
plt.title('Plots from data of the BMP Sensor')
plt.grid(True)
plt.ylabel('Tempature')
plt.subplot(2, 2, 1)
plt.plot(tempArray, 'ro-', label='Degrees K', linewidth=2)
plt.legend(loc='upper left')
#plt2 = plt.twinx()
#plt2.plot(pressureArray, 'bx-')
def plotPresData():
#plt.ylim(260,320)
plt.title('Plots from data of the BMP Sensor')
plt.grid(True)
plt.ylabel('Pressure')
plt.subplot(2, 2, 2)
plt.plot(pressureArray, 'bo-', label='Pascals', linewidth=2)
plt.legend(loc='upper left')
plt.plot(pressureArray, 'bo-')
plt.show()
############################################################
############################################################
while (1==1):
#First things first, lets wait for data prior to reading
if (arduinoSerialInput.inWaiting()>0):
myArduinoData = arduinoSerialInput.readline()
# print myArduinoData -Line commented out, see below
#The arduino should be set up to proovide one string of data
#from here we will seperate that one string into two or more
#to make it easier to plot
#This will create an array seperated by the comma
#we specified in the Arduino IDE aasign it to a
#variable of our choice and convert the string
#back into a number using the float command
dataArray = myArduinoData.split(',')
temp = float(dataArray[0])
pressure = float(dataArray[1])
#Used to test the printing of values to output
#print temp, " , ", pressure, " , ", altitude
#We need to create an array to to hold the values in question
#Looking at the top, you will see the empty array we need to
#create that will hold the values we need to plot
tempArray.append(temp)
pressureArray.append(pressure)
plt.figure(1)
drawnow(plotTempData)
plt.pause(.000001)
#plt.figure(2)
drawnow(plotPresData)
plt.pause(.000001)
#We want to clip some data off since the graph keeps
#expanding and too many points are building up.
clippingCounter = clippingCounter + 1
if(clippingCounter>50):
tempArray.pop(0)
pressureArray.pop(0)
############################################################
############################################################