Introduction: Fast, Portable and Affordable Oscilloscope and Inductance Meter

Picture of Fast, Portable and Affordable Oscilloscope and Inductance Meter

When turned off, it looks like an ordinary toy car that would entertain a kid for hours, but actually it is an oscilloscope kit in disguise!

The idea and also part of the code for this project came from another scope called STM-32-O-Scope (aka pigScope), which uses a more powerful Arduino cousin called STM32. I originally posted my version on hackaday, but now I've deciced to bring it here too, so it may help more people who don't have a commercial oscilloscope and also becase there's a contest happening ;)

I use this tool daily to watch signals or as a second voltmeter and also to measure inductance of home-wound inductors. As the code is open, you may add, remove or improve features according to your needs.

As it's more than just an oscilloscope and "oscilloscope and inductance meter" is too cumbersome, I named this little guy multiScope. Here's what it currently does:

  • Measure inductances greater than 100uH with 10% precision
  • Display analog or digital signals with up to 1.7MS/s sampling rate
  • Temperature and pressure sensing (an extra feature)
  • Displays voltages, frequency and duty cycle

Step 1: Materials

Picture of Materials

The core parts for the oscilloscope:

  • STM32F103C8T6 minimal dev. board (aka "blue pill"), buy one like this STM32F103C8T6 min. dev. board

  • 3.3V USB/Serial adapter (FT232RL or something like that)

  • 2.4 TFT LCD touch screen display (the display library I used was adapted to the model of the picture, but with some changes in code, you might be able to use others). Example link: 2.4" TFT LCD Shield on eBay

  • A box or enclosure (may be something 3D-printed, an old box you have or even a plastic toy)

  • 6-9V battery (I used 7.2 li-ion as it lasts very long)

  • Small switch (main power switch)

  • (2x)2.2K Resistor

  • LM7805 (5V regulator)

Parts for the inductance meter:

  • LM339 (comparator IC)

  • Resistors: 330R, 150R

  • 1uF ceramic capacitor (the higher the precision, the better)
  • 1N4007 (common diode)

Parts for attenuators :

  • 2x3 female header socket
  • Resistors: how many will depend on how much attenuation you need, but they are regular resistors and trimpots.

Step 2: Add STM32 Support to the Arduino IDE

Picture of  Add STM32 Support to the Arduino IDE

Before building our hardware, let's setup our development environment. Here, standard Arduino IDE was used with an add-on called Arduino STM32. The guys who made it also host a forum called Arduino for STM32 that is not so beginner oriented as the Arduino forum, but people can discuss things related to the STM32 board family and also share their projects. There's even a page with other oscilloscopes based on pigScope too, from which I've learned many things and maybe you will too.

OK, so do the following:

  • Make sure you have a compatible IDE version. They recommend 1.6.9, but I used 1.8.1 without any problem
  • Install Arduino SAMD Boards package with the Arduino Boards Manager (in case you don't know, it's a tool inside the Arduino IDE)

  • Download or clone Arduino STM32 into the Arduino/hardware folder

  • Open the IDE, select your board (Generic STM32F103C series for blue or red pill) and Serial as Upload Method to program using the USB-Serial adapter

  • Connect the board by following the little sketch. You may test it with the ordinay Blink code, just note that the onboard led is on PC13. Every time you upload code, you will have to change the position of the first jumper to switch between Run and Program modes before powering or resetting the board

Step 3: A Quick Arts Class

Picture of A Quick Arts Class

Once we're sure the blue pill is working, let's proceed to the display. I won't cover the placement of parts in detail because it will depend on the enclosure you've chosen. Be creative and put them where you think it's best.

The patched TFT library contains code that might not work well with the default Wire library due to pin conflict, so let's edit a few lines to avoid trouble:

  • Go to Arduino\hardware\Arduino_STM32\STM32F1\libraries\Wire
  • Open Wire.h with a text editor you like and look for #define SDA
  • Make it like this:

#define SDA PC15
#define SCL PC14

  • Save the file. Now SDA is on PC15 and SCL is on PC14.

Now, do the display wiring as described in my drawing. After it's finished, download and extract to your libraries folder. To test it, upload lcd_touch_paint.ino. The pins are already adjusted. All you need to do is set your inner artist free.

Step 4: To Measure Inductance

Picture of To Measure Inductance

