HI All -
Thanks in advance for taking out your valuable time to read and suggest improvements.
We have been working on outdoor dust measurement with Ultrasonic and VL6180X.
We have 2 installations
- first one includes Ultrasonic sensor and VL6180
- second one just VL6180
Both of the above sensors are firmly fixed with fixtures - and they are not subjecting to any movement and are absolutely stable(fixing).
We have set up the first unit as under
- We have used external timers to switch on the units at specific times,it will power up the units till measurements are taken and are switch off
- while we test outdoor (switched on/off the system more than 30 times) - we get consistent readings(we are controlling the LUX to have constant lux levels - we are switching them on only during nights with external LED lights)
Now the issue starts
- Values of VL6180X are not consistent inspite of maintaining constant LUX levels - wondering what's happening
In the second unit
- We are not controlling LUX levels but readings are fairly consistent, but some times there is change in the consistency due to varying LUX (that is understandable)
Now, I,need help to understand - where things are going wrong with the first sensor.
Best,
Ramesha
LP_Sensor1_18_11_2018_e1.ino (8.33 KB)
LP_Sensor2_ILS_US_18_11_2018_e2.ino (9.61 KB)
#include <EEPROM.h>
#include <SoftwareSerial.h>
SoftwareSerial GPRS(10, 11);// RX, TX
#include <Wire.h>
#include "Adafruit_VL6180X.h"
Adafruit_VL6180X vl = Adafruit_VL6180X();
int error = 0, i = 0, sample = 5, k = 0, l = 0, j = 0,
Start = 0;
unsigned int value = 0, val; //71-change 66,60,64
float lux = 0;
String contact[4] {
"8123745416",
};
void setup()
{
GPRS.begin(115200);
Serial.begin(115200);
GPRS.println("AT");//AT commands
delay( 2500);
GPRS.println("AT+CMGF=1");//AT for messages mode
delay( 2500);
if (! vl.begin()) {
Serial.println("sensor not found");
errorsms(1);
}
delay(100);
EEPROM.get(100, val);
Serial.print("\tvlx6180- pre-memory_value = ");
Serial.println(val);
Start = 0;
}
void loop()
{
while (Start <= 3) {
i = 0; j = 0; k = 0; l = 0; value = 0;
value = sensorCheck();
delay(10);
Serial.print("thickness=");
Serial.println(value);
Serial.println(lux);
Start++; if (Start == 3) {
if ( value <= val + 3) {
Serial.print(" vlx6180-new_value = "); Serial.println(value);
Serial.println("pass");
SMS(value, 1);
delay(2000);
SMS (val, 2);
EEPROM.put(100, value);
delay(100);
EEPROM.get(100, val);
Serial.print("\tvlx6180- present-memory_value = ");
Serial.println(val);
}
else
{
Serial.print("vlx6180-pre_value = "); Serial.println(val);
Serial.println("error");
SMS (value, 3);
delay(2000);
SMS (val, 2);
EEPROM.put(100, value);
delay(100);
EEPROM.get(100, val);
Serial.print("\tvlx6180- present-memory_value = ");
Serial.println(val);
}
}
}
}
int sensorCheck()
{
int reference = 61;
// Serial.print(" checking");
float range = 0;
uint8_t status;
lux = vl.readLux(VL6180X_ALS_GAIN_5);
Serial.print("Lux: "); Serial.println(lux);
while (i < sample) {
range = vl.readRange();
status = vl.readRangeStatus();
Serial.println(range);
// Serial.print("status"); Serial.println(status);
if (status == VL6180X_ERROR_NONE) {
// Serial.print("Range: "); Serial.println(range);
}
if ((status >= VL6180X_ERROR_SYSERR_1) && (status <= VL6180X_ERROR_SYSERR_5)) {
Serial.println("System error");
errorsms(2);
}
else if (status == VL6180X_ERROR_ECEFAIL) {
Serial.println("ECE failure");
errorsms(3);
}
else if (status == VL6180X_ERROR_NOCONVERGE) {
Serial.println("No convergence");
errorsms(4);
}
else if (status == VL6180X_ERROR_RANGEIGNORE) {
Serial.println("Ignoring range");
errorsms(5);
}
else if (status == VL6180X_ERROR_SNR) {
Serial.println("Ambient conditions too high ");
errorsms(6);
}
else if (status == VL6180X_ERROR_RAWUFLOW) {
Serial.println("Raw reading underflow");
errorsms(7);
}
else if (status == VL6180X_ERROR_RAWOFLOW) {
Serial.println("Raw reading overflow");
errorsms(8);
}
else if (status == VL6180X_ERROR_RANGEUFLOW) {
Serial.println("Range reading underflow");
errorsms(9);
}
else if (status == VL6180X_ERROR_RANGEOFLOW) {
Serial.println("Range reading overflow");
errorsms(10);
}
delay(1000);
k = k + range;
i++;
}
l = k / sample;
Serial.print("average -");
Serial.println(l);
if (lux >= 1200 && lux <= 1225 )l = l - 2;
else if (lux >= 1226 && lux <= 1250) l = l - 18;
else if (lux >= 1251 && lux <= 1275) l = l - 25;
else if (lux >= 1276 && lux <= 1300) l = l - 29;
else if (lux >= 1301 && lux <= 1370) l = l - 30;
else if (lux >= 1601 && lux <= 1850) l = l - 10;
else l = l;
j = reference - l;
return j;
}
void SMS(int Thickness, int f) {
Serial.println("SENDING.............");
int mem = 0;
Serial.flush();
GPRS.flush();
delay(200);
Serial.print("Thickness=");
Serial.println(Thickness);
Serial.print("day&error=");
Serial.println(f);
for (int i = 0; i < 4; i++) {
Serial.println(i);
GPRS.println("AT+CMGF=1\r");
delay(1000);
Serial.println(contact*);*
_ Serial.println("AT+CMGS="+91" + contact + ""\r");_
_ GPRS.println("AT+CMGS="+91" + contact + ""\r");
* delay(1000);
if (f == 1) {
GPRS.println("ILS");
Serial.println("ILS");
Serial.println("today");
GPRS.println("Today");
GPRS.println("lux");
GPRS.println(lux);
Serial.println(lux);
}
else if (f == 2) {
GPRS.println("ILS");
Serial.println("ILS");
Serial.println("yesterday");
GPRS.println("Yesterday");*_
* }*
* else if (f == 3) {*
* GPRS.println(lux);*
* GPRS.print(Thickness);// The SMS value*
* GPRS.println("mm ");*
* GPRS.println(" - Unusual dust level wait next 24-hours to verify ");*
* Serial.println(" - Unusual dust level wait next 24-hours to verify ");*
* }*
* else if (f == 4) {*
* Serial.println("US");*
* GPRS.println("us ");*
* }*
* if (Thickness >= 0 && Thickness <= 19) {*
* GPRS.println("In dust level is ");*
* Serial.println("In dust level is ");*
* GPRS.print(Thickness);// The SMS value*
* Serial.println(Thickness);*
* GPRS.println("mm ");*
* Serial.println("mm");*
* }*
* else if ( Thickness >= 20 && Thickness < 30) {*
* GPRS.println("In dust level is ");*
* Serial.println("In dust level is ");*
* GPRS.print(Thickness);// The SMS value*
* Serial.println(Thickness);*
* GPRS.println("mm ");*
* Serial.println("mm ");*
* GPRS.println("Plan cleaning.");*
* Serial.println("Plan cleaning.");*
* }*
* else if (Thickness >= 30 && Thickness <= 91) {//91=reference*
* GPRS.println("In dust level is");*
* Serial.println("In dust level is ");*
* GPRS.print(Thickness);// The SMS value*
* Serial.println(Thickness);*
* GPRS.println("mm ");*
* Serial.println("mm ");*
* GPRS.println("Dust exceeded Clean immediately.");*
* Serial.println(" Dust exceede Clean immediately.");*
* }*
* else if (Thickness <= 0) {*
* GPRS.print(Thickness);// The SMS value*
* GPRS.println("mm ");*
* GPRS.println(" - Unusual dust level wait next 24-hours to verify ");*
* Serial.println("please check the reference ");*
* }*
* else {*
* Serial.println("please check the reference ");*
* }*
* delay(100);*
* GPRS.write( 0x1a ); // ctrl+Z character*
* GPRS.println((char)26);*
* delay(5000);*
* }*
}
int errorsms(int error) {//error sms
* for (int i = 0; i < 4; i++) {*
_ Serial.println(contact*);
Serial.println("AT+CMGS="+91" + contact + ""\r");
GPRS.println("AT+CMGS="+91" + contact + ""\r");
delay(1000);
if (error == 1) {
GPRS.println("Failed to find sensor");
Serial.println("Failed to find sensor");
}
else if (error == 2) {
GPRS.println("System error");
Serial.println("System error");
}
else if (error == 3) {
GPRS.println(" laser convergence estimate fail");
Serial.println(" laser convergence estimate fail");
}
else if (error == 4) {
GPRS.println("No convergence of laser triangulation");
Serial.println("No convergence of laser triangulation");
}
else if (error == 5) {
GPRS.println("Ignoring range");
Serial.println("Ignoring range");
}
else if (error == 6) {
GPRS.println("Ambient light too high");
Serial.println("Ambient light too high");
}
else if (error == 7 || error == 9) {
GPRS.println("Range underflow");
Serial.println("Range underflow");
}
else if (error == 8 || error == 10) {
GPRS.println("Range overflow");
Serial.println("Range overflow");
}
delay(100);
GPRS.write( 0x1a ); // ctrl+Z character*
* GPRS.println((char)26);
delay(1000);
}
// Start =15;
}
//mobilenumber 9972362598*
//pin connection
//red ->+5
//black->gnd
//green->sda
//yellow->scl
//purple->echo-7
//blue->trigger-6
//vlx6180
//black->scl
//yellow->vcc
//brown->sda
//orange->gnd
//ultrasonic
//yellow->gnd
//brown->vcc
//orange->echo
//pruple->trigger
//old_sensor
// red-vin
//black- gnd
//orange - scl
//brown- sda_
Please post you code in tags. Not doing so corrupts the code (see the smiley faces?).
The code in reply #1 does not even compile
exit status 1
call of overloaded 'println(String [4])' is ambiguous
There is a whole pile of errors regarding the contact variable.
Note:
Don't use single character variable names for global variables. The letter i occurs 353 times in your code and the letter l 393 times. Nearly impossible to find where those variables are used.
Barometric pressure difference will affect ultrasonic measurements.
Humidity will affect ultrasonic measuments.
Temperature will affect ultrasonic measurements.
Finally, didn’t try to figure out your code, but you stated your measuring dust, and your using term “thickness” in the code, so you also have different types of dust in the air which will affect ultrasonic measurements..
Have not had much experience with TOF sensors, definately would try a makeshift heater circuit to see if that solves some possible enviorment variables.
sterretje:
The code in reply #1 does not even compile
exit status 1
call of overloaded 'println(String [4])' is ambiguous
There is a whole pile of errors regarding the *contact* variable.
Note:
Don't use single character variable names for global variables. The letter *i* occurs 353 times in your code and the letter *l* 393 times. Nearly impossible to find where those variables are used.
The string is 4 nos in actual, for not showing the phone numbers - just one phone no, this part we are aware.
Thanks
rockwellramesha:
The string is 4 nos in actual, for not showing the phone numbers - just one phone no, this part we are aware.
Thanks
That's not the problem; you can add the 4 numbers as shown below and it will still not compile.
String contact[4] {
"8123745416",
"8123745416",
"8123745416",
"8123745416",
};
sterretje:
That's not the problem; you can add the 4 numbers as shown below and it will still not compile.
String contact[4] {
"8123745416",
"8123745416",
"8123745416",
"8123745416",
};
Thanks