# Siemens IOT 2040 and IO module

**URL:** <https://forums.balena.io/t/siemens-iot-2040-and-io-module/43943>\
**Category:** balenaOS\
**Created:** [November 13, 2019, 2:14pm UTC](https://forums.balena.io/t/siemens-iot-2040-and-io-module/43943 "2019-11-13T14:14:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcomisso](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mcomisso/32/2620_2.png) [@mcomisso](https://forums.balena.io/u/mcomisso)\
**Post date:** [November 13, 2019, 2:14pm UTC](https://forums.balena.io/t/siemens-iot-2040-and-io-module/43943/1 "2019-11-13T14:14:38Z")

</div>

Hi,  
since it took me quite a lot of time to figure out how to have this working, I want to share with you what I learnt.

**TL;DR:** don’t use Debian, since it doesn’t support i386 boards. Use Alpine, and build mraa from sources. Also, remember to configure the pin connector via the jumpers o the main board.

My Dockerfile ended up like this:

```
FROM balenalib/i386-nlp-alpine:3.10-build
LABEL io.balena.device-type="iot2000"

# Install some packages
RUN apk add --update \
	less \
	vim \
	net-tools \
	ifupdown \
	usbutils \
	gnupg \
	python3 \
	python3-dev \
	nodejs \
	nodejs-dev \
	cmake \
	swig \
	json-c-dev \
	py3-paho-mqtt \
	&& rm -rf /var/cache/apk/*

# Defines our working directory in container
WORKDIR /usr/src/app

# Download and compile mraa
RUN git clone https://github.com/intel-iot-devkit/mraa
RUN cd mraa
RUN mkdir build
RUN cd build
# cmake ..
RUN cmake -DBUILDSWIGNODE=OFF -DCMAKE_INSTALL_PREFIX:H=/usr /usr/src/app/mraa
RUN make
RUN make install

# This will copy all files in our root to the working directory in the container
COPY . ./

CMD ["python3", "app.py"]

```

With this Dockerfile I’ve been able to run a simple Python script that follows a MQTT topic and blinks a led:

```
import mraa
import time
import paho.mqtt.client as mqttClient

broker_address="my-mqtt-broker"
port=1883
client = mqttClient.Client("SiemensIOT")

def on_connect(client, userdata, flags, rc):
  if rc == 0:
    print("Connected to broker")
    client.subscribe("dht22")
  else:
    print("Connection failed")

gpio_1 = mraa.Gpio(8)
gpio_1.dir(mraa.DIR_OUT)

def on_message(client, userdata, msg):
    if msg.payload.decode == "True":
        gpio_1.write(1)
        time.sleep(1)
        gpio_1.write(0)

client.connect(broker_address, port=port)
client.on_connect = on_connect
client.on_message = on_message
client.loop_forever()

```

I hope this post could help someone one day 😀

Regards,  
Matteo

---

<div class="post-metadata">

**Author:** ![zubairlk](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/zubairlk/32/954_2.png) [@zubairlk](https://forums.balena.io/u/zubairlk)\
**Post date:** [November 13, 2019, 2:16pm UTC](https://forums.balena.io/t/siemens-iot-2040-and-io-module/43943/2 "2019-11-13T14:16:59Z")

</div>

That is a very useful post. Thank-you very much!
