The pocket dossier.
Serial contracts, pin numbers, vocabulary and the corrections we made to the original workshop file. Project 2024-2-RS01-KA210-SCH-000271542.
Serial contracts
One line, newline at the end, 9600 baud. Close the Serial Monitor before Processing starts.
| Lab | Arduino prints | Processing expects |
|---|---|---|
| L01 Climate | 24.50,61.00 | two floats, comma |
| L02 Light | 731 | one integer 0–1023 |
| L03 Distance | 50.12 | one float (cm) |
| L03 Radar | 90,42.0 | angle,distance |
| L03 Combo | distance: 42.0 cm | parse the number out |
| L04 Ohm | 1500.0 or -1 | ohms, or OPEN |
| L05 Soil | 610 | one integer, calibrate yourself |
Default pin map
| Lab | Signals |
|---|---|
| L01 DHT11 | DATA → D2 · 10 kΩ pull-up on a bare sensor |
| L02 LDR | junction → A0 · LDR to 5V · 10 kΩ to GND |
| L03 Distance | TRIG D3 · ECHO D2 |
| L03 Servo | signal D9 · red 5V · brown GND |
| L03 Combo | TRIG D6 · ECHO D7 · servo D9 |
| L03 Radar | servo D6 · TRIG D9 · ECHO D10 |
| L04 Ohm | junction → A0 |
| L05 Soil | AOUT → A0 |
Glossary
- ADC
- Analog-to-digital converter. 5 V / 1023 ≈ 4.9 mV per step.
- analogRead()
- Arduino function that samples A0–A5 as an integer 0–1023 (10-bit ADC, 0–5 V).
- Blocking code
- A `for` + `delay` that hogs `loop()` so serial commands (STOP) are ignored until the sweep ends.
- Calibration
- Recording real readings in known states (dry cup, damp cup, wet cup) so 0–1023 becomes a meaning.
- Capacitive probe
- Measures soil as a dielectric. The electronics stay out of the water, so it lasts longer.
- CSV
- Comma-separated values. One line, two numbers: `24.5,61`.
- DHT11
- A low-cost digital sensor for temperature (0–50 °C, ±2 °C) and relative humidity (20–90 % RH, ±5 %).
- HC-SR04
- Ultrasonic ranger. TRIG sends a 40 kHz burst; ECHO stays HIGH for the round-trip time.
- Hysteresis
- Two thresholds — on and off — so a pump does not chatter at one magic number.
- Known / reference resistor
- The resistor whose value you trust (here 1 kΩ). You calculate the other one from it.
- LDR / photoresistor
- A resistor whose resistance drops when more light hits it.
- Library
- Ready-made code you include so you do not have to speak the sensor’s protocol yourself.
- map()
- Processing (and Arduino) helper that remaps a number from one range into another.
- NaN
- “Not a Number” — what `dht.readTemperature()` returns when the read failed. Test with `isnan()`.
- Ohm’s law
- V = I × R. Voltage, current and resistance are three faces of one relationship.
- Open circuit
- No path for current. `analogRead` sits near 0 or 1023 and the formula explodes — guard it.
- Polar coordinates
- A point as (distance, angle). Radar screens are polar plots.
- Pull-up resistor
- A resistor that keeps a signal line HIGH when nothing is pulling it LOW. Needed on a bare 3-pin DHT11.
- pulseIn()
- Waits for a pin to go HIGH (or LOW) and returns the duration in microseconds. Always pass a timeout.
- Relative humidity (RH)
- How much water vapour the air holds compared with the maximum it could hold at that temperature, in %.
- Resistive probe
- Two exposed legs. Current flows through damp soil. Cheap, rusts, the handbook figure looks like this.
- serialEvent()
- A Processing function that runs when a full serial line arrives. Safer than reading inside `draw()`.
- SG90
- Hobby servo. `Servo.write(0…180)` asks for an angle. It needs 5 V and its own GND.
- Speed of sound
- About 343 m/s in dry air at 20 °C. It rises ~0.6 m/s per °C.
- Tolerance
- A 1 kΩ ±5 % resistor may actually be 950–1050 Ω. That error transfers into R_x.
- Voltage divider
- Two resistors in series. The middle tap is a fraction of the supply voltage.
Teacher notes & errata
The original .docx repeated every sketch twice, used HTML entities in Processing, and contradicted itself on the ohm-meter formula. This edition keeps the same five labs and the same photos, and writes one clean copy of each program.
The original Tinkercad figure shows the DHT11 floating above the board — DATA is not drawn to pin 2.
Follow the pin table: VCC→5V, GND→GND, DATA→D2. Use a 10 kΩ pull-up on a bare 3-pin sensor.
The original sketch used HTML entities (`'`) and read serial inside `draw()`.
Use a real newline character and `serialEvent()` with `bufferUntil('\n')`.
Blocking `for` loops meant STOP was ignored until a full 0–180–0 sweep finished.
One `servo.write()` per `loop()`, check serial every step.
`pulseIn()` with no timeout can freeze for about 1 s when there is no echo.
Always pass a timeout, e.g. `pulseIn(echoPin, HIGH, 30000)`.
The handbook text used two opposite Ohm-meter formulas. The diagram labels unknown on the 5 V side.
R_x = R_known × (V_in / V_A0 − 1). Code, wiring table and figure now match.
The text says “capacitive v1.2”; the figure shows a two-prong resistive probe.
Either sensor works on A0. Capacitive probes last longer in wet soil; resistive probes rust. Calibrate dry / damp / wet for *your* probe.
- USB only for the Uno + one SG90. If the board resets, give the servo its own 5 V and a common GND.
- No mains. No 12 V pumps in this workshop edition.
- Dry resistive soil probes after the lesson.
- One COM port owner at a time — Serial Monitor or Processing, never both.
