Projects | Botshop
Simple Arduino esp8266 web server ESP-07 ESP-12

Simple Arduino esp8266 web server ESP-07 ESP-12

Arduino esp8266 web server

To be able to host your own simple web server is easy all you need is the ESP8266 Serial WIFI Module and FTDI232 downloader here is a short description of both and a link on where to find it, An Arduino is not required at all and the ESP8266 board can be a stand alone board and it can be programmed with an FTDIboard. This blog is called Arduino esp8266 web server because you can also connect the wifi module to an Arduino if you want.

The ESP8266-03 is a highly integrated chip designed for the needs of a new connected world. It offers a complete and self-contained Wi-Fi networking solution, allowing it to either host the application or to offload all Wi-Fi networking functions from another application processor.

The USB to TTL serial adapter is based on the high quality and very popular FTDI FT232RL chipset and is an excellent way to connect TTL serial devices to a PC through a USB port and to program your Arduino esp8266 web server.

Unlike most USB to TTL serial adapters, this adapter supports both 5V AND 3.3V operation! Simply set the jumper as required to choose between 5V and 3.3V as labelled on the board.

Part List
  • ESP-07/ESP-12
  • FTDI232
  • Jumper Wires
  • 10k Resistor
  • Pushbutton
  • Breadboard
  • Stripboard
  • 2x 8 pin headers male or female
STEP1: Easy Access

Grab your headers, ESP module and strip board. Cut the Stripboard down to size (8 columns 9 rows), if you are unsure of the size you could cut it afterwards, remember to break the tracks at the bottom. Next solder thin wire to the pads of the ESP module and put each wire in its own column and solder it to the stripboard, next solder in the headers.

This part is very important because the pitch of the module’s pads are 2mm and that of the breadboard are 2.54mm.

esp8226-bb-2

20161123_111632

STEP2: Wiring

Now we will look at the wiring of the module, something to keep in mind is that the module runs on 3.3V. The above mentioned Downloader(FTDI232) supports both 3.3V and 5V, switch the jumper to 3.3V if your downloader does not support 3.3v, you will have to add a voltage divider as shown below, below that is the wiring of the module.

untitled

esp8226-bb-1

 

STEP3: Setup

First things first, if you haven’t got the ESP8266 library yet see “Getting Started with NodeMCU with ESP8266 part 1” on how to install the library, next we have to select the type of board and programmer.

First select the Board Tools -> Board -> Generic ESP8266 Module

board

Next select the programmer Tools -> Programmer -> USBasp

programmer

Now you can connect your programmer and select the port. We’re using an example sketch for this tutorial. File -> Examples -> ESP8266WebServer -> Hello Server. Remember to add your SSID and password.

 

STEP4: Uploading

Now that the wiring is done and your Arduino IDE is set up, we can start the upload process.Uploading to the ESP module could become tricky if you don’t keep track so pay close attention.

Firstly  connect GPIO 0 to ground.

gpio0

If the ESP module is powered up already, press the reset button you installed on the breadboard (pushbutton), if not just power up the module via the USB cable to the downloader. This process boots the  module up in program mode. You can now upload you sketch to the module. Once upload is complete, disconnect GPIO 0 from ground and reset it again, this allows the module to operate as normal. and your upload is complete.

 

STEP5: Connecting To The Server

When you are done uploading and you have removed the wire from GPIO 0 you can open your “Serial Monitor”. It should display the connection status after it has connected to your WIFI-router it will display an IP-address, copy this IP and enter it into your browser’s search bar. It will display the words “Hello From ESP8266” in your browser window.

Arduino Simulator App Review

Arduino Simulator App Review

Arduino Simulator Review – Start Developing Without a Real Arduino Board

We had stumbled across this Arduino simulator, in which you can use both electronics and you Arduino skills to be able to test your circuit before buying the necessary component or just to prevent you having a fried Arduino.

This Arduino simulator is free and works really great, although it has one major downside, the sketches have to be saved in .hex files then imported into the simulator but other than that it’s a really great app to have. Once you get the hang of creating the hex files it is actually not too bad and it becomes quite effortless.

 

 

Below is a simple explanation on how to use the Simulide Arduino simulator.

First, you will have to download Simulide.zip and extract the entire archive to your desired folder. If you run the executable from within the archive some functions will not be available. After extraction process has completed you can run the executable (.exe).

Next, build your circuit, remember to adjust the resistor values, on the left click on Properties and double click on the resistance value.

 

 

