LinkitONE DIY Oscilloscope

by ssarthak598 in Circuits > Arduino

4380 Views, 16 Favorites, 0 Comments

LinkitONE DIY Oscilloscope

IMG_0881.JPG
ur270.gif

Ever wanted to own a oscilloscope? Well it starts from $300 which can't be afforded by all! So I came up with a new solution for this!

Imagine, if you could use your PC screen as display, and your LinkitONE as data receiver!!!

YES, you can do it, and that too under $100!

Let's get started!

What Do You Need?

IMG_0880.JPG

1) LinkitONE Board

2) micro-USB cable (to program board)

3) Many sensors to test!!!

(I'm using sound sensor, PIR motion sensor, air quality sensor, DHT temprature sensor, dust sensor etc.)

Hook Up Your Sensor(s)

IMG_0854.JPG
IMG_0855.JPG
IMG_0868.JPG
IMG_0869.JPG

Here you should chose any kind of sensor that can give you an analog reading. You can use any of the analog sensors available in the world!!!

Sound sensor, light sensor, soil moisture sensor, touch sensor!! even more! Any!

Writing Some Code

arduino sketch.PNG

The code is really simple here! There's nothing much!

We're just taking a analog reading from sensor and then sending it to the computer. Then a program in the computer will convert the data to a real time graph.

CODE:

------------

#define ANALOG_IN 1
void setup()

{

Serial.begin(9600); //Serial.begin(115200);

}

void loop() {

int val = analogRead(ANALOG_IN);

Serial.write( 0xff );

Serial.write( (val >> 8) & 0xff );

Serial.write( val & 0xff );

}

------------

Okay, so now burn this code to your board. In the next step we'll write another code for the computer to visualize the readings.

Developing the Graph Interface

processing sketch.PNG

We'll be making the GUI part with processing software. First of all download processing from www.processing.org and install latest version.

The code is really simple, we're just taking readings from the serial and then plotting a graph. Please download the code attached in this step.

CODE:

---------

import processing.serial.*;

Serial port; // Create object from Serial class int val; // Data received from the serial port int[] values; float zoom;

void setup() { size(1280, 480); // Open the port that the board is connected to and use the same speed (9600 bps) port = new Serial(this, Serial.list()[0], 9600); values = new int[width]; zoom = 1.0f; smooth(); }

int getY(int val) { return (int)(height - val / 1023.0f * (height - 1)); }

int getValue() { int value = -1; while (port.available() >= 3) { if (port.read() == 0xff) { value = (port.read() << 8) | (port.read()); } } return value; }

void pushValue(int value) { for (int i=0; i

void drawLines() { stroke(255); int displayWidth = (int) (width / zoom); int k = values.length - displayWidth; int x0 = 0; int y0 = getY(values[k]); for (int i=1; i

void drawGrid() { stroke(255, 0, 0); line(0, height/2, width, height/2); }

void keyReleased() { switch (key) { case '+': zoom *= 2.0f; println(zoom); if ( (int) (width / zoom) <= 1 ) zoom /= 2.0f; break; case '-': zoom /= 2.0f; if (zoom < 1.0f) zoom *= 2.0f; break; } }

void draw() { background(0); drawGrid(); val = getValue(); if (val != -1) { pushValue(val); } drawLines(); }

--------

Once you've done this move to next step and start testing your oscilloscope!

Testing It Out!

processing run.PNG

Now test it out!

Plug in your Linkit board and then run the program you made in processing by clicking the play button!

You'll be seeing the readings update in real time! You can try it with different sensors! Cool? try some more :D

Testing Sound Sensor

Capture.PNG
IMG_0876.JPG
IMG_0861.JPG

This is the sound sensor!

You can see the readings analysed while taking breath.

Testing Air Quality Sensor

Capture.PNG
IMG_0879.JPG
IMG_0838.JPG

You can also test air quality! The program plotted a graph about air quality in my room that changed in 30 seconds.

Testing PIR Motion Sensor

Capture.PNG
IMG_0877.JPG
IMG_0856.JPG

Wala! Motion sensor! You get digital readings in this! You'll have lot of fun testing it!

Final Touches!

IMG_2568s.jpg
IMG_0881.JPG

Cool! You can also make a simple frame box that is portable so you can carry it anywhere!