HC-05 Module sending data problem (Mater + Slave) - arduino

I've been working with a Siemens PLC to send data using RS232. The communication itself is working perfectly, I can monitor it if I connect the PLC to my PC (via a serial comm port).
Now, I wanted to make this communication wireless. I found out about the HC-05 modules and decided to get a few. I set 2 of them up with my arduino (one as master, one as slave, both paired and using the UART 9600,1,0 which is the same that my PLC uses).
I made the following connections:
PC Connection (with a serial comm adapter)
PLC Connection
Let's say I want to send this string:
<SoH>1RZ<CR>
If I check my serial monitor, I get weird stuff. Like:
##NULL©#NUL
The weird thing is that if I just remove the bluetooth modules and connect the PLC's Rx and Tx to the PC's Tx and Rx, respectively, the data is sent flawlessly. So I know that I have everything sorted out on the PLC/PC side.
Has anyone been through this, or does anyone have a suggestion that I can try?

RS232 typically uses ±12V. Negative voltages between -3V and -15V is logic high and positive voltages +3V till +15V is logic low.
Your bluetooth module on the other hand uses TTL logic. With a voltage range of 0-5V.
0-0.8V is low, 2-5V is high.
So
a) you cannot create the necessary voltage levels
b) you risk to destroy your 5V hardware by connecting it to ±12V.
c) you might run into problems as RS232 also has optional mechanisms for flow control. So Rx and Tx might not be enough.
You'll at least need a TTL-> RS232 level shifter for the PLC side and a USB to TTL serial adapter for the PC

Related

Advice needed for connecting multiple arduinos as slave to raspberry pi

