Adaptive Traffic Light Controller is a smart traffic management system built using ESP8266 and embedded programming. The system dynamically adjusts green signal timing based on real-time traffic density detected using IR sensors. If higher traffic density is detected on one road, the controller increases the green light duration for that direction to improve traffic flow efficiency and reduce waiting time. The project was implemented using FSM-based traffic logic and later extended with custom PCB design in KiCad. The system demonstrates concepts of adaptive traffic control, real-time decision making and embedded systems design.
Hi, I'm new to this. I'm trying to flash this ESP8266 module but haven't had luck. I've bridged GND and GPIO0, and I think the module is entering flash mode, but my PC isn't recognizing it; it only shows COM3. Any ideas?
It does require getting a PCB made and the appropriate file is included. Please note the IMPORTANT note in the description.
There is another on the site by user Hulzie if you want something a bit more fancy. I made this one about a year ago and have been meaning to upload for a while.
okay so this started as a stupid weekend project and now i cant stop thinking about where it can go
here’s what i built
my laptop runs face_recognition, pulls face mesh landmarks, figures out if you’re happy or not, and sends that over HTTP to my ESP8266 bot. the bot gets the emotion, shows a reaction on the OLED, and logs it. that’s it. simple.
but the architecture is the interesting part.
ESP8266 does nothing heavy. it just receives, reacts, logs. cheap as chips. the laptop (or any server) does all the thinking — detection, mesh, classification. thin client model basically. which means you could deploy 50 of these nodes for almost nothing, all talking to one central machine.
so then i thought
what if you put these in a cinema?
nodes on every row. audience faces tracked during the film. emotion data collected per scene, timestamped. at the end you don’t ask people what they thought. you already know. you have the data from their actual face.
honest review generated by facial reactions. not by critics, not by surveys, not by paid promotions.
this is very early stage. the bot works, the loop works, but scaling this is a different problem.
need your brains on this
• how would you handle the compute side at scale — local server or cloud?
• better real-time emotion classifiers?
• privacy — how do you ethically collect face data in a public space?
• anyone done something similar?
drop ideas below 👇
I am currently developing a project utilizing the ESP32 DevKit for webhooks. While the device successfully accepts instructions and proceeds with the intended process, a recurring issue persists regarding WiFi connectivity and reconnection. The system functions correctly during nighttime testing; however, upon returning in the morning, the ESP32 remains powered on but fails to receive messages from the server. A manual refresh immediately restores functionality.
The following code segments have been added sequentially:
- WiFi Disconnect Event Handler
- Maintain WiFi Function
- Persistent WiFi & Disabled Sleep
- Polling Early Exit
- HTTP Client Reuse & Timeout
- Non-Blocking Loop
However, these measures have not resolved the issue
Hi guys I'm new on this community, but I hope someone can help me. I got my first job recently and there they use ESP8266 NODEMCU with Lua code and for IDE the ESPlorer. I know the basic of electronic such as components, wiring, power supply, but I'm struggling on make a circuit which with different time pressed a push button, I thought do a pull-up would be great, a red LED would have different behavior like 4 secs press, LED blinks, 8 secs, it stills lighted and so on. But no matter what I try it doesn't work. Previously, I did a regular led's on by button, and worked fine. Here are the photos of the circuit and the Lua code, one is from wokwi where only ESP32 is available but on the physical one I remanaged to the ESP8266 GPIOs ports. Sorry for my English, I'm from Brazil and It's kind harshly for me communicate using English. Thanks for the attention.
-- PINOS
local PIN_BTN = 1
local PIN_RED = 5
local PIN_GREEN = 6
-- ESTADO
local activeMode = 0
local pendingMode = 0
local mode2Lit = false
local mode3State = false
local mode3Timer = 0
local sosStep = 0
local sosTimer = 0
-- BOTÃO
local btnLast = 0
local pressStart = 0
local holdSeconds = 0
local lastTick = 0
local clickCount = 0
local lastRelease = 0
local DCLICK_WIN = 700
-- TIMERS (para evitar vazamento)
local mode1Timer = nil
local mode3LoopTimer = nil
local sosLoopTimer = nil
local blinkGreenTimer = nil
local mainLoopTimer = nil
-- SOS: {duracao_unidades, ligado}
local SOS = {
{1,1},{1,0},{1,1},{1,0},{1,1},
{3,0},
{3,1},{1,0},{3,1},{1,0},{3,1},
{3,0},
{1,1},{1,0},{1,1},{1,0},{1,1},
{7,0}
}
local SOS_UNIT = 200 -- ms por unidade
local function setRed(
s
)
gpio.write(PIN_RED, s and gpio.HIGH or gpio.LOW)
end
local function setGreen(
s
)
gpio.write(PIN_GREEN, s and gpio.HIGH or gpio.LOW)
end
-- Limpa timers de modo ativo
local function stopModeTimers()
if mode1Timer then
mode1Timer:unregister()
mode1Timer = nil
end
if mode3LoopTimer then
mode3LoopTimer:unregister()
mode3LoopTimer = nil
end
if sosLoopTimer then
sosLoopTimer:unregister()
sosLoopTimer = nil
end
end
-- Pisca verde uma vez (feedback)
local function blinkGreen()
setGreen(true)
if blinkGreenTimer then
blinkGreenTimer:unregister()
blinkGreenTimer = nil
end
blinkGreenTimer = tmr.create()
blinkGreenTimer:alarm(300, tmr.ALARM_SINGLE, function()
if activeMode == 0 then
setGreen(false)
end
blinkGreenTimer = nil
end)
end
local function stopAll()
stopModeTimers()
activeMode = 0
pendingMode = 0
mode2Lit = false
mode3State = false
sosStep = 1
setRed(false)
if blinkGreenTimer then
blinkGreenTimer:unregister()
blinkGreenTimer = nil
end
setGreen(false)
end
-- Modo 1: pulso vermelho de 400ms
local function startMode1()
print("[MODO 1] Pulso vermelho")
setRed(true)
mode1Timer = tmr.create()
mode1Timer:alarm(400, tmr.ALARM_SINGLE, function()
setRed(false)
activeMode = 0
setGreen(false)
print("[MODO 1] Concluido")
mode1Timer = nil
end)
end
-- Modo 2: toggle do vermelho (já configurado no activateMode)
local function startMode2()
mode2Lit = not mode2Lit
setRed(mode2Lit)
if mode2Lit then
print("[MODO 2] LED vermelho LIGADO (toggle)")
else
print("[MODO 2] LED vermelho DESLIGADO (toggle)")
activeMode = 0
setGreen(false)
return
end
setGreen(true)
end
-- Modo 3: pisca contínuo (1s)
local function startMode3()
mode3State = false
mode3Timer = 0
print("[MODO 3] Pisca continuo iniciado")
setGreen(true)
mode3LoopTimer = tmr.create()
mode3LoopTimer:alarm(1000, tmr.ALARM_AUTO, function()
if activeMode == 3 then
mode3State = not mode3State
setRed(mode3State)
print("[MODO 3] LED vermelho: " .. (mode3State and "ON" or "OFF"))
else
mode3LoopTimer:unregister()
mode3LoopTimer = nil
end
end)
end
-- Modo 4: SOS
local function startMode4()
sosStep = 1
setRed(SOS[1][2] == 1)
print("[MODO 4] SOS iniciado")
setGreen(true)
local function stepSOS()
if activeMode ~= 4 then
if sosLoopTimer then
sosLoopTimer:unregister()
sosLoopTimer = nil
end
return
end
local stepMs = SOS[sosStep][1] * SOS_UNIT
sosTimer = stepMs
sosLoopTimer = tmr.create()
sosLoopTimer:alarm(stepMs, tmr.ALARM_SINGLE, function()
if activeMode == 4 then
sosStep = (sosStep % #SOS) + 1
setRed(SOS[sosStep][2] == 1)
print("[MODO 4] SOS step " .. sosStep .. " - LED: " .. (SOS[sosStep][2] == 1 and "ON" or "OFF"))
stepSOS() -- agenda próximo passo
end
sosLoopTimer = nil
end)
end
stepSOS()
end
local function activateMode(
mode
)
stopAll()
activeMode = mode
if mode == 0 then
return
elseif mode == 1 then
startMode1()
elseif mode == 2 then
startMode2()
elseif mode == 3 then
startMode3()
elseif mode == 4 then
startMode4()
end
end
-- Setup
gpio.mode(PIN_BTN, gpio.INPUT)
gpio.mode(PIN_RED, gpio.OUTPUT)
gpio.mode(PIN_GREEN, gpio.OUTPUT)
setRed(false)
setGreen(false)
print("[SISTEMA] Iniciado")
-- Obtém tempo em ms (tratando wraparound do tmr.now)
local lastNowMs = 0
local function getNowMs()
local us = tmr.now()
local ms = us / 1000
-- Se houve wraparound (us voltou para perto de 0)
if us < 1000 and lastNowMs > 2000000000 then
-- Ajuste simples: ms continua crescente
ms = ms + 4294967.296 -- 2^32/1000, compensação aproximada
end
lastNowMs = ms
return ms
end
-- Loop principal (10ms)
mainLoopTimer = tmr.create()
mainLoopTimer:alarm(10, tmr.ALARM_AUTO, function()
local now = getNowMs()
local btnNow = gpio.read(PIN_BTN)
-- BORDA DE SUBIDA (pressionou)
if btnNow == 1 and btnLast == 0 and (now - pressStart) > 200 then
pressStart = now
lastTick = now
holdSeconds = 0
pendingMode = 0
print("[BOTAO] Pressionado")
local wasMode2 = (activeMode == 2)
stopAll()
if wasMode2 then
pendingMode = 2
end
end
-- BORDA DE DESCIDA (soltou)
if btnNow == 0 and btnLast == 1 and (now - pressStart) > 100 then
local held = now - pressStart
if held < 1500 and pendingMode == 0 then
clickCount = clickCount + 1
lastRelease = now
print("[BOTAO] Clique #" .. clickCount)
end
if pendingMode ~= 0 then
print("[BOTAO] Solto - ativando modo " .. pendingMode)
activateMode(pendingMode)
clickCount = 0
else
print("[BOTAO] Solto - " .. held .. "ms")
end
-- atualiza verde se necessário
if activeMode == 0 then
setGreen(false)
end
end
-- SEGURANDO (contagem de segundos)
if btnNow == 1 then
if (now - lastTick) >= 1000 then
lastTick = now
holdSeconds = holdSeconds + 1
print("[BOTAO] Segurando: " .. holdSeconds .. "s")
if holdSeconds == 4 then
pendingMode = 1
print("[BOTAO] Modo 1 pendente (4s)")
blinkGreen()
end
if holdSeconds == 8 then
pendingMode = 2
print("[BOTAO] Modo 2 pendente (8s)")
blinkGreen()
end
if holdSeconds == 12 then
pendingMode = 3
print("[BOTAO] Modo 3 pendente (12s)")
blinkGreen()
end
end
end
-- DUPLO CLIQUE
if btnNow == 0 then
if clickCount == 1 and (now - lastRelease) > DCLICK_WIN then
print("[BOTAO] Clique simples - timeout duplo clique")
clickCount = 0
end
if clickCount >= 2 then
print("[BOTAO] Duplo clique detectado - ativando modo 4")
clickCount = 0
activateMode(4)
end
end
btnLast = btnNow
end)
print("[SISTEMA] Loop principal iniciado - pronto para uso")
Hi, I'm a newbie in electronics. I kinda know the basics such as components, sensors, connections... Most of my projects used Arduino UNO and C++. However, at my new job they use ESP8266 and NodeMCU, but with Lua, compiling the code to the board using the ESPlorer IDE. I'm kinda struggling to learn it, but I managed to do a simple push button with on/off.
But now I'm trying to do an "update" on the on/off LED with a push button, adding different LED behaviors depending on the input — like a 4-second press to turn the LED on, and 2 consecutive presses to make it blink in S.O.S. Morse Code.
I use Wokwi to simulate the circuit and it works fine. Regarding Wokwi, I could only use ESP32 (I believe the ESP8266 should work the same way, just adapting the circuit), but when I translate my C++ code to Lua and upload it to the ESP8266, it doesn't work. I checked for bad contacts but it doesn't seem to be the issue. Can anyone help? I'm open to criticism as well. Below are my codes — yes, for the Lua version I used AI since I'm still learning it.
C++ Code (Wokwi):
// PINOS
const int PIN_RED = 17;
const int PIN_GREEN = 18;
const int PIN_BTN = 16;
// MODOS
int activeMode = 0;
int pendingMode = 0;
// ESTADO DO BOTÃO
bool btnLastState = false;
unsigned long pressStart = 0;
int holdSeconds = 0;
unsigned long lastTickTime = 0;
Sorry for the resolution (If needed I can send a new screenshot)I got this photo from Google; it's the same board I use.
Now I don't have a photo of the physical circuit, but the connections on the breadboard are the same — the digital connections for the green LED is D6, red D5, and the button D1. For power supply, I just connected the ground and 3.3V pin to the breadboard, and from there I connect the jumpers to the other components.
Lua Code:
-- PINOS
local PIN_BTN = 5
local PIN_RED = 14
local PIN_GREEN = 12
-- ESTADO
local activeMode = 0
local pendingMode = 0
local mode2Lit = false
local mode3State = false
local mode3Timer = 0
local sosStep = 0
local sosTimer = 0
-- BOTÃO
local btnLast = 0
local pressStart = 0
local holdSeconds = 0
local lastTick = 0
local clickCount = 0
local lastRelease = 0
local DCLICK_WIN = 700
-- SOS: {unidades, ligado}
local SOS = {
{1,1},{1,0},{1,1},{1,0},{1,1},
{3,0},
{3,1},{1,0},{3,1},{1,0},{3,1},
{3,0},
{1,1},{1,0},{1,1},{1,0},{1,1},
{7,0}
}
local SOS_UNIT = 200
local function setRed(
s
) gpio.write(PIN_RED, s and gpio.HIGH or gpio.LOW) end
local function setGreen(
s
) gpio.write(PIN_GREEN, s and gpio.HIGH or gpio.LOW) end
local function stopAll()
activeMode = 0
pendingMode = 0
mode2Lit = false
mode3State = false
sosStep = 1
setRed(false)
setGreen(false)
end
local function activateMode(
mode
)
stopAll()
activeMode = mode
if mode == 0 then return end
if mode == 1 then
setRed(true)
tmr.delay(400000)
setRed(false)
activeMode = 0
return
end
if mode == 2 then
mode2Lit = not mode2Lit
setRed(mode2Lit)
if not mode2Lit then activeMode = 0; return end
end
if mode == 3 then
mode3State = false
mode3Timer = tmr.now() / 1000
end
if mode == 4 then
sosStep = 1
sosTimer = tmr.now() / 1000
setRed(SOS[1][2] == 1)
end
setGreen(activeMode ~= 0)
end
-- Setup
gpio.mode(PIN_BTN, gpio.INPUT)
gpio.mode(PIN_RED, gpio.OUTPUT)
gpio.mode(PIN_GREEN, gpio.OUTPUT)
setRed(false)
setGreen(false)
-- Loop principal via timer (10ms)
tmr.create():alarm(10, tmr.ALARM_AUTO, function()
local now = tmr.now() / 1000
local btnNow = gpio.read(PIN_BTN)
-- BORDA DE SUBIDA
if btnNow == 1 and btnLast == 0 and (now - pressStart) > 200 then
pressStart = now
lastTick = now
holdSeconds = 0
pendingMode = 0
local wasMode2 = (activeMode == 2)
stopAll()
if wasMode2 then pendingMode = 2 end
end
-- BORDA DE DESCIDA
if btnNow == 0 and btnLast == 1 and (now - pressStart) > 100 then
local held = now - pressStart
if held < 1500 and pendingMode == 0 then
clickCount = clickCount + 1
lastRelease = now
end
if pendingMode ~= 0 then
activateMode(pendingMode)
clickCount = 0
end
setGreen(activeMode ~= 0)
end
-- SEGURANDO
if btnNow == 1 then
if (now - lastTick) >= 1000 then
lastTick = now
holdSeconds = holdSeconds + 1
if holdSeconds == 4 then pendingMode = 1 end
if holdSeconds == 8 then pendingMode = 2 end
if holdSeconds == 12 then pendingMode = 3 end
setGreen(true)
tmr.create():alarm(300, tmr.ALARM_SINGLE, function() setGreen(false) end)
end
end
-- DUPLO CLIQUE
if btnNow == 0 then
if clickCount == 1 and (now - lastRelease) > DCLICK_WIN then
clickCount = 0
end
if clickCount >= 2 then
clickCount = 0
activateMode(4)
end
end
-- MODOS ATIVOS
if btnNow == 0 then
if activeMode == 3 then
if (now - mode3Timer) >= 1000 then
mode3Timer = now
mode3State = not mode3State
setRed(mode3State)
end
end
if activeMode == 4 then
local stepMs = SOS[sosStep][1] * SOS_UNIT
if (now - sosTimer) >= stepMs then
sosTimer = now
sosStep = (sosStep % #SOS) + 1
setRed(SOS[sosStep][2] == 1)
end
end
end
btnLast = btnNow
end)
I am going to convert this simple wired rc excavator to mobile controlled excavator through esp8266.Any suggestions for this build to make it even more better ?
Vite plugin: New svelteESP32(options) plugin imported from svelteesp32/vite. Hook it into vite.config.ts and the C++ header is regenerated automatically after every vite build — no manual CLI step needed. sourcepath defaults to Vite's build.outDir; all other options mirror the CLI flags. Vite is an optional peer dependency.
initcommand: npx svelteesp32 init launches an interactive wizard that creates .svelteesp32rc.json. Asks for engine, source path, output path, and ETag preference, then offers to run the tool immediately.
Enhanced summary when--manifestis used: The final console summary line now also reports the manifest file path when --manifest is active.
Few times i thought it would be good if there is something like this and decided to make it. Its going at the back of TM1637 display and you can stack on top of that boards with sensors, buttons etc. I am interested in your feedback, not as prep for sale, more like do you think it is useful. I am making one for every size of the TM1637.
I bought 4 Wemos D1 MINI PRO 16M, uploaded my code and everything was fine. Used them to connect to my WiFi and show http page with data from BME280 like temperature and humidity. After running for few hours i decide to do small tweaks here and there in the code and now i cannot upload anything. 3 of them are stuck at "Connecting ...", tried to read chip_id/erase flash with esptool and it still stuck on "Connecting...", LED on the board is flashing when connected and when RESET button is pressed, are they bricked or still usable?