Header Files
#include Wire.h
#include Adafruit_GFX.h
#include Adafruit_SSD1306.h
#include ESP8266WiFi.h
#include Adafruit_MLX90614.h
#include HX711.h
Variable Declaration
Temperature
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
float maxf, maxc, tafa[15], taca[15],tafo[15],taco[15];
OLED
#define SCREEN_WIDTH 128 OLED display width, in pixels
#define SCREEN_HEIGHT 64 OLED display height, in pixels
#define OLED_RESET -1 Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int ledPin=12;
int inputPin=2;
Weight
float calibration_factor = -4160; -7050 worked for my 440lb max scale setup
float wt;
#define LOADCELL_DOUT_PIN 15 d8
#define LOADCELL_SCK_PIN 0 d3
HX711 scale;
IR Sensor
int val=0;
US Sensor
const int trigP1 = 16; D0 Or GPIO-16 of nodemcu
const int echoP1= 14; D5 Or GPIO-14 of nodemcu
const int trigP2 = 13 ; D7
const int echoP2 = 12 ; D6
long duration;
float distance1, distance2, d[3][15], max1, max2, maxfo, maxco, maxca,
maxfa,finaldist[4];
int i=0, j,k=0,m,z=1; For Loops
int count=0;
void setup()
{
[Link](9600);
delay(1000); wait a second
[Link](SSD1306_SWITCHCAPVCC, 0x3C); initialize with the I2C addr 0x3C
(128x64)
delay(2000);
pinMode(ledPin, OUTPUT);
pinMode(inputPin, INPUT);
[Link](Temperature sensor MLX90614);
pinMode(trigP1, OUTPUT); Sets the trigPin as an Output
pinMode(echoP1, INPUT); Sets the echoPin as an Input
pinMode(trigP2, OUTPUT); Sets the trigPin as an Output
pinMode(echoP2, INPUT); Sets the echoPin as an Input
[Link]();
[Link](4,5);
[Link](LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale();
[Link](); Reset the scale to 0
long zero_factor = scale.read_average(); Get a baseline reading
}
void loop()
{
[Link]();
[Link](1);
[Link](WHITE);
[Link](15, 10);
val=digitalRead(inputPin);Reading IR Sensor Value
if(val==LOW) If Object Detected
{
if(z==1)
{
[Link](Vehicle Status);
[Link]();
[Link](2);
[Link](WHITE);
[Link](0, 15);
[Link](VS Yes );
[Link](5, 40);
[Link](Vehicle No MH 320870);
[Link](nDr. Jayesh Ruikar);
[Link]();
z=0;
}
Reading Ultra Sonic Sensor
digitalWrite(trigP1, LOW); Makes trigPin low
delayMicroseconds(2); 2 micro second delay
digitalWrite(trigP1, HIGH); tigPin high
delayMicroseconds(10); trigPin high for 10 micro seconds
digitalWrite(trigP1, LOW); trigPin low
duration = pulseIn(echoP1, HIGH); Read echo pin, time in microseconds
distance1= duration0.0342; Calculating actualreal distance
digitalWrite(trigP2, LOW); Makes trigPin low
delayMicroseconds(2); 2 micro second delay
digitalWrite(trigP2, HIGH); tigPin high
delayMicroseconds(10); trigPin high for 10 micro seconds
digitalWrite(trigP2, LOW); trigPin low
duration = pulseIn(echoP2, HIGH); Read echo pin, time in microseconds
distance2= duration0.0342; Calculating actualreal distance
while(distance14 && distance24 && i10) Repeat the operation if distance is
less than 4
{
digitalWrite(trigP1, LOW); Makes trigPin low
delayMicroseconds(2); 2 micro second delay
digitalWrite(trigP1, HIGH); tigPin high
delayMicroseconds(10); trigPin high for 10 micro seconds
digitalWrite(trigP1, LOW); trigPin low
duration = pulseIn(echoP1, HIGH); Read echo pin, time in microseconds
d[1][i]= duration0.0342; Calculating actualreal distance
digitalWrite(trigP2, LOW); Makes trigPin low
delayMicroseconds(2); 2 micro second delay
digitalWrite(trigP2, HIGH); tigPin high
delayMicroseconds(10); trigPin high for 10 micro seconds
digitalWrite(trigP2, LOW); trigPin low
duration = pulseIn(echoP2, HIGH); Read echo pin, time in microseconds
d[2][i]= duration0.0342; Calculating actualreal distance
tafa[i]= [Link]();
tafo[i]= [Link]();
taca[i]= [Link]();
taco[i]= [Link]();
i++;
delay(500);
}
while(distance14 && distance24 && i==10)
{
if(count==0)
{
max1=d[1][0];
for(j=1;j10;j++)
{
if(max1d[1][j])
max1=d[1][j];
}
[Link](Distance1 = );
[Link](max1);
max2=d[2][0];
for(j=1;j10;j++)
{
if(max2d[2][j])
max2=d[2][j];
}
[Link](Distance2 = );
[Link](max2);
if(max1max2)
{
finaldist[k]=max1;
}
else
{
finaldist[k]=max2;
}
[Link](Distance Tyre= );
m=k;
[Link](m+1);
[Link]( );
[Link](finaldist[k]);
k++;
Temperature
maxfo=tafo[0];
for(j=1;j10;j++)
{
if(maxfotafo[j])
maxfo=tafo[j];
}
maxfa=tafa[0];
for(j=1;j10;j++)
{
if(maxfatafa[j])
maxfa=tafa[j];
}
[Link](Ambient = );
[Link](maxfa);
[Link](FtObject = );
[Link](maxfo);
[Link](F);
maxca=taca[0];
for(j=1;j10;j++)
{
if(maxcataca[j])
maxca=taca[j];
}
maxco=taco[0];
for(j=1;j10;j++)
{
if(maxcotaco[j])
maxco=taco[j];
}
[Link](Ambient = );
[Link](maxca);
[Link](Tyre Temperature = );
[Link](k);
[Link]( );
[Link](maxco);
[Link](C);
count=1;
i=i+1;
Weight Calculation
scale.set_scale(calibration_factor); Adjust to this calibration factor
[Link](Weight1 );
wt=scale.get_units();
[Link](wt);
[Link]( kg); Change this to kg and re-adjust the calibration factor
if you follow SI units like a sane person
}
}
if(distance1 6 && distance26)
{
i=0;
count=0;
}
}
else
{
digitalWrite(ledPin, HIGH);
if(z==0)
{
[Link]();
[Link](2);
[Link](WHITE);
[Link](0, 15);
[Link](VS No);
[Link](5, 40);
[Link](VS No);
k=0;
z=1;
}
delay(1000);
}
delay(1000);
}