How to Configure and Connect to Cumulocity IoT in Rasbery Pi?

So I need to follow this command, right?

sudo tedge config set c8y.url “aatif312.eu-latest.cumulocity.com

sudo tedge cert upload c8y --user “aatif_jariwala”

I followed this command shown in the figure, but it gives the same error :frowning_face:

From what I can tell it looks like you’re now using the correct url and username (though I can’t verify that myself, so I will have to trust you on that).

So I can still think of a few scenarios which might be causing you to get a 401 (not authorized) response:

  1. You are using the wrong password (or something unexpected is happening when you are pasting/typing the password when you are prompted by the tedge command).
  2. You are using a SSO (Single Sign On user). SSO users can’t access the API (used by tedge cert upload) via a username/password, as it requires the generation of a token instead. An alternative solution would be to create a new user in your tenant by following the Cumulocity documentation, though don’t enable TFA (Two Factor Authentication) for this user as that is also not supported for the uploading of certs.

It is an ‘external’ user being used.

Can you use a different account or allow me to create you one for the certificate upload?

The same problem occurs when I use another different account.

How do I give you access to create a new account?

I’ve created a user ‘certuser’. I’ll email you the password.

ok, please share the password to my email

Sent to aatif.jariwala@dnkmail.in

Hi Robert, I have not received the mail yet

Is there an alternative email address I can use?

mdaatif2000.dnk@gmail.com

You can send me credentials to this email.

Ok I have got it password from my email address

my tenant id:- certuser

So I can log in with these credentials, and what is my environment name for login purposes?

certuser is your user id. You have the password via emal.

the tenant is http://aatif312.eu-latest.cumulocity.com

Type this in a browser address bar and use the credentials to check you can log on to the tenant.

Hi Robert,
I have successfully connected to the Cumulocity account using (certuser) user id in the raspberry pi device.
But I can not send data using Mosquito broker
I have faced such kinds of errors:-

From the screenshot that you posted, it shows that you are running the mosquitto MQTT broker from a non-standard location (e.g. just from a folder under ~/Downloads/...).

I would highly recommend following the thin-edge.io getting started guide, and installing it as per the instructions.

Yes you can use a custom installed mosquitto broker, however you need to then managed the bridge configuration yourself…I would avoid this if possible, as the more non-standard your setup is, the more likely you will run into unexpected pitfalls, and unless you know how to handle them, it just unnecessarily complications things. It also makes it hard to offer support :wink:

1 Like

Yes Reuben we have followed the thin-edge.io steps but it gives an error

We are using the default setup of Paho mosquito broker, Are there any steps for installation for Mosquitto broker? Because we are currently using by default MQTT broker by Eclipse Paho.

What Reuben is mentioning is that you should use the MQTT Broker that comes with thin-edge.io because the configuration is much more easier than using your own installed MQTT Broker.

Btw. paho is the mqtt client, mosquitto is the mqtt broker.

The manual steps to configure a mqtt broker can be found here Mosquitto Configuration | Thin-edge. This excludes the bridge configuration, so this is why Reuben mentioned to avoid this and use the pre-configured broker which comes with these steps:

If you installed thin-edge.io using the install script (as detailed in the getting started instructions), then it would have installed the mosquitto Debian package which runs the mosquitto broker as a service under the service manager (systemd, part of the operating systemd).

From your previous screenshot showing the mosquitto log output, it showed that you were starting mosquitto manually and not using the system service, because the screenshot showed you were calling mosquitto from the command line…this is not correct.

Also, you can’t have two mosquitto brokers running either as this can cause problem.

So I would try the following:

  1. Stop your manually started mosquitto broker

  2. Start the mosquitto service using:

    sudo systemctl stop mosquitto
    sudo systemctl enable mosquitto
    sudo systemctl start mosquitto
    

    Check that the mosquitto systemd service is actually running afterwards using:

    sudo systemctl status mosquitto
    

    If there are any errors shown (or the service is not running), then you will have to consult the mosquitto documentation or their project page. But just doing a google search of your mosquitto specific error should be enough to find some relevant information.

  3. Installing additional mosquitto clients (this installs the mosquitto_sub and mosquitto_pub cli commands)

    sudo apt-get update
    sudo apt-get install -y mosquitto-clients
    
  4. Try publishing to the broker (just to check that the broker is running)…the message could be anything, but you shouldn’t see any errors when running the command.

    mosquitto_pub -t 'dummy/topic' -m ''
    
  5. Then try to reconnect the thin-edge.io mapper.

    sudo tedge disconnect c8y
    sudo tedge connect c8y
    

