loading

In this guide I will explain how to use a Windows 8.1 phone, Arduino Uno board, and HC-05 Bluetooth module to build a wireless oscilloscope. The phone application has the critical functions of an oscilloscope, although the bandwidth is a measly 300 Hz. Still, if you want to see squiggly lines on your phone, it is a fun project.

Today's phones have the ability to perform real-time signal processing. The challenge is getting the data into the phone and sourcing a low-cost front end. The Arduino Uno performs the data acquisition and packaging. It sends the data, using rfcomm, over the HC-05 Bluetooth module to the phone. The phone runs an application called "SerialScope" that unpacks the data and plots it.

Step 1: Components and Wiring

Parts

I have tested this guide with the following components:

  • Nokia 1520 phone with Windows Phone 8.1
  • HC-05 Bluetooth module
  • Arduino Uno R3
  • Arduino IDE 1.6.1

Wiring

  • HC-05 GND --- Arduino GND Pin
  • HC-05 VCC (5V) --- Arduino 5V
  • HC-05 TX --- Arduino Pin 10 (soft RX)
  • HC-05 RX --- Arduino Pin11 (soft TX)
  • A0 --- Analog in for channel 1
  • A1 --- Analog in for channel 2

Without any conditioning the input to the 'scope is limited to 0-5V. It also doesn't include any anti-aliasing filters so that can be a problem if you are doing any serious analysis.

Step 2: Program the HC-05

The HC-05 needs to be programmed to transmit at 115,200 baud. There is an Instructable at: https://www.instructables.com/id/Modify-The-HC-05-B... that shows how to do this. The only thing I found missing in the Instructable is that if you're using Arduino's serial monitor make sure you select "Both NL and CR" on the drop down.

None of the other parameters of the HC-05 need to be modified.

Step 3: Download the MinSegBus Library for the Arduino

In order to send data over a serial link, it is wrapped in a data frame. This frame includes a CRC and an address byte that is used to verify no frames are dropped.

The data bus library is called MinSegBus and is available on a public repository on GitHub:

https://github.com/MoreCoffee12/MinSegBus

You can fork this repository and use the code that way or use the attachment to this step. The GitHub will always have the latest version so that's the preferred method. Either way, you will need to add the library to your Arduino IDE (see http://www.arduino.cc/en/guide/libraries for details).

Step 4: Program the Arduino

To get accurate samples, the timer interrupts are used on the Arduino so this program structure might look a little different from other Arduino programs you have worked on. This Instructable has a lot more details on the Arduino timers, if you are interested: https://www.instructables.com/id/Arduino-Timer-Inte...

