flagtrax
Posts: 38
Joined: Thu Mar 02, 2017 12:31 am

Newbie requires help for using MQTT

Sun Mar 04, 2018 3:43 pm

I posted this on another subject (relating to web sockets) so apologies for duplicate I think it better belongs here.

I really need steering. I have to say I am still new to Raspian, Linux type OS's in general, and the Raspberry pi. Not chronologically mind you but by lack of experience and time to work with it. In an effort to learn more, I'm currently trying to work through a project that was posted on You Tube (here https://www.youtube.com/watch?v=AUbFWSz8PjA )that uses a Raspberry Pi running mosquitto to communicate between clients on ESP8266's etc. The first module sets up the broker and I can publish and subscribe fine terminal windows. The second module adds a Python reporting/logging script requiring paho. There was not much instruction given as to how to incorporate the paho py libraries into the Pi environment. That being said I was able to install (I think) paho-mqtt. with a sudo pip3 install paho-mqtt command. I then tried to run the script from the project (downloaded from author's github) with sudo MQTT_logger.py. This generates an error "File "MQQT_logger.py, line 4, in <module> import paho.mqtt.client as mqtt Import Error: No module named paho..mqtt.client" I honestly don't know enough to ask the proper questions, I'm sure. But if anyone can steer me to an explanation of what I'm not doing right, I'd sure appreciated it.

User avatar
DougieLawson
Posts: 35025
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Newbie requires help for using MQTT

Sun Mar 04, 2018 4:39 pm

Get https://github.com/knolleary/pubsubclient and your ESP8266 can subscribe or publish direct to your Raspberry Pi broker.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11665
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Newbie requires help for using MQTT

Sun Mar 04, 2018 7:01 pm

please don't hijack threads, or post duplicate posts.

User avatar
DougieLawson
Posts: 35025
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Newbie requires help for using MQTT

Sun Mar 04, 2018 7:07 pm

mahjongg wrote:
Sun Mar 04, 2018 7:01 pm
please don't hijack threads, or post duplicate posts.
He broke the thread off deliberately from another hijacked thread. That's not duplication, that's almost sane behaviour.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

flagtrax
Posts: 38
Joined: Thu Mar 02, 2017 12:31 am

Re: Newbie requires help for using MQTT

Sun Mar 04, 2018 8:59 pm

My apologies mahjongg, but I don't understand what you mean by "hijacking". I am a member of numerous forums, from auto enthusiasts, antique tractor enthusiasts, computer, windows, arduino, ESP8266, skydiving, diesel forums, etc, and never before been accused of hijacking. I'm sorry if I don't understand your protocol, and I'll apologise in front of stating it seems a bit unfriendly. All I'm doing is trying to learn something new and gain information. Your term hijacking makes it sound like I'm trying to steal something.
Thank you Dougie for your response. I can tell you that I do have 2 ESP8266's working through a mosquitto broker running on a Rpi 2b. The project I'm following works in steps to ultimately build a complete home automation system. The purpose of the python script according to the author is to familiarize one with the concept of integrating python scripts into the mix which will later become more complex. There are 8 (as I recall) modules to this project and paho and python were introduced in the second module. Thanks again.

User avatar
DougieLawson
Posts: 35025
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Newbie requires help for using MQTT

Sun Mar 04, 2018 9:09 pm

I've got some sample programs that talk to my MQTT broker from a Raspberry with a BMP180 temp and pressure sensor, from a Wemos with a MXP31855 thermocouple and an Arduino with a MAX6675 thermocouple. I've also got a second Wemos with an LCD that subscribes to the messages published by the Arduino and displays them on an I2C LCD. Some bits are in python, some bits in Arduino IDE code. Some bits in HTML/Javascript. It's all a bit rough and ready.

I'll see if I can collect all of those pieces together and drop them on Github for you. I'm using Wemos D1 Minis as they're a handy form of ESP processor and only cost £3.28 from Banggood (some soldering needed).
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

flagtrax
Posts: 38
Joined: Thu Mar 02, 2017 12:31 am

Re: Newbie requires help for using MQTT

Sun Mar 04, 2018 9:30 pm

Thanks Dougie, I've been using generic ESP 07'S and 12's for the most part. I started out using an ESP-05 before I quickly learned (as did many others), that the GPIO's were not brought out for use. In other words it is stuck with the "AT" command os. Not many knew back then the power within the ESP8266. As fast as information was posted it was obsolete, and better platforms were created (IMHO). I struggled with the NodeMcu IDE for a while until Arduino finally added the 8266's to their IDE. Since I'd already worked with that platform on other projects, it made it much easier. I don't consider myself an expert by any means, but I can say I started building systems back when Gates and Jobs did. The difference was they sold their stuff, I gave mine away; not too smart eh :lol: . The whole learning curve is multiplied when dealing with several new disciplines all at once. For me Linux/Raspian is quite different to work with so what is obvious to others is mystery to me. My first instinct when having problems is "what did I do wrong", because truthfully I really don't know the OS. When I came across the Rpi, I thought it would be a good way to learn the principles of Linux and build some fun projects along the way. What it has come to is spending days scanning the internet for answers every time I have a question. Kinda takes the fun out. So any help is surely appreciated :!:

User avatar
DougieLawson
Posts: 35025
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Newbie requires help for using MQTT

Sun Mar 04, 2018 10:17 pm

Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

flagtrax
Posts: 38
Joined: Thu Mar 02, 2017 12:31 am

Re: Newbie requires help for using MQTT

Mon Mar 05, 2018 1:19 am

Thanks Doug I'll check 'em out!

Return to “Networking and servers”