ESP8266 Wi-Fi Module Revisited

A while back I posted some information about the ESP8266 Wi-Fi Module. You can view that post here. I mentioned that for testing it, an Arduino with multiple hardware serial ports would be ideal. Well, I just got an Arduino Leonardo which matches that criteria.

Here is how I hooked it up:

 

ESP8266 Fritzing Diagramyou can get the Fritzing file here. (The Fritzing part for the ESP8266 can be found here.)  Notice that the TX and RX serial connections ‘crossover’. Not crossing over is a common mistake when first hooking up a serial communications device.

The Arduino sketch I used was chosen via

Examples->04.Communication->MultiSerialMega

 

You only need to change the serial BAUD rate for Serial1 (the ESP8266) from the default of 9600 to 115200. Once you upload the sketch to the Arduino, run the serial monitor and the commands you type will be sent to the ESP8266. Any response from the ESP8266 will be ‘echoed’ in the serial monitor.

Testing the ESP8266 on an Arduino with two hardware serial ports is much easier than my original way. Now I can add sensors to this circuit and send the information they gather through the ESP8266 to the WEB.

 

UPDATE: 12/29/2014

 

I ran into a common problem with the ESP8266. Sometimes the ESP8266 will return ‘busy’ when you enter a command. The ESP8266 is essentially locked up (i.e. frozen) at this point. To recover you can power off the device and power back on. However that is not a programatic solution. Fortunately there is a way to ‘RESET’ the ESP8266 from code if this situation occurs.

 

Here is how to wire the ESP8266:

 

ESP8266 Reset Circuit

 

 

 

 

 

 

You can download the Fritzing diagram source here.

 

Here is a sketch showing the Reset function.

 

 

 

Explaindio Video Creator

You may not think this post has a lot to do with MicroController Electronics, however, read on before you formulate an opinion.

There is a new Windows and Mac Video Creator program called Eplaindio that recently became available. I am using it to create training, educational and advertising videos for various projects. It is very powerful yet simple to use.

Basically you can take images, SVG graphics, video backgrounds, optional audio files and create scenes which you put together in sequences to make a video. Additionally, slides created in Adobe Flash can be imported to provide additional animation like capabilities.

I made a sample demo video to demonstrate its potential use (especially in electronics)  which you can view below.

All of the electronic SVG images in the sample demo are from fritzing.org. I took those (~6,500) SVG files (which are distributed under the Creative Commons license) and put them into folders and then created a PNG image for each SVG. (The PNGs are used by Explaindio to present a view of the SVG for selection / inclusion into a ‘sketch’.)  I used Inkscape in non-gui batch mode (-z)  to take the SVGs and save them as  PNG images.  (You can download the python script I used to do that HERE.) Contact me if you want a copy of the Fritzing.org electronics SVG/PNG library for use with Explaindio.

If you are interested in that library you might also be interested in the (~8000) SVG graphic files from OpenClipart.org.The SVGs from there can be freely used commercially. I converted them also into folders (with PNGs) for use in Explaindio. Contact me if you want a copy of that library.

It is interesting to note that the Explaindio project files ([.explaindio] used to create the videos) are XML like. That opens possibilities to generate them ‘programatically’.  For example, when I browse through an SVG library looking for ideas or specific images that I need, I can drag/drop them into a folder with my project/scene creator script (add optional text files for adding text slides) and when done, click on the creator script for it to create the project and/or scenes. It saves me a bit of time. Contact me if you are interested in it. (You’ll need to download and install Python in order to use it.)

All in all, I think Explaindio can be taken advantage of to teach Electronics (and other things).

What do you think? Leave a comment and buy your copy of Explaindio here.

 

Prototyping Circuits using a Breadboard

When I first heard the term ‘breadboard’ when reading about electronic circuits, I thought about bread of course and some great bread making recipes. I must have been hungry!

For electronic recipes 🙄 (i.e. circuits), originally a smooth piece of wood (literally a breadboard with nails and wiring) was used as a surface for assembling/wiring  electronic components. We still use the term breadboard today although the synonym protoboard  is also used.

The breadboard of today is reusable and does not use solder which makes it a good experimental tool to prototype circuits. It consists of a perforated block of plastic with numerous metal spring clips under the holes and comes in various colors and sizes (i.e. number of holes):

BreadBoard_170_red BreadBoard_170_green BreadBoard_170_blue

 

 

 

 

