Prerequisites for Real-Time Weather Data Collection

Simuli Virtual Lab

First, we need to create a new instance on the Simuli Virtual Lab platform which has an Arduino Uno, a W5500 Ethernet Module and an SHT2X Temperature and Humidity Sensor.

Log in to your Simuli account and navigate to the Simuli Virtual Lab. Here we will create a new emulated instance of the Arduino Uno. Click on the Launch button under the Arduino to get started.

This will open the configuration menu. First, provide a name for the project. Then, we will add the SHT2X Temperature and Humidity Sensor and the W5500 Ethernet Module by selecting them from the list of available components. Finally, review that the name for the project and the selected sensors are correct and click on the Launch button.

Once we have clicked on the Launch button, a new instance of the Arduino Uno will be created. It can take a few minutes for this process to be completed.

While our new instance is being created, let's move forward to creating a ThingSpeak account and configure it.

ThingSpeak

Before we can start using ThingSpeak, we first need to create a MathWorks account, Go to this page and click on No account? Create one! in the login prompt. This will open a new form for creating your account. Finish filling out this form and click on Continue.

Now the page will prompt you to check your email. An email verification link should be in your inbox. Open your email account and click on the given link. Now your email has been verified. Now go back to the the original form and click on continue. Now the form will ask you to provide a password. Choose a strong password and click on continue. Our MathWorks account is now ready and linked to ThingSpeak. Click on OK and you will be redirected to the Channels page.

Now let's create our channel, where we will actually send the data. Click on the Channels button in the navigation bar and then click on My Channels. This will bring you back to the channels page. Now let's create our first channel. Click on the New Channel button.

This will open a new form where we can configure the channel. ThingSpeak supports up to 8 data fields per channel. For our purposes we'll be using two of them, one for sending the Temperature data and the other for sending the Humidity data. Provide a name for the channel, for instance, Weather Data. Rename the first data field to Temperature. Then, enable the second field as well and rename it to Humidity. We don't need the rest of the fields, so scroll down to the bottom and click on Save Channel. Our channel is now ready to receive the data. You will also notice that ThingSpeak has created graphs for visualising the incoming data. Once our data is on the ThingSpeak platform, we can also run MATLAB analysis on our data.

Since we will be communicating with ThingSpeak via MQTT, we add an MQTT device from the Devices Menu. This will ask you to link the device to a channel and genrate the MQTT username, password and clientID that will be used in our Arduino code later.

Arduino IDE

If you have not set up your Arduino IDE, follow the guide linked below.

pagePrerequisites for Arduino Development

Before using MQTT to publish our data to ThingSpeak, we need to install the relevant library. For this, open your Arduino IDE and go to Tools and then to Manage Libraries.... This will open up the library manager, here we can search for PubSubClient, select the library and install it. Then, search for Sodaq_SHT2x.h library select and install it. Now we are ready to communicate with ThingSpeak via MQTT.

Now we are ready to program our Arduino Uno.

Last updated