Libelium RS-232 User Manual

RS-232 Module
Communication Guide
Document version: v7.1 - 02/2017 © Libelium Comunicaciones Distribuidas S.L.
INDEX
1. Introduction ......................................................................................................................................... 4
2. Hardware ............................................................................................................................................. 6
3. Dual radio with Expansion Board ..................................................................................................... 10
3.1. Expansion Radio Board ........................................................................................................................................................... 10
Index
4. RS-232 on Plug & Sense! ................................................................................................................... 12
5. Applications ....................................................................................................................................... 14
6. Libelium’s library ............................................................................................................................... 16
7. Library functions ............................................................................................................................... 17
7.1. Library constructor ................................................................................................................................................................... 17
7.2. Switching the module on .......................................................................................................................................................17
7.3. Switching the module o ......................................................................................................................................................17
7.4. Conguring communication speed ................................................................................................................................... 18
7.5. Conguring the number of stop bits ................................................................................................................................. 18
7.6. Conguring the parity bit ...................................................................................................................................................... 19
7.7. Sending data...............................................................................................................................................................................20
7.7.1. Sending a char ............................................................................................................................................................20
7.7.2. Sending an integer ...................................................................................................................................................20
7.7.3. Sending a string .........................................................................................................................................................20
7.7.4. Sending with base .....................................................................................................................................................21
7.7.5. Sending a long ............................................................................................................................................................21
7.8. Receiving data ............................................................................................................................................................................ 22
7.9. Knowing when new data is available ................................................................................................................................23
7.10. Flushing buer ........................................................................................................................................................................23
8. Certications ...................................................................................................................................... 24
9. Code examples and extended information ..................................................................................... 25
-2- v7.1
Index
10. API changelog .................................................................................................................................. 27
11. Documentation changelog ............................................................................................................. 28
-3- v7.1
Introduction

1. Introduction

This guide explains the RS-232/Modbus module features and functions. This product was designed for Waspmote v12 and continues with no changes for Waspmote v15. There are no great variations in this library for our new product line Waspmote v15, released on October 2016.
Anyway, if you are using previous versions of our products, please use the corresponding guides, available on our Development
website.
You can get more information about the generation change on the document “New generation of Libelium product lines”.

1.1. The standard

The RS-232 standard was rst introduced in 1962 by the Radio Sector of the EIA. The original DTEs (data terminal equipment) were electromechanical teletypewriters, and the original DCEs (data circuit-terminating equipment) were usually modems. When electronic terminals began to be used, they were often designed to be interchangeable with teletypewriters, and so supported RS-232. The C revision of the standard was issued in 1969 in part to accommodate the electrical characteristics of these devices. For many years, an RS-232-compatible port was a standard feature for serial communications, such as modem connections, on many computers. The RS-232 standard is still used to connect industrial equipment (such as PLCs), console ports and special purpose equipment.
The IEEE RS-232 standard denes electrical, signal timing, and size connectors. Use of a common ground, limits RS-232 to applications with relatively short cables. RS-232 connection consisting only of transmit data, receive data, and ground. RS-232 protocol uses bipolar signal. Valid signals are ±3 to +15 volts, the ±3V range is not a valid RS-232 level. Data signals between -3V and -15V represents a logic 1. The logic 0 is represented by a voltage of between +3 V and +15 V.
Figure : RS-232 voltage conversion
-4- v7.1
Introduction
Serial transmission requires synchronization. A logic 0 is sent as a start bit for the synchronization, followed by normally eight bits. After the data itself, a parity bit is sent. It is optional and it can be chosen to have even or odd parity. Finally a stop bit is sent. This is normally one bit long and is used to signify the end of a particular byte. Sometimes two stop bits are required. This is an option that can be set on some equipments.
This list includes some of the more common uses of the standard:
Dial-up modems
GPS receivers (typically NMEA 0183 at 4,800 bit/s)
Bar code scanners and other point of sale devices
LED and LCD text displays
Satellite phones, low-speed satellite modems and other satellite based transceiver devices
Flat-screen (LCD and Plasma) monitors to control screen functions by external computer, other AV
components or remotes
Test and measuring equipment such as digital multimeters and weighing systems
Updating Firmware on various consumer devices
Some CNC controllers
Uninterruptible power supply
Stenography or Stenotype machines
Software debuggers that run on a 2nd computer
Industrial eld buses
-5- v7.1
Hardware

2. Hardware

The RS-232 / Modbus module has been tested with various devices and is compatible with the majority of commercial modules, but this does not ensure the working with all of them. Be sure that the RS-232 module ts your technical requirements. The nal user is the responsable to perform the task of communicatiing the RS-232 module with other commercial devices.

2.1. Electrical features

Board power voltages: 3.3 V
Maximum admitted voltage: -0.3 V to +6 V
Typical data rate: 115200 bps
Temperature range: [ 0 °C, 70 °C ]
Dimensions: 33 x 31.5 mm

2.2. Connection diagram

The RS-232 Serial / Modbus module uses the UART pins, RX and TX, for communication. The Expansion Board allows to connect two boards at the same time in the Waspmote sensor platform. This means a lot of dierent combinations are possible using any of the radios available for Waspmote (802.15.4, ZigBee, DigiMesh, 868 MHz, 900 MHz, LoRa, WiFi, GPRS, GPRS+GPS, 3G, 4G, Sigfox, LoRaWAN, Bluetooth Pro, Bluetooth Low Energy and RFID/NFC) and the RS-232 module.
In the next photo you can see the available sockets along with the UART assigned. The RS-232 module can be connected normally on socket 0, and in socket 1 with the Expansion Board.
Figure : RS-232 in socket0
-6- v7.1
Hardware
Figure : RS-232 in socket1
The RS-232 Serial / Modbus module can be used with two dierent protocols:
1. RS-232 Serial standard (this is the scope of this guide)
2. Modbus protocol (which adds some features; see the Modbus Communication Guide for more details)
-7- v7.1
Hardware

2.3. Consumption

RS-232 module uses a low power transceiver. The board is guaranteed to run at data rates of 120 kbps while maintaining RS-232 output levels. The next table shows the consumption at various baud rates.
Baud rate (bps) Consumption (mA)
300 1,65
600 1,65
1200 1,65
2400 1,67
4800 1,67
9600 1,72
19200 1,8
38400 1,9
57600 2,0
115200 2,26
Figure : RS-232 consumption table

2.4. Connector

The standard recommends but does not make mandatory the D25-pin connector. In the RS-232 module, the connector is a DB9 female. The RS-232 module uses pin 2 to receive data, 3 to transmit and ground pin. The DB9 connector is used in many applications; for example, any PC has a serial DB9 connector. It provides size and cost benets. Also the RS-232 9-pin conguration is sucient in most circumstances, because many of the lines available for RS-232 signaling are rarely used. This means that the DB9 connector is able to provide all the required connectivity for most applications.
Figure : DB9 connector
-8- v7.1
Hardware
The RS-232 module comes with a standard male-female DB9 cable. This cable is useful for connecting the module to other RS­232 devices which have a DB9 male connector.
Figure : Male-female DB9 cable
-9- v7.1
Loading...
+ 19 hidden pages