BreadBoard

BreadBoard

 

My favorite one is transparent so you can see the spring clips. It has 400 holes and looks like this:

BreadBoard

On this breadboard there are two identical sides separated by the middle notch. Each side has 200 holes ( each divided into two ‘strips’). One strip is called the terminal strip and the other is called a bus strip (which contains two columns:  one for ground – and one for a supply voltage +.)  The clips on the right and left of the middle notch are each connected in a radial way;  five clips (i.e., beneath five holes) in a row on each side of the notch are electrically connected. On the bus strip the whole row (+ or -) is electrically connected.

Breadboards usually have an adhesive backing and can be interlocked for larger projects. The spacing between the holes is typically 0.1 in (2.54 mm). Integrated circuits (ICs) in dual in-line packages (DIPs) can be inserted to straddle the centerline/notch of the block. Interconnecting wires and the leads of components (such as capacitors, resistors, and inductors) can be inserted into the remaining free holes to complete the circuit. Connecting wire should be 22 AWG (0.33 mm2) solid copper. If you have any CAT5 cable around, that is perfect.

Cat5_Cable

Just cut to the length you need unravel the wire  and straighten it out. The wire ends should be stripped 316 to 516 in (4.8 to 7.9 mm).

Arduino Weather Station

With just a few sensors, one can determine a lot about the weather.

 

BMP085 Barometric Sensor

BMP085

DHT11 Humidity and Temperature Sensor

DHT11

 

 

 

 

 

 

 

The BMP085 can be used to sense barometric pressure and temperature and the DHT11 can be used to sense humidity and also temperature.

Here is what they look like attached to a mini breadboard:

Weather_Station

Arudino Breadboard Weather Station

An FTDI cable (not shown in the above image) can be plugged in at the top left of the breadboard to power this circuit and collect the data.

To collect data in an arduino sketch. the DHT library and the Wire Library will be needed. Both of which are included in the Aruduino IDE.

Here is the arduino sketch (code) to display barometric pressure, humidity and temperature (from both devices) :

Update 11/5/2020, things have changed in the Arduino IDE and libraries since this was first posted. Here is an updated sketch:

 

 

HC-SR04 Distance Sensing

Animals such as bats and porpoises use ultrasound for locating prey and obstacles.  If you have an electronic device that needs to sense distances from objects (like a robot or an automatic door opener) you might consider using an HC-SR04 Sensor Module.

HC-SR04 Ultrasonic Sensor

HC-SR04

No one can sneak up on you with a couple of these and a buzzer attached to your favorite Arduino board. 🙄

The HC-SR04 module sends out an ultrasonic ‘PING’ and then detects its return after ‘bouncing off’ something in the distance. By measuring the round trip time (and knowing the speed that sound travels), a calculation can be made to determine the distance of the object from the HC-SR04.

Here is a public domain Ardunio sketch (the comments show the math involved to calculate the distances, they also show how the HC-SR04 is wired):

 

Measuring Light Intensity

Any camera buffs out there? Sometimes it is handy to be able to measure the amount of light at a particular spot. This is needed sometimes so you can adjust your camera to take the ‘perfect’ picture. Or perhaps you are calculating the amount of solar energy your solar panels will be producing given the amount of light available.

In any case, there  are a couple of components that are very useful for this, the TSL235R light to frequency converter and the BH1750 digital light sensor.

 

TSL235R

TSL235R

BH1750

BH1750

 

 

 

 

 

 

 

 

 

Here are both components on a DIY Arduino breadboard (click on the image to enlarge it):

Arduino LUX Meter

Arduino LUX Meter

Here is the Arduino sketch (code) to get the readings from these components. (Note: the code comments show how these components are wired.) Two libraries are need for this sketch (Wire and BH1750).  The BH1750 library can be downloaded here.  The Wire library is included in the standard Arduino IDE.

 

ESP8266 Wi-Fi Module

My children bought a present for me recently (yes, another birthday, I really am getting older 🙁 ). It is an ESP8266 Module which is a self-contained [IoT] Wi-Fi networking solution. Here are pictures (with the pins labelled):

 

ESP8266

ESP8266 Wifi Transceiver Module

 

 

 

 

 

 

 

 

 

My module comes from Elecrow.com. Since this module is rather new there is not much documentation nor sample code for it, however there is a WEB site dedicated to these devices here :  esp8266.com.

