Using GPIO class to run Click Boards on BeagleConnect Freedom

This blog covers the use of Water Detect Click and Relay Click on BeagleConnect Freedom using the Zephyr Port of MicroPython

Table of contents

  1. Prerequisites
  2. Water Detect Click
  3. Relay Click
  4. References

Prerequisites

  1. Before taking the Zephyr Port of MicroPython into use we must flash the MicroPython application firmware,for which you can follow my previous blog
  2. To access the prompt over USB-serial you need to use a terminal emulator program. On Windows TeraTerm is a good choice, on Mac you can use the built-in screen program, and Linux has picocom and minicom.For example to install picocom on Linux you can run:

sudo dnf install picocom

  1. Changing permissions on serial ports: Use this command to change permission- sudo chmod 666 /dev/ttyUSB0
  2. Starting off please enter into the terminal emulator program by running the following command :

picocom /dev/ttyUSB0 -b115200

This will make REPL available for usage.

Water Detect Click:

Water Detect click is used for detecting water and other electroconductive liquids. If the detection area is wet the output of Microchip’s MCP606 CMOS op-amp will go positive, signaling the presence of liquid.The water detection area is made of exposed conducting wire.

Water Detect click can be used as a household flood alarm sensor, rain detector for smart buildings or for water tanks that act as a limit switch for a pump. The Water Detect click functions on the GPIO interface.The MicroPython code can be seen as follows.

image alt text

The Explanation of the code is as follows:

  1. We import the necessary classes and modules.
  2. We initialise the pin and port number to the waterdetect variable.We take pull up registers into use to ensure the known state for signal.
  3. We write an if-else loop,that prints 1 in presence of water and 0 in absence of it.

A relatively detailed visual explanation can be seen from my video: https://www.youtube.com/watch?v=DrWm3_VK2vY

Relay Click:

Relay click is a dual relay Click board, which can be operated by the host MCU.

Relay click features two G6D-1A-ASI DC5 mini-relays.Despite its size, the G6D-1A-ASI DC5 relay is able to withstand up to 5A and 220V AC/30V DC. It can endure up to 300,000 operations, with 30V DC and 2A. This relay has a single pole only - when the coil is energized, it will attract the internal switching elements and close the circuit, similarly to a switch.

Since it is able to operate on mains voltage level, it can even be used control the power for a number of small home appliances. It can also be used to activate various electromotors, switch on the lights, or power on the entire embedded system. The Relay click functions on the GPIO interface.The MicroPython code alongwith commented explanation can be seen as follows.

image alt text

A detailed working can be seen from my video: https://www.youtube.com/watch?v=eG4dUhQTFf8

References:

https://github.com/micropython/micropython/blob/master/ports/zephyr/README.md https://github.com/jadonk/beagle_connect_zephyr_board

 Share!

 
comments powered by Disqus