Community project

Real-Time Cargo Visualization

Photo of Real-Time Cargo Visualization

Pablo González

Last updated November 16, 2026

This project creates a real-time cargo weight monitoring system using seven independent load cell platforms connected to an ESP32 microcontroller. Each platform measures weight independently through an HX711 amplifier, allowing simultaneous tracking of cargo across multiple zones or containers.

The guide provides a complete wiring diagram showing how to connect all seven load cells to their respective HX711 modules and the ESP32, a full parts list, calibration firmware with web-based visualization, and step-by-step assembly instructions for mounting the load cell platforms and establishing wireless connectivity.

Wiring diagram

Wiring diagram for Real-Time Cargo Visualization
Loading diagram…

Gather all the parts

QtyComponent
1

HX711 Load Cell Amplifier

24-bit ADC front-end for strain-gauge load cells and weigh scales. DT/DOUT and SCK are MCU-facing pins; E+/E-/A+/A- connect to the load cell bridge.

1

Load Cell

Four-wire strain-gauge straight-bar load cell, common 5 kg hobby scale sensor. It produces a small bridge signal and should be read through a load-cell ADC/amplifier such as HX711 or NAU7802 rather than directly by a microcontroller GPIO.

1

HX711 Load Cell Amplifier

24-bit ADC front-end for strain-gauge load cells and weigh scales. DT/DOUT and SCK are MCU-facing pins; E+/E-/A+/A- connect to the load cell bridge.

1

Load Cell

Four-wire strain-gauge straight-bar load cell, common 5 kg hobby scale sensor. It produces a small bridge signal and should be read through a load-cell ADC/amplifier such as HX711 or NAU7802 rather than directly by a microcontroller GPIO.

1

HX711 Load Cell Amplifier

24-bit ADC front-end for strain-gauge load cells and weigh scales. DT/DOUT and SCK are MCU-facing pins; E+/E-/A+/A- connect to the load cell bridge.

1

Load Cell

Four-wire strain-gauge straight-bar load cell, common 5 kg hobby scale sensor. It produces a small bridge signal and should be read through a load-cell ADC/amplifier such as HX711 or NAU7802 rather than directly by a microcontroller GPIO.

1

HX711 Load Cell Amplifier

24-bit ADC front-end for strain-gauge load cells and weigh scales. DT/DOUT and SCK are MCU-facing pins; E+/E-/A+/A- connect to the load cell bridge.

1

Load Cell

Four-wire strain-gauge straight-bar load cell, common 5 kg hobby scale sensor. It produces a small bridge signal and should be read through a load-cell ADC/amplifier such as HX711 or NAU7802 rather than directly by a microcontroller GPIO.

1

HX711 Load Cell Amplifier

24-bit ADC front-end for strain-gauge load cells and weigh scales. DT/DOUT and SCK are MCU-facing pins; E+/E-/A+/A- connect to the load cell bridge.

1

Load Cell

Four-wire strain-gauge straight-bar load cell, common 5 kg hobby scale sensor. It produces a small bridge signal and should be read through a load-cell ADC/amplifier such as HX711 or NAU7802 rather than directly by a microcontroller GPIO.

1

HX711 Load Cell Amplifier

24-bit ADC front-end for strain-gauge load cells and weigh scales. DT/DOUT and SCK are MCU-facing pins; E+/E-/A+/A- connect to the load cell bridge.

1

Load Cell

Four-wire strain-gauge straight-bar load cell, common 5 kg hobby scale sensor. It produces a small bridge signal and should be read through a load-cell ADC/amplifier such as HX711 or NAU7802 rather than directly by a microcontroller GPIO.

1

HX711 Load Cell Amplifier

24-bit ADC front-end for strain-gauge load cells and weigh scales. DT/DOUT and SCK are MCU-facing pins; E+/E-/A+/A- connect to the load cell bridge.

1

Load Cell

Four-wire strain-gauge straight-bar load cell, common 5 kg hobby scale sensor. It produces a small bridge signal and should be read through a load-cell ADC/amplifier such as HX711 or NAU7802 rather than directly by a microcontroller GPIO.

Assemble it in 3 steps

1. Montar siete plataformas independientes

