S. ChasinsEmily ToNoura HowellJon LaiAdam Hutz
Published

Jack

A waveboard with a personality. Keep him entertained!

Full instructions provided3,753
Jack

Things used in this project

Hardware components

Waveboard
×1
3D Plastic Filament (ABS)
Used in Afinia H-Series 3D Printer
×1
Machine screw, 1/4 inch, gauge 6
×1
Nut, gauge 6
×1
Arduino Yun
Arduino Yun
×1
Adafruit 3-Axis 3G Acceleremoter
×1
Adafruit GPS Breakout Chip
×1

Story

Read more

Custom parts and enclosures

Chassis.stl

Code

Main Arduino Code

C/C++
The sketch for the Arduino Yun. We first gather accelerometer and GPS data, then POST it to our server through a Python script, accessible via Bridge.
#include <Bridge.h>
#include <Process.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#define GPSECHO false

Adafruit_GPS GPS(&Serial1);
HardwareSerial mySerial = Serial1;
uint32_t timer = millis();
const int sampleSize = 10;
const int xInput = A0;
const int yInput = A1;
const int zInput = A2;

// Raw Ranges:
int xRawMin = 378;
int xRawMax = 633;

int yRawMin = 377;
int yRawMax = 640;

int zRawMin = 380;
int zRawMax = 630;

void setup() {
  analogReference(EXTERNAL);
  Serial.begin(115200);
  delay(5000);
  Serial.println("Adafruit GPS library basic test!");
  GPS.begin(9600);
  
  //turn on RMC and GGA (fix data) including altitude
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  
  // Set the update rate
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
  GPS.sendCommand(PGCMD_ANTENNA);

  delay(1000);
  mySerial.println(PMTK_Q_RELEASE);
}

void loop() {
  char c = GPS.read();
  if (GPS.newNMEAreceived()) {
    if (!GPS.parse(GPS.lastNMEA())) { return; }
  }

  if (timer > millis()) { timer = millis(); }
  if (millis() - timer > 2000) {
    //reset the timer
    timer = millis();
    
    int xRaw = ReadAxis(xInput);
    int yRaw = ReadAxis(yInput);
    int zRaw = ReadAxis(zInput);
    long xScaled = map(xRaw, xRawMin, xRawMax, -1000, 1000);
    long yScaled = map(yRaw, yRawMin, yRawMax, -1000, 1000);
    long zScaled = map(zRaw, zRawMin, zRawMax, -1000, 1000);
    float xAccel = xScaled / 1000.0;
    float yAccel = yScaled / 1000.0;
    float zAccel = zScaled / 1000.0;

    Serial.print("\nTime: ");
    Serial.print(GPS.hour, DEC); Serial.print(':');
    Serial.println(GPS.minute, DEC);
    Serial.print("Fix: "); Serial.print((int)GPS.fix);
    Serial.print(" quality: "); Serial.println((int)GPS.fixquality); 
    if (GPS.fix) {
      Serial.print("Location: ");
      Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
      Serial.print(", "); 
      Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
      Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
      
      String gps = String(GPS.latitude) + String(GPS.lat) + ", " + String(GPS.longitude) + String(GPS.lon);
      post(gps, String(xAccel), String(yAccel), String(zAccel));
    }
    
  }
}

int ReadAxis(int axisPin) {
  long reading = 0;
  analogRead(axisPin);
  delay(1);
  for (int i = 0; i < sampleSize; i++)
  {
    reading += analogRead(axisPin);
  }
  return reading/sampleSize;
}

void post(String gps, String x, String y, String z) {
  Process p;
  p.begin("/mnt/sda1/tts.py");
  p.addParameter(gps);
  p.addParameter(x);
  p.addParameter(y);
  p.addParameter(z);
  p.run();
}

POST Python Script

Python
The Python script we run via Arduino's Bridge to POST data to our server
#! /usr/local/bin/python

import pycurl
import os, sys
from urllib import urlencode

c = pycurl.Curl()
c.setopt(c.URL, 'http://localhost:8000/data') #TODO: choose server location

post_data = {'gps': sys.argv[1], 'x': sys.argv[2], 'y': sys.argv[3], 'z': sys.argv[4] }
postfields = urlencode(post_data)
c.setopt(c.POSTFIELDS, postfields)

c.perform()
c.close()

Github

All the code is available in our github repository. Jack's hardware uses an arduino script to record accelerometer and GPS data and a Python script to POST that data to a node server.  The node server uses websockets to push the data to the web application.  The web application uses the Google Maps API to display GPS readings.  A custom HTML5 Canvas visualization reflects current accelerometer data.  The accelerometer readings are also audialized using the Web Audio API.

Credits

S. Chasins

S. Chasins

3 projects • 0 followers
Emily To

Emily To

12 projects • 3 followers
I am Emily
Noura Howell

Noura Howell

5 projects • 5 followers
Jon Lai

Jon Lai

5 projects • 2 followers
Adam Hutz

Adam Hutz

3 projects • 7 followers

Comments