Build it step by step
0 of 6 doneWire the sensor and screen
Connect both on the I2C bus as in the table.
Check the readings
Open the Serial Monitor at 115200 and watch the median distance on the display.
Mount in the lid
Point the sensor straight down, away from the walls and the fill pipe.
Save empty
With the bin empty send "e" in the Serial Monitor.
Save full
Fill it, then send "f".
Add the low-level LED
Fit it where it is visible when you walk by.
How do you build a fodder silo level meter?
A VL53L1X laser sensor at the top of a fodder bin shows how full it is, so you reorder before it runs out. You need Arduino Nano, VL53L1X long-range ToF sensor, SSD1306 OLED Display, LED 5 mm red and Resistor 220 Ω. It takes 6 steps and about 75 minutes.
- Level
- Intermediate
- Time
- About 75 min
- Parts
- 5
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- DisplaysBuy
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 220 Ω × 1
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| VL53L1X VIN, GND | Nano 5V, GND | Power (check your board accepts 5 V on VIN, otherwise use 3V3) |
| VL53L1X SDA, SCL | Nano A4, A5 | I2C |
| OLED SDA, SCL | Nano A4, A5 | I2C, same bus |
| OLED VCC, GND | Nano 5V, GND | Power |
| Nano D6 | 220 Ω resistor then red LED, to GND | Low-level warning |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "VL53L1X" by Pololu and "U8g2". The EEPROM stores the calibration so it survives power cuts. Keep the sensor window clean of dust. If it sits in a metal lid, set it flush with the inside surface so the beam is not clipped.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <Wire.h>
#include <VL53L1X.h>
#include <EEPROM.h>
#include <U8x8lib.h>
VL53L1X sensor;
U8X8_SSD1306_128X64_NONAME_HW_I2C oled(U8X8_PIN_NONE);
const byte LED = 6;
int emptyMM = 1500, fullMM = 200; // distance when empty and when full, saved in EEPROM
const byte N = 15;
int median() {
int v[N];
for (byte i = 0; i < N; i++) { v[i] = sensor.read(); delay(60); }
for (byte i = 1; i < N; i++) { int k = v[i]; int j = i - 1; while (j >= 0 && v[j] > k) { v[j + 1] = v[j]; j--; } v[j + 1] = k; }
return v[N / 2];
}
void setup() {
Serial.begin(115200);
Wire.begin();
pinMode(LED, OUTPUT);
sensor.setTimeout(500);
sensor.init();
sensor.setDistanceMode(VL53L1X::Long);
sensor.setMeasurementTimingBudget(50000);
sensor.startContinuous(50);
EEPROM.get(0, emptyMM); EEPROM.get(2, fullMM);
if (emptyMM < 100 || emptyMM > 4000) { emptyMM = 1500; fullMM = 200; }
oled.begin();
oled.setFont(u8x8_font_chroma48medium8_r);
}
void loop() {
if (Serial.available()) { // send e with the silo empty, f with it full
char c = Serial.read();
if (c == 'e') { emptyMM = median(); EEPROM.put(0, emptyMM); Serial.println("Empty saved"); }
if (c == 'f') { fullMM = median(); EEPROM.put(2, fullMM); Serial.println("Full saved"); }
}
int d = median();
int pct = constrain(map(d, emptyMM, fullMM, 0, 100), 0, 100);
char buf[17];
snprintf(buf, sizeof buf, "Full %3d %%", pct);
oled.drawString(0, 1, buf);
char bar[17]; byte n = pct * 16 / 100;
for (byte i = 0; i < 16; i++) bar[i] = i < n ? '#' : '.';
bar[16] = 0;
oled.drawString(0, 4, bar);
digitalWrite(LED, pct < 15); // warn below 15 %
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Empty bin | About 0 % |
| Half full | About 50 % |
| Full bin | About 100 % |
| Below 15 % | Red LED on |
If it does not work
Reads 8190
Nothing in range or the sensor is blinded by dust. Clean and recalibrate.
Reading jumps
The surface is uneven. Aim at the pile centre and use the median.
Percentage backwards
You swapped e and f. Save them again.
Screen blank
Check the I2C address and wiring.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the fodder silo level meter?
Arduino Nano, VL53L1X long-range ToF sensor, SSD1306 OLED Display, LED 5 mm red and Resistor 220 Ω.
How long does the fodder silo level meter take to build?
About 75 minutes for a intermediate maker, in 6 steps.
How do I know the fodder silo level meter works?
Empty bin: About 0 %. Half full: About 50 %. Full bin: About 100 %.
Reads 8190: what should I check?
Nothing in range or the sensor is blinded by dust. Clean and recalibrate.
Reading jumps: what should I check?
The surface is uneven. Aim at the pile centre and use the median.
Percentage backwards: what should I check?
You swapped e and f. Save them again.
Screen blank: what should I check?
Check the I2C address and wiring.