Fija un extremo de cada célula de carga de 5 kg a la base y el otro a su plataforma, con separadores para que la barra pueda flexar. Cada zona debe apoyar únicamente en su propia célula, sin rozar paredes ni las otras plataformas.

  • No superes 5 kg por zona contando la plataforma. Evita golpes y cargas laterales.

2. Conectar las células a sus módulos

Con el USB desconectado, une E+ y E- de cada célula a E+ y E- de su HX711 (alimentación del puente), y A+ y A- a A+ y A- (señal de peso). Identifica los hilos con la ficha de tu célula; no te fíes solo de los colores. Usa un HX711 por célula.

3. Alimentar y conectar al ESP32

Une VCC de los siete HX711 a 3V3 y sus GND a GND. DT es la línea de datos y SCK la de reloj. Para las zonas 1 a 7 conecta DT/SCK respectivamente a GPIO13/14, GPIO16/17, GPIO18/19, GPIO21/22, GPIO23/25, GPIO26/27 y GPIO32/33. Mantén cortos los cables de las células y alejados de la antena del ESP32.

  • Usa módulos HX711 compatibles con alimentación de 3.3 V. No alimentes sus señales a 5 V porque puedes dañar el ESP32.

Review all connections

1. Connections between "hx1" and "ESP32"

Functionhx1ESP32
powerVCC3V3
groundGNDGND
digitalDTGPIO 13
digitalSCKGPIO 14

2. Connections between "cell1" and "ESP32"

Functioncell1ESP32
powerE+ → HX711 Load Cell Amplifier E+EXT
groundE- → HX711 Load Cell Amplifier E-EXT
analogA+ → HX711 Load Cell Amplifier A+EXT
analogA- → HX711 Load Cell Amplifier A-EXT

3. Connections between "hx2" and "ESP32"

Functionhx2ESP32
powerVCC3V3
groundGNDGND
digitalDTGPIO 16
digitalSCKGPIO 17

4. Connections between "cell2" and "ESP32"

Functioncell2ESP32
powerE+ → HX711 Load Cell Amplifier E+EXT
groundE- → HX711 Load Cell Amplifier E-EXT
analogA+ → HX711 Load Cell Amplifier A+EXT
analogA- → HX711 Load Cell Amplifier A-EXT

5. Connections between "hx3" and "ESP32"

Functionhx3ESP32
powerVCC3V3
groundGNDGND
digitalDTGPIO 18
digitalSCKGPIO 19

6. Connections between "cell3" and "ESP32"

Functioncell3ESP32
powerE+ → HX711 Load Cell Amplifier E+EXT
groundE- → HX711 Load Cell Amplifier E-EXT
analogA+ → HX711 Load Cell Amplifier A+EXT
analogA- → HX711 Load Cell Amplifier A-EXT

7. Connections between "hx4" and "ESP32"

Functionhx4ESP32
powerVCC3V3
groundGNDGND
digitalDTGPIO 21
digitalSCKGPIO 22

8. Connections between "cell4" and "ESP32"

Functioncell4ESP32
powerE+ → HX711 Load Cell Amplifier E+EXT
groundE- → HX711 Load Cell Amplifier E-EXT
analogA+ → HX711 Load Cell Amplifier A+EXT
analogA- → HX711 Load Cell Amplifier A-EXT

9. Connections between "hx5" and "ESP32"

Functionhx5ESP32
powerVCC3V3
groundGNDGND
digitalDTGPIO 23
digitalSCKGPIO 25

10. Connections between "cell5" and "ESP32"

Functioncell5ESP32
powerE+ → HX711 Load Cell Amplifier E+EXT
groundE- → HX711 Load Cell Amplifier E-EXT
analogA+ → HX711 Load Cell Amplifier A+EXT
analogA- → HX711 Load Cell Amplifier A-EXT

11. Connections between "hx6" and "ESP32"

Functionhx6ESP32
powerVCC3V3
groundGNDGND
digitalDTGPIO 26
digitalSCKGPIO 27

12. Connections between "cell6" and "ESP32"

Functioncell6ESP32
powerE+ → HX711 Load Cell Amplifier E+EXT
groundE- → HX711 Load Cell Amplifier E-EXT
analogA+ → HX711 Load Cell Amplifier A+EXT
analogA- → HX711 Load Cell Amplifier A-EXT

13. Connections between "hx7" and "ESP32"

