ESP8266 and the Arduino IDE

Updated: 30.10.2017
The old guide was out of date and had become a little messy and I had been thinking about redoing it for a while. Also, how I use the ESP8266 has changed and since I am using one as part of a IOT Word Clock I am currently building I thought I would update the guide. So, here is the all new version 2.0. The post for the IOT Word Clock will come later, probably much later…

Part 1: The Esp8266 and setting up the Arduino IDE
Part 2: Control an LED from a web page using Access Point Mode (AP)
Part 3: Control an LED from a web page using Access Station Mode (ST)
Part 4: mDNS
Part 5: wifiManager
Part 6: JavaScript and AJAX
Part 7: More Controls. 3 LEDs
Part 8: Auto Updating Webpage
Part 9: First steps with Websockets
Part 10a: IOT Monitor part 1 – webpage
Part 10b: IOT Monitor part 2 – enhancing the webpage
Part 10c: IOT Monitor part 3 – adding a LCD
Part 10d: IOT Monitor part 4 – the final project

Read more

ESP8266 and the Arduino IDE Part 2: Control an LED from a web page using Access Point Mode (AP)

In the first part I explained how to set up the IDE and got the basic blink sketch working. Here I go through building a web page control panel to control the LED remotely. I will start with a basic web page and then slowly refine it so we end with a simple but elegant control panel.

ESP8266_035_LED_Control_525

 
For this example I will be using the ESP8266 as an access point (AP Mode). This means the ESP8266 will create its own little network which we can connect to. The ESP8266 will then serve a small web page which we can view on a mobile device or any web enabled device such as a laptop.

I still have the LED connected to pin D1 but now I want to turn it on and off from a web page viewed on a mobile device. The web page will need 2 buttons, one for on and one for off. It would be nice if it also showed the current LED status. Something like “LED is on” and “LED is off”. Since this is a first example of a web control the actual web page should be as simply as possible.

I won’t go in to detail about creating web pages, if you are new to this there are many other sites to help you.

Read more

ESP8266 and the Arduino IDE Part 3: Control an LED from a web page using Station Mode

In the previous part we used the ESP8266 in Access Point mode where the ESP8266 generated it’s own mini network. Here we get the ESP8266 to connect to an existing wifi network. To do this we use the ESP8266 in Station Mode (STA). Switching to Station Mode is done by the library automatically so we do not need to mess around.

When using the ESP8266 in Station Mode, the connecting device has to be connected to the same network as the ESP8266. In AP mode, since the ESP8266 creates its own network, other local networks don’t matter.

ESP8266_Part3

Read more

ESP8266-01 Programming Breakout Board

Here is my 5V ESP8266-01 programming breakout board.

ESP8266-01_ProgrammingBoard_002_1200

I am now programming the ESP8266’s via the Arduino IDE and I found using bread boards and wires was annoying, especially because I have a habit of VCC and GND mix up. I have a small pile of dead ESP8266-01s, dead due to shorting them while moving wires around. They are next to the pile of Arduino Nanos I have killed for the same reason.

Since starting to use the ESP8266’s again I have made a couple of breadboard friendly breakout boards. Version 1 worked but moving wires was inconvenient (the ESP8266 was in the way). Version 2 was better but I still had to mess with power, resistors and lots of wires. This lead me to version 3. A fully self contained programming breakout board.

Read more

Arduino with HD44780 based Character LCDs

Introduction
Arduino Libraries
Parallel Interface: Getting Started with a JHD162A 16×2 display
I2C Interface: Getting Started with a J204A 20×4 display with I2C daughter board
Creating custom characters

Introduction

HD44780 compatible LCDs come in many shapes and sizes and two very common ones are the 16×2 and 20×4 characters. Although most screens come with a back light some do not. And although the original interface is parallel some screens come with an I2C adapter/daughter board pre attached (you can buy the I2C adapters separately).

A 16x2 and a 20x4 character LCD display
A 16×2 and a 20×4 character LCD display

Read more

Arduino with Optocouplers

There are many types of optocoupler and you chose one based on the requirements of your circuit. My intention was to create a automatic shutter trigger for my Canon camera, so the circuit was a 5V Arduino and a Canon 40D which has about 3.2V on the shutter release connections. Due to the relatively low voltages there are many suitable optocouplers to pick from. I already had a Fairchild 4N26 so this is the one I used.

4N26

4N26

Optocouplers are digital switches. They work by using an LED emitter paired with a photo detector transistor. This means they can be used to allow one circuit to switch a separate circuit without having any electrical contact between the two. Basically, if you put a current through pins 1 and 2 and light the LED the photo detector transistor detects the light from the LED and allows a current to flow through pins 5 and 4. No current on pins 1 and 2 means current does not pass through pins 5 and 4.

Read more

ESP8266-01 Bread Board Adapter Version 2

I have been playing with the ESP8266 modules again and had made a small adaptor to enable me to use the ESP8266 on a breadboard. It soon became apparent the adaptor was not the best design as it blocked access to some of the rear connections. This lead me to version 2.