I have a project in hand where I need to connect 5 or more arduinos as slaves to Raspberry Pi. Load Cells, Reed Switch, Solenoid lock will be connected to each of the arduino. The arduinos need to send the weight readings when a communication is started by the raspberry pi(master). Only a single arduino will be activated at a time. The arduinos will be placed at a maximum of 6ft distance from the raspberry pi. I need advice regarding how to make this connection. I read that I2C cannot be used for long distances so I am unsure if 6 ft is a long distance for I2C. Next, I am trying to see if a USB would work for my case but the issue is the Pi has only 4 USB slots. So can I use a external USB hub with an external power supply and connected each of the arduinos to the USB hub and provide individual power supply to the arduinos? Will this arrangement work or should I be looking at any other protocol apart from I2C and USB?? Any advice on this will be much appreciated. Thanks a lot for your time.
Arduino (Nano, Uno, Mega etc.) can communicate via SPI, I2C or UART.
Long story short, SPI is not suitable for your application. It is used for fast data transfer over short distances (usually milimeters or centimeters), so mainly for communication between chips mounted on the same PCB or PCBs close together (e.g. display shields).
Using I2C is perfectly fine (let's say up to 10 meters) and in your case it is a way to go. The maximum possible length depends on baud rate, for 10 meters a 9600 baud rate would be OK. The big advantage is that you need only 2 wires to connect all Arduinos, the disadvantage is that only one device can transfer data at the time – in your case, that does not matter.
UART is used for communication with many external modules (GSM, GPS, HMI, ...) and also in combination with USB-TTL chip for communication via USB (virtual COM port). In your case, you can use UART e.g. in combination with external UART-RS485 converter module, but there is no need since you can use I2C.

Connect several COM ports into one

I will have several devices with atmel microcontrollers which Im going to connect to PC using COM. Is there any way to connect several devices into one COM? (Let's assume COM can handle amounts of data I need to transmit and I can choose the way of sending data using COM)
Sure, chain the ATmegas together via serial, and use a single USB-serial device. Combine all the data you need to send, and send it out of the single serial port. In each ATmega, you can either relay all the data to the next one, or use a little more intelligent scheme and only forward data meant for other ATmegas.
The standard RS232 COM port does not allow to connect several devices to one port. Because parallel connection of several devices may change electrical signal characteristics such as voltage levels. You may build a chain of ATmegas as uint128_t suggested or change the physical interface type to RS485.
RX pins: you can connect more RX pins together.
TX pins: you can connect more TX pins together if you ensure that only one is active at any time. Others pins must be configured as input or high impedance. This can be done with a suitable protocol.
The parasitic capacitances of pins connected together sum up - this can eventually limit the transfer speed.

Arduino 2006 how to connect to my laptop?

I have borrowed an Arduino BT-V06 (analogue) from my college IT storage department.
At home I am trying to do some research on this for subsequent work I am going to perform with this Arduino later on. As this model is a 2006 version; my question is, how do I connect it to my laptop? Some sort of adapter? or perhaps shield it with a newer model that has a usb-port?
Because I would like to have it connected to my laptop in order to try out some codes on it.
Thank you very much for your time!
-M
There's at least two options. First, it's set up to be programmed over Bluetooth. So if you have Bluetooth on your laptop, you can connect the two wirelessly. Pins 0 and 1, per the documentation, are TTL serial transmit and receive pins (which are also used for Bluetooth communications), so if you AREN'T connecting via Bluetooth, you could connect a serial to USB adapter so you can connect to your laptop via USB. This reference has this to also say:
"The on-board serial communication between the bluetooth module and the Arduino sketch (running on the ATmega328) needs to be at 115200 baud (i.e. call Serial.begin(115200) in your setup() function). Communication between the bluetooth module and the computer can be at any baud rate.
Communication between the BT module and the computer can be temperamental. You might want to open the serial monitor a couple of seconds after resetting the board. The text of the Arduino getting started guide is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain."

What happen when use rs232 instead of usb in arduino?

I just start a project which is very basic actually. But I need an information. It is about arduino serial communication. Here is the question.
If I connect arduino to computer using TTL to RS232 converter without USB cable then can I still use serial monitor to get some data or what happens ? Assume arduino is programmed before using usb cable, and it is powered externally when usb is not used.
for instance the code just
Serial.println("It is working");
delay(1000);
Thansk a lot.
you will fry it. Standard RS232 use a +-12V level, while arduino use TTL level (0-5V), so you still need a RS232 -> RS232TTL converter. If you use it, then using virtual serial over USB or real hardware serial is exactly the same, except that hardware serial port never appear/disappear when you plug in the arduino (there is not something like plug'n'play in rs232, it is always plugged)

How do I wire a 9 pin serial connection to an Arduino?

My question is pretty straightforward. I've got a big old machine that has an RS-485 connection on the back and I've got a converter from RS-485 to 9 pin serial.
The device I'm connecting to sends out an ACK signal to see if anything is connected. How do I wire up my Arduino (Uno) to the 9 pin serial connector so that I can read the ACK (and in future write back) and display the ACK signal in the Serial Monitor?
I would first check the voltage of the data lines coming from the RS-485 converter. The arduino ports are expecting 0 to 5 volts. Also, look-up the standard for RS-485 to determine what should be on the lines from the RS-485.
Notice, the arduino does NOT directly implement an RS-232 port. Rather, it has a USB port for connecting to a PC. I know that the RS-232 connection does NOT use TTL or 0 to 5V signals, and would question what signal levels are produced by an RS-485.
If the RS-485 does NOT generate 0 to 5 volts, then you will need to get an arduino RS-485 shield.
Finally, in fact, this is what you need to do. I just searched on "RS-485 Arduino" and found multiple hits.
Now, this is the good news, because once you have installed a RS-485 shield then you connect the shield to pins 1&2 on the Arduino and you have a serial connection!!
In most cases you need to wire only RX, TX and Ground signals (RX of Arduino to TX of RS-232 and vice versa). But it really depends on your RS-485 converter, if you need any additional lines. If this converter is half-duplex, may be you will also need to control it with DTR signal. You can use any digital IO on UNO then, and control it in software. Also you need to know the speed of serial port of this old machine, and configure UNO serial port accordingly.

Resources