If this still does not work, then you need to provide some more information about your setup, as all systems are not the same, so without knowing more specifics then it is a bit difficult to assist.

  • What hardware are you using (Raspberry Pi 3/4 ?)
  • What operating system version are you using: cat /etc/os*
  • What system architecture are you using: uname -a
  • What version of thin-edge.io are you using: tedge --version

Though I suspect if you still feel out of depth, then maybe a more hands on meeting would be appropriate, however this would depend on support contracts etc.

1 Like

I am using this Ubuntu 18.04.5 version, not raspberry pi. Is there any issue with the Ubuntu version ??

I have followed your process, but it gives some error, What am I doing wrong?

I think we need to talk about some general guidelines first when posting responses, before continuing.

Guide to being a good forum citizen

1. Please don’t post misleading/false information

The title of the ticket mentions that you are using a Raspberry Pi, but now you’re saying you’re on Ubuntu.
Having misleading information makes it very difficult (and frustrating) for people to help.

2. Provide more context when something does not work as expected

Generally don’t just post “What am I doing wrong?” without providing more context. A screenshot of one line form the console is not enough context to help. Most of the time the lead up to the error is more useful than the error itself.

3. Use code-blocks over images if you can

Images are not very helpful to transmit information on forum style websites. Images are less searchable, and generally it is a pain for anyone helping to copy information from the image when debugging unexpected behaviour.

Instead use a markdown code block (see the link for the syntax). A code block makes it much easier for everyone to read/copy from (especially when we’re talking about console output which is 100% text based).

Here is an example how a markdown code block is visualized…it is just plain text but rendered in a nice fenced block.

# sudo systemctl status mosquitto
● mosquitto.service - Mosquitto MQTT Broker
     Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-06-28 07:37:35 UTC; 1 weeks 2 days ago
       Docs: man:mosquitto.conf(5)
             man:mosquitto(8)
    Process: 35 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS)
    Process: 38 ExecStartPre=/bin/chown mosquitto /var/log/mosquitto (code=exited, status=0/SUCCESS)
    Process: 44 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS)
    Process: 46 ExecStartPre=/bin/chown mosquitto /run/mosquitto (code=exited, status=0/SUCCESS)
   Main PID: 60 (mosquitto)
      Tasks: 1 (limit: 9515)
     Memory: 52.9M
     CGroup: /docker/c2d0a8898f9600d80a088d1bf3c0bfec9b43ea084b9dcc6d854ae70bb3255dd9/system.slice/mosquitto.service
             └─60 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Jul 08 06:17:52 c2d0a8898f96 mosquitto[60]: 1688797072: Sending PUBLISH to auto-B4BB0523-8946-3F87-FB13-33E6D4DE58A4 (d0, q0, r0, m0, 'tedge/measurements/tedge_c2d0a8898f96_child01', ... (65 bytes))
Jul 08 06:17:52 c2d0a8898f96 mosquitto[60]: 1688797072: Received PINGREQ from tedge_c2d0a8898f96_child01

Ok now back to the topic.

Point 1: You are using a operating system which is now End-of-Line and no longer supported by Ubuntu!

You are using an older Ubuntu 18.04 version which is now in End-of-Line and no longer supported since official 2023-05-31, however generally you should be upgrading the operating system before the end-of-line date.

I would strongly insist upgrading your (server/virtual machine?..hard to say because you didn’t post your the hardware information I requested). Never use unsupported/outdated operating systemd as they do not receive security patches for both the operating system and any software package!

Point 2: Did you follow my instructions?

If you followed all of the instructions from my last post, can you please include the entire output in a markdown code block (mentioned in the guideline above). And if you didn’t follow my instructions, can you please run them again.

It is very difficult to say “what went wrong” without showing me proof that you did in fact run the commands. As previously you’ve posted confusing information, where I believe your description is misleading to what you are actually doing. For example, you posted that the thin-edge.io install script worked just fine, but then you post console output showing that you manually started mosquitto by calling the binary directly from a custom downloaded folder!

You could also be experiencing problems because you are using an unsupported operating system, that the mosquitto version available there is too old…but this is pure speculation, as I don’t have any information from you to go by.

3 Likes