Closed sandeepmistry closed 5 years ago
Here's a version without the SD card stuff to complicate it:
/*
MKR ENV Shield - Read Sensors
This example reads the sensors on-board the MKR ENV shield
and prints them to the Serial Monitor once a second.
The circuit:
- Arduino MKR board
- Arduino MKR ENV Shield attached
This example code is in the public domain.
*/
#include <Arduino_MKRENV.h>
void setup() {
Serial.begin(9600);
while (!Serial);
if (!ENV.begin()) {
Serial.println("Failed to initialize MKR ENV shield!");
while (1);
}
}
void loop() {
float temperature = ENV.readTemperature();
float humidity = ENV.readHumidity();
float pressure = ENV.readPressure();
float illuminance = ENV.readLux();
float uva = ENV.readUVA();
float uvb = ENV.readUVB();
float uvIndex = ENV.readUVIndex();
Serial.print("Temperature = ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity = ");
Serial.print(humidity);
Serial.println(" %");
Serial.print("Pressure = ");
Serial.print(pressure);
Serial.println(" kPa");
Serial.print("illuminance = ");
Serial.print(illuminance);
Serial.println(" lux");
Serial.print("UVA = ");
Serial.println(uva);
Serial.print("UVB = ");
Serial.println(uvb);
Serial.print("UV Index = ");
Serial.println(uvIndex);
Serial.println();
delay(1000);
}
Should we go with the one you posted above?
float temperature = ENV.readTemperature();
float humidity = ENV.readHumidity();
float pressure = ENV.readPressure();
float illuminance = ENV.readLux();
float uva = ENV.readUVA();
float uvb = ENV.readUVB();
float uvIndex = ENV.readUVIndex();
This scared me a bit, so I opted for split functions.
Should the "lux", be changed to illuminance
in the example?
Serial.print("illuminance = ");
Serial.print(illuminance);
Serial.println(" lux");
I tend to like to use the correct terms, hence "illuminance". Technically it could be a read of luminance, exitance, or illuminance, but now I'm just being a lighting jerk. I guess most people would call it brightness.
As for separate functions, in examples I try not to add a separate function if I can get the basic idea across in the loop. If it's one line to read and one to print, put it in the loop. If it's seven or eight lines and a couple calls to get the result, put it in a separate function.
On Tue, Apr 23, 2019 at 10:21 AM Sandeep Mistry notifications@github.com wrote:
Should we go with the one you posted above?
float temperature = ENV.readTemperature(); float humidity = ENV.readHumidity(); float pressure = ENV.readPressure(); float illuminance = ENV.readLux(); float uva = ENV.readUVA(); float uvb = ENV.readUVB(); float uvIndex = ENV.readUVIndex();
This scared me a bit, so I opted for split functions.
Should the "lux", be changed to illuminance in the example?
Serial.print("illuminance = "); Serial.print(illuminance); Serial.println(" lux");
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arduino-libraries/Arduino_MKRENV/pull/1#issuecomment-485823792, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC45H3UXRPBYKGSO45OXYDPR4LMZANCNFSM4HHX6PHQ .
I tend to like to use the correct terms, hence "illuminance". Technically it could be a read of luminance, exitance, or illuminance, but now I'm just being a lighting jerk. I guess most people would call it brightness.
I'll open another pull request shortly on this topic ...
As for separate functions, in examples I try not to add a separate function if I can get the basic idea across in the loop. If it's one line to read and one to print, put it in the loop. If it's seven or eight lines and a couple calls to get the result, put it in a separate function.
Ok, I've removed the separate functions.
Update example with feedback from @tigoe.
cc/ @simonepda