AST-CAN485 WiFi Shield Hookup Guide

Pages
Contributors: Alex the Giant, Ell C, JamesBM
Favorited Favorite 0

Software Setup and Programming

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library or board add-on, please check out our library installation guide and instructions to install the AST-CAN485 board add-on files.

The Programming Mode Selection Switch

The ESP and CAN485 modules are connected using a hardware serial port. The same port is used to program either of the devices. It is therefore necessary to disconnect the serial port in order to program either of the devices. A selector switch is provided in order to make this possible.

If the selector switch is set to RUN, the ESP and CAN485 are connected via a serial port. If the switch is set to PROG, the serial port is disconnected and the devices may be programmed.

Programming Selector Port

Setup Arduino For ESP Programming

There are many options for programming ESP8266 based devices. The approach recommended by this guide is to make use of the ESP8266 Arduino Addon which has been developed by the ESP community. The Addon can be downloaded via the GitHub Repository or by clicking the button below.

This implementation is based on the ESP8266 Thing and the same setup instructions may be used. For more information, refer to the ESP8266 Thing Hookup Guide.

ESP8266 Thing Development Board Hookup Guide

November 5, 2015

An overview of SparkFun's ESP8266 Thing Development Board - a development board for the Internet of Things.

If you have not previously installed an Arduino library, please check out our installation guide.

Installing an Arduino Library

January 11, 2013

How do I install a custom Arduino library? It's easy! This tutorial will go over how to install an Arduino library using the Arduino Library Manager. For libraries not linked with the Arduino IDE, we will also go over manually installing an Arduino library.

Programming the ESP

The following process is followed in order to program the ESP module:

  • Switch the mode selection switch to PROG.
  • Insert a 3.3V FTDI into the FTDI header.
  • Hold down the ESP programming button and upload a sketch.
  • Return the mode selection switch to RUN to reconnect the devices.

Programming the ESP Module

Programming the ESP Module

Image courtesy of AST

Programming the CAN485

The following process is followed in order to program the CAN485 module:

  • Switch the mode selection switch to PROG.
  • Connect a 5V FTDI to the FTDI header on the CAN485 module.
  • Upload a sketch
  • Return the mode selection switch to RUN to reconnect the devices.

Programming the Inserted CAN485 Module

Programming Inserted CAN485 Module

Image courtesy of AST

Examples

The WiFi Shield GitHub Repository includes a few examples which demonstrate the use of the board. After downloading the repository, open up one the examples in the Arduino IDE. Select the CAN485 as the board, the COM port that it enumerated on, and hit upload to test.

Basic Serial Example

This example demonstrates serial communication between and inserted CAN485 and the on board ESP8266. Each device has a built in LED which is controlled by the other device over the serial port. Operation is as follows:

  • The CAN485 sends a command to the ESP every 100 ms.
  • The ESP sets its LED on or off depending on the command.
  • The ESP sends the same command back to the CAN485.
  • The CAN485 sets its LED depending on the command received by the ESP.

In addition to the examples in the WiFi Shield GitHub Repository, there are a number of examples using the ESP8266 in the ESP Arduino Library. These are accessible in the Arduino IDE under File>Examples. Examples may also be found in the ESP Github Community Forum.