Pseudocode
Assign sensor to pin A3
Assign BLE service with UUID 180C
Assign BLE characteristic with UUID 2A56, read and notify, max 50 bytes
Set delay value to 250
Set time window for average to 10 seconds
Set max readings to (1000 / delay) * time window
Set scale factor to 5.0
Set reference voltage to 5.00
Set forward voltage drop to 1.8
Set estimated voltage to forward voltage + 0.45
Set reading index to 0
Set total readings to 0
Set peak voltage to 0
Start Serial
If BLE fails to begin stop execution
Set BLE name to VoltageSensor
Advertise BLE service and characteristic
Loop forever
Read analog voltage from sensor
Convert to output voltage using 1023 and reference voltage
Scale to input voltage using factor
If voltage is less than or equal to estimated voltage multiply it by 2
Else add estimated voltage
Add adjusted voltage to readings array
Update average of readings
If adjusted voltage is greater than peak voltage set peak voltage to it
If adjusted voltage >= 5 set water condition to Harsh
Else if >= 2 set water condition to Moderate
Else if >= 0.8 set water condition to Mild
Else set water condition to No waves
If adjusted voltage > 0.3 set status to Generating
Else set status to Idle
Print adjusted voltage and water condition
Print average voltage
Print peak voltage
Format data string as adjusted voltage, water condition, average, peak, and status
Send data string over BLE
Wait delay time before next loop




