This week I work in a system thay sens a signal (potentiometer), a data signal send through Arduino Mega to Raspberry Pi. In Raspberry Pi, datais storaged in a base date () and will see at time in a window. SENSOR I use a Potentiometer in Analog pin in Arduino Mega. ARDUINO MEGA This is the sensor conections in Arduino mega Arduino Program: const int analogInPin = A0; // Analog input pin that the potentiometer is attached to const int analogOutPin = 9; // Analog output pin that the LED is attached to int sensorValue = 0; // value read from the pot. int outputValue = 0; // value output to the PWM (analog out) void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // map it to the range of the analog out: outputValue = map(sensorValue, 0, 1023, 0, 255); // change the analog out value: analogWrite(analogOutPin, outputValue); // print the results to the serial monitor: Serial.print("{\"sensor\":"); Serial.print(sensorValue); Serial.println("}\n"); // wait 2 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(3000); } RASPBERRY PI V3 See about Raspberry Pi v3 here To install Software you need: 1. Download .img Raspbian from its Web page 2. SD card 16GB or higer 3. Win32DiskImager program for burn .img image to SD card Conect to Screeen by ethernet I followed tutorial from here 1. Share internet in Local Area Adapter WiFi. In Local Area Adapter appear automatic Ip number 2. Conect your Raspberry and find it with IpScan Software Download 3. Open IpScan and find Raspberry 4. Take the SD card from Raspberry and insert in PC SD card. Open Terminal and write: echo>E:\ssh. E:\ is disk mount letter in your PC 5. Install MobaXterm software Download 6. Put Raspberry name in SSH and click OK 7. Login as user: pi; password: raspberry 8. Write startlxde to enter in desktop 9. For to VNC access follow this Tutorial 9.1. In terminal: sudo apt-get install tightvncserver vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565 1 (is desktop number) geometry (width screen recomended use from your PC) 9.2. You can install chrome aplication for VNC conections 9.2.1 When you connected, use IP number + :1 (desktop number) like this: 192.168.137.237:1 Start Raspberry Pi and follow this steps in lxterminal 1. sudo addgroup www-data 2. sudo usermod -a -G www-data www-data 3. sudo apt-get update 4. sudo apt-get install apache2 php5 libapache2-mod-php5 5. sudo /etc/init.d/apache2 restart 6. sudo ifup lo 7. sudo apt-get install mysql-server mysql-client php5-mysql phpmyadmin 8. sudo nano /etc/php5/apache2/php.ini 9. extension=mysql.so //Before “Dynamics Extensions”: line 10. sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf 11. sudo /etc/init.d/apache2 reload 12. sudo /etc/apache2/apache2.conf 13. Include /etc/phpmyadmin/apache.conf //in the end (ctrl+x, y, enter) 14. sudo /etc/init.d/apache2 (restart) 15. Open a browser and past this text: localhost/phpmyadmin if server is run, web page admin will open in login CREATE BASE DATA When you create base data, is important create a incrementable "id" table for storage incrementate data. 1. Create New Database and name it. 2. Create a tables and name it. Select number of columns 3. Use atributes in Id table an Incrementable in Column "A_I" 4. Use atributes in data table CREATE PYTHON PROGRAM 1. Change user to super user and install pyserial apt-get install pyserial 2. Create in root directory a file.py and edit it with the program a. nano ejex.py b. Past the python program c. execute with: python ejex.py PYTHON PROGRAM #!/usr/bin/env python #!/usr/bin/env python import serial import json import MySQLdb arduino = serial.Serial('/dev/ttyACM0',9600) print arduino.readline() print arduino.readline() while True: character= arduino.readline() MyJson = character db = MySQLdb.connect("localhost","root","root","Data") if character != '\n': try: data=json.loads(character) print data print data['sensor'] curs = db.cursor() curs.execute("INSERT INTO axex(FECHA,EJEX)values(now(),"+str(data['sensor'])+")") db.commit() except ValueError: print "" arduino.close() 3. Rename database and variables 3. Execute python file a. execute with: python ejex.py 3. Open Database and look in table axex results ARDUINO AND PROCESSING You can process data using Arduino and Processing software like this example Arduino Program void setup() { // initialize the serial communication: Serial.begin(9600); } void loop() { // send the value of analog input 0: Serial.println(analogRead(A0)); // wait a bit for the analog-to-digital converter // to stabilize after the last reading: delay(100); } Processing Program import processing.serial.*; Serial myPort; // The serial port int xPos = 1; // horizontal position of the graph float inByte = 0; void setup () { // set the window size: size(400, 300); // List all the available serial ports // if using Processing 2.1 or later, use Serial.printArray() println(Serial.list()); // I know that the first port in the serial list on my mac // is always my Arduino, so I open Serial.list()[0]. // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[0], 9600); // don't generate a serialEvent() unless you get a newline character: myPort.bufferUntil('\n'); // set inital background: background(0); } void draw () { // draw the line: stroke(127, 34, 255); line(xPos, height, xPos, height - inByte); // at the edge of the screen, go back to the beginning: if (xPos >= width) { xPos = 0; background(0); } else { // increment the horizontal position: xPos++; } } void serialEvent (Serial myPort) { // get the ASCII string: String inString = myPort.readStringUntil('\n'); if (inString != null) { // trim off any whitespace: inString = trim(inString); // convert to an int and map to the screen height: inByte = float(inString); println(inByte); inByte = map(inByte, 0, 1023, 0, height); } } VIDEO DOWNLOAD All files Download