Introduction
In this post, we will show you how to perform HTTP requests with the POST method to send information to an external server.
The information is received from analog data of a potentiometer filtered by software.Â
If you want to know more about analog data filtering do not hesitate to follow this post!
Requirements
Ethernet PLC or 20 I/Os PLC:
Ethernet PLC >>>Â Â Â 20 I/Os PLC >>>
ArduinoHTTPClient library:
Download ArduinoHTTPClient library on Github >>>
Industrial Shields Power supply:
Industrial Shields Accessories >>>
Industrial Shields boards:
Install Industrial Shields boards >>>
Connections
To know the part related to the connection of the potentiometer, the Analog data filtering and also the SD card datalog, follow this blog post .
The Ethernet PLC will act as a client making write requests to the server to send the analog data received periodically. This will be connected via Ethernet to a Router with access to the server where the received data is written.
So that, at the Hardware level we will only require an ethernet connection between the Arduino-based PLC and the server.
Software
This sketch creates a client in our PLC based on Arduino responsible for making POST requests to the URL path composed of server IP + "/ analog-value": 192.168.1.209:1880/analog-value.
The values that we will show in the server will be the filtered analog results received from a potentiometer connected to the Arduino based PLC to be able to test the global operation of this test.Â
The post requests that the server waits follow this structure: {"value": data}.
Â
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Â
Http requests to a server using an Arduino based PLC