Professional Documents
Culture Documents
Serial Communication Between STM32F103C8 and Arduino UNO Using RS-485
Serial Communication Between STM32F103C8 and Arduino UNO Using RS-485
LOG IN
Search
Serial Communication
Between STM32F103C8 and
Arduino UNO using RS-485
Pramoth Thangavel
P
Author
of 5V.
C
ONS
VCC 5V
Non-inverting Receiver
Input
A
Non-Inverting Driver
Output
Operating voltage: 5V
On-board MAX485 chip
A low power consumption for the RS485
communication
Slew-rate limited transceiver
5.08mm pitch 2P terminal
Convenient RS-485 communication wiring
All pins of chip have been lead to can be
controlled through the microcontroller
Board size: 44 x 14mm
Components Required
STM32F103C8
Arduino UNO
MAX485 TTL to RS485 Converter
Module - (2)
10K Potentiometer
Push Button - 3
LED - 3
Resistors
Breadboard
Connecting Wires
Circuit Diagram
RS-485 STM32F103C8
DI PA9 (TX1)
DE
PA3
RE
R0 PA10 (RX1)
VCC 5V
GND GND
A To A of Slave RS-485
B To B of Slave RS-485
DI 1 (TX)
DE
2
RE
R0 0 (RX)
VCC 5V
GND GND
A To A of Master RS-485
B To B of Master RS-485
Programming STM32F103C8
& Arduino UNO for RS485
Serial Communication
Arduino IDE is used for development and
programming of both boards i.e. STM32 and
Arduino UNO. But make sure you have selected
the corresponding PORT from Tools->Port
and Board from Tools->Board
Tools->Board. If you find any
difficulties or doubt then just refer
Programming your STM32 in ARDUINO IDE.
The programming for this tutorial consists of
Two section one for STM32F103C8 (Master)
and other for Arduino UNO (Slave). Both the
codes will be explained one by one below.
STM32F103C8 as Master
In Master side, the status of the Push Button is
read and then serially written those values to
the RS-485 bus through the Hardware Serial
Ports 1 (PA9, PA10) of STM32F103C8. Also
there is no external library needed as of now.
The Arduino has all the necessary library for
serial communication.
Serial1.begin(9600);
digitalWrite(enablePin, HIGH);
if (button1val == HIGH)
{
int num1 = 1;
Serial1.println(num1);
}
else
{
int num = 0;
Serial1.println(num);
}
digitalWrite(enablePin, LOW);
Code
Master Code:STM32F103C8
void setup()
pinMode(enablePin, OUTPUT);
pinMode(button1,INPUT);
pinMode(button2,INPUT);
pinMode(button3,INPUT);
delay(10);
void loop()
if (button1val == HIGH)
int num1 = 1;
Video
Tags
Comments
Submitted by Jay on Wed, 05/20/2020 - 14:21
Permalink
Good demo