ESP8266 Adaptor version 2

Read more

HM-10 Bluetooth 4 BLE Modules

Since I first posted about the HM-10 the firmware has been updated many times and some of the commands have changed. Therefore, I decided to redo the guide. For the main article I am using modules with firmware 5.49 (regular) except the one I am using for the firmware update guide which started with v5.40 and become 5.47.

There have been several firmware updates since this guide was written, as of March 2020 the latest is v707.

 
Updated 2019-08-25
I thought it was time for a minor update.

Read more

HC-06 hc01.comV2.0

HC-06_hc01.com_02_800

ZS-040_HC-06_hc01.comV2.0

The latest zs-040 HC-06 modules have an updated firmware, hc01.comV2.0. This firmware has the following defaults:
– baud rate = 9600
– password = 1234
– nl/cr line endings not required.
– AT commands are required to be in upper case
– Firmware version = hc01.comV2.0
– Name = HC-06
– No parity
– SLAVE mode

Since the Bluetooth hardware is the same as the previous zs-040 HC-06s the Bluetooth specs are also the same. Bluetooth 2.0 EDR, SSP.
These use a slightly different BT module than the other zs-040 boards and there is a blue LED at the top left of the daughter board.

Read more

Arduino to Arduino by Bluetooth

Updated 12.06.2016: Added example 2

In the Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Pair, Bind, and Link post I explained how to connect a HC-05 to a HC-06 so that when powered they automatically made a connection. Here we look at using that connection to get Arduinos talking over Bluetooth. Before continuing you need to have the Arduinos and BT modules set up as per the previous post. Here I am using 2 HC-05s. One in master mode the other in slave mode. The setup process for the slave mode HC-05 is the same as the HC-06 in the previous post.

Arduino2ArdionoBT_Breadboards_01_1600

Read more

Bluetooth Modules

Updated: 21.07.2017

new Bluetooth Modules

There are many very similar Bluetooth modules available and sometimes it can be difficult finding out, not only which one you have, but also how yo use them. Here I look at some of the modules I have and try to show the basic settings.

Getting Started
Connecting To A Computer
Android Apps

Bluetooth 2.0/2.1 EDR Modules
    HC-06 (ZG-B23090W) Bluetooth 2.0 EDR modules
    HC-05 (ZG-B23090W) Bluetooth 2.0 EDR modules
    SPP-C HC-06 / BT06 HC-06
    HC-06 zs-040 hc01.com v2.0
    HC-05 zs-040 hc01.com V2.1
    HC-05 FC-114 and HC-06 FC-114
    HC-05 and HC-06 zs-040 Bluetooth modules

Bluetooth 4 / BLE Modules
    HM-10
    HM-11
    BT05-A mini BLE Bluetooth V4.0 iBeacon
    AT-09 Bluetooth V4.0 CC2541

Read more

ESP8266-01 Bread Board Adapter

Update: 2017-01-15
Although the below adaptor works I found it inconvenient. The rear connectors are blocked by the ESP8288. I therefore built a ESP8266 bread board adaptor version 2

After a lengthy pause I have started playing with the ESP8266 modules again and I was getting annoyed by all the wires when using them on a bread board. So, like others before me, I built a small bread board adapter.

ESP8266BreadbaordAdapter_03_1600

Read more

Android MIT App Inventor – Auto Connect To Bluetooth

In a previous post I showed how to connect an app inventor Android app to a Bluetooth module connected to an Arduino to control an LED. See Turning a LED on and off with an Arduino, a HC-06 and Android

A few people have asked how to make it so that the app auto-connects to the Arduino on start up and I thought I would offer my solution. This example adds to the previous guide.

Read more

App Inventor 2 Pseudo Screens

A!2_Pseudo_Screens_01
As you may have noticed from some of the other posts, I use App Inventor 2 to create Android apps. I do not have time to learn JAVA programming and I found App Inventor an easy way to get in to the world of Android apps. AI2 is not perfect. It is designed as a teaching aid rather than a fully featured Android programming language and as such there are many things missing. However, you can create some surprisingly advanced apps with it. The Arduino Bluetooth Control and the dropController apps were created in AI2 as is the new Bluetooth Control Panel app.

Read more

HC-05 FC-114 and HC-06 FC-114. Part 3 – Master Mode and Auto Connect

Update 19.09.2015
The FC-114 boards I have have the Bolutek firmware. User DS has reported that he/she has FC-114 boards that have the linvorV1.8 firmware. So if the below does not work for you then check what firmware you have.

I may be missing something but I can not get the HC-05 FC-114 boards in to Master Mode and connect to other BT devices with just AT commands. The modules say they have accepted the commands, such as AT+ROLE1 but when I try to connect to other modules I get the error message “Can only be used in Lord Mode”.

The modules accept “AT+ROLE1” and report they have changed mode but they haven’t really.

