Simulating how disinformation spreads, on an ESP32
Academic project · 2025–2026
A 625-agent model of how people come to adhere to false information, running on an ESP32 and steered from a browser. In partnership with Campus Cyber.
In short
- What it is
- A simulation of 625 agents on a 25×25 grid, each with cognitive traits and a camp, that become "infected" by a message with a probability built from social-psychology models. It runs on an ESP32 microcontroller, which hosts its own Wi-Fi network and a web page to steer and watch it.
- Why
- Disinformation is mass social engineering. The project models which factors make a population adhere to a message regardless of its truth, and which ones help it resist.
- My role
- Team leader and lead developer, in a team of 5.
- Domains and tech
- IoT and embedded. C++ (Arduino framework), ESP32, FreeRTOS, PlatformIO, LittleFS, ArduinoJson, HTML and JavaScript front end.
- Status
- Academic project. Demonstrated as a working simulator. Its findings are qualitative, chiefly that ambient stress is the strongest driver of spread. The public repository holds an earlier, simpler firmware than the one demonstrated.
- Period
- 2025 – 2026
Context and problem
Information manipulation works like social engineering at the scale of a population: it relies on cognitive, social and media factors to get past critical thinking. The project set out to identify the parameters that make people adhere to a piece of information regardless of whether it is true, and to propose a formal model that can simulate a campaign and show where collective resilience comes from.
It was ESILV coursework for the 2025–26 academic year, in a team of five that I led as team leader and lead developer, run in partnership with Campus Cyber.
Closure report, §1.1–1.2; repository README; role and partnership as stated by meThe model
Each of the 625 agents sits on a 25×25 grid and sees its Moore neighbourhood, up to eight neighbours. Agents belong to one of two camps (60 % and 40 %), hold an opinion between 0 and 1, and carry traits such as polarisation, discernment, resistance to manipulation and distrust of outside sources. Infection is one-way: an agent that adheres to the message stays infected.
The demonstrated version, documented in the closure report, combines three layers:
- Opinion dynamics (Deffuant-Weisbuch). Neighbours whose opinions are close enough, within a tolerance of 0.30, move towards each other at a rate of 0.04 per tick.
- Persuasion (Elaboration Likelihood Model). An agent’s rational defence, its discernment and resistance, is weakened by ambient stress; the message’s pull grows as it gets closer to the agent’s existing opinion.
- Social pressure (Drive Theory). The share of infected neighbours pushes towards adhesion, and stress amplifies that push, with an extra boost that grows exponentially above a stress level of 0.7.
These terms feed a logistic function that gives each healthy agent with an infected neighbour its probability of adhering at the next tick. The message can target camp A, camp B or both, and starts either from a single “patient zero” or from a campaign of six seeds.
src/simulation.cpp, lines 84–90 (public firmware)
const float disc_eff = me.disc * (1.0f - 0.8f * stress);
const float social_pressure = (float)infected_neighbors / total_neighbors;
const float rational_defense = (disc_eff + me.ino) * (1.0f - stress);
const float ideological_pull = me.pol * (1.0f - fabsf(me.opinion - message)); // fabsf, not abs
const float social_drive = social_pressure * (1.0f + stress);
const float logit = ideological_pull + social_drive - rational_defense - me.trust;
const float probability = 1.0f / (1.0f + expf(-5.0f * logit));
The public firmware holds a simpler form of this rule (a fixed 0.8 where the report uses a per-agent stress sensitivity, plus certain infection above a stress of 0.95), but not the opinion dynamics, the boost above 0.7 or the polarisation setting: it is an earlier version than the one demonstrated, and the report’s code listing doesn’t correspond to any file in the repository.
Try the model
The model from the closure report runs here in your browser, ported to JavaScript from the report’s equations and tables (§2–4). Choose a target, send a wave, then raise the stress to see the spread speed up.
This is a reconstruction written for this page, not the firmware that ran on the board during the demonstration, whose source is lost. Some choices are mine, where the report leaves a gap or contradicts itself. It gives the opinion update for a pair of neighbours but not how pairs are picked, so here each healthy agent moves towards one random neighbour per tick (eq. 2.2), and that neighbour doesn’t move in the same exchange. Infected neighbours can pull a healthy agent this way, but infected agents only drift towards the message (eq. 4.9). The grid has edges, as in the report’s code listing, although its text calls the grid toroidal. An agent that adheres drifts from its opinion at the start of the tick, as in the listing. Traits are drawn at random, so two populations never react quite the same way.
Closure report, §2–4, tables 2.1 and 3.1, listing A.1; src/scripts/opinion-sim.js in this site’s repositoryArchitecture
The board is a dual-core ESP32. A FreeRTOS task pinned to core 0 computes a new generation every 100 ms with vTaskDelayUntil, so the tick rate doesn’t drift with the work done. It computes each generation into a private buffer and copies it into the shared grid under a mutex, so the web server never reads a half-updated grid. The Arduino loop serves the web pages from the LittleFS file system and a small JSON API: /data returns the state of the 625 cells, and control routes change the stress, the target and the injection mode.

Security considerations
These protections are in the firmware on GitHub, the older version. Whether the demonstrated firmware had them isn’t known: the web interface recovered from the demonstration board sends no token on its control calls, and the report never mentions one. What the public firmware does:
- The control routes require a shared token, sent in an
X-Tokenheader or atokenparameter; anything else gets a 401. /datais open by design but limited to one answer every 100 ms, with a 429 beyond that.- Stress and target values are clamped to [0, 1].
- The Wi-Fi password and the token come from a
secrets.hfile kept out of git. - The README has a short threat model that names the risks it accepts.
src/web_server.cpp, lines 11–19
static bool isAuthorized() {
if (server.hasHeader("X-Token") && server.header("X-Token") == API_TOKEN)
return true;
// Also accept token as query param for easy browser testing
if (server.hasArg("token") && server.arg("token") == API_TOKEN)
return true;
server.send(401, "text/plain", "Unauthorized");
return false;
}
The limits are real, and some are accepted in the README. The device serves plain HTTP, so the token travels in clear. Accepting it as a URL parameter puts it in browser history. State changes use GET requests. /data allows any origin. The rate limit is global, so one client can starve the others.
Results


The report’s findings are qualitative. Ambient stress is the strongest lever: as it rises, rational defence falls and social pressure grows, and spread speeds up. Initial polarisation speeds up the formation of opinion bubbles, and the two camps react differently to the same message. The report and the repository contain no run counts, timings or curves, so these are observations of the simulator’s behaviour, not measurements.
Closure report §6.1 and §7.1; English summaryLimitations
- The repository is behind the demonstration. The public firmware is the earlier model: no opinion dynamics, no boost above 0.7, no polarisation setting, one mutex where the report describes two, and its initial trait distributions differ from the report’s table. The web front end and the
secrets.htemplate aren’t committed, so the repository can’t be built and flashed as its README describes. - Shared state in the firmware. Stress and target are plain variables written by the web handlers and read by the simulation task without a lock. A reset that arrives mid-tick can be overwritten by that tick’s commit. If the commit can’t take the mutex within 10 ms, the tick is dropped silently; if
/datacan’t within 20 ms, it answers with an empty grid. - Model limits stated by the team. No recovery state, a regular grid instead of a realistic social network, static traits and a single message.
- No tests, and the sources contain no recorded experiments behind the results.
Possible next steps
The report lists a recovered state, a scale-free network topology, traits that learn, competing narratives and calibration on survey data. None of it was done. On the device side, the gaps above have direct fixes: POST routes with the token in a header only, a lock around the shared parameters, and the demonstrated firmware and front end committed to the repository.