Now, we're going to build the inductance meter circuit. It's a very simple one, and works in a somewhat similar way to ultrasound sensors: STM32 sends a "trigger" pulse to pulse_in and receives another trough pulse_out, from which we extract frequency (and thus inductance) information. This site explains the schematic and the physics principles in detail if you're interested.

You should connect pulse_in to PB3 and pulse_out to PB4. The unknown inductor of the schematic is the one we want to measure. Solder some alligator clips or female jumpers if you want.

Step 5: Signal In, Signal Out

Picture of Signal In, Signal Out

In this step we'll to cover the scope main signal input (CH1), test wave output (WAVE_OUT) and the attenuators. You will need at least a 2x3 female header socket and two single male of female jumper tips. Each attenuator requires a 2x2 male header.

This project uses both 3-resistor and 2-resistorattenuators. The 2-resistor ones are ordinary voltage dividers and allow us to reliably scale down a positive signal. They're simpler to design and build, but won't handle negative voltages.

The 3-resistor ones are a little bit more complex, but will scale down and offset signals, being capable to take positive and negative input voltages.

To design a voltage divider, just follow the simple equation in the pictures, replacing Vout with 3.3V and Vin with the max. voltage you want to measure. For no attenuation just connect CH1 directly to ADC and ignore GND and 3.3V.

About the 3-resistor attenuator, I've made a small python terminal script to calculate rough values. For a deeper understanding you should see this StackExchange answer.

To keep things simple though, I've provided the schematic to the attenuators I currently use, so you don't have to worry about any math for now.

That schematic also contains the wirings to STM32, whose pins are defined in the code: PIN_TEST_WAVE is PB1;PIN_CH1_ANALOG is PB0; PIN_CH1_FALL is PA15; PIN_CH1_RISE is PA12.

Step 6: Ambient Sensing

Picture of Ambient Sensing

The ambient sensing is kind of a bonus feature and in case you're here just for the essential, just skip this step.

The sensor I used was bmp180, and it's capable of sensing pressure and temperature. It could be used to detect current altitude or even predict the weather, it's all up to you!

Besides power, you just have to connect SDA to PC15 and SCL to PC14, since we changed I2C pins before.

Step 7: Upload and Turn On

Picture of Upload and Turn On

All the wiring is finished and we are ready to upload the final code. If everything is fine, you should see a splash screen and a screen with options just like in the images. By shorting the test wave and CH1 a nice square wave will show up on the screen!

Some things about the scope:

  • Currently it only detects voltage divider probes. It means frequency counting and everything else may work for any probe, but voltages shown on the screen won't be accurate for 3-resistor ones.
  • The 3-resistor attenuators have trimpots that will allow you to offset the signal
  • Frequency counting will work for both analog and digital signals, as long as they cross the falling edge, which I marked with a dotted line
  • The fastest changing signal I tried was a 62.5kHz square wave, so there's definitely more room for exploration!

Well, that was all. I hope you enjoyed.


misterxp made it! (author)2017-06-21

First I must say I am an absolute beginner to Arduino and electronics but with this very well documented and brilliant tutorial by Vitorbnc I was able to get through the various steps without too many problems. Main problem was that I had different hardware and so went very cautiously.

I chose this for my first electronics project because it touched on various aspects that I am interested in: LCD, serial interface, the actual sketch, the electronics side of it. As I said before, it was a little more difficult than expected because my hardware is slightly different. However, the tutorial is very well done and has all the information necessary (you just need to read everything carefully though!). I did not have to adapt the multiScope sketch either, except to correct the orientation for my display. I lost more time trying to get the paint sketch to work and even now can only get dots out of it instead of lines. I also decided to make bread board "sockets" for the display and STM 32 so that I could unplug my boards and use them for other projects if I wish. On the other hand, I also brought out a jumper extension and serial interface leads so that I could programme the boards without removing them!

I could not find any info on the web for my STM32 but found it was very similar to other such boards. I attached photos of the interface connections and jumper position for programming in case anyone is interested. I also had to install the drivers for the board and then, once programmed, just removed the serial interface and jumper and switched on.