The SDK is here. The Cross-Compiler is here. A very handy ESP8266 ROM Bootloader utility is here.

The module I have takes 5 pins (3.3V, GND, TxD, RxD and CH_PD). The CH_PD pin on my module needs 3.3V. The default BAUD rate for my module is 115200. I connected to it using an FTDI cable and Minicom. (For 3.3V I used an Arduino Nano.)

Here is a good article on hooking it up similar to how I did it with links to new firmware, sample code, newer SDK and other tools.

I plan on eventually attaching mine to an Arduino and using it to send sensor data to a WEB site for data collection.

Since the ESP8266 is a serial device and the debugging ‘view’ to what is going on with it (USB to the Arduino)  is also using a serial connection (FTDI probably), two serial connections are needed. I probably should explain this (especially if you are new to using Arduinos). All Arduino boards have at least one serial port (also known as a UART or USART). The  serial port communicates using digital pins 0 (RX) and 1 (TX) as well as communicating with the computer via USB. So,  if you use USB to communicate with the Arduino, you cannot also use pins 0 and 1 for digital input or output and thus you need to another serial port to both communicate with the Arduino and the ESP8266.

One might be tempted to try the Arduino software serial library to connect to the ESP8266, however the software serial library is too slow to keep up. Two hardware serial connections are therefore needed. An Arduino Leonardo, Due or Mega 2560 have at  least two hardware serial interfaces and would work fine for this purpose.

DIY Dual Relay Circuit

It is sometimes very handy to be able to control mains electric via an arduino to turn things like lights on and off.  [warning]BE VERY CAREFUL hooking up any mains electricity. [/warning]

I built a dual circuit so that two things can be controlled from one board. Here is the fritzing graphic:

 

DIY Dual Relay CircuitOnce built, here is what it looks like:

Dual Relay Circuit TopDual Relay Circuit Back

Click on the above images to enlarge them and see the parts used.

Input (3 pins) comes from a simple arduino circuit (GND, 5V Power and another pin to control the relay state). A simple arduino sketch can toggle the relay off/on.

Here is the fritzing source so you can modify it yourself.

3 PIN HD44780 LCD

One of the problems of connecting an HD44780 LCD

HD44780 LCDto an arduino is the number of pins taken up (usually 6). There is an older article here for hooking up an HD44780 LCD to an arduino with only 3 pins.  (Note: There is an alternate link here as the original link may be down.)

The circuit uses the 74HC595 shift register IC.  I liked the idea and have built several of these circuits.

 

LCD_Shift_Register

 

LCD_Shift_register_1

 

 

 

 

 

Thus I have a handy way of attaching an LCD to arduino projects without taking too many pins.

 

You will need a library for controlling the LCD (attached via the 74HC595 shift register) which you can get here. (Updated:  here)  A sample sketch is shown below. It is the same one here from the original author but I modified it via:

to turn the backlight on. Here is the sketch:

 

DIY Arduino Circuit Board

Shown below is one of my DIY Arduino circuits.

DIY Arduino Circuit FrontDIY Arduino Circuit (Back View)

 

 

 

 

 

 

 

 

The circuit does not have the FTDI chip built in. The FTDI circuit is only needed for programming and cutting out un-necessary components saves a bit of money. The ICSP connection (6 pins comming out the side) on this circuit is perfectly connected to the SparkFun FTDI breakout board:

 

FTDI Breakout 5V

FTDI Breakout 5V

 

 

 

or an FTDI cable:

 

FTDI Cable

 

Here is the Fritzing graphic:

DIY Arduino Circuit Board

DIY Arduino Circuit Board

If you’d like to modify the Fritzing source, get it by clicking here.

Here is the parts list:

 

Quantity Description
 connecting wire
1 AVR Atmega328P
1 16Mh Crystal
2 22pf Capacitor
1 fiber protoboard
1 5mm Red LED
1 0.1 uf Capacitor
1 Base 28 Dip .3 inch
1 1/2 Watt 10K Ohm Resistor
1 1/2 Watt 220 Ohm Resistor
2 16 Pin Header Connector
1 6 Pin Connector 90 degrees

 

If you’d like to experiment on a breadboard before building (soldering) the circuit, here is the breadboard view:

Arduino on a BreadboardYou can  get the Fritzing source here if you’d like to modify it.

Load more