STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
pt_reading.ino
Go to the documentation of this file.
1#include <esp_now.h>
2#include <WiFi.h>
3#include <Wire.h>
4#include <Arduino.h>
5
6// Define pins for various sensors and connections
7#define LED_BUILTIN 2
8#define SENSOR 27
9#define ONBOARD_LED 2
10#define PT_UPSTREAM 25 // Upstream pressure
11#define PT_TANK 26 // Tank pressure
12#define PT_DOWNSTREAM 27 // Downstream pressure
13#define PT_VENTURI_1 32 // Venturi inlet pressure
14#define PT_VENTURI_2 35 // Venturi throat pressure
15//#define PTDOUT3 35 // PT3 - Adjust pin as needed
16#define SOLENOID_PIN_1 13
17#define SOLENOID_PIN_2 12
18
19// Initialize pressure sensor data var iables
20float pt1 = -1;
21float pt2 = -1;
22float pt3 = -1;
23float pt4 = -1;
24float pt5 = -1;
25
26bool control_active = true;
27
28// String to store incoming serial messages
29String serialMessage = "";
30
31void setup() {
32 // Set up serial communication for debugging
33 Serial.begin(115200);
34 Serial.println("SETUP");
35
36 // Set up sensor pins
42
43 // Set up solenoid pin as output and turn it on
45 digitalWrite(SOLENOID_PIN_1, HIGH); // Keep the solenoid on
47 digitalWrite(SOLENOID_PIN_2, HIGH); // Keep the solenoid on
48
49 // Additional setup code for WiFi, ESP-NOW, etc. can be added here
50}
51
52void loop() {
53 // Read sensor data from pins
59
60 // Print the sensor data for debugging
61 Serial.print(pt1);
62 Serial.println(" ");
63 Serial.print(pt2);
64 Serial.print(" ");
65 Serial.print(pt3);
66 Serial.print(" ");
67 Serial.print(pt4);
68 Serial.print(" ");
69 Serial.print(pt5);
70 Serial.print(" ");
71
72 delay(100);
73}
static SerialStub Serial
Definition Arduino.h:128
#define INPUT
Definition Arduino.h:21
#define HIGH
Definition Arduino.h:19
void pinMode(int, int)
Definition Arduino.h:46
#define OUTPUT
Definition Arduino.h:22
int analogRead(int)
Definition Arduino.h:53
void digitalWrite(int, int)
Definition Arduino.h:48
void delay(int ms)
#define SOLENOID_PIN_2
#define PT_VENTURI_2
#define PT_DOWNSTREAM
void setup()
#define PT_VENTURI_1
float pt1
float pt3
float pt4
bool control_active
String serialMessage
float pt5
#define SOLENOID_PIN_1
#define PT_UPSTREAM
#define PT_TANK
float pt2
void loop()