Arduino and usb wifi

UNO R3 + WIFI ESP8266 + CH340G Arduino and WIFI single board

This specific development board has numerous advantages (which will be covered later) but lacks comprehensive documentation. This surprising because it would seem the ideal development platform for WiFi enabled Arduino projects. Hopefully this project can help with providing more details.

The Arduino ESP8266 WIFI development board

A search for the following text “UNO R3 WIFI ESP8266 ATMEGA328 CH340G” will yield numerous results of sites that sell this particular development board. It can be found on eBay, AliExpress, Banggood and other sites. Cost is approximately 10 to 14 USD before shipping. Before purchasing, make sure that the photograph in this article matches the picture on the selling site.

High level specifications of the board as follows:

  • Model Number: UNO+WiFi-R3-AT328-ESP8266-32MB-CH340G
  • Supply Voltage: 6 to 9V
  • CPU: ATmega328
  • WiFi: ESP8266
  • USB- TTL converter: CH340G
  • Header PinOut: Uno R3

A description of the components on the board in the image below:

Some notes on the components:

  • The board includes a 5V and 3.3 V Voltage regulator to allow for the differing voltage requirements for the ESP8266 and ATMega328
  • Instead of the large USB connector used on a standard Arduino, this board uses a micro USB connector for serial communication and programming
  • The Reset button rests both the ESP 8266 and ATMega328
  • The header pin out is standard Arduino; this allows any Arduino compatible shield to be connected to this development board
  • The board includes a small WiFi antenna. If greater range is required, provision is made for connecting an external antenna

Advantages of The Arduino ESP8266 WIFI development board

It seems that this specific board has several advantages over similar solutions (specifically the WeMos D1 board)

The Arduino pin out allows for connection of many of the Arduino shields available

The different voltage levels are built into the board and become transparent to the User

It allows for easy implementation of WiFi communication in Arduino projects

As there are two processors incorporated on the board, a greater range of processing power is available

Communication between the ATMega328 and the ESP8266 is via the serial lines and utilizes the well known Serial library

Crucial to the operation of the board is the Mode Selection switch, consisting of a 8 switch DIP mounted in the center of the board.

The mode switch allows for four possible settings

Mode 1 – USB Serial connected to ATMega328 for both programming and serial communication

Mode 2 – USB Serial connected to ESP8266 for programming

Mode 3 – USB Serial connected to ESP8266 for serial communication

Mode 4 – ATMega328 and ESP8266 serial connected together, allowing for serial communication between the two devices. The voltage difference between the Arduino and ESP8266 is taken care of in the board.

Читайте также:  Beeline wi fi sim

The ESP8266 requires that GPIO0 is pulled to ground while programming, a requirement not applicable to the ATMega328. Hence there are two separate modes for the ESP8266; switching SW7 on grounds GPIO0.

The DIP switch settings for these modes in the following table:

DIP Switch settings for various modes. X = Switch On Blank = Switch Off

The board has a legend showing the switch settings.

Programming the ATMega328

As a first demonstration, we can program the ATMega328 with the Blink Sketch. Steps as follows:

  • Disconnect the board from power
  • Using a paper clip or pencil point (or any other sharp end device), set the switches to Mode 1. This means that SW3 and SW4 are On, all other switches are off.
  • Call up the Blink Sketch in the Arduino IDE from Examples → Basic
  • Connect the Micro USB port to your computer with a USB to Micro USB cable
  • Upload the Sketch

The ATMega328 will automatically reset and the LED labeled “L” will start blinking.

Success, the ATMega328 is working and can be programmed. Simple.

This part is a little more complicated.

Before programming the ESP8266, you have to ensure that the Arduino IDE you are using is configured to do this type of programming. There are numerous articles on the Internet explaining how to do this. A search of “program ESP8266 from Arduino IDE” will provide many results.

The basic steps are as follows:

  • In File → Preferences, add a url to the Additional Boards Manager: http://arduino.esp8266.com/stable/package_esp8266com_index.json
  • Under Tools → Boards → Boards Manager, Search for ESP8266 and install latest version of “ESP8266 by ESP8266 Community”
  • Once this is done, you should have an option under Tools→ Board for a ESP8266 Boards. Choose Generic ESP8266 Module.

After all that you are ready to get a Blink program working on the board. There appears to be no built in LED for the ESP8266 on this board, so you have to connect an LED to demonstrate the blink program.

The ESP header on the board allows access to GPIO12 from the ESP8266, this will be used for connecting the LED. The pin functions are given on the rear of the board. Connect a 330 Ohm (or similar) and LED wired in series between GPIO12 and the GND pin on the Arduino header.