When I booted the multiscope sketch for the first time, I thought I had done something wrong because the screen was white for quite a while. However, it booted into the menu and all was well. I have not looked properly through the sketch yet but I found I can't go back out of a menu and have to switch off and on. Also if I touch the centre of the screen in oscilloscope mode, it freezes. Perhaps to see the wave details better? Also if I touch the screen, in any menu, I get little dots where I touch. Anyway I will check the sketch which is well commented too. I am still at the beginning with Arduino so not in a position to modify anything (or even understand half of it!) yet. I also have not made the induction circuit yet but don't think I would use it anyway. I would like to try and play with the temperature and atmospheric part of it though.

So all I have left to say is thanks very much again to Vitorbnc for his excellent and interesting tutorial !!

ailed and well done.

Vitorbnc (author)misterxp2017-08-27

Your scope looks great! It's nice to see that the code works even on different hardware like yours. About the blue dots, they're a debug feature that I decided to keep, they can be disabled by commenting this line:

TFT.fillCircle(touchX, touchY, 3, ILI9341_NAVY);

Touching the screen center changes trigger type. If the input signal voltage is too low (below trigger value) and trigger is set to positive, the screen will freeze until a voltage higher than the trigger value is detected (the contrary is also true). Default trigger is "any", which means it is always showing samples.

misterxp (author)Vitorbnc2017-08-28

Hello Vitorbnc!
Thanks for the info and compliments! However I am new to electronics but quite embarrassed, in any case to say, I don't seem tobe able to use it ! If I use the test connection it works but I can't figure out how to measure something on a circuit. I checked the internet but only find information on commercial units. Anyway, I wanted a curve from a capacitor for example. I put one wire in CH1 IN and the other wire in GND. Then I tried testing the circuit by touching gnd to gnd on the circuit and CHI IN on the + after the capacitor or gnd before the capacitor and + after and other combinations of connections but cant seem to get it to work. Do I need to use an oscillator circuit using a timer like 555? If you have time, please could you give some quick basic set up info to get me started (point me in the right direction) ? A photo of example connection ma be enough. For the inducer it is clear. I thought I would not use it but it could be useful indeed and I will add it soon. Thanks again for sharing your project. Warm regards misterxp

Vitorbnc made it! (author)misterxp2017-08-29


To see waveforms from some oscillator circuit you need to connect scope GND to your circuit GND and CH1 IN to the circuit output. Do a quick test using an Arduino with the Fade example sketch. It could be hard to get a pretty curve from a single capacitor discharge, unless you add some data logger function. However, using the built-in 1Khz test signal and a 4.7uF cap. you are going to see a wave with the typical RC curves you want, just like in the pictures.

misterxp (author)Vitorbnc2017-08-29

Hello Victorbnc,

for the quick reply. I will play with it some more and on different circuits.
For the trigger then, I can set a voltage or frequency and, when the trigger is
reached or value is more I will get a "screen shot" (still screen).
Signal is always via CH1 IN right? Sorry for silly question but have only
started messing with electronics a few months ago

Vitorbnc (author)misterxp2017-09-03


About the trigger, it is used to get a steady image of the signal. Choosing a proper trigger will give you that, but a still screen means the signal couldn't cause triggering, so you should change trigger type. And yes, currently CH1 is the only input.

misterxp (author)Vitorbnc2017-09-03

Hi Vitorbnc,

Thanks for your patience and quick replies. I have something to work with now and will experiment with it. Thanks again and I wish you all the best for the future!

hardyla (author)2017-08-26

Great project, thanks for sharing.

Bought everything and tried to follow Your instructions. Got a problem when trying to edit Wire.h, its seems it was changed recently, at least I cannot find SDA or SCL. Tried without it, but get a white screen only. Could the reason be the changed Wire.h? Hopefully You can give me advice. Many thanks hardy

Vitorbnc (author)hardyla2017-08-27

I've checked the Arduino_STM32 GitHub repo and they seem to have updated the Wire library indeed. White screen is probably related to this. If you aren't using bmp180, try removing all stuff related to it from the code.

mikenaly (author)2017-04-11

Great instrucable. Could you list sources for the parts?

Vitorbnc (author)mikenaly2017-04-12

Thank you. I've bought most parts at local stores or a website that only ships to Brazil (Mercado Livre). But I updated the instructable just now with links to eBay parts that I believe to be the same used in the project.

About This Instructable




Bio: I'm an enginnering student who loves to build stuff!
More by Vitorbnc:Gesture Controlled Levitating Night LightFast, Portable and Affordable Oscilloscope and Inductance MeterThe Simplest Drill Ever
Add instructable to: