Maker Hacks

Ideas, news & tutorials for makers and hackers – Arduino/Raspberry Pi, 3D printing, robotics, laser cutting, and more

  • Home
  • About Maker Hacks
  • Blog
  • YouTube Channel
  • Recommendations
  • Contact
You are here: Home / Hacks, Tips, and Tutorials / Ultrasonic Rangefinding with the Wio Terminal and Grove Ultrasonic Sensor

Ultrasonic Rangefinding with the Wio Terminal and Grove Ultrasonic Sensor

Chris Garrett

FacebookTweetPin

Seeed sent me a Wio Terminal to play with, and I have to say I am impressed.

Rather than do a straight review, I thought I would show how easy it is to make a quick project with it.

As you can tell, I like it! For under $30 this little guy delivers:

  • ARM Cortex 120-200MHz ATSAMD51 with BLE / BLE 5.0 bluetooth and 2.4Ghz / 5Ghz Wi-Fi
  • 4 MB External Flash, 192 KB RAM
  • 2.4” LCD Screen + buttons and joystick
  • Accelerometer, microphone, buzzer, light sensor
  • microSD, SPI, I2C, I2S, ADC, DAC, PWM, UART
  • Infrared emitter,
  • 2x Grove ports
  • USB Host/Client OTG
  • 40-pin Raspberry Pi compatible GPIO (Can be mounted to a Pi or use Pi HAT!)
Wio Terminal

Check out the intro video here for a better idea what is packed into the tiny box.

It can be coded with Arduino or Micro/CircuitPython.

Just take a look at what the community has built with it already.

Some pretty impressive stuff, I am sure you will agree.

Display, IoT + the Grove Ecosystem

What really makes this stand out is it isn’t just powerful for the price, it’s not just wireless, it hasn’t just got a pretty display … it’s all that AND it enables use of the plug-and-play Grove system of sensors and inputs!

I am a big fan of the Grove Ecosystem (and have been for a while), especially when working with kids and folks like me who don’t want to touch a soldering iron unless 100% necessary.

Here is my ultrasonic range finding example in action.

Setting up CircuitPython is as simple as downloading the firmware file from the link above, double clicking the reset button, and dragging the firmware to the CircuitPython drive that pops up. Saving your code is a simple case of writing code.py to the same drive.

Wio Terminal Pinouts Pin Diagram

The sensor plugs into the right-hand port in the case as you look at the screen, which is the Analog A0 input.

Add the code below to try it out:

import board
import pulseio
import time
import board
import terminalio
from adafruit_display_text import label

sig = pulseio.PulseIn(board.A0)
text = "000.0000 [cm]"
text_area = label.Label(terminalio.FONT, text=text)
text_area.x = 10
text_area.y = 10

while True:

    sig.pause()
    sig.clear()
    sig.resume(10)
    time.sleep(0.1) # should poll len(sig) here with a timeout
    sig.pause()
    sig_value = sig[0]*0.017

    if len(sig) != 0 and sig_value < 500:
        text= "{:6.2f} [cm]".format(sig_value)

    text_area.text = text
    board.DISPLAY.show(text_area)
    

If you really want to get fancy, you can change the text color or the font face.

The fonts are bitmap fonts in the BDF format. You can drag and drop a font file onto the CircuitPython drive and change the following:

from adafruit_bitmap_font import bitmap_font
text = "000.0000 [cm]"
FONT = bitmap_font.load_font("/IBMPlexMono-Medium-24_jep.bdf")
text_area = label.Label(FONT, text=text)
text_area.x = 20
text_area.y = 20

Related

FacebookTweetPin

by Chris Garrett Filed Under: Hacks, Tips, and Tutorials

About Chris Garrett

StudioPress Marketing Director at WP Engine. Co-author of the Problogger Book with Darren Rowse. Maker of things. 🇨🇦 Canadian

☕️ Support Maker Hacks on Ko-Fi and get exclusive content and rewards!

« Programming the Amiga with AMOS BASIC: A Playable “Shoot ’em up” Game
Easiest. Hackintosh. Ever. – How to Install MacOS Virtual Machine on Your PC Using Sosumi & Ubuntu »

The website for makers and hackers – Arduino, Raspberry Pi, 3D Printing and more

Get fresh makes, hacks, news, tips and tutorials directly to your inbox, plus access to the 30 Days to Arduino course

Recently Popular

  • How to choose the right 3D printer for you
  • Glowforge Review – Glowforge Laser Engraver Impressions, Plus Glowforge Versus Leading Laser Cutters
  • Original Prusa i3 Mk3S Review
  • Best 3D Printing Facebook Groups
  • Elegoo Mars Review – Review of the Elegoo Mars MSLA Resin 3D Printer
  • Glowforge ‘Pass-Through’ Hack: Tricking the Front Flap of the Glowforge with Magnets to Increase Capacity
  • How to Make a DIY “Internet of Things” Thermometer with ESP8266/Arduino
  • Wanhao Duplicator i3 Review
  • IKEA 3D Printer Enclosure Hack for Wanhao Di3
  • Creality CR-10 3d printer review – Large format, quality output, at a low price!
  • 3D Printed Tardis with Arduino Lights and Sounds
  • Anet A8 Review – Budget ($200 or less!) 3D Printer Kit Review
  • Make your own PEI 3D printer bed and get every print to stick!
  • Upgrading the Wanhao Di3 from Good to Amazing
  • How to Install and Set Up Octopi / Octoprint
  • Creality CR-10 S5 Review

Copyright © 2021 Maker Hacks