Hello everyone, once again requesting assistance from the comunity.
I managed to put a few libraries together, the code is complete, and it does compile, however the loop stops at the VL6180X TOF sensor.
I will appreciate any help figuring out what is wrong with the code.
The program works when I run it alone.
This is the main code:
#include <Adafruit_MLX90614.h>
#include <DistanceSensor.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "Adafruit_VL6180X.h"
#include <Wire.h>
#include <Adafruit_AMG88xx.h>
// Define pins
const int echoPin = 12;
const int trigPin = 13;
const int buzzer = 9; //buzzer to arduino pin 9
float pixels[AMG88xx_PIXEL_ARRAY_SIZE];
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
DistanceSensor sensor(trigPin, echoPin);
Adafruit_VL6180X vl = Adafruit_VL6180X();
Adafruit_AMG88xx amg;
void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
if (!mlx.begin()) {
while (1)
;
Serial.println("Adafruit VL6180x test!");
if (!vl.begin()) {
Serial.println("Failed to find sensor");
while (1)
;
}
Serial.println("Sensor found!");
;
};
/***************************************************************
TOF continuous mode to take range measurements with the VL6180X.
The range readings are in units of mm.
***************************************************************/
bool status;
// default settings
status = amg.begin();
}
void loop() {
/***********************************************************
This is a library example for the MLX90614 Temp Sensor
***************************************************************/
int ambient0 = 32;
int ambient1 = mlx.readAmbientTempF();
int delta_ambient = ambient1 - ambient0;
if (delta_ambient > 0) {
delay(1000);
/***************************************************************
Ultra Sonic HC-SR04 sensor and prints it to the serial port.
Get distance in cm
***************************************************************/
int distance0 = 14;
int distance1 = sensor.getCM();
int delta_distance = distance0 - distance1;
if (delta_distance > .3) {
/***************************************************************
TOF continuous mode to take range measurements with the VL6180X.
The range readings are in units of mm.
***************************************************************/
float lux = vl.readLux(VL6180X_ALS_GAIN_5);
uint8_t range1 = vl.readRange();
float range0 = 1;
float deltarange = range0 - range1;
uint8_t status = vl.readRangeStatus();
if (status == VL6180X_ERROR_NONE) {
if (deltarange <= 3) {
Serial.println("ICE ");
Serial.println(range1);
delay(100);
/***************************************************************
AMG88xx GridEYE 8x8 IR camera.
Celsius Degrees
***************************************************************/
//read all the pixels
amg.readPixels(pixels);
for (int i = 1; i <= AMG88xx_PIXEL_ARRAY_SIZE; i++) {
if (pixels[i - 1] <= 0) {
//delay a second
delay(1000);
/***************************************************************
Photocell
***************************************************************/
int photo0 = 1;
int photo1 = analogRead(A0);
int delta_photo = photo1 - photo0;
Serial.println(analogRead(A0));
if (delta_photo >= 5) {
Serial.println("***ICE***ICE***");
delay(1000);
/***************************************************************
BUZZER
***************************************************************/
tone(buzzer, 10); // Send 1KHz sound signal...
delay(1000); // ...for 1 sec
}
///PHOTOCELL
else {
Serial.println("WARM CHANGO");
delay(1000);
}
}
}
}
}
}
}
}
This is the code by itself
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "Adafruit_VL6180X.h"
Adafruit_VL6180X vl = Adafruit_VL6180X();
void setup() {
Serial.begin(9600);
Serial.println("Adafruit VL6180x test!");
if (!vl.begin()) {
Serial.println("Failed to find sensor");
while (1)
;
}
Serial.println("Sensor found!");
}
void loop() {
float lux = vl.readLux(VL6180X_ALS_GAIN_5);
uint8_t range1 = vl.readRange();
float range0 = 117;
float deltarange = range0 - range1;
uint8_t status = vl.readRangeStatus();
if (status == VL6180X_ERROR_NONE) {
if (deltarange <= 3) {
Serial.println("ICE ");
Serial.println(range1);
//Serial.println(deltarange);
Serial.println();
delay(100);
} else Serial.println("NO ICE ");
Serial.println(range1);
delay(100);
return;
}
}