A project log for Wireless remote LCD

Battery powered remote display for logging station

muthMuth 08/02/2016 at 22:580 Comments

By looking at the tests I made, I have to make something simpler (indeed). Java uploading an image using FTP which is translated to hex by a PHP script, to be received on the ESP8266 and interpreted in LUA to be sent to the SPI screen...


Why use the web server ? I should focus, I digress. It could be nice to have a LCD screen showing whatever an image from internet, but it's another project.

From what I have, I could simplify by open a socket server on the Pilogger Java program and connect to it with the ESP to retrieve the image data.

On java side I not used sockets often, but it is not so complicated.

serverServer = new ServerSocket(9999);
clientSocket = serverServer.accept();
inputStream = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
outputStream = new PrintStream(clientSocket.getOutputStream());

while (true) {
	line = inputStream.readLine();
	if (line.contains("LCD")) {

On port 9999, if I receive the string "LCD", I send the raw data for the LCD. it is even nicer as I could directly send the bytes needed by the LCD, in the correct format. All the processing is done in Java on the raspberry pi. What still to be done on the ESP is the socket connection, and the CS line logic. The LUA script is as short as :
-- GPIO 2 is the CS line of the LCD SPI connection
gpio.mode(2, gpio.OUTPUT)
gpio.write(2, gpio.LOW)
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 50, spi.HALFDUPLEX)

srv = net.createConnection(net.TCP, 0)

srv:on("receive", function(sck, c) 
    spi.send(1, c)

srv:on("connection", function(sck, c)
    print("socket connected")
    gpio.write(2, gpio.HIGH)

srv:on("disconnection", function(sck, c)
    gpio.write(2, gpio.LOW)
    print("socket disconnected")

srv:connect(9999, "")
And it works really well, the screen is refreshed in about 100ms !