I am road testing https://www.element14.com/community/roadTests/2184/l/Arduino-MKR-WAN-1300-+-ENV-Sensor-Shield , as part of this blog post I am going over the MKR Environmental Sensor Shield. For this I am using Arduino MKR 1010 which I had in my parts bin (a MRK family of boards that has WiFi and Bluetooth).



The MKR ENV Shield allows a MKR board to acquire environmental data collected by an array of sensors. These sensors are of the latest generation and measure atmospheric pressure, temperature, humidity, UVa intensity, UVb intensity, UV Index and light intensity (in LUX). To help you build projects with locally stored data, this shield has a microSD slot.This shield has all the sensors on one side and should be kept on top of any pile of shields, otherwise it won't be able to measure properly all the values related to light.The first sensor on the left is an LPS22HB and measures atmospheric pressure; the next one is an HTS221 and measures temperature and humidity, next is the reset button that has been replicated on the shield to allow you to reset the MKR board below. The top sensor on the right is a TEMT6000 and measures the Lux of the ambient. The last sensor, just below the Lux, is a VEML6075 and measures the two UV wavelenghts named as A and B. This last sensor is also capable of producing the UV Index through some calculations performed by our MKRENV library. On the left of the board the metallic square is the slot for a microSD.

After connecting the MKR ENV Shield to MKR 1010 board, i ran the sample sketch at https://www.arduino.cc/en/Guide/MKRENVShield, to view the sensor data on serial monitor.

Note : Since I am using Arduino MKR 1010, I had to add to the SAMD Core as part of the Board Manager, for more info check out the guide at https://www.arduino.cc/en/Guide/MKRWiFi1010


The interfaces used by this shield are i2c, analog and SPI. i2c is used by pressure, temperature, humidity and UV; the interface is the usual 12 (SCL) and 11 (SDA) . Analog is for the Lux ambient light sensor and is connected to A2. The SD card relies on SPI interface, therefore it uses 8 (MOSI), 9 (SCK) and 10 (MISO). Other pins used by the shield are the SD CS on D4 to select the microSD, HTS221HTS221 DataReaDY on pin D6 and LPS22HB DataReaDY on pin D7.




image from https://www.arduino.cc/en/Guide/MKRENVShield


As part of the next sketch, I am using OLED display to show the environmental sensor value, and I also connected a Lipo battery to take it outside to check the UV values over the weekend.  The picture below was taken indoors.


