2

I'm currently trying to create a small diagram with arrows between two nodes and text next to the arrows.

Currently, my diagram looks like this:

enter image description here

But, I would like to have the text at the left of the arrow going from Raspberry Pi to SIM7600E-H 4G HAT.

MWE:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{calc}

\tikzstyle{process} = [rectangle, minimum width=6cm, minimum height=1cm, text centered, text width=6cm, draw=black, fill=orange!30]
\tikzstyle{arrow} = [thick,->,>=stealth]

\begin{document}
    \begin{figure}
        \centering
        \begin{tikzpicture}[node distance=4cm]
            \node (rpi) [process] {Raspberry Pi};
            \node (sim) [process, below of=rpi] {SIM7600E-H 4G HAT};
            
            \node (command) at ($(rpi) !0.5! (sim)$) {Send AT command};

            \draw [arrow] (rpi.west) -- node[anchor=south] {} +(-1.5, 0) |- (sim);
            \draw [arrow] (sim.east) -- node[anchor=south] {} +(1.5, 0)  |- (rpi);
        \end{tikzpicture}
    \end{figure}
\end{document}
5

2 Answers 2

1

You was very close to desired result. JUst need add to text in nodes at arrows:

\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                calc,
                positioning}

\begin{document}
\begin{figure}
    \centering
    \begin{tikzpicture}[
 node distance = 11mm and 5mm,
    arr/.style = {-Stealth, thick},
process/.style = {draw, fill=orange!30, 
                  minimum height=1cm, text width=6cm, align=center}
                        ]
\node (rpi) [process] {Raspberry Pi};
\node (sim) [process, below=of rpi] {SIM7600E-H 4G HAT};
%
\node (command) at ($(rpi) !0.5! (sim)$) {Send AT command};
%
\draw [arr] (rpi.west) -- ++(-1,0) |- (sim) node[pos=0.25, left] {text};
\draw [arr] (sim.east) -- +(1, 0)  |- (rpi);
    \end{tikzpicture}
\end{figure}
\end{document}

enter image description here

Or you after the following:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}

\begin{document}
\begin{figure}
    \centering
    \begin{tikzpicture}[
 node distance = 11mm and 5mm,
    arr/.style = {-Stealth, thick},
    lbl/.style = {font=\small, align=center},
process/.style = {draw, fill=orange!30, 
                  minimum height=1cm, text width=6cm, align=center}
                        ]
\node (rpi) [process] {Raspberry Pi};
\node (sim) [process, below=of rpi] {SIM7600E-H 4G HAT};
%
\draw [arr] (rpi.west) -- ++(-1,0) |- (sim) node[lbl, pos=0.25, left] {Send AT\\ command};
\draw [arr] (sim.east) -- +(1, 0)  |- (rpi);
    \end{tikzpicture}
\end{figure}
\end{document}

enter image description here

2
  • This works, thanks! Just wondering why you added the the lbl style though?
    – juniel
    Jun 24 at 20:12
  • @juniel, that the code of edge label is shorter, i.e that I do not need to rite its code in node's options.
    – Zarko
    Jun 24 at 20:37
1

Maybe you like this.

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[thick,>=stealth]
\path[nodes={draw,fill=yellow!50,minimum width=5cm,minimum height=9mm}]
(0,0)    node (Ras) {Raspberry Pi}
(0,-2.5) node (SIM) {SIM7600E-H 4G HAT}
;
\draw[<-] (Ras)--+(3.5,0)|-(SIM);       
\draw[->] (Ras)--+(-3.5,0)|-(SIM) node[pos=.25,align=center,left]{Send AT \\command};
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.