Homemade Environment Sensor + Arduino Shield

This information is specific form Arduino Mega 2560 shield.

Connections

There are 3 connections that need to be made from the shield to the Arduino. There is one optional connection depending on how you power the Arduino. When starting, it is make sense to use jumper cable to connect the shield and Arduino. Here are the connection that need to be made.

You will need to make the green arrow connection. The yellow arrow is needed if your Arduino take power from the shield. WARNING: If you make the yellow connection, you should not power your Arduino separately. It probably not going to cause any problem, however, my personal opinion is just don't do it.

Moving into more permanent setup, you do not have to consider the green arrow above. With the headers installed and shield and Arduino stacked on top of each other, you will make the green connection by default. Please do not route cable manually once in this configuration. The 5V power is still separated.

The next stage of connecting if you decided to get power from the shield, you can short the following jumper (red circle).

Example

To introduce this shield I am making GPIO proxy as an example. GPIO proxy sketch is basically expose arduino GPIO for us to use in our DTH. It serialized the Arduino GPIO pin API through the serial port which in turn send them back and forth between DTH and Arduino.

My goal with the example is to make GPIO expansion. Arduino Mega 2560 has 60+ GPIO pin usable to drive relay or take input from sensor and switch. Here is some pictures for the test.

Google Photos

Google Photos

This shield communicate to the Arduino using Serial1 object in the sketch. A couple of the green arrow above is the connection. If you skip the Arduino UNO instruction above, here is a brief information on how to send data back and forth between Arduino and hub though the shield.

We will be using SLIP protocol. Here is my implementation library for Arduino.

You can declare it as global variable in your sketch.

image

And initialized it this way in the setup.

image

Any time you want to send data to the hub, just do this

Data coming in to theArduino look like below.

image

The packet it can be any form. The GPIO proxy has format that is specific to the example. However, the only restriction on the packet is the size. It can deliver at minimum 32 bytes. In some case more. This is the detail on how SLIP handle escape bytes. If you need to send data more than 32 byte, you can fragment the data and prefix it with index so the receiving end can re-assemble it. But, word of caution, Zigbee is not design to stream data. It is not like you can stream image or audio back an forth.

DTH for GPIO Proxy device in the example.

Here is the DTH shown in the demo. You will have to install it in your Device Code. There is an app called. GPIOManager_App.groovy to help you adding the child devices and associating it to the GPIO pin.

1 Like