empowering creative people

Videos / Getting Hands On With Some Popular Sensors

What good is a robot if it can’t interact with the environment around it? Sensors are the backbone of almost every electronics project as they allow your program to make decisions based on external stimuli. We’ve got sensors for all kinds of applications such as light, colour, sound pressure, temperature, and heaps more. However, one of the big stumbling blocks for a lot of people is which sensors are going to work for them, and how to use them in their project.

Search Videos

Related Content



Hey guys, how're you going, Sam here from Core Electronics, and today I wanted to have a bit of a conversation about sensors! It's such a broad category, you've got so many different types of Sensors I just wanted to showcase a couple of my favorite sensors that I use in projects all the time that are Maker Favorites of ours, why I love them, why I use them and a bit about what they are and what they do. So if you're not sure, perhaps you're new to electronics or DIY projects and you've heard the term sensor thrown around a huge amount and you sort of get the gist, but you're not 100% sure, then this is for you. So I'm going to be talking about what a sensor is, how it works and why you would use it. So a sensor really, is anything that converts external stimuli, things from the world around you, into tangible data. Whether that is pressure, force, light, sound, whatever it is, the moisture content in something. Even things like vision and date and time, those things can be measured, quantified into something that we can record and process on a microcontroller or microprocessor.

So that's a bit about what sensors are, first, off I have the waterproof temperature sensor, the DS18B20, it's a famous and commonly used temperature sensor and it's fantastic for a few reasons. It's a digital sensor, it's a one-wire temperature sensor, meaning you only need 1 wire to get all of the data, it has a hard coded unique ID on there, much like the I2C bus, or the SPI bus, you can have multiple devices on the same network, so you can simply plug it in, use the one wire library, Adafruit has some great ones, there are heaps of great ones floating around for essentially every platform, Arduino, Particle everything else. They are all out there, which makes it really easy to use, it's digital so you can be sure that unlike an analog sensor where you are trying to measure that voltage and then apply a formula to convert the voltage increments into a temperature, this one just gives you the temperature, straight up here is the degrees and away you go. So it's waterproof, it's got this stainless steel probe on the end so you can use it in watery environments. It's got a temperature reading range of -55 to 125 degrees celsius, huge! A few things to point out with that is that whilst the stainless steel probe may be able to handle that, the PVC sheathing cannot so realistically you don't want to be going over anything that is going to melt the PVC so around the 80-90 degree mark is when this is going to get soft, so try and avoid that. But it is important to note that it is -10 to about 90 degrees where the sensor is accurate to 1/2 a degree, outside of that it starts to get a little bit of variation. It will still give you an accurate temperature reading but inside that range is where readings will be most accurate. So extremely easy, one thing I would recommend is to get yourself a little terminal screw block as there are 3 wires. Red for power, it is a 5 and 3 Volt Device (I'm pretty sure) so you can use it with RPi and Arduino. Black for Ground and Yellow for data. But the wires are a little thin, so they are designed to go into a screw terminal like this or to be soldered onto a board, so grab a screw terminal because it can be a little hard to breadboard with. Just make sure you get one with breadboard friendly spacing otherwise you have shot yourself in the foot there a little. So that's my favorite temperature sensor, I use it all the time.

Next up we have a soil moisture sensor, so a little bit different here. This one is from DFRobot, it is a particularly well thought out product. You've got these gold plated probes here to resist corrosion, on a standard fibreglass PCB, and gold plated electro PCBs are usually reserved for high-end boards, the name of the board is actually on the PCB rather than in a silk screen here. And this guy is quite easy to use, you've got your two prongs here which go to a really simple 3 component circuit and it measures the conductivity across the two probes. Meaning you put it in some soil and the more moisture in the soil, the better that will conduct electricity across the probes, when the soil is a lot drier, obviously the resistance goes up and it conducts the electricity a lot less. And you can read that it will supply 5v or 3.3V, GND and your Data. That data pin is just an analogue voltage that you can measure, which the voltage being relative to the soil moisture sensor. You do need an analogue pin to read it though so if you're using a Raspberry Pi you're going to need an external analogue to digital converter, but most boards do have an analogue pin to use it with.

Next up, we've got the ultrasonic distance sensor, the formidable HC-SR04, formidable in the sense that millions of these, if not billions have been used in maker projects around the world. Extremely common bit of gear that will cost you around $5.00, for an ultrasonic sensor. And whilst measuring distance to precise ranges can be a bit tricky and expensive because of the high-quality components you need, this sensor actually does it in centimetres and it does a pretty good job of it. I recommend these for anything where you want some rudimentary object collision, so when it gets closer than 10cm give your robot a warning. Or when it's further away from something it can go. Because they are so cheap, you can easily setup an array of them to get some 360-degree collision detection going. So they just have a trigger pin, an echo pin, 5V and ground, and you just the trigger pin in the library, there are some great libraries out there which make it so easy to get started. What a world we live in. The trigger pin sends out a pulse, pulse goes into the room and is reflected off surfaces and then received back by the echo pin, which means a few things. So acoustically soft surfaces, such as cloth etc will give it trouble but 99% of materials around us are going to be fine. It gives an advantage over IR distance sensors, as you know sources of IR light, dust particles, things like that aren't going to obscure the distance reading.

Next up we've got the DS3231 RTC module from Adafruit. This is a breakout board with the DS3231 chip onboard, and Adafruit is really great at making surface mounted ICs and things like that, packaging them into a really easy to use breakout board. So you've got a coil cell battery, some nice supporting components, it's all self-contained and some header pins, it comes with the pins. The idea of a real time clock is that if you have a microcontroller or microprocessor, it's all well and good, it can use the clock speed to keep time fairly well, but when you disconnect power it resets the device. So you're at a loss there, unless you have some form of backup in an RTC. And what this guy does is, using its coin cell battery and oscillator, it can send the time to the main chip you are using, so when you are powering a chip you can say this is the time right now and it will run and record the time, so when you check it again it will feed you back the time and date. This particular RTC operates via I2C so it's really easy to setup with a whole bunch of chips, again the Adafruit library makes it really easy to get setup, you just import the library into Arduino for example, it gives you the date and time. This guy is really nifty, it's a little more expensive than others but I really like it. It has onboard temperature compensation for the oscillator, which can cause some drift, and is an extremely precise RTC.

Next up, and last but not least, well for now. This is going to be a tutorial that is kept up to date. The Raspberry Pi Camera Board, perhaps not what you would think of when you hear the word sensor, but it converts light into data. It's a sensor. And the thing I love about this is, I think we take for granted sometimes how cool technology like this is. This is an 8MP camera, it can record 1080p video at 30 frames per second, subdivide that and you've got higher framerates as well. It can take images at some crazy resolution, 3280x2464 pixels, so great resolution images. Now it's not going to be a replacement for that nice SLR you've got but it does a reasonable job for a DIY camera, but I think we take for granted the world we live in and the era, when you can do something as complex as digital image processing, there is a lot going on, can be bought in a camera module, 1 ribbon cable plugs into your Raspberry Pi you can record video, you can take pictures, you can apply filters, you can do all that with a few lines of code. Simply import the Pi Camera Library and away you go. It's so easy and cool as there is so much complicated low-level engineering and technology that has gone into this product to just make a really easy to use the device. To get that more complicated system into a really user-friendly, maker-friendly package. That's why it is one of my favourites.

So they were a few sensors that I am loving at the moment, putting them into some projects and just using them all the time. This wasn't an in-depth, hands-on how do I connect these up and get them the working tutorial, I've got some links for those under each sensor. So you can see there, the links for all of them which actually point you to the wiring diagrams, breadboard layout of circuits and example codes, library links and everything you need to get hands on with these sensors. But that was a bit of an overview of what sensors I love and why I am loving them, that's all for today guys. Take some of these guys and put them into your projects and get making!