<aside>

<aside>
The OS is setup through Raspberry Pi Imager. Here’s a nice tutorial.
<aside>
hostname: bio-logger
username: bal
password: bxxxxxxxRxxxxx
Wifi SSID: RayRayRule (my phone hotspot)
</aside>
I used a 32 GB microSD card, and write the 64-bit RasPberry Pi OS Lite(desktop-free) onto it. The writing process will spend around 5-10 mins. The booting also takes about the same time.
</aside>
<aside>
Some nice terminal to remember
//For ssh into the local pi device:
ssh [email protected]
//By default would be: ssh [email protected]
//for my case, the command code would be: ssh [email protected]
//After connecting to the pi
//for setting wifi or other configuration post-os setup
sudo raspi-config
sudo shutdown now
sudo reboot now
<aside>
Issue
I was having an internet connection issue on the ITP floor
</aside>
</aside>
<aside>
I connected the pi with SSH key in VS code, then started the testing process. I prepared non-additive tangerine juice, and soaked the DFRobot sensor in
<aside>
The below python file is used to test the stability of the sensor readings:
import time
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
# 初始化 I2C
i2c = busio.I2C(board.SCL, board.SDA)
# ADS1115
ads = ADS.ADS1115(i2c, address=0x48)
# Gain = 1 → ±4.096V(適合 0–2.3V TDS sensor)
ads.gain = 1
# Channel 0 (A0)
chan = AnalogIn(ads, 0)
print("ADS1115 A0 voltage reading (Ctrl+C to stop)")
while True:
print(f"Voltage: {chan.voltage:.4f} V | Raw: {chan.value}")
time.sleep(1)
EOF
Below is the voltage acquired every second:
Voltage: 2.0610 V | Raw: 16508
Voltage: 2.3625 V | Raw: 18890
Voltage: 2.3634 V | Raw: 18897
Voltage: 2.3634 V | Raw: 18897
Voltage: 2.3635 V | Raw: 18897
Voltage: 2.3634 V | Raw: 18898
Voltage: 2.3635 V | Raw: 18898
Voltage: 2.3635 V | Raw: 18897
Voltage: 0.7430 V | Raw: 5923 //-->When I moved the sensor out of the juice
Voltage: 0.2375 V | Raw: 1918
The reading seems very stable.
</aside>
<aside>
Since the raw reading was stable and realizable, I use the below code to tested on the TDS transformation formula: tdsValue = (133.42v^3 - 255.86v^2 + 857.39*v) * 0.5
import time
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
# ---------- TDS 轉換公式 ----------
def voltage_to_tds(v):
"""
DFRobot Gravity TDS polynomial
Note: absolute accuracy not critical; relative change matters.
"""
if v < 0:
return 0.0
return (133.42 * v**3 - 255.86 * v**2 + 857.39 * v) * 0.5
# ---------- ADS1115 初始化 ----------
i2c = busio.I2C(board.SCL, board.SDA)
ads = ADS.ADS1115(i2c, address=0x48)
ads.gain = 1 # ±4.096V
chan = AnalogIn(ads, 0) # A0
print("ADS1115 TDS test (Ctrl+C to stop)")
print("Voltage (V) | TDS (ppm)")
print("-------------------------")
while True:
voltage = chan.voltage
tds = voltage_to_tds(voltage)
print(f"{voltage:>7.4f} V | {tds:>8.2f} ppm")
time.sleep(5)
EOF
Below is the TDS data output every 5 seconds:
Voltage (V) | TDS (ppm)
-------------------------
2.3646 V | 1180.41 ppm
2.3646 V | 1180.41 ppm
2.3646 V | 1180.41 ppm
0.4080 V | 158.14 ppm //-->when i raised the sensor from the juice surface
2.3644 V | 1180.17 ppm
2.3645 V | 1180.29 ppm
2.3645 V | 1180.29 ppm
2.3645 V | 1180.29 ppm
2.3645 V | 1180.29 ppm
2.3646 V | 1180.41 ppm
2.3645 V | 1180.29 ppm
2.3644 V | 1180.17 ppm
2.3512 V | 1167.86 ppm //-->when I added equal amount of water into the juice
2.3509 V | 1167.51 ppm
2.3510 V | 1167.63 ppm
2.3502 V | 1166.93 ppm
2.3498 V | 1166.46 ppm
2.3495 V | 1166.23 ppm
2.3494 V | 1166.11 ppm
2.3493 V | 1165.99 ppm
2.3491 V | 1165.88 ppm
2.3491 V | 1165.88 ppm
2.3489 V | 1165.65 ppm
2.3487 V | 1165.53 ppm
2.3487 V | 1165.53 ppm
2.3486 V | 1165.41 ppm
2.3486 V | 1165.41 ppm
2.3484 V | 1165.18 ppm
2.3484 V | 1165.18 ppm
2.3484 V | 1165.18 ppm
2.3483 V | 1165.06 ppm
2.3481 V | 1164.95 ppm
2.3481 V | 1164.95 ppm
2.3481 V | 1164.95 ppm
2.3479 V | 1164.71 ppm
2.3479 V | 1164.71 ppm
2.3481 V | 1164.95 ppm
2.3481 V | 1164.95 ppm
2.3481 V | 1164.95 ppm
2.3481 V | 1164.95 ppm
2.3483 V | 1165.06 ppm
2.3480 V | 1164.83 ppm
2.3480 V | 1164.83 ppm
2.3480 V | 1164.83 ppm
2.3479 V | 1164.71 ppm
2.3480 V | 1164.83 ppm
2.3481 V | 1164.95 ppm
Change the bio-logger code into sampling per minute for the same cup of juice:
Bio logger started (60s interval)
Logging to: /home/bal/logs
2026-02-05 02:07:51 | V=2.3495 | TDS=1166.23
2026-02-05 02:08:51 | V=2.3499 | TDS=1166.58
2026-02-05 02:09:51 | V=2.3501 | TDS=1166.81
2026-02-05 02:10:51 | V=2.3505 | TDS=1167.16
2026-02-05 02:11:51 | V=2.3510 | TDS=1167.63
2026-02-05 02:12:52 | V=2.3512 | TDS=1167.86
2026-02-05 02:13:52 | V=2.3512 | TDS=1167.86
2026-02-05 02:14:52 | V=2.3518 | TDS=1168.33
2026-02-05 02:15:52 | V=2.3521 | TDS=1168.68
2026-02-05 02:16:52 | V=2.3524 | TDS=1168.91
2026-02-05 02:17:52 | V=2.3524 | TDS=1168.91
2026-02-05 02:18:52 | V=2.3527 | TDS=1169.26
2026-02-05 02:19:52 | V=2.3527 | TDS=1169.26
2026-02-05 02:20:52 | V=2.3531 | TDS=1169.61
2026-02-05 02:21:52 | V=2.3533 | TDS=1169.73
2026-02-05 02:22:52 | V=2.3531 | TDS=1169.61
2026-02-05 02:23:52 | V=2.3534 | TDS=1169.85
The fluctuation across 16 mins is 0.3%, which is ideal. My only concern is the fact that there’s a overall tendency of TDS increasing, and I’m not sure if this will be accurate in a 48 hours run.
But also, this might be a result of me adding water suddenly, and the composition is balancing from the un-even state to the even state.
</aside>
</aside>