EmonPi: Error MQTT not connected, SSH says otherwise

We have just bought an EmonPi but using our own raspberry Pi 3 and flashed 07-Nov-16 image to 8GB SD card. Order number #15430, order date: 20/07/2017
(Have already tried related topic solutions from forum)
Had an LCD connection problem- fixed (soldered button’s wire) and therefore checked all other connections - hardware is fine.

On Emoncms, running locally on the pi, no inputs appear, although LCD shows that CT clips and temperature sensor are present when booting up.
When checking mqtt status and restarting it on SSH it all looks fine, but still there is the error message on LCD:
Error
MQTT not connected.

We have no data from our EmonPi.

Please help.

As the base SD card image is quite old now, can you run the “UPDATE” function from the web page ?

Have already tried that.

What happens when you follow the testing guide from here?

Specifically when you run the command (from SSH)

mosquitto_sub -v -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ’ emon/#’

When running that command it appears to hang on the command line.

Would this command usually return the results quickly or take a long amount of time (I left it for 5 minutes to complete)?

I tested publishing using mqttlens and messages appear in the chrome web app so i am able to connect.

The above command should hang, but also dump out any messages passing over MQTT

Can you try running “sudo service emonhub restart”

Are you getting any logs in the emonhub web page?

No messages were output the whole time that command was running.

I restarted the emonhub service and here is the output from the emonhub web page.

2017-08-03 11:01:40,492 INFO MainThread Creating EmonHubJeeInterfacer ‘RFM2Pi’
2017-08-03 11:01:40,495 DEBUG MainThread Opening serial port: /dev/ttyAMA0 @ 9600 bits/s
2017-08-03 11:01:42,498 WARNING MainThread Device communication error - check settings
2017-08-03 11:01:42,499 INFO MainThread Setting RFM2Pi frequency: 433 (4b)
2017-08-03 11:01:43,501 INFO MainThread Setting RFM2Pi group: 210 (210g)
2017-08-03 11:01:44,503 INFO MainThread Setting RFM2Pi quiet: 0 (0q)
2017-08-03 11:01:45,506 INFO MainThread Setting RFM2Pi baseid: 5 (5i)
2017-08-03 11:01:46,508 INFO MainThread Setting RFM2Pi calibration: 230V (1p)
2017-08-03 11:01:47,510 DEBUG MainThread Setting RFM2Pi subchannels: [‘ToRFM12’]
2017-08-03 11:01:47,511 DEBUG MainThread Interfacer: Subscribed to channel’ : ToRFM12
2017-08-03 11:01:47,512 DEBUG MainThread Setting RFM2Pi pubchannels: [‘ToEmonCMS’]
2017-08-03 11:01:47,512 DEBUG MainThread Interfacer: Subscribed to channel’ : ToRFM12
2017-08-03 11:01:47,514 INFO MainThread Creating EmonHubMqttInterfacer ‘MQTT’
2017-08-03 11:01:47,515 INFO MainThread MQTT Init mqtt_host=127.0.0.1 mqtt_port=1883 mqtt_user=emonpi
2017-08-03 11:01:47,519 DEBUG MainThread MQTT Subscribed to channel’ : ToEmonCMS
2017-08-03 11:01:47,520 INFO MainThread Creating EmonHubEmoncmsHTTPInterfacer ‘emoncmsorg’
2017-08-03 11:01:47,522 DEBUG MainThread emoncmsorg Subscribed to channel’ : ToEmonCMS
2017-08-03 11:01:47,621 INFO MQTT Connecting to MQTT Server
2017-08-03 11:01:47,624 INFO MQTT connection status: Connection successful
2017-08-03 11:01:47,625 DEBUG MQTT CONACK => Return code: 0
2017-08-03 11:01:47,727 INFO MQTT on_subscribe
2017-08-03 11:02:17,559 INFO emoncmsorg sending: https://emoncms.org/input/bulk.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y&data=[]&sentat=1501758137
2017-08-03 11:02:17,659 DEBUG emoncmsorg acknowledged receipt with ‘ok’ from https://emoncms.org
2017-08-03 11:02:17,660 INFO emoncmsorg sending: https://emoncms.org/myip/set.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y
2017-08-03 11:02:47,590 INFO emoncmsorg sending: https://emoncms.org/input/bulk.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y&data=[]&sentat=1501758167
2017-08-03 11:02:47,685 DEBUG emoncmsorg acknowledged receipt with ‘ok’ from https://emoncms.org
2017-08-03 11:02:47,686 INFO emoncmsorg sending: https://emoncms.org/myip/set.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y
2017-08-03 11:03:17,621 INFO emoncmsorg sending: https://emoncms.org/input/bulk.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y&data=[]&sentat=1501758197
2017-08-03 11:03:17,750 DEBUG emoncmsorg acknowledged receipt with ‘ok’ from https://emoncms.org
2017-08-03 11:03:17,750 INFO emoncmsorg sending: https://emoncms.org/myip/set.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y

Okay that looks normal.

Do you have inputs and feeds configured ?

I don’t have any inputs displaying on the webpage by default even though i have connected a temperature sensor. The only time anything shows on the inputs page is when i send a fake message using the API to generate inputs.

My understanding was that having the temperature sensor connected should automatically generate some input figures or am I wrong?

Thanks

2017-08-03 11:01:40,495 DEBUG MainThread Opening serial port: /dev/ttyAMA0 @ 9600 bits/s
2017-08-03 11:01:42,498 WARNING MainThread Device communication error - check settings

9600 is the wrong baud for an emonPi, try setting com_baud = 115200 in the [[RFMP2Pi]] [[init_settings]]] section of emonhub.conf.

com_baud has been updated to 115200 but mqtt error still appears on LCD. See below for emonhub log which still states ‘device communication error - check settings’.

