Wednesday, August 16, 2017

H-Bridge for your robot




Intro

Turning a DC motor on and off isn't that much of a problem, is it? But if you want to change direction, you must have a way to switch the polarity that drives your motor. Well, that is what a H-bridge does.

How to control

For each motor, you should have 2 pins to control the output. If you pull one pin HIGH and the other one LOW the motor should spin. If you invert this configuration, the motor will spin in the other direction. Pulling both pins to LOW or both to HIGH will stop the motor.
Now you have the ability to turn the motor on in both directions. If you also want to control the speed of the motors, you should connect it to PWM ports.


Wiring




Video 



Pro-Tip

If your motor doesn't spin, you probably have a too low input voltage. These boards are equipped with voltage regulators. So you can try using a higher voltage. I used a 9V battery for the 5V motors myself. Worked perfectly.

For controlling your robot it makes sense to extract the commands for the wheel to spin in separate methods. Make a method for spinning the left wheel in clockwise direction. And one for counterclockwise direction. It's so easier to program some logic to your vehicle.

Buy at Amazon

H-Bridge L298N
5V DC Motor with gearbox
Robot chassis with motors
H-Bridge L9110

Monday, July 24, 2017

Text on your Display



Intro

If you want to add some visual output to your Arduino projects, you'll need a display. If you need only little to display, the LCD 1602 is a quite good solution. But you'll waste about 8 Pins on your Arduino for the display to get working. Luckily there exists a I2C adapter that you can solder right onto the pins of the display. So all you need to connect are the I2C pins, a good library and little of coding.

Wiring 

If you already have the I2C adapter soldered onto the board, wiring is quite easy. You should usually have only four pins to hook up. VCC and GND of course. The LCD display works with 5 Volts. So we go for the 5V Pin. The Arduino Uno and Nano can handle the current need for this display. SDA (data line) to analog 4 on your Arduino Uno or Nano. And SCL (clock line) to analog 5 (other Arduinos or ESP might have different pins).





Video





Needed library

https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library

When thinks aren't working

  • Did you remember to call the begin()-method of the library?
  • Did you turn the backlight on?
  • Have you tried to adjust the contrast with the potentiometer on I2C adapter?
  • Did you check the I2C address? (use the i2cdetect sketch)

Where to buy

You can search on eBay for LCD1602 I2C. You'll get plenty of results.
Or, here are some direct links to Amazon:

LCD 1602 with I2C adapter

LCD 1602 without I2C adapter

I2C adapter

The bigger LCD 2004

Monday, June 12, 2017

Extend your analog inputs




Intro

Is yours too small? You want to get more? No, that is no advertisement for a penis enlargement product. It's for a board to extend the numbers of analog inputs to your microcontroller.
It's quite rare that you run out of analog inputs, when using an Arduino Uno, Nano, Micro, etc. Even a ATTiny is already equipped with 4 analog inputs. BUT if you are so keen in using a ESP8266, like I am, you'll find your self in the position having only 1 (!)  analog in. This is where a digital to analog converter comes into play.


It's all about libraries

The name of the sensor (ADS1115) already can lead to the conclusion that the board is developed by Adafruit. And of course, if you'll open the library manager in the Arduino IDE and search for ADS1X15. There you have it all. Ready-To-Use library, good commented examples.

I2C on your NodeMcu board

The default pins for I2C on the NodeMcu board are pins D1 (SCL) and D2 (SDA). But the cool thing with the NodeMcu board is, you can define for yourself where the I2C has to be.

With the command:
Wire.begin();
You usually start the Wire-library, that is responsible for the I2C bus. But you can also add the pins for SDA and SCL as parameters:
Wire.begin(D2, D1); // Wire.begin([SDA-Pin],[SCL-Pin]);

There can be more than one

The ADC1115 has a fixed I2C address, like any other I2C device. Fixed? Not quite! It has up to five different I2C addresses. The default one, and four more addresses, that you can select by connecting the address pin (ADDR) with either SDA, SCL, GND or VDD.


Video


Wire up

Normal wiring


Wiring with two modules on I2C



Links

Adafruit Library
https://github.com/adafruit/Adafruit_ADS1X15

Amazon
ADS1115
NodeMcu

Friday, June 2, 2017

Keeping balance with a gyroscope




Intro

"I like to move it, move it! I like to move it, move it!"
If you want to measure movement, you probably will use one of these sensors. Why you want to measure movement anyway, you ask? Hey, who doesn't want to build a quadcopter? Or a self-balancing robot?
 There are 2 common senors, that will do the trick. The GY-61 (ADXL335) and the bigger brother the GY-291 (ADXL345).

The sensors

The GY-61 is the easier sensor to handle. It has VCC and GND and three analog outputs. One for each axis. You can read the sensor values with the analog inputs of an Arduino.
These are quite raw values. And even, when the sensor doesn't seem to move, the values does. So you have to program some method to smooth these values and probably a calibration routine, if you want to use it in a matter of a balanced project.
The GY-291 is a little different. It has an I2C bus. And I recommend to use the library, that is provided by Adafruit. If you're using the Arduino IDE, just search for ADXL345 in the Library Manager.



