from machine import Pin, ADC, I2C
import ssd1306
import time
# Pin Definitions
BOOST_PIN = 34 # Analog pin to read boost pressure
# Initialize I2C communication
i2c = I2C(scl=Pin(22), sda=Pin(21))
# Initialize OLED display
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
# Initialize analog input for boost pressure
adc = ADC(Pin(BOOST_PIN))
adc.atten(ADC.ATTN_11DB) # Set attenuation level for 0-3.6V range
def read_boost_pressure():
boost_value = adc.read()
# Convert analog value to PSI (assuming linear scaling)
boost_psi = (boost_value / 4095) * 30 # Adjust the scaling factor as needed
return boost_psi
def display_boost_pressure(psi):
oled.fill(0) # Clear the display buffer
oled.text("Boost:", 0, 0)
oled.text("{:.1f} PSI".format(psi), 0, 16)
oled.show()
# Main loop
while True:
boost_pressure = read_boost_pressure()
display_boost_pressure(boost_pressure)
time.sleep_ms(250) # Update the display every second
esp:0
esp:2
esp:4
esp:5
esp:12
esp:13
esp:14
esp:15
esp:16
esp:17
esp:18
esp:19
esp:21
esp:22
esp:23
esp:25
esp:26
esp:27
esp:32
esp:33
esp:34
esp:35
esp:3V3
esp:EN
esp:VP
esp:VN
esp:GND.1
esp:D2
esp:D3
esp:CMD
esp:5V
esp:GND.2
esp:TX
esp:RX
esp:GND.3
esp:D1
esp:D0
esp:CLK
oled1:GND
oled1:VCC
oled1:SCL
oled1:SDA
pot1:GND
pot1:SIG
pot1:VCC