I started out this tutorial by admitting I didn't build it in the best possible way. There are two ways I could have done it better.
- Send the light sensor data directly from the Feather ESP8266 to io.adafruit.com using the MQTT library and skipped the intermediate MQTT infrastructure altogether. This is probably the simplest option.
- Change the local MQTT topic to include subtopics, then directly bridge the local and io.adafruit.com MQTT queues.
Send directly to io.adafruit.com from the ESP8266.
I don't have the Lua code written and tested for doing this, but I know that Lua supports direct MQTT interactions. After all, that's how I get the data into the local MQTT queue. The trick is to use your Adafruit.IO key as the password when you configure the MQTT connection in Lua. Without testing this I can't guarantee it would work, but it should be ok. I'll get a couple more Feather Huzzah! ESP8266 modules and test both of these alternative configurations. I'm actually most interested in the next option
Broker-to-Broker Bridging
This is an intriguing possibility. According to the documentation, it should (again) work. The trick, once you have the local feed set up, is to modify your /etc/mosquitto/conf.d/mosquitto.conf file to append this section to the example I already provided::
# # Bridge to Adafruit.IO # connection adafruit-light-sensor address io.adafruit.com:1883 bridge_atetempt_unsubscribe false cleansession false notifications false remote_username CHANGE_TO_YOUR_USER_NAME remote_password CHANGE_TO_YOUR_AIO_KEY start_type automatic topic /sensors/lightsensor out 0 lightsensor
Restart mosquitto with this command:
sudo systemctl restart mosquitto.service
Once this is done the lightsensor data should be flowing automatically from your local MQTT instance into io.adafruit.com, where you can configure dashboards as before.
As I noted, I have NOT tried these two techniques yet, though I plan to do so.
Text editor powered by tinymce.