#include <Arduino_MKRENV.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
String vals ="";
void setup() {
    if (!ENV.begin()) {
    Serial.println("Failed to initialize MKR ENV shield!");
    while (1);
  // put your setup code here, to run once:
  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  delay(2000); // Pause for 2 seconds
  // Clear the buffer


void loop() {
    // read all the sensor values
  float temperature = ENV.readTemperature();
  float humidity    = ENV.readHumidity();
  float pressure    = ENV.readPressure();
  float illuminance = ENV.readIlluminance();
  float uva         = ENV.readUVA();
  float uvb         = ENV.readUVB();
  float uvIndex     = ENV.readUVIndex();
  vals = "T:"+String(temperature)+ " H:"+String(humidity)+ "\nP:"+ String(pressure)+ " I:" + String(illuminance)+ "\nUva:"+String(uva)+ "Uvb:"+String(uvb)+ "\nuvI:"+String(uvIndex);//
  delay (2000);  


Here is an interesting table I found for the UV index on WHO website (world health organization site) https://www.who.int/news-room/q-a-detail/ultraviolet-(uv)-index, over the weekend I was able to see a UV index of 1.6 on the OLED, which meant it is safe to head out with out sun cream(SPF).

0 to 2You can safely enjoy being outside!
3 to 7Seek shade during midday hours! Slip on a shirt, slop on sunscreen and slap on hat!
8Avoid being outside during midday hours! Makde sure you seek shade! Shirt, sunscreen and hat are a must!




In addition, since i am using MKR 1010 WiFi board, I wanted to host a web server on the WiFi board so that I can see the sensor values using a web page on my Mobile/Laptop


To upload this sketch you will have to perform a Firmware Update on the MKR1010 and also install the WiFiNINA library , refer to the post at https://www.arduino.cc/en/Reference/WiFiNINA

  WiFi Web Server LED Blink

  A simple web server that lets you blink an LED via the web.
  This sketch will create a new access point (with no password).
  It will then launch a new server and print out the IP address
  to the Serial monitor. From there, you can open that address in a web browser
  to turn on and off the LED on pin 13.

  If the IP address of your board is yourAddress:
    http://yourAddress/H turns the LED on
    http://yourAddress/L turns it off

  created 25 Nov 2012
  by Tom Igoe
  adapted to WiFi AP by Adafruit
//Carmelito 06/20/2020 modified to add code for MKR ENV sheild
#include <Arduino_MKRENV.h>
#include <SPI.h>
#include <WiFiNINA.h>
//#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = "XXXXXXX";        // your network SSID (name)
char pass[] = "XXXXXXXXXX";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;                // your network key Index number (needed only for WEP)
String vals ="";
int led =  LED_BUILTIN;
int status = WL_IDLE_STATUS;
WiFiServer server(80);

void setup() {
  if (!ENV.begin()) {
    Serial.println("Failed to initialize MKR ENV shield!");
    while (1);
  //Initialize serial and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  Serial.println("Access Point Web Server");

  pinMode(led, OUTPUT);      // set the LED pin mode

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);

  String fv = WiFi.firmwareVersion();
    Serial.println("Please upgrade the firmware");

  // by default the local IP address of will be
  // print the network name (SSID);
  Serial.print("Creating access point named: ");

  // Create open network. Change this line if you want to create an WEP network:
  status = WiFi.beginAP(ssid, pass);
  if (status != WL_AP_LISTENING) {
    Serial.println("Creating access point failed");
    // don't continue
    while (true);

  // wait 10 seconds for connection:

  // start the web server on port 80

  // you're connected now, so print out the status

void loop() {
  // compare the previous status to the current status
  if (status != WiFi.status()) {
    // it has changed update the variable
    status = WiFi.status();

    if (status == WL_AP_CONNECTED) {
      // a device has connected to the AP
      Serial.println("Device connected to AP");
    } else {
      // a device has disconnected from the AP, and we are back in listening mode
      Serial.println("Device disconnected from AP");
    // read all the sensor values from MKR ENV shield
  float temperature = ENV.readTemperature();
  float humidity    = ENV.readHumidity();
  float pressure    = ENV.readPressure();
  float illuminance = ENV.readIlluminance();
  float uva         = ENV.readUVA();
  float uvb         = ENV.readUVB();
   float uvIndex    = ENV.readUVIndex();
 vals = "<h1><p>Temperature:"+String(temperature)+ " <br/>Humidity:"+String(humidity)+ "<br/>Pressure:"+ String(pressure)+ " <br/>Illuminance:" + String(illuminance)+ "<br/>Uva:"+String(uva)+ "<br/>Uvb:"+String(uvb)+ 
 "<br/>uvIndex:"+String(uvIndex) +"</h1>"; //creating a string to display the sensor values on a webpage

  WiFiClient client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,
    Serial.println("new client");           // print a message out the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        if (c == '\n') {                    // if the byte is a newline character

          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");

            // the content of the HTTP response follows the header:
            //client.print("Click <a href=\"/L\">here</a> turn the LED off<br>");

            // The HTTP response ends with another blank line:
            // break out of the while loop:
          else {      // if you got a newline, then clear currentLine:
            currentLine = "";
        else if (c != '\r') {    // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
    // close the connection:
    Serial.println("client disconnected");

void printWiFiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");

  // print where to go in a browser:
  Serial.print("To see this page in action, open a browser to http://");




Note: my firmware version when writing this blog is 1.2.1


References :