Good Evening,
I am hoping that you can help. As part of my degree in Instrumentation, Measurement and Control, I have been asked to design a simple system using the Arduino Sensor Kit and a breadboard with an additional LED.
I am using the Potentiometer to mimic a hydraulic test pump. The green LED comes on when the test is good, the red LED comes on when test fails. The temperature is also to be monitored and recorded.
The pressure and temperature are showing fine on the serial monitor, but I cannot get them to show on the serial plotter.
Apologies if this is considered a basic concept, but I am a complete novice with this. Any help or advice would be very much appreciated.
Here is a copy of my sketch thus far......
#include "Arduino_SensorKit.h"
#define Environment Environment_I2C
const int potPin = A0;
const int redLEDPin = 6;
const int greenLEDPin = 9;
const int buzzerPin = 5;
const int pressureMin = 0;
const int pressureMax = 250;
const int pressureThreshold1 = 200;
const int pressureThreshold2 = 220;
const int DHTPIN = 3; // Define the pin to which the DHT20 sensor is connected
DHT20 dht20(DHTPIN); // Initialize DHT20
void setup() {
Wire.begin();
Serial.begin(9600);
Oled.begin();
Oled.setFlipMode(true); // Sets the rotation of the screen
pinMode(redLEDPin, OUTPUT);
pinMode(greenLEDPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
// Read the analog value from the potentiometer
int potValue = analogRead(potPin);
// Map the analog value to the pressure range
int pressure = map(potValue, 0, 1023, pressureMin, pressureMax);
// Display pressure and temperature on the OLED screen
Oled.setFont(u8x8_font_chroma48medium8_r);
Oled.setCursor(0, 0);
Oled.print("Press: ");
Oled.print(pressure);
Oled.println(" Bar");
Oled.setCursor(0, 30);
Oled.print("Temp: ");
Oled.print(Environment.readTemperature());
Oled.println(" C");
Oled.display();
// Print pressure and temperature on the same line in the Serial Monitor
Serial.print("Pressure: ");
Serial.print(pressure);
Serial.print(" Bar, Temperature: ");
Serial.print(Environment.readTemperature());
Serial.println(" C");
// Control the LEDs and buzzer based on pressure
if (pressure < pressureThreshold1) {
digitalWrite(redLEDPin, HIGH);
digitalWrite(greenLEDPin, LOW);
noTone(buzzerPin);
} else if (pressure >= pressureThreshold1 && pressure < pressureThreshold2) {
digitalWrite(redLEDPin, LOW);
digitalWrite(greenLEDPin, HIGH);
noTone(buzzerPin);
} else if (pressure >= pressureThreshold2 && pressure <= pressureMax) {
digitalWrite(redLEDPin, HIGH);
digitalWrite(greenLEDPin, LOW);
tone(buzzerPin, 1000);
}
// You can perform additional actions or send the pressure and temperature values to other devices here
delay(3000);
}
Regards
Daryl