Functionhx7ESP32
powerVCC3V3
groundGNDGND
digitalDTGPIO 32
digitalSCKGPIO 33

14. Connections between "cell7" and "ESP32"

Functioncell7ESP32
powerE+ → HX711 Load Cell Amplifier E+EXT
groundE- → HX711 Load Cell Amplifier E-EXT
analogA+ → HX711 Load Cell Amplifier A+EXT
analogA- → HX711 Load Cell Amplifier A-EXT

Deploy the firmware

#include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>
#include <Preferences.h>
#include <HX711.h>
#include <math.h>
WebServer server(80);
Preferences prefs;
HX711 hx[7];
const uint8_t dt[7]={13,16,18,21,23,26,32}, ck[7]={14,17,19,22,25,27,33};
struct Zone { double raw=0,zero=0,scale=0; float grams=0; int count=0; bool seen=false,tared=false; uint32_t last=0; } z[7];
void save(int i){String k=String(i);prefs.putDouble((k+"z").c_str(),z[i].zero);prefs.putDouble((k+"s").c_str(),z[i].scale);prefs.putBool((k+"t").c_str(),z[i].tared);}
const char page[] PROGMEM=R"HTML(<!doctype html><html lang="es"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Control de carga · Portacontenedores</title><style>
*{box-sizing:border-box}body{font:14px system-ui;margin:0;background:#0a1420;color:#dce7f0}header{padding:22px 5%;background:#101f2e;border-bottom:1px solid #304457}h1{margin:0;font-size:24px;letter-spacing:.5px}.sub{color:#91a8ba}main{max-width:1400px;margin:auto;padding:22px}.metrics{display:flex;gap:14px;flex-wrap:wrap;margin:20px 0}.metric{background:#142536;border:1px solid #304457;border-radius:8px;padding:16px;flex:1;min-width:180px}.metric strong{display:block;font-size:26px;color:#73d7df}.panel{background:#101f2e;border:1px solid #304457;border-radius:10px;padding:18px;margin-bottom:20px}.view{overflow:auto}svg{width:100%;min-width:850px;display:block}.legend{display:flex;gap:20px;flex-wrap:wrap;color:#a8bed0}.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(145px,1fr));gap:10px}.card{background:#182b3c;padding:12px;border:1px solid #314b60;border-radius:6px}.card h3{margin:0 0 10px}.val{min-height:65px;font-size:13px;color:#b5cadd}button,input{font:inherit;padding:8px;border-radius:5px;border:1px solid #466078;background:#0e1c29;color:#eef6ff;width:100%;margin-top:7px}button{cursor:pointer;background:#214657}button:hover{background:#306278}summary{cursor:pointer;font-size:17px}p{line-height:1.6}.warn{color:#ffbf69}#status{font-size:13px}svg text{font-family:system-ui}footer{color:#91a8ba;font-size:12px} .stale{opacity:.45}
</style><header><div class="sub">CARGO CONTROL / MAQUETA INSTRUMENTADA</div><h1>Portacontenedores · Plan de carga</h1><div id="status" role="status">Conectando…</div></header><main><div class="metrics"><div class="metric">Contenedores estimados<strong id="total">—</strong></div><div class="metric">Masa neta medida<strong id="mass">—</strong></div><div class="metric">Zonas disponibles<strong id="ready">— / 7</strong></div></div><section class="panel"><h2>Corte longitudinal · distribución por bodegas</h2><div class="view"><svg id="ship" viewBox="0 0 1200 470" role="img" aria-label="Corte longitudinal del barco con siete zonas de carga"><defs><linearGradient id="hull" x2="0" y2="1"><stop stop-color="#40596a"/><stop offset="1" stop-color="#1c303f"/></linearGradient><pattern id="ribs" width="7" height="20" patternUnits="userSpaceOnUse"><path d="M2 0V20" stroke="#000" opacity=".23"/></pattern></defs><rect x="0" y="320" width="1200" height="100" fill="#102f45"/><path d="M0 335H1200M0 380H1200" stroke="#23506a" stroke-dasharray="16 9"/><text x="15" y="328" fill="#80b5cc" font-size="11">LÍNEA DE AGUA · REFERENCIA GRÁFICA</text><path d="M45 243L1050 243L1160 200L1110 320Q1080 387 1000 390H150Q80 382 45 243Z" fill="url(#hull)" stroke="#91aabc" stroke-width="3"/><path d="M115 270H1040V363H150Z" fill="#0b1722" stroke="#607a8d"/><path d="M100 245H1060M150 365H1010" stroke="#8fa8b8" stroke-width="3"/><path d="M60 240V141H140V240M70 140V110H127V140" fill="#a9bac6" stroke="#597589" stroke-width="2"/><path d="M75 118H120M70 159H130M70 178H130" stroke="#234458" stroke-width="8"/><path d="M91 109V72M91 83H133" stroke="#8ca6b9" stroke-width="3"/><rect x="144" y="178" width="20" height="65" fill="#bca582"/><rect x="144" y="174" width="20" height="10" fill="#d97e50"/><text x="55" y="437" fill="#9db4c5" font-size="13">POPA / PUENTE</text><text x="1060" y="437" fill="#9db4c5" font-size="13">PROA →</text><g id="holds"></g></svg></div><div class="legend"><span>▰ Contenedor equivalente a 300 g</span><span>7 zonas de pesaje independientes</span><span class="warn">Ámbar: revisar carga o sensor</span></div></section><section class="panel"><h2>Estado de las bodegas</h2><div id="cards" class="cards"></div></section><details class="panel"><summary>Calibración y ajuste de cero</summary><p>Con la plataforma vacía y estable, pulsa «Cero». Después coloca una masa conocida, espera 3 segundos, introduce sus gramos y pulsa «Calibrar». Los ajustes quedan guardados. No hagas cero con contenedores encima.</p><div id="settings" class="cards"></div><p id="msg" role="status"></p></details><footer>Representación esquemática: cada célula mide la masa total de una zona, no la posición de los contenedores. El dibujo rellena las bodegas de abajo arriba. No calcula estabilidad, calado ni seguridad de un barco real. Límite por célula: 5 kg incluyendo la plataforma. La línea de agua es decorativa, no una medición.</footer></main><script>
const NS='http://www.w3.org/2000/svg',last=Array(7).fill('');
function svg(tag,attrs,parent){let e=document.createElementNS(NS,tag);for(let k in attrs)e.setAttribute(k,attrs[k]);parent.appendChild(e);return e}
function text(id,value){let e=document.getElementById(id);if(e.textContent!==value)e.textContent=value}
for(let i=0;i<7;i++){let x=185+i*121,g=svg('g',{},document.getElementById('holds'));svg('rect',{x:x-5,y:263,width:115,height:99,fill:'#102333',stroke:'#526c80'},g);let label=svg('text',{x:x+50,y:407,'text-anchor':'middle',fill:'#9eb8cc','font-size':13},g);label.textContent='BODEGA '+(i+1);svg('g',{id:'s'+i},g);let t=svg('text',{id:'t'+i,x:x+50,y:458,'text-anchor':'middle',fill:'#77d9df','font-size':14},g);t.textContent='—';document.getElementById('cards').insertAdjacentHTML('beforeend',`<div class="card"><h3>Zona ${i+1}</h3><div class="val" id="v${i}">Sin datos</div></div>`);document.getElementById('settings').insertAdjacentHTML('beforeend',`<div class="card"><h3>Zona ${i+1}</h3><button onclick="act(${i},'zero')">Cero</button><input id="m${i}" type="number" min="1" max="4500" value="300" aria-label="Masa conocida en gramos, zona ${i+1}"><button onclick="act(${i},'cal')">Calibrar</button></div>`)}
async function act(i,op){if(!confirm(op==='zero'?'¿La plataforma está vacía y estable?':'¿La masa conocida está colocada y estable?'))return;try{let r=await fetch('/adjust',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:`i=${i}&op=${op}&mass=${document.getElementById('m'+i).value}`});text('msg',await r.text())}catch(e){text('msg','Sin conexión')}}
async function poll(){try{let r=await fetch('/data',{cache:'no-store'});if(!r.ok)throw Error();let a=await r.json(),sum=0,mass=0,good=0;document.getElementById('ship').classList.remove('stale');a.forEach((v,i)=>{let valid=v.ok&&v.cal,n=valid?v.n:-1,warn=!valid||v.g>4800||v.g< -100;let value=!v.ok?'Sensor sin respuesta':!v.cal?'Pendiente de cero y calibración':`${v.g.toFixed(0)} g · ${n} contenedores${v.g>4800?' · CERCA DEL LÍMITE':''}${v.g< -100?' · Revisar cero':''}`;text('v'+i,value);text('t'+i,valid?`${n} uds · ${v.g.toFixed(0)} g`:'SIN DATOS');let key=n+':'+warn;if(key!==last[i]){let st=document.getElementById('s'+i);st.replaceChildren();let x=185+i*121;for(let j=0;j<Math.min(17,Math.max(0,n));j++){let xx=x+(j%3)*36,yy=342-Math.floor(j/3)*24;let colors=['#308b99','#b76b3c','#657ca8'];svg('rect',{x:xx,y:yy,width:33,height:21,rx:1,fill:warn?'#c28a3e':colors[i%3],stroke:'#a1b9c6','stroke-width':.7},st);svg('rect',{x:xx+2,y:yy+2,width:29,height:17,fill:'url(#ribs)'},st)}last[i]=key}if(valid){sum+=n;mass+=v.g;good++}});text('status','● En directo · actualización cada 0,5 s');text('total',sum+' uds');text('mass',mass.toFixed(0)+' g');text('ready',good+' / 7');}catch(e){text('status','⚠ Conexión perdida: los últimos datos NO son actuales');document.getElementById('ship').classList.add('stale');text('total','—');text('mass','—');text('ready','— / 7')}finally{setTimeout(poll,500)}}poll();
</script></html>
)HTML";
void setup(){
 Serial.begin(115200);prefs.begin("bodega",false);
 for(int i=0;i<7;i++){String k=String(i);z[i].zero=prefs.getDouble((k+"z").c_str(),0);z[i].scale=prefs.getDouble((k+"s").c_str(),0);z[i].tared=prefs.getBool((k+"t").c_str(),false);hx[i].begin(dt[i],ck[i]);}
 WiFi.mode(WIFI_AP);WiFi.softAP("Bodega-Barco","Bodega300g");Serial.println(WiFi.softAPIP());
 server.on("/",HTTP_GET,[]{server.send_P(200,"text/html; charset=utf-8",page);});
 server.on("/data",HTTP_GET,[]{String s="[";for(int i=0;i<7;i++){if(i)s+=",";bool ok=z[i].seen&&millis()-z[i].last<2000;s+="{\"ok\":"+String(ok?"true":"false")+",\"cal\":"+String(z[i].tared&&z[i].scale!=0?"true":"false")+",\"g\":"+String(z[i].grams,1)+",\"n\":"+String(z[i].count)+"}";}s+="]";server.send(200,"application/json",s);});
 server.on("/adjust",HTTP_POST,[]{
 if(!server.hasArg("i")||!server.hasArg("op")){server.send(400,"text/plain","Faltan datos");return;}
 int i=server.arg("i").toInt();if(i<0||i>=7||!z[i].seen||millis()-z[i].last>2000){server.send(400,"text/plain","Sensor no disponible");return;}
 if(server.arg("op")=="zero"){z[i].zero=z[i].raw;z[i].tared=true;z[i].count=0;}
 else if(server.arg("op")=="cal"){float m=server.arg("mass").toFloat();double delta=z[i].raw-z[i].zero;if(!z[i].tared||m<=0||m>4500||fabs(delta)<100){server.send(400,"text/plain; charset=utf-8","Haz cero primero y usa una masa conocida estable de 1 a 4500 g");return;}z[i].scale=delta/m;}
 else {server.send(400,"text/plain","Operacion desconocida");return;}
 save(i);server.send(200,"text/plain; charset=utf-8","Ajuste guardado");});server.begin();
}
void loop(){server.handleClient();for(int i=0;i<7;i++){if(hx[i].is_ready()){long r=hx[i].read();z[i].raw=z[i].seen?z[i].raw*.75+r*.25:r;z[i].seen=true;z[i].last=millis();if(z[i].tared&&z[i].scale!=0){z[i].grams=(z[i].raw-z[i].zero)/z[i].scale;float g=max(0.0f,z[i].grams);int n=max(0,(int)lroundf(g/300));if(fabsf(g-z[i].count*300)>180)z[i].count=n;}}}delay(1);}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik