Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
ESP8266 Robotics Projects

You're reading from   ESP8266 Robotics Projects DIY Wi-Fi controlled robots

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781788474610
Length 210 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Pradeeka Seneviratne Pradeeka Seneviratne
Author Profile Icon Pradeeka Seneviratne
Pradeeka Seneviratne
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Getting Ready FREE CHAPTER 2. Building a Mini Round Robot with Original ESP8266 3. Using Encoders 4. Building a Mini Round Robot with the Feather HUZZAH ESP8266 5. Line-Following Zumo Robot 6. Building an ESP8266 Robot Controller 7. Building a Gripper Robot 8. Photo Rover Robot

Using the Arduino IDE

The Arduino IDE provides an easy way to write sketches for Arduino and other development boards. You can use ESP8266 with the Arduino IDE. First, install the ESP8266 board package on Arduino IDE.

The ESP8266 also supports the following development environments:

  • Use a simple Notepad/GCC setup
  • Fine-tune an Eclipse environment
  • Use a virtual machine provided by Espressif

Installing the Arduino core for an ESP8266 Wi-Fi chip

The Arduino core for ESP8266 includes a set of libraries to do the following things with your ESP8266 Wi-Fi module:

  • Communicate over Wi-Fi using TCP and UDP protocols
  • Set up HTTP, mDNS, SSDP, and DNS servers
  • Perform OTA updates
  • Use a filesystem in flash memory
  • Work with SD cards, servos, SPI, and I2C peripherals

It also allows you to write sketches for ESP8266 with the core Arduino functions and libraries. You can run the sketches directly on ESP8266 without using an external microcontroller board:

  1. Open the Arduino IDE and on the menu bar select File | Preferences.
  1. Type the URL http://arduino.esp8266.com/stable/package_esp8266com_index.json for the ESP8266 board manager package for Arduino in the Additional Boards Manager URLs text box and click on OK to close the dialog box (Figure 1.9):
Figure 1.9: The Arduino IDE preferences
  1. Open the Boards Manager by selecting Tools | Board | Boards Manager. You should see a new entry in the list titled esp8266 by ESP8266 Community (Figure 1.10):
Figure 1.10: The Arduino IDE Boards Manager
  1. At the time of this writing, the Arduino core for ESP8266 Wi-Fi chip supports the following boards:
    • Generic ESP8266 Module
    • Olimex MOD-WIFI-ESP8266(-DEV)
    • NodeMCU 0.9 (ESP-12 Module)
    • NodeMCU 1.0 (ESP-12E Module)
    • Adafruit HUZZAH ESP8266 (ESP-12)
    • ESPresso Lite 1.0
    • ESPresso Lite 2.0
    • Phoenix 1.0
    • Phoenix 2.0
    • SparkFun Thing
    • SweetPea ESP-210
    • WeMos D1
    • WeMos D1 mini
    • ESPino (ESP-12 Module)
    • ESPino (WROOM-02 Module)
    • WifInfo
    • ESPDuino
  2. Click on the Install button to install it on your Arduino IDE. This will take a few minutes to install, depending on your internet speed.
  3. Click on Close to close the Boards Manager dialog box.
  4. Select Tools | Board: "Generic ESP8266 Module" | Generic ESP8266 for board type.
  5. The upload speed should be 115200; however, you can increase it to a higher value by clicking on Tools | Upload Speed and selecting a value greater than 115200.

Hello world

Now, you will write your first program (sketch) for ESP8266 with the Arduino IDE to blink a LED connected to PIN 2 of ESP8266.

You'll need the following things to build the circuit:

  • One LED (any color)
  • One 1 kilo ohm resistor
  • 3V regulated power supply

Connect the components together, as shown in Figure 1.11:

Figure 1.11: The LED blink circuit hook up

Listing 1-1 – Blink a LED

Using your Arduino IDE, type the code as shown in the Listing 1-1:

#define ESP8266_LED 2
    
void setup() 
{
  pinMode(ESP8266_LED, OUTPUT);
}
    
void loop() 
{
  digitalWrite(ESP8266_LED, HIGH);
  delay(500);
  digitalWrite(ESP8266_LED, LOW);
  delay(500);
}  

Then, verify the sketch by clicking on the Verify button. Finally, upload the program by clicking on the Upload button. This will take a few seconds to complete. After completing the flashing, the LED will start to blink.

You have been reading a chapter from
ESP8266 Robotics Projects
Published in: Nov 2017
Publisher: Packt
ISBN-13: 9781788474610
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image