After you have built your circuit you can compile your sketch into a HEX file. In your Arduino IDE make sure your sketch is saved then go to Sketch->Export compiled Binary, or press Ctrl->Alt->S.

Now it’s time to load your sketch into the simulator, Right-click on the Arduino and select “Load firmware” and load your HEX flie you just exported, there will be two HEX files “xx.ino.standard.hex” and “xx.ino.with_bootloader.standard.hex” you have to select the one without the bootloader.

You are all set now and you can click on the power button at the top.

Another great Feature

The probe is another great feature the app has. Put the probe on up to four of your output pins and right click on it and select add to plotter.

Please note that this might look like an oscilloscope but it is a logic analyzer and will not work with PWM signals, for PWM signals select “Add to Oscope” instead of “Add to plotter”

How to create a PCB From a Diagram

How to create a PCB From a Diagram

How to create a pcb

Converting a circuit diagram to a Printed Circuit Board (PCB) could prove to be a challenging task.

But luckily with technology today it is fairly simple to complete this task, so there’s no need to be stressed out. We will be doing an easy one for today. It is called an A-Stable Multi Vibrator.

First, I will explain the circuit and the working thereof. Imagine that R2 were absent from the circuit, and suppose Q1 started out being turned on. Then Q2 would have nothing to turn it on, and Q1 would be held on by current through R3, while the R4 and the LED would charge C2. The effect would be that LED1 would come on and stay on, while LED2 would never light.

Now add R2. This will cause C1 to charge to -0.7 volts, until Q2 turns on. Once that happens, the charge on C2 would cause the base of Q1 to go negative, turning it off. When that happens, current flowing through LED1  will start flowing through C1 and the base of Q2, turning it on even harder. Once Q2 has turned on, it will keep Q1 off until C2 charges to -0.7 volts.

Note that while the circuit would have a stable state with both transistors on and both capacitors reverse-biased by 0.7 volts, in practice the winky-blink circuit always starts oscillating rather than entering such a state.

 

We will now start with our process. First download your software HERE for Design Spark or HERE for EAGLE CAD, I use Design Spark most of the time.

 

STEP1: Layout
,,,hFirst we’re going to place all of the components in the correct place.

flip-flop-raw-schem

It can be a bit difficult to find the components, but design spark has a great function under view -> Model Source Bar where you could either look under categories or enter a RS Components stock ,number just select your country and search your components you need, enter the stock number and click use component the software will tell you in which library it save the component and you can go fetch it from there. Marked in red are the two ways to find the components you need.

finding-comps-flip-flop-schem

 

STEP2: Connecting
Next we will connect the components together as shown in the image above, note that instead of a battery I have have added a two pole header, when we have the final product we will have two holes where you can solder in the battery leads or you can put headers in those same holes.

flip-flop-schem

STEP3.1: Converting
From here you have a few options. First option is to simply click on translate to PCB.

translate-to-pcb

and follow the easy steps. Your PCB will look something like this

translated-to-pcb

This does not always come out like expected, in which case we will see how to fix this in Step 3.2

STEP3.2: Converting
If your results was not what you expected in Step 3.1, click on Tools -> Unroute Nets -> All Nets.

unroute

You will see that the tracks has disappeared and now there are thin yellow lines. These yellow lines are to show you how the components were connected.

If you chose not to follow the previous option you will have to insert the components manually again. If you did follow the previous option you now only move the components how you feel fit.

This is what mine looks like yours can be different.

option-12-layout

STEP4: Wiring Compnents
For option 1 go to Tools -> Auto Route Nets -> All Nets

auto-route

and follow the instructions.

For option 2 you have to add the track in manually as in the schematic.

Your end result may look different than mine, but in the end, we achieve the same product.

finale

Note: Using option two may result in errors making the PCB useless. Yes option one may have errors as well but only if your schematic was wrong. Some of these errors may prove to be fatal.

I hope this blog post gave you a starting point on how to create a pcb.

IOT devices NodeMCU with ESP8266 part 2

IOT devices NodeMCU with ESP8266 part 2

IOT devices Part 2

Part 1 can be read here.
In this tutorial we will control electrical devices like fans, lights, etc., using esp8266 from a web browser.  To do that we need to get familiar with IOT devices. The Arduino sketch below shows how you can add HTML code (web page code) to the NodeMcu board so it will give you a web page when connecting to it. The web page the NodeMcu shows you will have buttons you can click on to control relays that in turn will control lights and so on.
What makes this cool is that you can connect to your NodeMcu from your wireless network from any device that got a web browser, including your phone.
Note: Make sure your browser enabled devices and the NodeMcu board is on the same wireless network. Depending on your networking knowledge you can take this a step further and configure your wireless router to do port forwarding and dynamic DNS to access your NodeMcu from anywhere on the Internet. Another good idea is to setup your router to always assign the same IP to your NodeMcu board in your router’s DHCP settings.
The components that you will need for completing this project are very simple, you need to have a NodeMcu module and a relay, make sure you buy a 5v relay, which are very easy to use with esp chips, it doesn’t require an external power supply.
We tested and sell this NodeMCU board.
You can also use this board with the easy and powerful LAU scripting language, more info can be found on the LAU website.

For this example project, I have used a 2 relay circuit. The actual program is written to connect four relays to IOT devices.

You can watch the above video on how it works and how to connect your browser to the IP address returned from esp, all the details are included in this video. The MCU IoT devices make it really easy these days.

Copy the below Arduino code and paste it into your Arduino IDE, then upload the program to your nodemcu or any other esp devices that you are using, make sure to choose the correct port and board. Also, don’t forget to change the SSID and password to your Wi-fi settings.
This program for the esp8266 also will return the status of the device, which will. in turn notify you when it’s connected to the specified network and it will also tell you what IP it received from the router.

#include <ESP8266WiFi.h>

const char* ssid = “Your Network Name”;
const char* password = “Your Password”;

; //
WiFiServer server(80);

void setup() {
Serial.begin(9600);
delay(10);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(0, OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
digitalWrite(0, LOW);
digitalWrite(13, LOW);

// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print(“Connecting to “);
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.println(“WiFi connected”);

// Start the server
server.begin();
Serial.println(“Server started”);

// Print the IP address
Serial.print(“Use this URL to connect: “);
Serial.print(“http://”);
Serial.print(WiFi.localIP());
Serial.println(“/”);

}

void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}

// Wait until the client sends some data
Serial.println(“new client”);
while(!client.available()){
delay(1);
}

// Read the first line of the request
String request = client.readStringUntil(‘\r’);
Serial.println(request);
client.flush();

// Match the request

if (request.indexOf(“/light1on”) > 0) {
digitalWrite(5, HIGH);

}
if (request.indexOf(“/light1off”) >0) {
digitalWrite(5, LOW);

}

if (request.indexOf(“/light2on”) > 0) {
digitalWrite(4, HIGH);

}
if (request.indexOf(“/light2off”) >0) {
digitalWrite(4, LOW);

}
if (request.indexOf(“/light3on”) >0) {
digitalWrite(0, HIGH);

}
if (request.indexOf(“/light3off”) > 0) {
digitalWrite(0, LOW);

}
if (request.indexOf(“/light4on”) > 0) {
digitalWrite(13, HIGH);

}
if (request.indexOf(“/light4off”) > 0) {
digitalWrite(13, LOW);

}
// Set ledPin according to the request
//digitalWrite(ledPin, value);

// Return the response
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“”); // do not forget this one
client.println(“<!DOCTYPE HTML>”);
client.println(“<html>”);
client.println(“<head>”);
client.println(“<meta name=’apple-mobile-web-app-capable’ content=’yes’ />”);
client.println(“<meta name=’apple-mobile-web-app-status-bar-style’ content=’black-translucent’ />”);
client.println(“</head>”);
client.println(“<body bgcolor = \”#f7e6ec\”>”);
client.println(“<hr/><hr>”);
client.println(“<h4><center> Esp8266 Electrical Device Control </center></h4>”);
client.println(“<hr/><hr>”);
client.println(“<br><br>”);
client.println(“<br><br>”);
client.println(“<center>”);
client.println(“Device 1”);
client.println(“<a href=\”/light1on\”\”><button>Turn On </button></a>”);
client.println(“<a href=\”/light1off\”\”><button>Turn Off </button></a><br />”);
client.println(“</center>”);
client.println(“<br><br>”);
client.println(“<center>”);
client.println(“Device 2”);
client.println(“<a href=\”/light2on\”\”><button>Turn On </button></a>”);
client.println(“<a href=\”/light2off\”\”><button>Turn Off </button></a><br />”);
client.println(“</center>”);
client.println(“<br><br>”);
client.println(“<center>”);
client.println(“Device 3”);
client.println(“<a href=\”/light3on\”\”><button>Turn On </button></a>”);
client.println(“<a href=\”/light3off\”\”><button>Turn Off </button></a><br />”);
client.println(“</center>”);
client.println(“<br><br>”);
client.println(“<center>”);
client.println(“Device 4”);
client.println(“<a href=\”/light4on\”\”><button>Turn On </button></a>”);
client.println(“<a href=\”/light4off\”\”><button>Turn Off </button></a><br />”);
client.println(“</center>”);
client.println(“<br><br>”);
client.println(“<center>”);
client.println(“<table border=\”5\”>”);
client.println(“<tr>”);
if (digitalRead(5))
{
client.print(“<td>Light 1 is ON</td>”);

}
else
{
client.print(“<td>Light 1 is OFF</td>”);

}

client.println(“<br />”);

if (digitalRead(4))
{
client.print(“<td>Light 2 is ON</td>”);

}
else
{

client.print(“<td>Light 2 is OFF</td>”);

}
client.println(“</tr>”);
client.println(“<tr>”);

if (digitalRead(0))

{
client.print(“<td>Light 3 is ON</td>”);

}

else

{
client.print(“<td>Light 3 is OFF</td>”);
}
if (digitalRead(13))
{
client.print(“<td>Light 4 is ON</td>”);

}
else
{
client.print(“<td>Light 4 is OFF</td>”);
}

client.println(“</tr>”);
client.println(“</table>”);

client.println(“</center>”);
client.println(“</html>”);
delay(1);
Serial.println(“Client disonnected”);
Serial.println(“”);

}

