Difference between revisions of "Serial Communication with Explore M3"
(Created page with "In this tutorial, we will look at the hardware serial ports of the Explore M3. Having four hardware serial ports is awesome isn't it? Now you can connect all of your GPS, GSM,...") |
(No difference)
|
Revision as of 18:19, 23 May 2016
In this tutorial, we will look at the hardware serial ports of the Explore M3. Having four hardware serial ports is awesome isn't it? Now you can connect all of your GPS, GSM, Bluetooth, WiFi and what not, without using soft serial ports.
In fact Explore M3 has additional Virtual Serial COM port. The USB port not only is used to upgrade firmware but also it double up has virtual com port. That means you can send messages to the computer without additional USB to Serial chip like the CP2102 or FTDI.
Alright, so lets get started. I will do a simple test example now to print serial port messages and sometime later will will connect multiple serial devices.
Hookup
Simply plug in the USB cable to test the virtual com port and USB to serial converter to other serial ports.
Code
//Example to test all serial ports at once. //Explore M3 has 4 hardware serial ports and 1 USB serial. //Serial --refers to USB Serial //Serial0, Serial1, Serial2 and Serial3 refer to the hardware serial ports. Refer the pinout diagram for more details //This example prints a string on all the serial ports, you need to connect a USB to serial convertor to check messages on hardware serial ports. void setup() { Serial.begin(9600);// refers to USB Serial, the baud rate actually has no meaning. Serial0.begin(9600); Serial1.begin(9600); Serial2.begin(9600); Serial3.begin(9600); } void loop() { Serial.println("Message printed on USB Serial"); Serial0.println("Serial communcation with Serial 0"); Serial1.println("Serial communcation with Serial 1"); Serial2.println("Serial communcation with Serial 2"); Serial3.println("Serial communcation with Serial 3"); }