We are using a Raspberry Pi 3 Model B V1.2 . Are there any know issues with this?

2017-08-03 14:06:08,552 INFO MainThread EmonHub emonHub ‘emon-pi’ variant v1.2
2017-08-03 14:06:08,553 INFO MainThread Opening hub…
2017-08-03 14:06:08,554 INFO MainThread Logging level set to DEBUG
2017-08-03 14:06:08,555 INFO MainThread Creating EmonHubJeeInterfacer ‘RFM2Pi’
2017-08-03 14:06:08,557 DEBUG MainThread Opening serial port: /dev/ttyAMA0 @ 115200 bits/s
2017-08-03 14:06:10,559 WARNING MainThread Device communication error - check settings
2017-08-03 14:06:10,561 INFO MainThread Setting RFM2Pi frequency: 433 (4b)
2017-08-03 14:06:11,563 INFO MainThread Setting RFM2Pi group: 210 (210g)
2017-08-03 14:06:12,565 INFO MainThread Setting RFM2Pi quiet: 0 (0q)
2017-08-03 14:06:13,567 INFO MainThread Setting RFM2Pi baseid: 5 (5i)
2017-08-03 14:06:14,569 INFO MainThread Setting RFM2Pi calibration: 230V (1p)
2017-08-03 14:06:15,572 DEBUG MainThread Setting RFM2Pi subchannels: [‘ToRFM12’]
2017-08-03 14:06:15,573 DEBUG MainThread Interfacer: Subscribed to channel’ : ToRFM12
2017-08-03 14:06:15,573 DEBUG MainThread Setting RFM2Pi pubchannels: [‘ToEmonCMS’]
2017-08-03 14:06:15,574 DEBUG MainThread Interfacer: Subscribed to channel’ : ToRFM12
2017-08-03 14:06:15,576 INFO MainThread Creating EmonHubMqttInterfacer ‘MQTT’
2017-08-03 14:06:15,577 INFO MainThread MQTT Init mqtt_host=127.0.0.1 mqtt_port=1883 mqtt_user=emonpi
2017-08-03 14:06:15,580 DEBUG MainThread MQTT Subscribed to channel’ : ToEmonCMS
2017-08-03 14:06:15,581 INFO MainThread Creating EmonHubEmoncmsHTTPInterfacer ‘emoncmsorg’
2017-08-03 14:06:15,583 DEBUG MainThread emoncmsorg Subscribed to channel’ : ToEmonCMS
2017-08-03 14:06:15,682 INFO MQTT Connecting to MQTT Server
2017-08-03 14:06:15,686 INFO MQTT connection status: Connection successful
2017-08-03 14:06:15,688 DEBUG MQTT CONACK => Return code: 0
2017-08-03 14:06:15,790 INFO MQTT on_subscribe

I cannot comment on the mqtt error message on the screen, but the data arrives to the RPi via the the serial port which is read directly by emonhub. If emonhub isn’t reading any any stream from the serial port it cannot publish it to MQTT regardless of whether the MQTT side is good or not.

You need to focus on getting a data stream into emonhub via the serial port first.

  1. Is the emonPi add-on board powered? You must power via the mini usb on the emonpi board, not via the micro usb on the RPi.
  2. Is the serial port functional on the RPi? I would expect the std image to work from the get go with any RPi 3, Have you altered any serial port settings using raspi-config or editing config.txt or cmdline.txt?
  3. Is the firmware installed on the emonPi (I have no idea if the unassembled emonPi is preloaded), Is the LED flashing on the emonpi add-on board (assuming it’s uncased, it isn’t visible once cased)
  4. Did you run the emonpi update with the emonpi board attached? or before you attached it to the RPi?
  5. Have you tried power-cycling the RPi and the emonpi board together since updating? Rebooting doesn’t restart the emonpi board, try disconnecting and re-applying the power.

Can you also post your update.log, available via the emoncms admin page?

  1. Yes, I am using mini usb and not the micro usb as we are using the EmonPi enclosure which prevents using the micro usb.
  2. No serial port settings have been changed. This is a fresh image with the only config change being to the com_baud value as you recommended.
  3. I am not sure if the EmonPi firmware is installed. Is there any way to check this? LED is flashing on both boards.
  4. EmonPi update was performed when the emonPi board was attached to the RPi.
  5. Have power-cycled the RPi and emonpi board since updating.

See attached txt file for the update log from emoncms admin page:
emonpiupdate.txt (5.8 KB)

The first line of your update.log says

I2C LCD NOT DETECTED on either 0x['27', '3f'] ...exiting LCD script

With issues on both the I²C and the GPIO serial port I have to ask if the emonpi board is definitely seated correctly on the RPi. Although i have to say I would expect bigger issues if it was wrongly connected, but worth a check.

Can you also see if any errors are reported in /var/log/service-runner.log? this will require logging into the RPi command line via ssh.

Just noticed you are using your OWN Pi 3

You need to disable the internal bluetooth module as this is conflicting with the serial port used by emonPI.

See this section “Raspberry Pi 3 Compatibility”

I had assumed that to be included in the standard downloaded image to work on any Pi 3, shop supplied or not, hence asking if any changes were made to the config.txt etc. plus I²C shouldn’t be affected by the BT and serial mapping (as far as I’m aware), fingers crossed it is that straight forward.

You are probably correct, I don’t have a PI 3

Yesterday after one of the reboots the Pi 3 was no longer receiving power from the GPIO pins so may have been a faulty board. I would be interested to see whether the bluetooth module was causing the problem in the first place.

In the meantime i have found a spare Pi 2 which is successfully picking up data.

If i get the chance to check against a Pi 3 again then i will update this post with the information.

Many thanks for the help.