My kids would check our server to see if there are anyone logged in. With this display they do not have to boot the computer and start minecraft. Just a little look at the display and they know.
I wanted to make the hardware as simple as possible. Only an ESP8266, a servo and nessesary components around them.
I wanted all software to be in the esp8266 so that it should be easy to replicate.
The software on the ESP8266 module is simple too. It is an short script in LUA.
pl=1000
pin=4
tmr.alarm(0, 5000, 1, function()
po=pl
sk=net.createConnection(net.TCP, 0)
sk:on("receive", function(sck, c)
st,en= string.find (c, "Online: ")
if (en ~= nil) then
onl=string.sub (c,en+1,en+3)
st,en= string.find (c, "Max: ")
maon=string.sub (c,en+1,en+3)
pl=1800-onl*1800/maon
if (pl < 1000) then pl = 1000endif (pl == 1800) then pl = 1900endelseif (pl < 2000) then print ("Offline") end
pl=2000endif (pl ~= po) then
print(onl,maon, pl)
endend )
sk:connect(80,"192.168.4.1")
sk:send("GET /ESPing.php HTTP/1.1\r\nHost: 192.168.4.1\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")
end)
gpio.mode(pin,gpio.OUTPUT)
tmr.alarm(1, 1000, 1, function()
gpio.write(pin,gpio.HIGH)
tmr.delay(pl)
gpio.write(pin,gpio.LOW)
end)
This script is uploaded as init.lua.
It consist of two main timers.
the first one is geting a webpage from my webserver every 5sek an calculates the server position in the variable "pl". There is also some if statements for spesial cases "pl <1000" makes everything abowe 10 players show as 10 players. "pl==1800" is if there is none players online to make this stand out. And if the search for the field "Online:" fails the pl is set to 2000 and pointing to offline.
the other timer send a pulse to the servo to set its position. A new pulse is sent every 1sek.
The calculations is ment to scale to the "Max:" player field, but is not testet with anything else than 20 players. And would probably fail, at least on the spesial cases the if statements is handeling. This is something to fix later.
I also want the ESP module to chec directly with the minecraft server, but when pinging the server from the module I always missed the first part of the response (the part with the number of players) With a network sniffer i did check an it was sent from the server. Tis is also somthing to fix later.
The hardware for this project is mainly a servo and a esp module.
There is two resistors between the esp and the servo. One to keep the gpio pin on the esp high when booting an one to protect the esp if anything goes wrong with the servo.
The rest of the circuit is an simple 3.3v regulator made of some resistor, capacitor and a npn transistor. I don't even know the type transistor I used, I did only use my
multimeter to check if it was a npn. My parts bin was empty of npn
transistor, and I did not have a 3.3v regulator either....
The 5V for the servo and input to the regulator is from a old phone charger with a broken plug.
There is an photo of my hand drawn schematics in the project description.
I have the display up running. I did get some problems with lost packets when pinging the server directly from the ESP.
As for now I have a PHP script running on my webserver to ping the minecraft server.
Then the ESP downloads this page and set the server position from what the page returns.
In the spesifications for the servo it should have a pulse from 1 to 2 ms that sets the position of the servo arm. This pulse should be repeated every 20ms. When i tried that I got a lot of jitter and noise from the servo. I have an update rate of 1 second now and it is nice and silent.