In this stage I integrated the Blynk cloud to the Arduino MKR WiFi 1010 board. I downloaded the latest release of the Blynk library from the link: https://github.com/blynkkk/blynk-library/releases.
I created a template and made a dashboard for visualizing the sensors data. Initially I included temperature, humidity and air quality reading in the dashboard shown in the screenshot below.
Then for programming I started with the example program for Arduino MKR 1010 board that is included in the blynk library.
I made all the necessary modification in the code and uploaded the code to the Arduino MKR board.
This is the arduino program that sends the sensor reading every three seconds in the blynk cloud.
//#define BLYNK_PRINT Serial /* Fill in information from Blynk Device Info here */ #define BLYNK_TEMPLATE_ID "TMPL6ZkZE1Xre" #define BLYNK_TEMPLATE_NAME "warehouse monitoring" #define BLYNK_AUTH_TOKEN "PNyrxA02ZuutaYsfYdUJMj1x_jCM9gLx" #include <SPI.h> #include <WiFiNINA.h> #include <BlynkSimpleWiFiNINA.h> #include "DHT.h" #include "Air_Quality_Sensor.h" BlynkTimer timer; #define DHTPIN 2 AirQualitySensor air_sensor(A0); #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "*************"; //put your wifi name char pass[] = "*************"; //put your wifi password float temperature, humidity; String air_quality = ""; void send_to_blynk() { read_temp_humidity(); //read temperature & humidity read_air(); //read air quality Blynk.virtualWrite(V0, temperature); Blynk.virtualWrite(V1, humidity); Blynk.virtualWrite(V2, air_quality); } void setup() { // Debug console Serial.begin(9600); Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); // You can also specify server: //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80); //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080); dht.begin(); air_sensor.init(); timer.setInterval(3000L, send_to_blynk); //call in every three seconds } void read_temp_humidity(){ temperature = dht.readHumidity(); // Read temperature as Celsius (the default) humidity = dht.readTemperature(); } void read_air(){ int quality = air_sensor.slope(); if (quality == AirQualitySensor::FORCE_SIGNAL) { air_quality = "High pollution!"; } else if (quality == AirQualitySensor::HIGH_POLLUTION) { air_quality = "High pollution!"; } else if (quality == AirQualitySensor::LOW_POLLUTION) { air_quality = "Low pollution!"; } else if (quality == AirQualitySensor::FRESH_AIR) { air_quality = "Fresh air."; } } void loop() { Blynk.run(); timer.run(); }