Stephen Smith's Blog

Musings on Machine Learning…

Playing with the Wio Terminal’s Grove Connectors

leave a comment »


Introduction

When I first reviewed Seeed Studio’s Wio Terminal, I didn’t have any Grove devices to make use of its two Grove connector ports. Since then I received a Seeed Studio Raspberry Pi Pico Grove Starter Kit and that provided me with 13 Grove devices to play with.

The Wio Terminal exposes a standard Raspberry Pi 40 pin header on its back, but some of these leads are wired to two Grove ports on the bottom of the terminal. This gives you one I2C grove port and another port that can be used as either a digital or analy port. There is no UART grove port, but you can use one of them for PWM which isn’t standard but can be configured. If you are using both the 40-pin connector and the Grove ports, then you need to be careful to avoid conflicts, as these are all wired up to the same pins in the SoC.

In this article, I’ll connect the mini PIR (Passive Infra-Red) motion sensor to the digital port. We use the Wio Terminal’s built in display to indicate whether movement is detected or not. The Wio Terminal is nice, in that you don’t need to use another port to connect a display.

Connecting it Up

 The PIR sensor plugs into the right Grove port, which is the one that supports general digital or analog devices. Below is a picture of this in action.

The sensor is quite sensitive, in this case it’s showing the motion of my cell phone taking the picture. At first I didn’t think it was working, since it kept indicating movement, until I realized it was sitting on the table and picking up the vibrations as I typed. To work well, the PIR sensor needs to be secure, so it doesn’t vibrate or move, otherwise it will report on movement of the sensor rather than objects in the room. This sensor works best for objects about two meters away. If you want something for your yard you might consider the Seeed’s non-mini PIR motion sensor. This sensor is good if you want a motion sensitive halloween display to scare the neighborhood kids, motion activated XMas displays or notification if someone comes right up to your door.

The Code

For this project, I’m using Arduino, since I find that environment is the best one for the Wio Terminal. Accessing the PIR motion sensor is easy, it sets the digital pin high if motion is detected and low if nothing is happening. This doesn’t require any special libraries or classes, being such a simple device. Notice the definition of D0, which is used to specify the primary digital pin in the Grove connector, or you could use the pin number which is 13 in this case. This is documented on the Wio Terminal wiki.

For the Wio’s display we use the TFT library like we did in our first impressions article, except we are displaying text rather than graphics. When I first coded this, the flashing was terrible, but after a bit of research on Seeed’s wiki, I discovered I needed to use a sprite to avoid the flashing. With the sprite you do all the drawing to the sprite and then update the display in one quick pushSprite statement. The TFT library for the Wio Terminal is quite powerful, but lacks a good technical reference, so you have to look at the code, or at least the TFT_eSPI.h header file which is quite long, or watch through some tutorial videos. The tutorials have a lot of good information, but are quite long, making them a bit time consuming to refer back to. 

#define PIR_MOTION_SENSOR D0
#include"TFT_eSPI.h"
TFT_eSPI tft;
TFT_eSprite spr = TFT_eSprite(&tft);
void setup()
{
    tft.begin();
    tft.setRotation(3);
    spr.createSprite(TFT_HEIGHT, TFT_WIDTH);
    spr.setTextColor(TFT_WHITE);
    spr.setTextSize(2);
    pinMode(PIR_MOTION_SENSOR, INPUT);
}
void loop()
{
    spr.fillSprite(TFT_BLACK);
    if(digitalRead(PIR_MOTION_SENSOR))//if it detects the moving people?
    {
             spr.drawString("Movement detected", 30, 60);
    }
    else
    {
         spr.drawString("Watching", 30, 60);
    }
    spr.pushSprite(0,0);
    delay(200);
}

Summary

The Wio Terminal is a great way to play in the Arduino world without requiring any soldering or breadboarding. The terminal has lots of useful built-in functionality, and allows you to easily connect up sensors and devices in a plug and play manner. This is great for the classroom where you might not want to supervise a large group of kids playing with soldering irons. The mini PIR sensor was fun to play with and getting the Arduino code working was easy. I find I get projects up and running much quicker with the Wio Terminal, since there is a lot built in, and I don’t get wiring problems, since the Grove connectors have been reliable.

Written by smist08

October 15, 2021 at 11:14 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: