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.
Page 5
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.
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 fits your technical requirements. The final user is the responsable to perform the task of communicatiing the RS-232 module with other commercial devices.
Page 7
Hardware Figure : RS-232 in socket1 The RS-232 Serial / Modbus module can be used with two different 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)
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;...
Page 9
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 v7.1...
3.1. Expansion Radio Board The RS-232 module can use the Expansion Radio Board. The Expansion Board allows to connect two communication modules at the same time in the Waspmote sensor platform. This means a lot of different combinations are possible using any of the wireless radios available for Waspmote: 802.15.4, ZigBee, DigiMesh, 868 MHz, 900 MHz, LoRa, WiFi, GPRS, GPRS+GPS, 3G, 4G,...
Page 11
Dual radio with Expansion Board The API provides a function to initialize the RS-232 module, it is called . This function supports a new parameter ON(socket) which permits to select the socket. It is possible to choose between socket0 and socket1.
4. RS-232 on Plug & Sense! The RS-232 protocol is available for Plug & Sense! as a secondary communication module. This is an optional feature. The RS-232 module is placed on socket 0 by default, being accessible through an additional and dedicated socket on the antenna side of the enclosure.
Page 13
RS-232 on Plug & Sense! Figure : Terminal box probe connected to Plug & Sense! The RS-232 signals are wired on the female DB9 connector and on the Terminal box according to the next table: RS-232 Terminal box probe Figure : Wiring of RS-232 signals on Plug & Sense! -13- v7.1...
1º- Connect any sensor to an existing RS-232 device/network Waspmote can be configured to work as a node in the network, inserting sensor data into the RS-232 bus already present. Waspmote can obtain information from more than 70 sensors which are currently integrated in the platform by using specific sensor boards (e.g: CO, CO...
Page 15
Applications 3º- Connect to the Cloud RS-232 devices Waspmote can be configured to read the information coming from the RS-232 bus and send it wirelessly directly to the Cloud using WiFi, GPRS, GPRS+GPS, 3G and 4G radio interfaces. Figure : Cloud connection -15- v7.1...
Libelium’s library 6. Libelium’s library It is mandatory to include the RS-232 library when using this module. The following line must be introduced at the beginning of the code: #include <Wasp232.h> Waspmote’s API RS-232 files: • Wasp232.cpp • Wasp232.h APIs functions - Private functions: The following functions are executed inside the API functions.
Wasp232 W232 Waspmote RS-232 library and it is public to all libraries. It is used through this guide to show how Waspmote RS-232 library works. When creating this constructor, all the variables are defined with an initial value by default.
7.4. Configuring communication speed RS-232 speed communication can be configured with the values of the RS-232 standard. The RS-232 module has been tested at 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600 and 115200 bps. The maximum supported datarate in the RS-232 module is 115200 bps.
Library functions 7.6. Configuring the parity bit Parity is used in many hardware applications to detect frame errors and is usually generated and checked by the interface hardware. The RS-232 module uses: • : No parity bit NONE • : Even parity EVEN •...
= 12345; W232.send(data); int data = -12345; W232.send(data); 7.7.3. Sending a string The same function can be used for sending string of characters. Example of use: W232.send(“Hello world”); See an example of use here: http://www.libelium.com/development/waspmote/examples/rs-232-01-send-data -20- v7.1...
Library functions 7.7.4. Sending with base function allows to represent the variable in a specific base. You can select binary, octal, byte, decimal, and send() hexadecimal representation. Example of use: int data = 12345; // Send 12345 in binary base. It prints 0110 000 0011 1001. W232.send(data, BIN);...
‘WaspRS232’ class. The buffer is called and the length of the buffer is stored in _buffer _length The function returns the number of bytes stored in the buffer. Example of use: if(W232.receive() > 0) USB.println(W232._buffer, W232._length); See an example of use here: http://www.libelium.com/development/waspmote/examples/rs-232-02-receive-data -22- v7.1...
(W232.available()) while (W232.available()) char data = W232.read(); USB.print(data); See an example of use here: http://www.libelium.com/development/waspmote/examples/rs-232-02-receive-data 7.10. Flushing buffer Flushes the buffer of incoming serial data. The function waits for outgoing data to transmit before clearing the buffer flush() contents.
Certifications 8. Certifications Libelium offers 2 types of IoT sensor platforms, Waspmote OEM and Plug & Sense!: • Waspmote OEM is intended to be used for research purposes or as part of a major product so it needs final certification on the client side.
Example: ------ [RS-232_01] RS-232 Send Data -------- This sketch shows how to send data through RS-232 standard. This standard defines the electrical characteristics of drivers and receivers for use in digital systems. It does not specify or recommend any communications protocol. For a complete communication protocol, please see the Modbus examples.
Page 26
// Use one stop bit configuration W232.stopBitConfig(1); delay(100); // Hello message USB.println(“RS-232 serial communication properly initialized.”); USB.println(“Hello, this is RS-232 communication send example! “); delay(100); void loop() { // Reading the analog input 1 int analog1 = analogRead(ANALOG1); // Reading the analog input 2 int analog2 = analogRead(ANALOG2);...
Page 27
API changelog 10. API changelog Keep track of the software changes on this link: www.libelium.com/development/waspmote/documentation/changelog/#RS_232 -27- v7.1...
Page 28
Documentation changelog 11. Documentation changelog From v7.0 to v7.1: • Added references to the integration of Industrial Protocols for Plug & Sense! -28- v7.1...
Need help?
Do you have a question about the RS-232 and is the answer not in the manual?
Questions and answers