Internet of things: Arduino + Blynk

Internet of things: Arduino + Blynk

Recently there is quite a swing with the term Internet of things. Wouldn’t it be nice if you can control your appliances with your smartphone.
Lets get started.

Step 1: Video

Step 2: Parts List

The part list for this project is super simple.

All you need is a Arduino, a LED, a computer with internet access and the Blynk app(running on either Android or iOS), and like most sketches the Blynk Library.

Step 3: Connections and Test

1.Connect one end of the usb to your arduino and the other to the computer having internet access.

2.Insert the led to Digital pin 13 as shown.(The shorter one is the cathode and goes to ground)

3.Install the Blynk app from google play store or app store.

4.Download the Blynk library from the link given.

5.Extract the zip file into Arduino’s library folder.

6.Now open the Arduino software,go to examples—>Blynk—->Boards_USB_serial—>Arduino_USB_serial

7.Enter the Authentication token from your email and then hit upload.

8.Go back to the Blynk library folder and under script open the windows batch file

9.Enter the COM port your Arduino is connected to.
Note:Make sure you do not close the command window.

*Now you are ready to blynk*

Step 4: Success!!!

Using a Washer To Steady Joints While Soldering

Using a Washer To Steady Joints While Soldering

If you have “helping hands,” clamping wire leads against a washer, as shown, stabilizes the whole setup dramatically by connecting the two arms with a rigid member, so you can bear down a bit more with the iron without pushing things out of alignment. But the hole in the middle of the washer still allows all-round access to the junction.

If you don’t have helping hands, you can just use a washer, as shown, with a pair of alligator clips (or even small binder clips) as a pretty effective improvised workholding jig for this kind of soldering.

using-a-washer-to-stabilize-soldering

Joining wires, The NASA way

Joining wires, The NASA way

Joining wires

Some commenters on my post about using a washer as a soldering aid noticed my sloppy splicing technique and were kind enough to educate me about the so-called “Western Union splice,” aka the “Lineman’s splice,” which is the preferred method for twisting solid-core wire leads together for inline electrical connections.

Developed during the heydey of the telegraph, the Lineman’s splice is designed for joining wires that will be under tension. It is commonly claimed that, properly made, a Lineman’s splice is stronger than the wires of which it is composed. In any case, it is a time-proven method, and, coolest of all, one of NASA’s Required Workmanship Standards. To wit, in a NASA-approved Lineman’s splice:

  1. The conductors shall be pre-tinned.
  2. There shall be at least 3 turns around each conductor and the wraps shall be tight with no gaps between adjacent turns.
  3. The wraps shall not overlap and the ends of the wrap shall be trimmed flush prior to soldering to prevent protruding ends.
  4. Conductors shall not overlap the insulation of the other wire.

Though the Lineman’s splice was originally used without solder, today soldering is common. And NASA insists on it:

  1. Solder shall wet all elements of the connection.
  2. The solder shall fillet between connection elements over the complete periphery
    of the connection.

This material comes from page 84 of NASA-STD 8739.4 (PDF), which is a great reference if you’re interested in best practices for interconnecting cables and wires.