The code can be downloaded from GitHub (https://github.com/MoreCoffee12/SerialScope/tree/m...), the .zip file attached to this step, or typed in from below.

// Firmware to capture 2-channels of data and send it out over BlueTooth.
// This implementation is designed to provide data to the Windows Phone 8
// Application
//
// Software is distributed under the MIT License, see ArduinoFirmware_License.txt
// for more details.

// This library provides a frame structure
// for the data.
#include <minsegbus.h>
MinSegBus mbus; 

// The SoftwareSerial library is used to provide
// data to the Bluetooth module.
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX


#define maxbuffer     0x0400
#define ADCChannels   0x0002

//storage variables
boolean toggle0 = 0;

// Define the ADC
int analogPinCh1 = 0;
int analogPinCh2 = 1;
bool bOutput;

// Buffers
unsigned short iUnsignedShortArray[ADCChannels*2];
unsigned char cBuff[maxbuffer];

// MinSegBus vaiiables
unsigned char iAddress;
unsigned short iUnsignedShort;
unsigned int iBytesReturned;
unsigned int iErrorCount;
unsigned int iIdx;



void setup()
{
  // Serial port setup
  Serial.begin(115200);
  BTSerial.begin(115200);

  // Definitions for the MinSegBus
  iAddress = 0x000;
  
  // Tattle tale pins, used to confirm timing
  pinMode(9, OUTPUT);
  
  // Get two samples before sending the frame
  bOutput = false;
  
  // Timer setup.  Begin by disabling the interrupts
  // Reference:  https://www.instructables.com/id/Arduino-Timer-Interrupts/?ALLSTEPS
  
  cli();
  
  // Timer control registers
  TCCR0A = 0;   // Set entire TCCR0A register to 0
  TCCR0B = 0;   // Same for TCCR0B
  // Set compare match register for 625Hz increment
  OCR0A = 99;  // = (16*10^6) / (500*256) - 1 (must be < 256)
  // Turn on the CTC mode
  TCCR0A |= (1 << WGM01);
  // Set CS01 and CS00 bits for 256 prescaler
  TCCR0B |= (1 << CS02 );
  // Enable the timer compare interrupt
  TIMSK0 |= ( 1 << OCIE0A );
  
  // enable interrupts
  sei();
}

//  All the work is done in the timer interrupt service routine (ISR)
void loop()
{
    return;
}

// Timer0 interrupt 1kHz.  This also toggles pin 31
// to provide a method to veriy the sampling frequency.
ISR(TIMER0_COMPA_vect){
  
  if (toggle0)
  {
    digitalWrite(9,HIGH);
    toggle0 = 0;
  }
  else
  {
    digitalWrite(9,LOW);
    toggle0 = 1;
  }

  if( bOutput)
  {
    iUnsignedShortArray[2] = analogRead(analogPinCh1);
    iUnsignedShortArray[3] = analogRead(analogPinCh2);
    iBytesReturned = 0;
    iAddress++;
    mbus.ToByteArray(iAddress, iUnsignedShortArray, ADCChannels*2, maxbuffer, &cBuff[0], &iBytesReturned);
    bOutput = false;
  }
  else
  {
    iUnsignedShortArray[0] = analogRead(analogPinCh1);
    iUnsignedShortArray[1] = analogRead(analogPinCh2);
    bOutput = true;
    for (iIdx = 0; iIdx<iBytesReturned; iIdx++)
    {
      // Uncomment this line to write to the serial port. Useful
      // only for debugging
      //Serial.write(cBuff[iIdx]);
      BTSerial.write(cBuff[iIdx]);
    }
  }

}

Step 5: Download and Install the Windows Phone App

The application that runs on the Windows Phone is called SerialScope and can be downloaded from the Windows Store or forked from this GitHub repository: https://github.com/MoreCoffee12/SerialScope. The software is also licensed under MIT License.

The video has the instructions on how to use the app. The only thing that's a little odd is that it sometimes fails to find the HC-05 Bluetooth device. You may have to try this a couple times to get the connection. It happened to me in the video, you can see me bring up the connection screen twice.

<p>Hello</p><p>Can this project be done on an android phone?</p>
<p>Hi, I've added your project to the <em style="">&quot;</em><em style="">Make Your Own Oscilloscope!</em><em style="">&quot;</em> Collection</p><p>This is the link If you are interested:</p><p><a href="https://www.instructables.com/id/Make-Your-Own-Oscilloscope/">https://www.instructables.com/id/Make-Your-Own-Osci...</a></p>
<p>Hi Brian</p><p>I just tried to do this project and have a few issues.</p><p>I have a Nokia 920 phone which has a screen resolution of 1280x768 compared to your phone with 1920x1080.</p><p>When I open the SerialScope on the phone the layout is not correct. All of the other controls/buttons seem to work OK. </p><p>Main issue is when I hit <strong>START ACQUISITION</strong>, the app shuts down. Should it still work on this phone (even if the layout is not correct)</p><p>I have also uncommented the &quot;<strong><em>Serial.write(cBuff[iIdx]);</em></strong>&quot; code in Arduino for debugging.</p><p>I do not see normal text - I see lots of printable and unprintable characters. Is this what to expect?</p><p>Any assistance appreciated.</p>
Hi...<br>i m going to work on this project.....<br>1)can u tell mi the exact working of this project..... ?<br>2)....and plz tell mi &quot;in what frequency range this oscilloscope work&quot;?<br>3)and what kind of analog signal we have to give to the arduino?
<p>I wonder how well this would display DMX data frames. I am working on some DMX lighting controllers and plan to send DMX data from my laptop to arduino</p>
<p>Please help</p>
<p>Hi Igh1, sorry to hear you are having trouble. Is this the Arduino IDE that is throwing the error? If so, which version are you using?</p>
<p>does this app works on laptop (windows 10)</p>
<p>Unfortunately, not yet. I'd like to port it over, but it'll be a while before I get to it.</p>
<p>I can not find her name library simstruc.h</p>
<p>what is error:</p><p>sketch_sep07a.ino:15:22: fatal error: simstruc.h: No such file or directory</p><p>compilation terminated.</p><p>Error compiling.</p>
hey, amazing instructables but, can you post a video to I see working?<br><br>thanks
<p>I posted a video to YouTube. You can find it at below. Let me know if you have any other questions. Thanks!</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/6TA1tdn71-8" width="500"></iframe></p>
can the sampling frequency be increase!!!?
<p>Yeah, it is slow. I've been looking at the Girino oscilloscope project here on the Instructables site. I'm going to take a little time and see if I can add an interface to SerialScope to the Girino front end. If I can make that work, it would definitely help the sampling. I'm in the middle of a move, so it will likely be a while before I can finish this up, tho.</p>
<p>hi, how can i use this firmware with a hc 06? i try change the tx and rx to 0 and 1 and i was able to conect but dont recice any data, probally because the key pin </p>
<p>The HC-06 can be re-programmed to 115200 baud, although the steps are a little different because it doesn't have a KEY pin. I found this Instructable and verified that for the HC-06 I have, I was able to re-program it to 115200 baud:</p><p><a href="https://www.instructables.com/id/AT-command-mode-of-HC-05-Bluetooth-module/" rel="nofollow">https://www.instructables.com/id/AT-command-mode-of...</a></p><p>I had a few difficulties connecting to the HC-06 in command mode. Make sure the HC-06 is not paired to anything (I'd forgotten how many devices I had paired it to), use capital letters, and do not include spaces in the commands.</p><p>I was able to download the firmware and connect with SerialScope once I had done this. Let me know if run into any troubles and I'll do what I can to help you get it up and running.</p>
<p>Here's a similar idea that works into the MHz but with Android. The trick is to use the micro USB connector.</p><p>https://www.youtube.com/watch?v=MDL7FIYKlkQ</p>
<p>That's a very nice project, I like their analog front end. Thanks for sharing it.</p>
<p>Cool project! It's good to have one of these around. Oscilloscopes are the best!</p>
<p>Thank you! First time I've done this, what a blast!</p>

About This Instructable

25,546views

271favorites

License:

More by brian howard:Realtime MPU-6050/A0 Data Logging With Arduino and Android Wireless Arduino Oscilloscope 
Add instructable to: