-
Notifications
You must be signed in to change notification settings - Fork 3
nCube:Thyme for Arduino Application : nCube Aqua (English)
-
nCube:Thyme for Arduino Development Environment Setup with Arduino IDE guide_EN
-
nCube:Thyme for Arduino Development Environment Setup with Arduino IDE guide_KR
-
nCube:Thyme for Arduino Development Environment Setup with PlatformIO IDE guide_EN
-
nCube:Thyme for Arduino Development Environment Setup with PlatformIO IDE guide_KR
At first, download ArduinoJson, PubSubClient, DallasTemperature, Adafruit_NeoPixel, OneWire libraries via github page linked below
- ArduinoJson github page
- PubSubClient github page
- DallasTemperature github page
- Adafruit_NeoPixel github page
- OneWire github page
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.
- 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.
- 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.
- 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.
- 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.
Adafruit Feather M0 and Sensors wired like picture below.
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.
Overall Structure of Mobius and Aquarium.
Copy nCube-Aqua.ino Arduino sketch example code under lib/oneM2MClient/examples/nCube-Aquarium to src directory,
like picture below.
TasAquarium.h 라이브러리를 추가시키고, Aqua 객체를 생성합니다.
AE-ID는 SAqua5로 AE-NAME은 aqua5로 합니다. (사용자별로 변경 가능)
sensing_interval값을 통해 센서들의 데이터 업로드 주기를 설정합니다.
예를들어, temp는 60초로 설정되어있는 것을 확인할 수 있습니다.
각 센서 데이터를 저장할 Container가 5개 필요하므로 buildResource() 함수의 코드를 아래와 같이 바꿔줍니다.
Container의 이름은 각 센서명(temp, ph, waterlevel, feeder, led)으로 수정합니다.
feeder, led 제어 데이터를 noti 하여줄 sub를 각각 생성합니다.
Subscription 리소스를 생성하는 부분에서 to값의 하위 리소스를 가리키는 값을 feeder는 nCube.resource[5].rn,
led는 nCube.resource[6].rn 로 수정합니다.
noti_callback() 함수 내의 if조건문 내에서 앞서 수정한 리소스 구조에 맞춰
nCube.resource[8]과 nCube.resource[9]로 수정합니다.
control_flag를 통해 feeder와 led를 제어할 수 있습니다.
setup() 함수 내에서 LED, Temp, WaterLevel, Feeder값을 초기화 해주는 함수를 호출합니다.
loop() 함수 내에서 Aqua.loop() 함수를 호출합니다.
Aqua.loop() 함수는 계속해서 Feeder 상태(on/off)를 체크하는 함수입니다.
temp가 create_cin 일 경우 Temperature 값을 읽어와 con 변수에 넣고 출력합니다.
ph가 create_cin 일 경우 PHSensor 값을 읽어와 con 변수에 넣고 출력합니다.
waterlevel가 create_cin 일 경우 WaterLevel 값을 읽어온 뒤
levelstatus가 HIGH(1)일 경우 Full, LOW(0)일 경우 Empty를 출력합니다.
loop() 함수 내에 control_flag 조건문에 따라 Mobius로부터 받은 noti값에 따라 feeder와 led가 동작되도록 합니다.
if(control_flag == 2)경우 feeder를 제어하며, noti_con이 1일 경우 feedFish(1)가 동작됩니다.
if(control_flag == 3)경우 led를 제어하며, noti_con이 1일 경우 showLED()가 동작되고,
1이외에 값이라면 stopLED()가 되어 LED가 꺼지게 됩니다.
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.
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 see the resource structure of the nCube-Aqua application.
In Container(cnt), sensing values uploaded.
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.
- Jaeho Kim, Team Manager (jhkim@keti.re.kr)
- Il Yeup Ahn, R&D Manager (iyahn@keti.re.kr)
- Chanhyung Lee (wwoorim2@gmail.com)
- Jaehyun Lim (wce5402@naver.com)
- Hana Jo (hanajo88@gmail.com)