ETHERNET SHIELD Arduino–Upload LM35 Data to THINGSPEAK
his post demonstrates how to upload temperature data from LM35 sensor to the server on THINGSPEAK.Before starting you should know how to connect the shield to
Uploading LM35 Temperature Data to ThingSpeak using Arduino and Ethernet Shield
Overview:
This article explains how to upload data obtained from an LM35 temperature sensor to the ThingSpeak server using Arduino and an Ethernet Shield. Users must first know how to connect the Shield to the network.
What is an Ethernet Shield?
The Ethernet Shield acts as a wired gateway between your Arduino and the Internet, enabling data exchange with external networks.
Methods of Connecting the Shield:
- Direct Connection: Connect the Ethernet Shield directly to an RJ-45 port on your router.
- Indirect Connection: Connect the Shield to your laptop via a cable, then connect the laptop to the router via Wi-Fi. This article uses the direct connection method.
IP Configuration:
Set a static IP for the Ethernet Shield so that it is assigned the same IP every time the router reboots. To do this, run CMD on your PC, enter ipconfig /all to find the default gateway IP, and then assign a fixed IP based on this in the DHCP settings.
Uploading Data:
Connect the first pin of the LM35 to the 5v on the Ethernet Shield, the third pin to GND, and the second pin to the A0 analog pin. Upload the following code to the Arduino. You will need to change the gateway IP of your router and the IP of the Shield, as well as the ThingSpeak API to suit your environment.
ThingSpeak Configuration:
Sign up at ThingSpeak.com and create a new channel under 'My Channels'. Enter a name and description for your channel, and set a field name such as 'Temperature'. Enable Public View and note the Write API key under the API Keys tab. Replace the ThingSpeak API key in your Arduino code with the one you noted.
Result Verification:
Open the serial monitor of the Arduino to check if the data is being uploaded to the server. Click on 'Public View' in your ThingSpeak channel to see the graphical representation of the temperature data uploaded from the LM35.
Troubleshooting:
If the Arduino fails to connect to the network, check the IP address settings again.
Additional Information:
The HTTP POST method is used to write data to the server. The ThingSpeak server only accepts data in string type. This article explains the process of converting data into a string and uploading it to ThingSpeak.