AST-CAN485 WiFi Shield Hookup Guide

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

Introduction

What would make the AST-CAN485 even better? WiFi! In order to further the communications capabilities of the CAN485, we present the AST-CAN485 Wifi Shield. The shield is based on the Sparkfun ESP8266 thing and allows for a CAN485 module to communicate over Wifi.

SparkFun AST-CAN485 WiFi Shield

WRL-14597
Retired

Required Materials

To follow along with this tutorial, you will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Tools

Depending on your setup, you will need a soldering iron, solder, and general soldering accessories to solder pins to the AST-CAN485. You will also need a flat head and wire strippers to connect wires to the screw terminals.

Soldering Iron - 60W (Adjustable Temperature)

Soldering Iron - 60W (Adjustable Temperature)

TOL-14456
$16.50
16
Pocket Screwdriver Set

Pocket Screwdriver Set

TOL-12891
$4.50
5
Solder Lead Free - 15-gram Tube

Solder Lead Free - 15-gram Tube

TOL-09163
$3.95
4

Wire Strippers - 20-30AWG

TOL-14763
3 Retired

Suggested Reading

We recommend checking out the AST-CAN485 Hookup Guide to get started with the board. Depending on your setup, you may need to install custom libraries and board add-ons.

AST-CAN485 Hookup Guide

March 1, 2018

The AST CAN485 is a miniature Arduino in the compact form factor of the ProMini. In addition to all the usual features it has on-board CAN and RS485 ports enabling quick and easy interfacing to a multitude of industrial devices.

If you aren’t familiar with the following concepts, we also recommend checking out these tutorials before continuing.

Working with Wire

How to strip, crimp, and work with wire.

ESP8266 Thing Development Board Hookup Guide

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

Three Quick Tips About Using U.FL

Quick tips regarding how to connect, protect, and disconnect U.FL connectors.

Hardware Overview

Input Power

The AST-CAN485 WiFi Shield provides screw terminals for your power, RS-485 signals, and CAN bus signals, presoldered to the board for fast and secure connections.

screw terminal highlight

The input voltage range is 7-24VDC. The input voltage is regulated down to 5V to supply power the CAN485 board, as well as 3.3V to power the ESP8266.

Integrated power highlight

ESP8266

Based on the SparkFun ESP8266 Thing, you can use either the PCB trace antenna, or the U.FL connector if housed in a metal enclosure.

ESP8266 highlight

Programming Switch

Because the UARTs are connected together for the CAN485 board and the ESP8266, a switch is used to separate the RX and TX signals. When programing either the ESP8266 or CAN485 board, move the switch over to the PROG position, and after the upload is complete, toggle the switch to the RUN position.

Switch highlight

Speaking of programming, the ESP8266 runs off of 3.3V logic, so to program the ESP8266, a 3.3V USB to UART bridge is used.

FTDI programming header hightlight

AST-CAN485 Serial Port

A header breaks out the Software Serial port used by the CAN485. This can be used as a debugging serial port or to connect other devices.

Software Serial Highlight

Pinouts

The pinout for the WiFi Shield is shown below:

Listed PinOuts

Image courtesy of AST

Schematic

The schematic below shows the layout of the interconnects between an inserted CAN485 module and the integrated ESP module.

Schematic of connection between inserted CAN485 module and the integrated ESP module

Image courtesy of AST

The primary interface between the CAN485 and the ESP8266 is a serial port. It operates on hardware serial port 0 on the CAN485 rather than the traditional Software Serial port. The reason for this is that it enables higher speed communications between the two devices. The trade-off of this feature is that it uses the main serial port, which is also used to program the CAN485 and is broken out on its FTDI header. This means that in order to program the CAN485 module, while it is inserted, the serial port must be disconnected. For this reason, the mode selection switch was added which allows for the rx and tx lines to be disconnected. In a similar way, the same serial port is used to both program the ESP8266 and communicate with the CAN485. The mode selection switch also enables the ESP to be programmed by disconnecting it from the CAN485.

Hardware Hookup

The AST-CAN485 WiFi Shield comes with headers pre-soldered to the board. Insert the CAN485 as shown with the CAN485's FTDI header close to the ESP8266.

WiFi Shield with CAN485 Inserted

Powering The Board

The Shield can be powered through the screw terminals. While the power input is intended to be supplied with 24V, an input voltage of 7-24V may be used.

An integrated power supply regulates the 24V input power down to 5V which is used to provide power to the inserted CAN485 board. This is further regulated down to 3.3V to power the ESP module.

It is also possible to power the board using the raw input pin of the CAN485 module. However, use of an external 24V supply is recommended and is the intended use case.

Providing power to the board

Image courtesy of AST

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.

Resources and Going Further

For more information, check out the resources below:

AST-CAN485 WiFi Shield

AST-CAN485 Dev Board

Need some inspiration for your next project? Check out some of these related tutorials:

OBD II UART Hookup Guide

How to start working with the OBD-II Uart board.

CAN-BUS Shield Hookup Guide

A basic introduction to working with the CAN-Bus shield.

Getting Started with OBD-II

A general guide to the OBD-II protocols used for communication in automotive and industrial applications.

Or dig in further with According to Pete for more information about RS485.