Video






Which sensor for which project?

Well the advantage of the GY-291 is, that you don't need to interpret the sensor values for yourself. The library does all the work for you. And it has a I2C bus. That means, you won't waste any pins on your controller. Because you can attach several devices to I2C, as long as they have different addresses. The smaller brother, the GY-61, doesn't need much code to operate. The sensor delivers it's values through 3 analog outputs. Well, at least it delivers something. You have to interpret the values for yourself. If you want to build something like a self balancing robot, I would recommend, that you build a small calibration routine. 
Both sensors costs about the same. 
For one of my next projects, where I want to use an ATtiny. Since the ram of this board is extremely limited and I just want to know, if the sensor is moving anyhow, I'll stick to the GY-61.

Links

Amazon

Friday, April 21, 2017

Shooting Laser to measure distance



Intro

This time-of-flight sensor is a laser distance sensor, that emits a 940nm laser. It can measure distance up to 125cm quite accurate. Adafruit delivers a ready-to-use library and a functional example you should try.

Wiring


The sensor is connected via I2C. So you have to use pin 4 and 5 on the Arduino Uno/Nano (other Arduinos may have different pins for I2C). It works with 3.3 volts. But since the breakoutboard has a voltage regulator implemented, you can connect it also to 5 volt.

Video


Casing

=> work in progress

Where to buy?
You can find it on eBay, if you search for "Time of flight"
Or directly from Amazon: Time of flight
Arduino Nano

Thursday, April 20, 2017

Raspberry Pi Zero W(ireless)





Intro

On the 28.02.2017, the fifth birthday of the Raspberry Pi, a new version was released. The Raspberry Pi Zero W. The W stands for wireless and indicates that Wifi and Bluetooth is already integrated on this board. Finally.
The 'old' Raspberry Pi Zero costs about 4£ plus shipping, while the new version costs about 9.60£ plus shipping.

Difference in power consumption

One thing that was on my mind is: does the integrated solution draws more or less power other than attaching external Wifi and Bluetooth.
The solution I found most similar to the configuration on the new Pi Zero W was the HAT from Redbear. It also extends the Pi Zero with the same connectivity as the new one has now.
So I installed the same Version of Raspian on both models (Kernel 4.4, Release Date: 2017-03-02), turned Bluetooth on and connect with active Wifi to my home network.

Pi Zero + Redbear HAT Pi Zero W
... ...
140-160 mA 130 mA

More expensive or cheaper?

Well, kind of a tricky question, isn't it? On the first sight, you see the same-sized board with identical specs for more than the double of the price. But think about it. If you want to use it, as a streaming-client, a home cloud server, a broker for IoT projects or even a small PC, you need what? Internet connection. So you need a Wifi dongle. And since it wouldn't fit, you also need a OTG adapter. And a small USB hub would be also nice. Oops! That's a lot of extra to buy.


Watch the Pi Zero W


Worth it?

If you are looking for a small single board computer as a replace for a Lunix based desktop computer, you should probably go for the Raspberry Pi 3.
But if you want to buy a Pi Zero anyway, you should go for the version with the integrated connectivity. Because if you are a maker and want to build your own IoT device, a Webserver or even a autonomous robot, you wish earlier or later that you can communicate with your Pi.

Monday, April 3, 2017

Coolest motion detection sensor


Intro

Ever want to build an alarm system?
The RCWL-0516 is a human body motion detection sensor. A sensor, that detects, through induction, human body movement. So it should only react if a body movement is detected. Moving objects should be ignored. How cool is that?

Wiring


Straight forward. 
GND => GND
5V => VIN
D2 => OUT

Pin 3V3 on the RCWL-0516 is an output. And the CDS-pin you can attach a light sensor. I will cover it in a later video.


Videos

Wiring & Use


ESP & detection tests





Code

Seriously? You set the pin, the RCWL-0516 is attached to, as an input. And if you register a 'HIGH' signal, you do stuff. Watch the video. Coding is done in 2 minutes.

Q&A

Update 29-05-2017
This sensor seems to get quite an attention. There are some questions that some of my viewers asks. Here is what I found out.

Q: Can you use the RCWL-0516 with an ESP8266? Or will you get randomly false positive results?
A: I've done a short term test with the ESP8266 on a NodeMCU board. It seems to work just fine. 
The ESP greater Version 12-E is shielded and is FCC certified. So it should, by definition, not interfere with other electronics.
 However one viewer reported randomly false positive results on a long shot.

Q: Is the water in the human body responsible for the detection?
A: Probably. I tested it with an empty and with a water filled bottle. And even with a cat. And it seems that the bigger the object the further away it can be detected.

Q: Can it be mounted mobile to detect persons? 
A: No. The sensor seems to be quite sensible to movement itself. Any movement of the sensor itself seems to trigger the output.

Q: Does the radiation of the sensor harm you in long term?
A: No. The Sensor uses about 30 milliwatts (mW). The radiation output is limited to that value. That is far less than your smartphone emits.

Links

Amazon

RWCL-0516
NodeMcu
Arduino Uno