Follow the following steps:

  • Make sure the Arduino IDE is set for the Generic ESP8266 Module
  • Remove power from the board. Set the switches to Mode 2. This means that SW5, SW6, SW7 are On. all other switches are Off.
  • Connect the Micro USB port to your computer with a USB to Micro USB cable
  • Upload the Sketch Blink ESP8266
/*
ESP8266 Blink
Blink the LED on the ESP8266 module
This example code is in the public domain

The external LED on the ESP8266 module is connected to GPIO12

*/

void setup()
pinMode(12, OUTPUT); // Initialize pin 12 which is GPIO12 as an output
>

// the loop function runs over and over again forever
void loop()
digitalWrite(12, LOW); // Turn the LED off
// low is off on the ESP8266-12
delay(1000); // Wait for a second
digitalWrite(12, HIGH); // Turn the LED on by making the voltage HIGH
delay(2000); // Wait for two seconds (to distinguish between low and high)
>
bool toggle;
String incomingString;

void setup()
pinMode(12, OUTPUT); // Initialize pin 12 which is GPIO12 as an output
toggle = false;

Serial.begin(115200); //All serial communication with ESP8266 at 115200 baud
>

void loop()

if (Serial.available() > 0)
// read the incoming string from the Arduino
incomingString = Serial.readString();

// If the incoming string from the Arduino equals "change" then we toggle the LED
if (incomingString.equals("change"))
digitalWrite(12, toggle); // Turn the LED off or on
toggle = !toggle;
>
>
delay(50); // Wait for half second
>

If successful, the Arduino IDE will produce the following message – “Hard resetting via the RTS pin”

Remove power from the board and toggle SW7 to off. This takes the ESP8266 out of programming mode.

Restore power to the board and the LED connected to GPIO12 should start blinking. Success!

Communicating between the ATMega328and ESP8266

The ATMega328 and ESP8266 can communicate via the serial bus include in both chips. This communication is bilateral; ATMega826 can send information to the ESP8266 and vice versa.

To demonstrate this, a simple circuit connected to the ATMega328 can activate an LED connected to the ESP8266. Circuit diagram below.

The programming steps as follows.

  • Set the DIP switch to Mode 1 (SW3 and SW4 are On )with power removed. Restore power and upload the Arduino Sketch “ArduinoESPCommunication
  • Remove power and set the DIP switch to Mode 2 (SW5, SW6, SW7 are On)
  • Change Arduino IDE to ESP8266 programming mode and upload the sketch “ESPRecieveCommunication”
  • Remove power and set the dip switch to Mode 4 (SW1 and SW2 are On)
  • Restore power
const int buttonPin = 2; // the number of the pushbutton pin
int buttonState = 0;
void setup()

// Initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200); //All ESP8266 serial communication at 115200 baud
>

void loop()
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH)
// Send a message to the ESP8266
Serial.write("change");
// Flash the built in LED to confirm that button push was registered
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(250);

>
else
delay(25);
>
>

Pressing the push button will cause the ATMega328 built in LED to flash and the LED connected to the ESP8266 will come on.

Pressing the push button again will flash the built in LED and turn off the LED connected to the ESP8266

Communication between the ATMega328 and the ESP8266 uses the Serial.write(“change”) and Serial.readString() commands. See the sketches for more details.

It is uncertain why this specific development board is not more popular (based on the number of articles and documentation available on line). It has several advantages over trying to implement an Arduino with a separate ESP8266 board and provides dual processing power.

Good luck using this board!

Источник

Arduino and usb wifi

Rather than buying something, make it.

Browse thousands of projects created by the Arduino community

794253 views • 605 comments • 415 respects

Arduino Based Mini CNC 2D Plotter

165263 views • 40 comments • 214 respects

212584 views • 90 comments • 57 respects

157127 views • 63 comments • 60 respects

Ultrasonic Security System

162843 views • 142 comments • 188 respects

Measure Heart Rate and SpO2 with MAX30102

321746 views • 154 comments • 244 respects

Share and Compete in Project of the Month!

Unlock amazing rewards by submitting your project today.

Create projects fast, with no coding

Import, use and customize ready-made templates for your IoT projects

Dream big, we will take care of the rest

See what you can create with Arduino Cloud

White Mountains Regional High School

Discover how this school is working with remote sensing applications that allow them to do things like automate lighting, regulate temperature, adjust humidity, and check on the greenhouse from their phones.

Smart ovens take a leap into the future

How a strong partnership and the Arduino Portenta Machine Control led historical company Rinaldi Superforni to revolutionize their business

The new Portenta X8 and Max Carrier

Industrial Arduino and Linux combined to get the best of both worlds

Источник

Оцените статью
Adblock
detector