A few days ago I saw a new (first commit on GitHub just 5 days ago) library that made it possible to use MQTT on an Arduino-ish board and use the ESP8266 Wifi Serial Transceiver to connect to a MQTT broker. I just had to try it out 🙂
I used the same setup as before cause it was still on my desk, installed the library in the Arduino IDE, checked the SERIAL_BUFFER_SIZE in [your program files]ArduinohardwarearduinocoresarduinoHardwareSerial.cpp (OK in Arduino 1.0.6, didn’t check older versions), changed the example regarding MQTT broker address, Wifi SSID & password, client id (JeeNode_on_your_desk), set the debug serial port to pins 6 & 7 and uploaded the sketch to the JeeNode.
And it’s working, as the Mosquitto MQTT broker messages show below:
D:Program Files (x86)mosquitto>mosquitto -c mosquitto.conf mosquitto version 1.1.2 (build date 30/01/2013 20:46:29.67) starting Config loaded from mosquitto.conf. Opening ipv6 listen socket on port 1883. Opening ipv4 listen socket on port 1883. New connection from 192.168.10.155. New client connected from 192.168.10.155 as JeeNode_on_your_desk. New connection from ::1. New client connected from ::1 as mosqpub/3228-devbox.
Nice! Let’s try to send an MQTT message to the JeeNode:
mosquitto_pub -h localhost -t /topic -m "Hi there, it's me!"
And the debug port showed this:
[espduino_mqttclient] RESET ESP done WIFI: Connected TCP: Connected AT+CIPSEND=36 MQTT: Connected MQTT:Connected MQTT: subscribe, topic AT+CIPSEND=13 MQTT: Subscribe successful MQTT: Send keepalive packet AT+CIPSEND=2 MQTT: Send keepalive packet AT+CIPSEND=2 MQTT: Send keepalive packet AT+CIPSEND=2 Received, topic:/topic, data:Hi there, it's me! MQTT: Send keepalive packet AT+CIPSEND=2 MQTT: Send keepalive packet AT+CIPSEND=2 ...
And here’s what the communication between JeeNode & ESP8266 looks like:
AT+RST ATE0 AT+CWMODE=1 AT+CWJAP="SSID","password" AT+CIPMUX=0 AT+CIPCLOSE AT+CIPSTART="TCP","192.168.10.179",1883 AT+CIPSEND=36 " MQIsdp JeeNode_on_your_deskAT+CIPSEND=13 , /topic AT+CIPSEND=2 AT+CIPSEND=2 AT+CIPSEND=2 ...
Nice; not that I have any immediate use case for it (my Zigbee network based on XBee modules is still working fine), but it’s fun to see this working and good to know it exists.
Next ‘experiment’ will be an MQTT client on the ESP8266 itself (yep, without MCU). I’ve already installed the ESP8266 Windows Eclipse IDE in a VM so that I can flash the ESP8266 with a firmware that includes this MQTT client; that will be even more exciting; stay tuned!