Day 4: UDP bidirectional
In yesterday’s project, the UDP communication was tested in one direction, i.e. from the board to the PC. In this program, the module is set so that communication in the other direction is possible as well, almost like in a chat. Behind the fourth door of the Advent calendar, there is a resistor with 1 kΩ (brown, black, red). The component is not used in today’s test yet, but should be kept for later.
The program: Day4_UDPBidirectional
Today’s program generally only contains a very small change that has a great effect on the communication with the UDP protocol. When you upload the program, another access point with which you can connect to a PC is generated. Again, you will need Packet Sender or a comparable program. Start the program and make the same settings as yesterday (File-> Settings->Network: Enable UDP Server, Port 90). Then you need to enter the address of the module (192.168.4.1) in the main window in the IP address field, set the port to 91 and select the item UDP in the dropdown menu farther to the right. When these settings have been made and the serial monitor has been opened, you can send the first message to the module by entering, e.g., Hi in the field labelled with ASCII.
! Attention: Some MAC-Users reportet a bug in the PacketSender-Software. This bug doesn’t allow you to change the ports. If you have problems with this bug you can change the ports in the Arduino program. All you have to do for todays project is to change the line 54 from
succes &= sendCom(“AT+CIPSTART=\”UDP\”,\”192.168.4.255\”,90,91″, “OK”);
succes &= sendCom(“AT+CIPSTART=\”UDP\”,\”192.168.4.255\”,5505,5506″, “OK”);
If you click Send now, the Serial Monitor will show
The message has been received. You can now also answer, by using the CIPSEND command again, e.g.
Chatting with two devices is possible, though very impractical.