ESP8266 Workshop - January 21 - "Attempting useful things"

After last years efforts,

Lets get together and have another ESP8266 Workshop.

This time, we’ll try to make something “useful” with an ESP8266. Maybe a door controller, water-pump thingy, who knows.

Come along and find out…

In a chat yesterday (at the space) it was suggested that for the next meeting we find out if “useful things” are actually available or are likely to happen on the day. I, for example, was waiting for my esp-07 (arrived today) and am still waiting for a few other items (antenna, adapter). I also planned to experiment with the latest SDK (v0.9.4) but will have no time before the 21st (LCA!).

Nevertheless, if a good plan is put forward then we can surely have fun attempting it. Maybe move forward and install and configure a dev VM then build an app (using the LUA firmware?) thus enabling people to implement their pet projects (mine is a standalone (small battery) sensor (temp, humid) accessible over WiFi)?

cheers
Eyal

Hi @Eyal,

Well I’m flexible. Over the break I was experimenting with LUA Socket Servers and sending them commands like “On” + “Off” and then fiddling the GPIO from that. I got that working nicely.

I’m making a central locking system for an old-car to operate the door locks. When my phone comes in range I want the doors to unlock.

I haven’t had what you are suggesting working yet. Which is the C/C++ side. I’m interested in that too.

What about doing the C++/VM the following week? That will give us all time to prepare? Does that suite?

Sure, I am OK with any plan, and can attend the 21st regardless.

Eyal

So lets do 28th as a C++/Epressif Toolchain night?

I have added both dates to the Calendar and will open up. Hopefully, I will also break a lifetime’s habit and do something useful before we meet.

Cool.

I figured out how to code a button so that it can send an “Instruction Packet” to another machine/module to do something:

-- Send a Packet on a Socket with keypress
 
count = 0
delay = 0
gpio.mode(4,gpio.INT)

function transmit_msg()
   sk=net.createConnection(net.TCP, 0)
   sk:on("receive", function(sck, c) print(c) end )
   sk:on("connection", function(sck) sk:send("ButtonPress\r\n") end )
   sk:connect(9000,"192.168.0.6")
   tmr.delay(1000000)
   print("Sent")
   end

function buttonpress(level)
   x = tmr.now()
   if x > delay then
      delay = tmr.now()+100000
      count = count + 1
      print(".")
      transmit_msg()
      end
   end

gpio.trig(4, "down",buttonpress)
1 Like

I also got a web server and web page up to control the GPIO.

This also worked on my mobile-phone.

Of course it could be easily customised too. But that was just a downloaded example.

The URL’s were:
http://192.168.0.9/?pin=OFF
http://192.168.0.9/?pin=ON

and I found that I could drive it from the command line too:

curl http://192.168.0.9/?pin=OFF

or

curl http://192.168.0.9/?pin=ON

1 Like

I know have the button side working that sends a HTTP Get request to the server allowing you to toggle the GPIO pin on the receiving end.

-- Send a Web Instruction to another module on keypress
count = 0
delay = 0
buttonstate = false
d1_input = 4 -- Pin number
gpio.mode(d1_input,gpio.INT)

function transmit_msg()
   sk=net.createConnection(net.TCP, 0)
   sk:on("receive", function(sck, c) print(c) end )
   sk:on("connection", function(sck) 
       if buttonstate then 
           sk:send("GET index.html/?pin=OFF HTTP/1.0")
           print("Off Sent")
       else
           sk:send("GET index.html/?pin=ON HTTP/1.0")
           print("On Sent")
           end
       buttonstate = not buttonstate
   end )
   sk:connect(80,"192.168.0.13")
   tmr.delay(1000000)
   end

function buttonpress(level)
   x = tmr.now()
   if x > delay then
      delay = tmr.now()+50000
      count = count + 1
      print(".")
      transmit_msg()
      end
   end

gpio.trig(d1_input, "down",buttonpress)

Just now received the (yellow) mounting plate. On top of the 16 pins, there are two pad pairs, one (left) for VCC<->CH_PD and another (right) for GND<->GPIO15. Programming jumpers? They are 1.5mm spacing.
Note how the silkscreen is not properly aligned.

cheers

(OK, discourse does not convert local images to uploaded ones… now uploading)

Are we having a Wednesday ESP8266 meeting again? One is scheduled for this wednesday.

Note there are other panels, e.g.
http://www.aliexpress.com/item/-/32262434129.html

and more involved items like:
http://www.aliexpress.com/item/-/32254810086.html
http://www.aliexpress.com/item/-/32243934351.html
I am not clear what are all the items on the above last board.

cheers

I expect we meet this Wed (21st).

I’ll open up for a workshop on the 21st.

Seeyas then. I will bring some spare modules if anybody needs them for $5 with proceeds going to the tin.

Time? 6pm? Calendar says 10am (?!!)

Hi @Michael. the space is open from around 12.00 today but the ESP8266 folk will turn up around 6.30 (pm)

Ah, thanks Paul for info. M

Some progress. I have a working skeleton with the latest firmware.

1 - blank the firmware first (upload blank512.bin). I think that the new firmware is confused by the old settings at the end of the memory.

2 - upload the latest firmware, I used:
https://github.com/nodemcu/nodemcu-firmware/blob/master/pre_build/0.9.5/nodemcu_20150108.bin

3 - use luatool.py to upload an init script

python loatool.py -p COM6 -f init-eyal.lua -t init.lua

My simple script is:

print ("setmode");
wifi.setmode(wifi.SOFTAP);

print ("config");
wifi.ap.config({ssid="test",pwd="12345678"});

ip = wifi.ap.getip();
print (ip);

gpio.mode(4, gpio.OUTPUT)

srv=net.createServer(net.TCP) 
srv:listen(80,function(conn) 
    conn:on("receive", function(client,request)
        buf = "<h1> Hello, NodeMcu.</h1>";
        client:send(buf);
        client:close();
        collectgarbage();
    end)
end)

4 - connect to the esp (I use putty) and execute

node.restart()

This way I do not need to hard reset the board.

I now see the progress messages.

> node.restart()
> J3C¦¦:6¦:¦;!B¦A¦H|
                        ¦BC¦
NodeMCU 0.9.5 build 20150108  powered by Lua 5.1.4
setmode
config
192.168.4.1
>

I now connect my laptop to wireless station ‘test’ and then browse to 192.168.4.1 and get the expected Hello string.
I can now remove the debug prints and add back the body of the server.

BTW, the main.lua from David has a minor spelling error ‘opton’.

cheers
Eyal

Tested latest firmware nodemcu_20150118.bin. OK.
Tested David’s main.lua and it works fine.

cheers
Eyal

1 Like