Everybody is welcome to come along to another ESP8266 workshop where we discover what can be done with the ESP8266.
We had some leftover things not quite finished on the 21st due to USB-Burnout (well I did) and needing to improve/streamline the upload process. But it looks like we’re good now.
So we will try again - playing with simple web servers.
@PaulG has offered to bring his water-pump from a tank. So we’ll be trying to install a wifi interface with a Webserver on that.
Unfortunately this will be another one I cant make due to work.
I’ve spent a few nights now with the ESP and lua firmware. I’m using ESPlorer to write scripts and upload, makes life pretty easy.
Overall quite cool things, however I’ve found the lua firmware to be a bit fragile.
Sometimes for no reason I can work out it will get into a state where any write access to the flash (i.e. saving files or deleting files) will cause it to restart. Restarting, including by power, has no effect and the only solution I’ve found is to re-flash the firmware.
Memory management is still a bit of a mystery to me with these things. When using the webserver it’s very easy to end up with code that starts behaving very strangely, locking up and resetting, whilst still reporting >4k of heap available. At first I thought it was a power supply issue, but monitoring that on the scope proved otherwise. Removing two lines of html cleared up the problems, so I’m pretty sure it’s running out of memory.
Overall it would be great if there were more verbose error reporting. There’s lots of occasions I’ve found where they silently fail or just reset with no indication. Makes debugging challenging!
tested the latest firmware (20150123) which is so far OK.
decided to use my FTDI dongle and discovered it is a fake which was instantly killed by windows. Had to fiddle with the driver to get it working again…
attached a DS18B20 one-wire thermometer and checked that it works (used supplied samples).
learnt how to upload code and then run it manually.
I now used the esp-07 -OK after a few hiccups.
Tried the adc input. Works but is limited to 0-1v, we need a generic solution to extend this range.
Next I will want to play with i2c.
Following from today’s problem with the latest (20150127) firmware, when working with Chris, I validated that it is really broken (failed to flash my esp-07). I then looked up the repository
When you re-flash the firmware onto the ESP8266 it does not clear the WiFi settings that get stored in EEPROM. So if you’re having problems with a module, it requires flashing a “Blank” firmware first that writes blanks into everything, then reload the firmware. The blank firmware is available in the https://github.com/nodemcu/nodemcu-firmware repository under the bin folder.
There is a bug in the firmware we were using that caused the modules to keep restarting when connected to the MHV wifi. No idea what the bug is, as David and myself hadn’t see this at home. I’ve got a couple of spare routers at home which I can donate one for this as unfortunately it wasted quite a bit of time last night.
Was great to meet up with some other folk working on the same boards. It can save quite a few hours by sharing the tricks with these modules!
there are a lot of spare wifi routers at MHV - I think they are on the shelves near the live router, but I’ll look for them tonight. There is also an ADSL modem with wifi router being used as a network switch that could probably have it’s wifi activated if that helped. You could also see if the wifi downstairs was any better.
I’ve just got the latest nodemcu firmware as of 27 Jan.
Big change is they’ve added floating point support to the prebuilt binary. Tested briefly with all the basic math operators and seems to all work fine, as well as printing correctly.
I really needed this for what I’m doing, so pretty happy with that change.
Really? I sure could not get it to even flash yesterday. I then tested again at home and it did not flash on my esp-07 either.
I then checked the github repository and noticed that it was removed. Checked again just now and it is still not there.
I have MQTT working well. Installed Mosquito MQTT broker on a PC at home, the ESP sending updates and using MQTT.fx to view the msgs. Here’s some example code to loop sending msgs.
Server_IP_Address = "192.168.1.4"
Server_Port = 1883
published = 0
function periodic_publish()
published = published + 1
-- publish a message with data = hello, QoS = 0, retain = 0
m:publish("testing/nodemcu" ,"msg: " .. published,0,0, function(conn) print("sent") end)
collectgarbage()
end
-- init mqtt client with keepalive timer 120sec
m = mqtt.Client("clientid", 120, "user", "password")
m:on("connect", function(con) print ("connected") end)
m:on("offline", function(con) print ("offline") end)
-- on publish message receive event
m:on("message", function(conn, topic, data)
print(topic .. ":" )
if data ~= nil then
print(data)
end
end)
m:connect(Server_IP_Address, Server_Port, 0, function(conn)
print("connected, starting 5sec loop")
tmr.alarm(1, 5000, 1, periodic_publish)
end)
-- *****************
-- Just sending, so not bothering to subscribe
--******************
-- subscribe topic with qos = 0
--m:subscribe("test",0, function(conn) print("subscribe success") end)
--*******************
-- Not disconnecting since in a loop
--*******************
--m:close();
-- you can call m:connect again