MQTT and ESP8266

Got the vibration detection board working with MQTT. This was really an ordeal given that the memory issues with LUA and the ESP8266 are really frustrating. Its trial and error. Finally and after stripping the code to the bare minimum, i.e., remove all the fancy web page interface to the board configuration, things got working pretty good.

I installed my own MQTT broker on a MacBook, Mosquitto, and got it to work without major issues.

MQTT is really great for IoT, of course if you have a broker running or want to go through a public broker, otherwise my ad-hoc messaging solution I think it is a bit easier for home projects. But again, MQTT is the way to go if you want to control several devices, send and receive various commands, etc.

On my future boards I will offer ad-hoc messaging or MQTT, check them out on Tindie

Advertisements

About hbouzas

Born in Buenos Aires, Argentina. Studied Physics at the University of Buenos Aires. Joined Schlumberger in February 1985 in Houston, Texas, and worked in several technical and managerial positions until 2000. From 2000 until 2008 held several management positions in Abingdon, UK; Calgary, Alberta and London, UK. Worked in the areas of Geophysical Exploration, Geological Modeling, Structural Modeling, Reservoir Modeling and Petroleum Economics and holds several patents. He is currently the Norway Technology Center Manager for Schlumberger Information Solutions and is based in Oslo and Stavanger. Main interest are software, technology, innovation, 3D visualization, design, human computer interaction, energy, environment.
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to MQTT and ESP8266

  1. JF says:

    What do you mean by “ad-hoc messaging solution”

    Can you explain how you did it ? I thought maybe to use UDP packets between multiple esp8266 (to keep complexity down)

    • hbouzas says:

      What I mean by ad-hoc messaging solution is defining a message format that the firmware in the module understands. For example, to control the temperature board I simply send a string of the format THL020030040050, where
      THL: is just a label to ensure that the module is receiving the right message
      020: minimum temperature
      030: maximum temperature
      040: minimum humidity
      050: maximum humidity

      If you want to reset the limits to 25 min temperature, 45 max temperature, 75 min humidity and 95 max humidity, you will then send:

      THL025045075095

      The code to listen and decode:

      sv=net.createServer(net.TCP, 30)

      sv:listen(9999,function(conn)
      conn:on(“receive”, function(conn, payload)
      code_s=string.sub(payload,1,3)
      if code_s == “THL” then
      code_s = nil
      lt_s=string.sub(payload,4,6)
      lt = tonumber(lt_s)
      lt_s =nil
      lt_s =string.sub(payload,7,9)
      ht = tonumber(lt_s)
      lt_s =nil
      lt_s =string.sub(payload,10,12)
      lh = tonumber(lt_s)
      lt_s =nil
      lt_s =string.sub(payload,13,15)
      hh = tonumber(lt_s)
      lt_s =nil
      payload =nil
      end)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s