ThingSpeak Setup
ThingSpeak Setup
ThingSpeak is used as the IoT cloud platform to visualize and log the NPK data collected by the Arduino. Follow these steps to configure your dashboard.
1. Create a ThingSpeak Channel
- Sign in to your ThingSpeak account.
- Click on Channels > My Channels.
- Click the New Channel button.
- Fill in the channel details:
- Name: NPK Sensor Monitoring (or any preferred name).
- Field 1: Nitrogen (N)
- Field 2: Phosphorus (P)
- Field 3: Potassium (K)
- Scroll to the bottom and click Save Channel.
2. Obtain API Credentials
To allow the Arduino to send data to the cloud, you need the unique API Key:
- Navigate to the API Keys tab within your channel view.
- Copy the Write API Key. This will be used in your Arduino sketch.
- Note your Channel ID (found at the top of the channel page).
3. Arduino Code Configuration
In your Arduino sketch, locate the configuration section (usually within a secrets.h file or at the top of the main .ino file) and update the following constants with your ThingSpeak credentials:
// ThingSpeak Settings
unsigned long myChannelNumber = 1234567; // Replace with your Channel ID
const char * myWriteAPIKey = "YOUR_API_KEY"; // Replace with your Write API Key
4. Data Mapping
The code is structured to send the RS485 sensor readings to specific ThingSpeak fields. Ensure your hardware values match the following mapping:
| Sensor Reading | ThingSpeak Field | Unit | | :--- | :--- | :--- | | Nitrogen (N) | Field 1 | mg/kg | | Phosphorus (P) | Field 2 | mg/kg | | Potassium (K) | Field 3 | mg/kg |
5. Visualization
Once the Arduino begins uploading data, you can view the results in the Private View tab of your ThingSpeak channel.
- Charts: Automatically generated line graphs for N, P, and K trends.
- Widgets (Optional): You can add "Gauge" or "Numeric Display" widgets by clicking Add Visualizations to create a more intuitive dashboard for real-time monitoring.
6. Public Sharing (Optional)
If you wish to make your NPK data accessible to others:
- Go to the Sharing tab.
- Select Everyone can view this channel.
- Use the Public View link to share the dashboard.