In an earlier post I mentioned that it looks likes pin 27 or pin 28 has to be pulled HIGH to enter Master Mode and this does indeed seem to be the case. Everything I have tried without pulling the pin(s) HIGH has failed.

HC-05_FC-114_autoConnectSerialMonitor01
They reply with “OK” and if you interrogate with “AT+ROLE” they report “+ROLE=1” but they are actually still in Slave Mode.

Read more

HC-05 FC-114 and HC-06 FC-114. Part 2 – Basic AT commands

Update 19.09.2015
The FC-114 boards I have have the Bolutek firmware. User DS has reported that he/she has FC-114 boards that have the linvorV1.8 firmware. So if the below does not work for you then check what firmware you have.

Since the HC-05 FC-114s and the HC-06 FC-11s share the same firmware the following should work on either module.

The default setting on start up is Slave Mode waiting for pairing or a connection and also accepting AT commands. This means it is fairly simply to start using AT commands.

HC-05 FC-114 & HC-06 FC-114_1200

Read more

HC-05 FC-114 and HC-06 FC-114. First Look

I have just received some new HC-05 and HC-06 Bluetooth modules. These were sold as zs-040s which is the module I actually wanted but I received modules marked FC-114. They share the same breakout board as the zs-040 but have different pins soldered between the Bluetooth module and the breakout board and have a very different firmware.

HC-05_FC-114_&_HC-06_FC-114_001_1600

The small push button switch still has traces to pin 34 and still pulls pin 34 HIGH, however, on the FC-114 boards, pin 34 is a regular IO pin and closing the button switch doesn’t do anything. On the zs-040 boards, closing the button switch and pulling pin 34 HIGH puts the modules in to AT mode. Since the FC-114 starts in AT mode this is no big loss.

It took me a while to figure out the differences.

Read more

HC-05 fs-040 State Pin

This post follows on from Arduino With HC-05 Bluetooth Module in Slave Mode

The STATE pin on the HC-05 zs050 board is connected to the LED 2 pin on the small bluetooth module and the LED 2 pin is used to indicate when there is an active connection. This means the Arduino can connect to the STATE pin and determine when we have a connection. The STATE pin is LOW when the HC-05 is not connected and HIGH when the HC-05 is connected.

As a quick visual indicator you can put a LED + suitable resistor on the STATE pin. When the module is connected the LED will light.

You can also use the Arduino to read the value of the STATE pin.

Read more

Arduino and Visual Basic Part 3: Controlling an Arduino

I am still very new to Visual Basic and I have been surprised at how quickly you can develop working apps. My first attempt resulted in a very basic app to receive data from the Arduino which taught me the basics of serial communication in VB. The next step is two way communication and controlling the Arduino from the VB program. I already have a similar project arduinoBTcontrol, where the Arduino is controlled from an Android app over Bluetooth. So all I need do is tweek the Arduino sketch and recreate the Android app in VB.

Read more

Arduino and Visual Basic Part 2: Receiving Data From the Arduino

This post continues from Arduino and Visual Basic Part 1: Receiving Data From the Arduino

In the previous post we received a stream of data from the Arduino and displayed it inside a Visual Basic text box. This is all well and good but we did not know what the data was, we simply received it and displayed it.

The next step is to send data that has some kind of meaning and display it in an appropriate field. This could be a temperature, a wind speed, a switch state or anything else. In the following example I am using a 1 wire temperature probe (it’s actually got 2 wires…), a potentiometer and a button switch.

Read more

Arduino and Visual Basic Part 1: Receiving Data From the Arduino

After creating the dropControllerBT app and realizing how much easier controlling the dropController device is through the app I started to think about creating a PC app. I haven’t done any PC programming for many years and so I looked at what various options are currently available. Visual Basic kept being recommended for ease of use and quick development. Visual Basic comes as part of Microsoft’s Visual Studio Suite and I initially download and played with Visual Studio Express which in turn lead to Visual Studio Community. Both are free for personal use.

Read more

arduinoBTcontrol

Updated on 06.08.2016

Controlling an Arduino over Bluetooth from Android using App Inventor 2

Here is an example of controlling the Arduino over Bluetooth using a HC-06 bluetooth module and an Android app. The example uses an Arduino Nano but other Arduinos will work just as well. A HC-05 module can be used stead of the HC-06.

arduinoBTcontrol - breadboard

The Android app was created in app inventor and the aia file can be downloaded at the bottom of the page.

Read more

Arduino & ESP8266 Webserver

Update:
This is a very old guide and things have moved on a lot since this was written. One of the main advances is the ESP8266 core for the Arduino IDE. This means the ESP8266 can now be programmed like an Arduino and this is how I use them now, no more messing around with AT commands. For a general overview and examples of using the ESP8266 with the Arduino core see ESP8266 and the Arduino IDE.

 
Here is my first attempt at a web server using the ESP8266. It includes a request count and also a text input field.

ESP8266 webpage

Enter your name and hit submit

ESP8266 webpage 2

Read more