Skip to content

nCube:Thyme for Arduino Application : nCube Aqua (English)

IoTKETI edited this page Mar 19, 2018 · 3 revisions

nCube:Thyme for Arduino - Application : nCube-Aqua

Development Environment Setup

IDE installation & nCube:Thyme for Arduino Libraries Download

Json & MQTT & Temperature & Adafruit_NeoPixel & OneWire Libraries for Arduino Download

At first, download ArduinoJson, PubSubClient, DallasTemperature, Adafruit_NeoPixel, OneWire libraries via github page linked below

Next, move these libraries to your arduino project libraries directory where is nCube:Thyme for Arduino libraries placed, like picture below.

Open PubSubClient.h under pubsubclient/src, edit MQTT_MAX_PACKET_SIZE variable's value to 400.

Hardware

List of Materials

  • One Adafruit Feather M0 WiFi with uFL
  • One 2.4GH Mini Flexible WiFi Antenna with uFL Connector
  • One Fish feeder for Open Aquarium
  • One Adafruit NeoPixel Digital RGBW LED Strip
  • One Vertical Liquid Level Sensor
  • One Gravity: Analog pH Sensor / Meter Kit For Arduino
  • One DS18B20 - Water Temperature Sensor
  • One Adafruit Power Relay FeatherWing
  • One Capacitor 1000uF, 6.3V
  • One 470Ω, One 10kΩ
  • One Bread Board
  • A set of Jumper Cable M/M
  • One USB Type-A to Micro-B Cable
  • One 5V 2A USB Micro-B Power Adaptor
  • One Acrylic plate(for led)
  • Four Neodium magnet(for led)
  • One Switch Box 12512575mm
  • Three Cable grand
  • One External filter

  • Cortex M0 processor
  • Support SPI, I2C, UART communications
  • Atmel WINC1500 WiFi chip that supports 802.11bgn

  • The feeder is one of the basic package products of Open Aquarium provided by Cooking Hack.
  • The size is 11cm in width, 10.7cm in length, and the power supply is 3.3v.
  • The feeder has a regulator to manually adjust the amount of food.

  • The ph sensor is a product offered by DF ROBOT, which makes it easy to connect with Arduino.
  • The pH sensor board is a power 5v module. If the power is connected, the LED light is turned on.
  • The pH sensor measures the range of PH density from 1 to 14.

DS18B20 Temperature Sensor

  • The power is 3.0-5.5V and includes a waterproof function because it must be in direct contact with water.
  • t use in the range from minus 55 degrees to 125 degrees, and it measure from minus 10 degrees to 85 degrees.

Vertical Liquid Level Sensor

  • The water level sensor is a vertical liquid level sensor as a water height sensor provided by cooking hack.
  • If the water pressure is high, the circular plastic rises up, which means that the water in the aquarium is enough to have a value of 1.

Adafruit NeoPixel Digital RGBW LED Strip

  • The LED is capable of controlling four colors and light of RGBW(Red, Green, Blue, White).
  • he power varies by length as 5V, typically 1 meter must supply 5V/2A power, 4 meters must supply 5V/10A power.
  • This sensor can be cut and used according to the desired length in the strip type.

nCube-Aqua Application Development

Hardware Connection

Adafruit Feather M0 and Sensors wired like picture below.

Adafruit board Detail Connection

Aquarium Installation Method

Install the external filter.

Install all the sensors in the aquarium.

After connecting the sensor to the board, put it in the case and connect the power.

Mobius Connection

Overall Structure of Mobius and Aquarium.

nCuba-Aqua Arduino sketch

Copy nCube-Aqua.ino Arduino sketch example code under lib/oneM2MClient/examples/nCube-Aquarium to src directory,
like picture below.

Add the TasAquarium.h library and create an Aqua object.
AE-ID is SAqua5, and AE-NAME is aqua5. (Change by user)

Set the data upload period of sensors through sensing_interval value.
For example, you can see that temp is set to 60 seconds.

Since you need five Containers to store each sensor data, change the code of buildResource() function as follows.
The name of Container was changed to each sensor name (temp, ph, waterlevel, feeder, led).

In order to control the feeder and led, you have to generate subscription resource to notify the data, respectively.
In the subscription resource creation section, the feeder should be changed to nCube.resource[5].rn,
the led to nCube.resource [6] .rn to point to the lower resource of the to value.

In the noti_callback() function, modify the resource number to nCube.resource [8] and nCube.resource [9]
according to the modified resource structure and control the feeder and led via control_flag.

In the setup() function, we call a function that initializes the LED, Temp, WaterLevel, and Feeder values.

Call the Aqua.loop() function in the loop() function.
The Aqua.loop() function continues to check the feeder state(on/off).

If temp is create_cin, it reads Temperature value and puts it in con variable and prints it.

If ph is create_cin, it reads PHSensor value and puts it in con variable and prints it.

If waterlevel is create_cin, when the levelstatus is HIGH(1), it is Full, when it is LOW(0),
it is Empty after reading WaterLevel value.

In the loop() function, the feeder and led are operated according to the noti value received from Mobius.
If(control_flag == 2), feeder is controlled and if noti_con is 1, feedFish (1) is activated.
If(control_flag == 3), LED is controlled and if noti_con is 1, showLED () is activated.
If noti_con is not 1, stopLED() is activated and LED turns off.

nCube-Aqua Arduino sketch sketch upload & execution


Connect Adafruit Feather M0 to PC using usb cable.


To compile and upload, click upload button on PlatformIO tool bar.


To check whether nCube-Aqua application running or not, open serial monitor.
click serial monitor button on PlatformIO tool bar.


Connect to 'wifi101-XXXX' (different name for each Adafruit Feather M0 board) displayed on the serial monitor using the WiFi of smartphone of laptop.


And then, open web browser to connect 'http://wifi101.local'.
Enter the SSID of the AP to be connected under the Network Name, the Password corresponding to the AP below the Passphrase, and connect to the WiFi by clicking the Connect button.


Now nCube-Base2 create resources and upload sensing value. These sequences are displayed in serial monitor.

nCube-Aqua Sensing Values Query

To query sensing values, open Mobius Resource Monitor.


Type AE_NAME variable's value in Resource Path like picture above.
And click start button.


You can check the resource structure of the nCube-Aqua application.


In Container(cnt), sensing values uploaded.

nCube-Aqua Feeder & LED Control

To control Feeder and LED, create Content-Instance(cin) on Feeder and LED cnt


To operate feeder, right click on the mouse pointer on the container and click on the create.


Input number 1 in Content(con), and click create button.


The feeder will fall down through the rotation of the circle container.


To operate led, right click on the mouse pointer on the container and click on the create.


You can turn on the LED by typing 1 to Content (con). If you enter a value other than 1, you can turn it off.

Clone this wiki locally