# I2C with MQTT MangOH Yellow

**URL:** <https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175>\
**Category:** mangOH Yellow\
**Created:** [May 18, 2021, 9:26am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175 "2021-05-18T09:26:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukasmertens](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lukasmertens](https://mangoh.discourse.group/u/lukasmertens)\
**Post date:** [May 18, 2021, 9:26am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/1 "2021-05-18T09:26:59Z")

</div>

Hi,  
Is it possible to get data from a I2C sensor and publish this to a broker? Is it necessary to use Airvantage? Or can you just send data to a broker?

If it is possible how can i do it? I’m using the IoT card for I2C.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [May 18, 2021, 9:40am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/2 "2021-05-18T09:40:33Z")

</div>

No, it does not need to use Airvantage.  
You can try the MQTT sample here:

> <https://github.com/legatoproject/legato-af/tree/master/apps/sample/mqtt>
>
> //github.com/legatoproject/legato-af/tree/master/apps/sample/mqtt

Previously someone makes it work on mosquitto server.

> [@mqttClient Service Connect error?](https://mangoh.discourse.group/t/mqttclient-service-connect-error/9093/88):
>
> Finally problem resolved: using mosquitto MQTT client and server must to be on the same wlan! I didn’t know it! The problem is that my wifi is 5G and my TaLON wifi card doesn’t read it: so my mangOH was on my phone’s lan and PC on WiFi. So I connected all on my phone’s lan and all work! Thank you all for the support, especially to @jyijyi . I’m so sorry to have bothered you, but it was a frustrating situation. Thanks again.

---

<div class="post-metadata">

**Author:** ![lukasmertens](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lukasmertens](https://mangoh.discourse.group/u/lukasmertens)\
**Post date:** [May 18, 2021, 9:55am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/3 "2021-05-18T09:55:23Z")

</div>

Thanks for your reply.  
How can i install the mqtt sample application. Can i do it in the ssh from the MangOH?  
 ![afbeelding](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/5/535ac6258b31a09c91938eafbe1ee6118221a4d7.png)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [May 18, 2021, 10:20am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/4 "2021-05-18T10:20:29Z")

</div>

you need to compile it in “leaf shell”.

You can first install the VSCODE with LEAF plugin:

[https://docs.legato.io/latest/tools\_vsCode.html](https://docs.legato.io/latest/tools_vsCode.html)

---

<div class="post-metadata">

**Author:** ![lukasmertens](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lukasmertens](https://mangoh.discourse.group/u/lukasmertens)\
**Post date:** [May 18, 2021, 12:27pm UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/5 "2021-05-18T12:27:59Z")

</div>

I installed LEAF. But how can i install mqtt. I am totally unfamiliar with leaf. I also want data from a i2c sensor is that the same proces?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [May 18, 2021, 1:08pm UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/6 "2021-05-18T13:08:31Z")

</div>

Did you try to read data via i2c with your hardware?

Maybe you also need to install vscode.

Here has the instruction on how to compile

> <https://github.com/legatoproject/legato-af/blob/master/apps/sample/mqtt/README.md>

---

<div class="post-metadata">

**Author:** ![lukasmertens](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lukasmertens](https://mangoh.discourse.group/u/lukasmertens)\
**Post date:** [May 18, 2021, 1:20pm UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/7 "2021-05-18T13:20:17Z")

</div>

> [@jyijyi](#):
>
> Did you try to read data via i2c with your hardware?

No, i didn’t know how to do it. I never worked with VSCODE and LEAP. Do i need to make a program and then compile?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [May 18, 2021, 1:25pm UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/8 "2021-05-18T13:25:23Z")

</div>

You need to have at least a linux driver, right?

---

<div class="post-metadata">

**Author:** ![lukasmertens](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lukasmertens](https://mangoh.discourse.group/u/lukasmertens)\
**Post date:** [May 18, 2021, 2:56pm UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/9 "2021-05-18T14:56:19Z")

</div>

Yes, I have 🙂 I also have VSCODE.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [May 18, 2021, 3:00pm UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/10 "2021-05-18T15:00:11Z")

</div>

if your driver works, you should be able to read the required value in command line.  
For example, in mangoh red project, if we run the pressure sensor driver correctly, we can see the value in /sys/bus/i2c/devices/4-0076/iio:device1/in\_pressure\_input.

After that you can import the value in .cdef, here is an example where we read the sensor in mangoh red board and send to the Airvantage:

> <https://github.com/mangOH/RedSensorToCloud/blob/717ca1019394e8726ad352b87c982fdb21499024/components/sensors/pressure/Component.cdef>

---

<div class="post-metadata">

**Author:** ![lukasmertens](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lukasmertens](https://mangoh.discourse.group/u/lukasmertens)\
**Post date:** [May 18, 2021, 3:04pm UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/11 "2021-05-18T15:04:23Z")

</div>

You need to code everything? That’s possible in VSCode? And with that data from the sensor you can publish with mqtt? Sorry for that many questions. I don’t get it al all.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [May 18, 2021, 3:08pm UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/12 "2021-05-18T15:08:25Z")

</div>

did you driver work now?

---

<div class="post-metadata">

**Author:** ![lukasmertens](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lukasmertens](https://mangoh.discourse.group/u/lukasmertens)\
**Post date:** [May 21, 2021, 6:17am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/13 "2021-05-21T06:17:53Z")

</div>

I don’t know what you mean. What do you mean by “driver”?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [May 21, 2021, 6:24am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/14 "2021-05-21T06:24:28Z")

</div>

> [@lukasmertens](#):
>
> IoT card for I2C

didn’t you have new hardware on the IoT card which is using I2C?

---

<div class="post-metadata">

**Author:** ![lukasmertens](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lukasmertens](https://mangoh.discourse.group/u/lukasmertens)\
**Post date:** [May 21, 2021, 6:28am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/15 "2021-05-21T06:28:55Z")

</div>

My question is, how can i read data from an extern i2c sensor on pin 22 and 23 on the IoT Card form the mangoh yellow. [IoT Expansion Cards: adding sensors and networks connectivity](https://mangoh.io/iot-cards)  
With that data i will send it with mqtt to a mqtt broker.  
sorry for my bad explanation!

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [May 21, 2021, 6:31am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/16 "2021-05-21T06:31:27Z")

</div>

have you tried the i2c command?

root@swi-mdm9x28-wp:~# i2c  
i2cdetect i2cget i2cset.i2c-tools  
i2cdetect.i2c-tools i2cget.i2c-tools i2ctransfer  
i2cdump i2cgpioctl  
i2cdump.i2c-tools i2cset

---

<div class="post-metadata">

**Author:** ![lukasmertens](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lukasmertens](https://mangoh.discourse.group/u/lukasmertens)\
**Post date:** [May 21, 2021, 6:33am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/17 "2021-05-21T06:33:44Z")

</div>

I get this error after executing the command  
 ![afbeelding](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/b/b7d0fd4993128167b9e6c15bb87fa3f3bd5f73c7.png)

i2cdetect does work

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [May 21, 2021, 6:45am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/18 "2021-05-21T06:45:51Z")

</div>

that is just to show you what command begins with “i2c” !!!

---

<div class="post-metadata">

**Author:** ![lukasmertens](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lukasmertens](https://mangoh.discourse.group/u/lukasmertens)\
**Post date:** [May 21, 2021, 9:32am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/19 "2021-05-21T09:32:04Z")

</div>

My bad, i’m sorry. I get it, but with what command can i read the data?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [May 21, 2021, 9:35am UTC](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175/20 "2021-05-21T09:35:21Z")

</div>

> [@jyijyi](#):
>
> i2cget

is it “i2cget”???..

[Next page](https://mangoh.discourse.group/t/i2c-with-mqtt-mangoh-yellow/9175.md?page=2)
