Manufaktur industri
Industri Internet of Things | bahan industri | Pemeliharaan dan Perbaikan Peralatan | Pemrograman industri |
home  MfgRobots >> Manufaktur industri >  >> Manufacturing Technology >> Proses manufaktur

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Komponen dan Perlengkapan

Alat dan Mesin yang Diperlukan

Aplikasi dan Layanan Online

Tentang Proyek Ini

Apa itu SMART CUBE?

Smart Cube adalah pengontrol untuk perangkat Rumah Pintar Anda.

Saat ini mengelola semua perangkat di rumah kita dengan cara yang lebih cerdas menjadi sebuah kebutuhan. Kami memerlukan sesuatu yang sederhana dan intuitif untuk digunakan. Smart Cube bisa menjadi solusi: ini adalah perangkat portabel yang berisi papan Arduino 101 dan beberapa sensor yang berkomunikasi dengan peralatan dan aktuator di Rumah Pintar Anda.

Inovasi pengontrol jarak jauh ini terkait dengan inovasi papan Arduino 101. Ini menggunakan Bluetooth (BLE) untuk mengontrol lampu, suhu, dan TV Anda, dan Anda juga dapat menyinkronkannya dengan smartphone Anda. Namun inovasi utamanya adalah cara Anda berinteraksi dengan Smart Cube dengan gerakan Anda menggunakan giroskop dan akselemeter. Kubus memiliki 6 sisi dan setiap satu mengontrol fungsi tertentu. Fungsi yang ingin Anda gunakan terdeteksi berkat giroskop yang mengenali sisi atas. Misalnya Anda dapat menyalakan lampu kamar tempat Anda berada hanya dengan memosisikan kubus dengan sisi “lampu” di posisi atas. Jika Anda ingin mematikan lampu Anda hanya perlu guncangkan kubus.

Jika sebuah sisi ATAS dan tidak bergerak selama lebih dari 2 detik, fungsi terkait diaktifkan. Tundaan ini dibuat sehingga Anda dapat mempunyai waktu untuk memutar dan berinteraksi dengan kubus untuk menemukan sisi yang Anda butuhkan tanpa mengaktifkan fungsi lain secara tidak sengaja. Saat Anda menguncang kubus selama lebih dari 2 detik, fungsi terakhir yang diaktifkan ditutup dan sisi diatur sebagai false.

Proyek ini bertujuan untuk membantu Anda membangun pengontrol pintar. Perluas ini membutuhkan penerima (pusat pintar dalam gambar) yang menafsirkan data dan mengelola fungsi rumah pintar Anda. Output utama kubus adalah sinyal BLE yang dapat digunakan dengan banyak cara: misalnya Anda dapat menghubungkan kubus dengan aplikasi smartphone (atau membuat sendiri), atau Anda dapat membangun stasiun dengan Arduino lain yang mengumpulkan data BLE dan secara langsung mengontrol peralatan rumah Anda. Karena berbagai kasus, bagian ini tergantung pada kebutuhan Anda. Dalam panduan ini kita akan melihat cara membangun smart cube dan Anda akan mempelajari cara menyesuaikannya.

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Fungsi:

Struktur kode mudah untuk disesuaikan (kami menganalisis kode nanti) sehingga Anda dapat memutuskan fungsi mana yang ingin dikontrol. Ini adalah fungsi yang saya putuskan untuk dikontrol:

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

LAMPU: Sisi ini dalam posisi ATAS membuka lampu kamar tempat Anda berada. Jika Anda menguncang kubus, lampu akan mati dan lampu led kuning di sisi ini diaktifkan sehingga Anda dapat menemukan kubus dalam kegelapan. Komunikasi dengan lampu Anda dilakukan melalui BLE papan 101.

SUHU: Sisi ini ATAS mengaktifkan (melalui BLE) pendingin udara jika panas atau pemanas jika dingin. Ini mendeteksi suhu menggunakan sensor termal dan membuka led biru jika pendingin nyala (bentuk salju) atau merah jika pemanas aktif (matahari).

TIMER: Sisi ini ATAS memulai timer yang dapat Anda lihat pada layar LCD. Ada buzzer yang berfungsi sebagai alarm saat hitung mundur selesai. Jika Anda menguncang Anda menghentikan timer dan dapat melihat waktu tersisa. Saat hitung mundur berakhir warna LCD berubah dari biru ke merah dan buzzer mengeluarkan tiga bunyi.

TV: Sisi ini ATAS membuka TV. Kubus menjadi pengontrol jarak jauh untuk TV Anda. Ada panel tombol dengan angka yang hanya diaktifkan jika sisi ini ATAS untuk menghindari sentuhan tidak sengaja. Angka yang Anda tekan dikirim melalui BLE ke pengontrol pusat yang terhubung ke TV Anda. Dengan menguncang kubus Anda menutup TV.

SUARA: Sisi ini ATAS mengaktifkan led yang kecerahannya berdasarkan tingkat kebisingan kamar. Kebisingan terdeteksi berkat sensor suara. Jika Anda menguncang kubus Anda menutup fungsi ini. (Jika Anda ingin Anda dapat mengaktifkan fungsi pribadi Anda dengan mencoba tangan).

sisi OFF: Jika Anda tidak menguncang kubus sisi ini seperti posisi netral di mana tidak ada yang berubah. Jika Anda ingin menutup semuanya posisikan kubus dengan sisi OFF ATAS dan uncapkan. Geser ini seperti tombol rumah pada smartphone Anda yang Anda tekan jika ingin keluar dengan cepat. Ada led merah sehingga Anda dapat menemukan kubus jika gelap.

Perbedaan dari konsep:

Rencana asli adalah untuk menggunakan komunikasi IR juga untuk menghubungkan TV Anda secara langsung ke kubus. Karena Arduino 101 tidak mendukung (untuk saat ini) pustaka yang mengelola sinyal IR saya memutuskan untuk mengirim informasi melalui BLE ke stasiun yang dapat mengelola pustaka ini (seperti Arduino UNO). Karena masalah ini saya telah menghapus fungsi radio (sangat mirip dengan sisi TV), menggantinya dengan sisi sensor suara. Sisi ini dapat digunakan untuk mendeteksi suara keras (seperti tepuk tangan) untuk mengaktifkan sesuatu. Perubahan terbesar ada pada material kubus. Awalnya saya berpikir untuk membangunnya dengan printer 3D tetapi kemudian saya memutuskan untuk menggunakan mesin pemotong laser. Dengan cara ini lebih mudah untuk mengganti sisi jika Anda ingin mengubah fungsi. Misalnya Anda dapat menghapus sisi timer dan menggantinya dengan sisi yang secara otomatis mengisi mangsa kucing Anda. Karena modular Anda tidak perlu membangun ulang seluruh struktur!

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Mari kita buat:

Ikuti petunjuk ini untuk membuat smart cube Anda sendiri. Kami akan memulai dari hardware, merakit komponen elektronik terlebih dahulu dan kemudian badan kubus pemotongan laser yang terbuat dari MDF. Setelah operasi ini saya akan menjelaskan bagaimana kode bekerja dan bagaimana Anda dapat menyesuaikannya. Setelah Anda mengunggah kode pada Arduino 101 Anda dapat mengunduh aplikasi untuk melihat output BLE kubus atau menghubungkannya langsung dengan rumah pintar Anda!

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Hardware - elektronik:

Mari kita mulai dari Arduino 101 Anda. Ini adalah skema fritzing yang harus diikuti:

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Pasang Grove base shield pada papan Anda dan mulai dengan koneksi.

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Keypad: Anda harus menghubungkan kabel sesuai dengan pin: 10, 8, 7, 6, 5, 4, 2.

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Koneksi LED:

Pertama-tama kita harus menyiapkan led:

- hubungkan kaki panjang led (anoda) ke resistor 220 ohm dan kemudian ke kabel merah (ini adalah kabel untuk menghubungkan ke pin)

- hubungkan kaki pendek (katoda) ke kabel putih (ini akan pergi ke gnd)

- solder bagian-bagian dan tutup dengan pita isolasi

- hubungkan semua kabel putih ke satu kabel putih (ini akan pergi ke gnd) dan solder semuanya bersama-sama

Sekarang hubungkan kabel merah ke Arduino Anda: LED HIJAU ke pin 9, LED KUNING ke pin 11, LED MERAH ke pin 12, LED BIRU ke pin 13 dan MERAH terakhir ke pin A2.

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Sensor Grove:

Hubungkan sensor Grove ke shield (lihat skema di lampiran).

Buzzer ke D3, LCD RGB ke I2C, Sensor Suhu ke A0, Sensor Suara ke A1.

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Oke, sekarang kita telah menghubungkan semua bagian listrik. Sekarang Anda membutuhkan kotak.

Hardware - kotak

Anda dapat mengunduh sketsa kubus untuk dipotong dengan laser. Garis merah dalam sketsa adalah simbol sisi, cukup ukir mereka. Garis hitam harus dipotong. Dimensi internal kubus adalah 9 cm. Sketsa baik jika Anda menggunakan bahan 3mm, jika Anda menggunakan ketebalan berbeda Anda harus memodifikasinya (Anda dapat menggunakan situs web ini: https://www.makercase.com/).

Bahan yang saya pilih adalah MDF (Medium Density Fiber) tetapi Anda dapat menggunakan apa pun yang Anda inginkan.

Berikut adalah beberapa gambar dari pemotongan laser:

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Sekarang kita harus merakitnya.

Saya melekatkan beberapa potong karton untuk membuat ketebalan untuk led. Dengan cara ini mereka akan teralign dengan permukaan.

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Sekarang kita memasang keypad. Masukkan ke dalam lubang dan hapus film perekat, lalu hubungkan kembali pin.

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Sekarang LCD RGB. Ini cocok dengan lubangnya.

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Mari kita siapkan konektor baterai:

Saya memotong stopper transformator lama dan menghubungkannya ke klips baterai. Dengan cara ini kami menghemat ruang di dalam kotak.

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan
Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Pada titik ini ini adalah apa yang harus Anda miliki:

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Sekarang Anda hanya perlu menghubungkan baterai, mengunggah kode dan menutup kubus!

TIPS: pasang papan dan baterai dengan kotak sehingga saat Anda menguncang kubus mereka akan stabil.

Smart Cube: Hub Kendali Rumah Pintar Generasi Depan

Kode

Anda dapat menemukan kode di lampiran. Unggah pada papan Anda dengan Arduino IDE (ingat untuk memperbarui perangkat lunak Anda untuk kompatibilitas Arduino 101).

Saya telah memberi komentar hampir setiap baris kode untuk membuatnya lebih mudah dipahami sebisa saya. Jangan takut dengan 500+ baris, struktur tidak terlalu rumit.

Di awal ada pustaka dan semua variabel deklarasi.

Di bagian ini juga ada definisi layanan dan karakteristik BLE. Saya menggunakan layanan Automation IO. Saya menggunakan karakteristik Digital untuk lampu dan suhu (ini menggunakan 2 bit, jadi 4 kasus yang mungkin untuk dikodekan) dan Analog untuk TV (untuk mengirim semua kode dari keypad).

Kemudian setup. Bagian ini dieksekusi hanya sekali di awal. Di sini kita menginisialisasi komponen sebagai input atau output dan menginisialisasi BLE serta giroskop papan 101.

Bagian utama adalah loop. Ini dibagi menjadi empat bagian:

Anda dapat memodifikasi fungsi sisi dengan beberapa modifikasi kode. Struktur utama harus seperti yang dijelaskan. Anda dapat mengubah bagian di dalam kondisi if dari setiap sisi.

if (face2 == true) { // TEMPERATURE face //START CHANGING HERE digitalWrite (LEDOFF, LOW); // if this face is true the OFF face led is LOW if (central.connected() == true) { // if the cube is BLE connected // read temperature value int val = analogRead(pinTemp); // get analog value resistance=(float)(1023-val)*10000/val; // get resistance temperature=1/(log(resistance/10000)/B+1/298.15)-273.15; // calculate temperature //conditions of activation if (temperature > tooHot) { // activate air conditioning digitalWrite(LEDhot, LOW); // close heating led digitalWrite(LEDcold, HIGH); // open air conditioner led termoChar.setValue(1); // set via BLE the condition 1 = cold on - hot off } if (temperature < tooCold) { // activate heating digitalWrite(LEDhot, HIGH); digitalWrite(LEDcold, LOW); termoChar.setValue(2); // 2 = cold off - hot on } if (temperature > tooCold && temperature < tooHot){ // ideal temperature: nothing is activated digitalWrite(LEDhot, LOW); digitalWrite(LEDcold, LOW); termoChar.setValue(0); // 0 = cold off - hot off } } //END HERE } 

Anda harus mengkode bagian "benar" (seperti dalam kode sebelumnya) dan juga bagian "salah" saat kubus diguncang:

// TEMPERATURE deactivation if (lastFUNCTION == 2) { // TEMPERATURE face //START CHANGING HERE // if a central is connected to peripheral: if (central.connected() == true) { digitalWrite(LEDhot, LOW); // close temperature red led digitalWrite(LEDcold, LOW); // close temperature blue led termoChar.setValue(0); // temperature BLE signal: 0 = cold off - hot off //END HERE } Serial.println("TEMPERATURE false - CLOSE"); face2 = false; // TEMPERATURE face became false } 

Ingat untuk mengatur sisi sebagai false saat Anda menguncangnya.

Aplikasi:

Untuk melihat output BLE kubus Anda dapat mengunduh aplikasi ini: nRF Connect

https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=it

Saat Anda membukanya, cukup cari perangkat dan hubungkan dengan "smartcubesketch". Kemudian Anda akan melihat tiga tab "Automation IO", klik pada mereka dan tekan pengumpul data kontinu.

Penting untuk menghubungkan kubus karena beberapa fungsi (lampu, suhu, dan tv) hanya dieksekusi jika kubus terhubung.

Cara kerjanya: VIDEO

Unggah kode, masukkan baterai, tutup kotak dan...

...sekarang Anda memiliki SMART CUBE!

Saya telah membuat video untuk menunjukkan semua fungsi kubus dan cara menggunakannya.

Kesimpulan

Proyek ini hanyalah langkah pertama menuju rumah pintar. Tujuan saya adalah untuk menggunakan potensi papan Arduino 101 untuk menciptakan sesuatu yang baru. Saya pikir akselemeter dan giroskop memberikan papan peluang baru dalam hal mobilitas. Dengan BLE, selain portabel, juga mudah untuk terhubung.

Ini adalah kali pertama saya mewujudkan secara konkret salah satu proyek saya (saya berarti dengan prototipe yang berfungsi). Itu sulit dan ada beberapa kesulitan di jalan tetapi akhirnya saya telah banyak belajar dan saya senang dengan hasilnya. Saya berharap juga semua orang yang membaca panduan ini dapat belajar sesuatu dari pekerjaan saya dan juga memodifikasi proyek ini sesuai kebutuhan mereka. Maaf untuk bahasa Inggris saya yang buruk tetapi saya berharap gambar dapat membantu Anda.

Di masa depan proyek ini saya berharap untuk menciptakan pusat yang seperti jembatan antara smart cube dan aktuator (lampu, suhu, tv...). Pusat ini akan menerima sinyal BLE dari kubus dan menggunakan informasi ini untuk melakukan hal-hal pintar di rumah Anda.

Saya sangat senang mendapat kesempatan untuk menggunakan Arduino 101 dan kit Grove (kit sangat sederhana dan cepat untuk prototipe).

Saya berharap menggunakan papan dengan cara ini dapat menjadi inspirasi untuk proyek Anda. Anda dapat menyesuaikannya sekehendak Anda: Saya penasaran untuk melihat fungsi apa yang akan Anda ciptakan dan dalam konteks apa Anda akan menggunakannya!

Mungkin ini bukan revolusi tetapi ini adalah cara baru untuk berinteraksi dengan rumah Anda.

Semoga Anda menyukai tutorial ini.

Sekarang giliran Anda: tangani kubus dan hack itu!

Kode

SMART CUBE - kode lengkap dengan komentarArduino
// Libraries #include "CurieIMU.h" // Acelerometer & Gyroscope #include <CurieBLE.h> // Bluetooth Low Energy #include <Wire.h> #include "rgb_lcd.h" // LCD #include <Keypad.h> // Keypad rgb_lcd lcd; // LCD initialization // Bluetooth initialization: BLEPeripheral blePeripheral; // BLE Peripheral Device (the board you're programming) // BLE Services BLEService lightsService("1815"); // BLE Automation IO (1815) - lights informations BLEService termoService("1815"); // BLE Automation IO - temperature informations BLEService TVService("1815"); // BLE Automation IO - tv informations // BLE characteristic BLEUnsignedCharCharacteristic lightsChar("2A56", // BLE characteristic Digital (2A56) - lights BLERead | BLENotify); BLEUnsignedCharCharacteristic termoChar("2A56", // BLE characteristic Digital - temperature BLERead | BLENotify); BLEUnsignedCharCharacteristic TVChar("2A58", // BLE characteristic Analog (2A58) - tv BLERead | BLENotify); // Constant and variables declaration: // Face orientation and shake functions: int lastOrientation = - 1; // previous orientation (for comparison) unsigned long previousMillis = 0; // last time update unsigned long interval = 2000; // time to wait in up position before the face activation unsigned long SHAKEpreviousMillis = 0; // last time update unsigned long SHAKEinterval = 2000; // time to wait during shaking for face deactivation boolean keep = false; // this is used to count only one time the face orientation change int lastFUNCTION = -1; // this is used to know what is the previous rientation // Faces initilization: at the beginning every face is false boolean face0 = false; boolean face1 = false; boolean face2 = false; boolean face3 = false; boolean face4 = false; boolean face5 = false; // LIGHTS face const int LEDlights = 11; // pin 11: yellow led // TEMPERATURE face const int pinTemp = A0; // pin A0: temperature sensor const int LEDhot = 12; // pin 12: red led const int LEDcold = 13; // pin 13: blue led float temperature; // temperature value memorization int B=3975; // B value of the thermistor float resistance; // resistance value memorization float tooHot = 26.0; // temperature at which the air conditioner is activated [SET] float tooCold = 23.0; // temperature at which the heater is activated [SET] // TIMER face int BUZZER = 3; // pin 3: buzzer boolean KEEPtime = false; // this is used to count only one time the face orientation change (not restart while counting) int TIMERmillis = 0; // the following are for the countdown determination int prevSHOWsecond = 0; int CountdownInMillis = 0; int SHOWmillis = 0; // millis value calculation result int SHOWminute = 0; // minutes value to show in the monitor for the countdown int SHOWseconds = 0; // seconds value to show in the monitor for the countdown const int SETminute = 2; // set 2 minute timer [SET] const int SETsecond = 30; // set 30 seconds timer [SET] // SOUND face const int soundLED = 9 ; // pin 9: green led const int soundSENSOR = A1; // pin A0: sound sensor int brightness = 0; // green led brightness initialization // TV face const byte ROWS = 4; // four rows keypad const byte COLS = 3; // three columns keypad char keys[ROWS][COLS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} }; // keypad button values byte rowPins[ROWS] = {10,8,7,6}; // pin 10,8,7,6: connect to the row pinouts of the keypad byte colPins[COLS] = {5,4,2}; // pin 5,4,2: connect to the column pinouts of the keypad Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); // keypad initialization // OFF face const int LEDOFF = A2; // pin A2: red led void setup() { pinMode(LEDlights, OUTPUT); // every led is set as an output pinMode(LEDhot, OUTPUT); pinMode(LEDcold, OUTPUT); pinMode(soundLED,OUTPUT); pinMode(LEDOFF, OUTPUT); Serial.begin(9600); // initialize Serial communication CountdownInMillis = (SETminute*60 + SETsecond)*1000; // this calculates the corrispondent value in millis from the minutes and seconds setting lcd.begin(16, 2); // LCD initialization lcd.setRGB(0, 0, 0); // LCD RGB is OFF at the beginning // initialize device Serial.println("Initializing IMU device..."); CurieIMU.begin(); // Set the accelerometer range to 2G CurieIMU.setAccelerometerRange(2); // Enable Shock Detection CurieIMU.setDetectionThreshold(CURIE_IMU_SHOCK, 7000); // 7.0g = 7000 mg (this value set the intensity of the shock) CurieIMU.setDetectionDuration(CURIE_IMU_SHOCK, 2000); // 2000ms (this value set the duration of the shock) CurieIMU.interrupts(CURIE_IMU_SHOCK); // BLE setup initialization blePeripheral.setLocalName("SmartCubeSketch"); // the name of the project blePeripheral.setAdvertisedServiceUuid(lightsService.uuid()); // add the lights service UUID blePeripheral.addAttribute(lightsService); // add the BLE lights service blePeripheral.addAttribute(lightsChar); // add the BLE lights characteristic lightsChar.setValue(3); // initial value for this characteristic = 3 //BLE lights value meaning: 0 = lights off, 1 = lights on, 3 = initial state, 4 = not used blePeripheral.setAdvertisedServiceUuid(termoService.uuid()); // add the temperature service UUID blePeripheral.addAttribute(termoService); // add the BLE temperature service blePeripheral.addAttribute(termoChar); // add the BLE temperature characteristic termoChar.setValue(0); // initial value is 0: cold off - hot off //BLE termo value meaning: 0 = cold off - hot off, 1 = cold on - hot off, 2 = cold off - hot on, 3 = not used blePeripheral.setAdvertisedServiceUuid(TVService.uuid()); // add the tv service UUID blePeripheral.addAttribute(TVService); // add the BLE tv service blePeripheral.addAttribute(TVChar); // add the tv characteristic TVChar.setValue('x'); // initial value for this characteristic (x means nothing) //BLE TV value meaning: #number corrispond to the pressed button, C: close TV, O: open TV, x: initial state blePeripheral.begin(); Serial.println("Bluetooth device active, waiting for connections..."); } // setup end void loop() { BLECentral central = blePeripheral.central(); // BLE connection unsigned long currentMillis = millis(); // current value of time in milliseconds // the following code comes from www.arduino.cc/en/Tutorial/Genuino101CurieIMUccelerometerOrientation // it is used to detect the orientation of the board int orientation = - 1; // the board's orientation String orientationString; // string for printing description of orientation // read accelerometer: int x = CurieIMU.readAccelerometer(X_AXIS); int y = CurieIMU.readAccelerometer(Y_AXIS); int z = CurieIMU.readAccelerometer(Z_AXIS); // calculate the absolute values, to determine the largest int absX = abs(x); int absY = abs(y); int absZ = abs(z); if ( (absZ > absX) && (absZ > absY)) { // base orientation on Z if (z > 0) { orientationString = "up"; orientation = 0; } else { orientationString = "down"; orientation = 1; } } else if ( (absY > absX) && (absY > absZ)) { // base orientation on Y if (y > 0) { orientationString = "digital pins up"; orientation = 2; } else { orientationString = "analog pins up"; orientation = 3; } } else { // base orientation on X if (x < 0) { orientationString = "connector up"; orientation = 4; } else { orientationString = "connector down"; orientation = 5; } } // end of the tutorial code. // at this point you have the orientation value of the board constantly updated: /* The orientations of the board: 0: flat, processor facing up (TIMER) 1: flat, processor facing down (TV) 2: landscape, analog pins down (TEMPERATURE) 3: landscape, analog pins up (OFF) 4: portrait, USB connector up (LIGHTS) 5: portrait, USB connector down (SOUND) */ // for this project you need to know if the face has changed from the previous face function [lastFUNCTION != orientation] // but this information is printed only if the face is in the UP position for more than [interval] time // and only for one time [keep] (you don't nedd to constantly activate the face, you just need it one time) // because the orientation value is constantly updated you need to start counting time when the orientation change [orientation != lastOrientation] if (orientation != lastOrientation) { // if the orientation has changed, start to count time lastOrientation = orientation; // memorize the current orientation of the face previousMillis = currentMillis; // memorize the time when the face has changed keep = false; } else if (currentMillis - previousMillis > interval && keep == false && lastFUNCTION != orientation) { //this condition print the orientation only if the face is up for an interval //and only for one time (keep) //and only if the face is different from the previous loop Serial.println(orientationString); // print the orientation // the current face [orientation] is set as true (that means that the face function is set as activated) if (orientation == 1) { // TV face face1 = true; // TV face becomes true lastFUNCTION = orientation; // memorize this activation in [lastFUNCTION] Serial.println("TV true"); // print the activated face TVChar.setValue('O'); // O: open the tv signal (BLE): tv is open only one time } if (orientation == 4) { // LIGHTS face face4 = true; lastFUNCTION = orientation; Serial.println("LIGHTS true"); } if (orientation == 3) { // OFF face face3 = true; lastFUNCTION = orientation; Serial.println("OFF true"); } if (orientation == 5) { // SOUND face face5 = true; lastFUNCTION = orientation; Serial.println("SOUND true"); } if (orientation == 2) { // TEMPERATURE face face2 = true; lastFUNCTION = orientation; Serial.println("TEMPERATURE true"); } if (orientation == 0) { // TIMER face face0 = true; lastFUNCTION = orientation; Serial.println("TIMER true"); if (KEEPtime == false) { // timer is activated only if it is the 1st cycle or has been stopped TIMERmillis = currentMillis; // start counting time } } keep = true; // [keep] change value so that, in the next loop, you can't enter in this condition if the face don't change (avoid to activate another time the same face) } // this condition is for the shake function: if you shake for more than [SHAKEinterval] time, the face is deactivated if (CurieIMU.getInterruptStatus(CURIE_IMU_SHOCK) && currentMillis - SHAKEpreviousMillis > SHAKEinterval) { Serial.println("SHAKE"); // print "SHAKE" if shake is detected // the last activated face [lastFUNCTION] is set as false (that means that the face function is deactivated) //TV deactivation if (lastFUNCTION == 1) { // TV face TVChar.setValue('C'); // C: close the tv BLE signal Serial.println("TV false - CLOSE"); // print the closed face face1 = false; // TV face becomes false } //LIGHTS deactivation if (lastFUNCTION == 4) { // LIGHTS face if (central.connected() == true) { // if a central is connected to peripheral: lightsChar.setValue(0); // lights OFF BLE signal digitalWrite (LEDlights, HIGH); // open the yellow led to see the cube in the dark } Serial.println("LIGHTS false - CLOSE"); face4 = false; // LIGHTS face become false } // OFF if (lastFUNCTION == 3) { // OFF face // OFF face shaked: everything is closed and red led OFF is open digitalWrite (LEDOFF, HIGH); // red led OFF is on when cube is closed // now close all the activated functions: // CLOSE TV TVChar.setValue('C'); // C: close the tv BLE signal Serial.println("TV false - CLOSE"); face1 = false; // CLOSE LIGHTS Serial.println("LIGHTS false - CLOSE"); if (central.connected() == true) { lightsChar.setValue(0); digitalWrite (LEDlights, LOW); // lights led is closed if OFF face is shaked } face4 = false; // CLOSE SOUND analogWrite(soundLED, LOW); // close the sound led Serial.println("SOUND false - CLOSE"); face5 = false; //CLOSE TEMPERATURE if (central.connected() == true) { digitalWrite(LEDhot, LOW); digitalWrite(LEDcold, LOW); termoChar.setValue(0); // temperature BLE signal: 0 = cold off - hot off } Serial.println("TEMPERATURE false - CLOSE"); face2 = false; // CLOSE TIMER Serial.println("TIMER false - CLOSE"); lcd.setRGB(0, 0, 0); // the LCD RGB is closed lcd.clear(); KEEPtime = false; face0 = false; // The cube is inactive, only OFF led is active Serial.println("OFF false - CLOSE"); face3 = false; // OFF face becomes false } // SOUND deactivation if (lastFUNCTION == 5) { // SOUND face analogWrite(soundLED, LOW); // close the sound led Serial.println("SOUND false - CLOSE"); face5 = false; // SOUND face becomes false } // TEMPERATURE deactivation if (lastFUNCTION == 2) { // TEMPERATURE face // if a central is connected to peripheral: if (central.connected() == true) { digitalWrite(LEDhot, LOW); // close temperature red led digitalWrite(LEDcold, LOW); // close temperature blue led termoChar.setValue(0); // temperature BLE signal: 0 = cold off - hot off } Serial.println("TEMPERATURE false - CLOSE"); face2 = false; // TEMPERATURE face became false } // TIMER deactivation if (lastFUNCTION == 0) { // TIMER face Serial.println("TIMER false - CLOSE"); face0 = false; // TIMER face became false // if you shake the cube when the time is running, the LCD became red and show the remaining time to countdown lcd.setRGB(180, 40, 0); // the RGB backlight become red lcd.clear(); // lcd is cleared lcd.setCursor(0, 0); lcd.print("STOP AT "); lcd.setCursor(8, 0); lcd.print(SHOWminute); // indicates the minutes when you shake the cube lcd.setCursor(9, 0); lcd.print(":"); lcd.setCursor(10, 0); lcd.print(SHOWseconds); // indicates the seconds when you shake the cube tone(BUZZER,1000,1000); // it make a short sound delay(2000); lcd.clear(); // clear the LCD lcd.setRGB(0, 0, 0); // LCD RGB backlight is closed KEEPtime = false; // TIMER face became false } SHAKEpreviousMillis = currentMillis; // memorize the value for the [SHAKEinterval] calculation } // the following instructions are executed in loop only if the face is activated if (face1 == true) { // TV face digitalWrite (LEDOFF, LOW); // if this face is true the OFF face led is LOW if (central.connected() == true) { // if the cube is BLE connected char key = keypad.getKey(); // read the value from the keypad if (key && orientation == 1){ // if something is pressed and only when the tv face is up (avoid involuntary keypad pression) if (key == '0') { // if the pressed key is 0 TVChar.setValue(key); // send the [key] value via BLE Serial.println(key); // print the pressed button (comment if you don't want to show this information) } if (key == '1'){ TVChar.setValue(key); Serial.println(key); } if (key == '2'){ TVChar.setValue(key); Serial.println(key); } if (key == '3'){ TVChar.setValue(key); Serial.println(key); } if (key == '4'){ TVChar.setValue(key); Serial.println(key); } if (key == '5'){ TVChar.setValue(key); Serial.println(key); } if (key == '6'){ TVChar.setValue(key); Serial.println(key); } if (key == '7'){ TVChar.setValue(key); Serial.println(key); } if (key == '8'){ TVChar.setValue(key); Serial.println(key); } if (key == '9'){ TVChar.setValue(key); Serial.println(key); } if (key == '*'){ TVChar.setValue(key); Serial.println(key); } if (key == '#'){ TVChar.setValue(key); Serial.println(key); } } } } if (face4 == true) { // LIGHTS face digitalWrite (LEDOFF, LOW); // if this face is true the OFF face led is LOW if (central.connected() == true) { // if a central is connected to peripheral: lightsChar.setValue(1); // LIGHTS activated BLE signal digitalWrite (LEDlights, LOW); // yellow led is closed because the home lights are on } } if (face3 == true) { // OFF face // when OFF face is up nothing is done digitalWrite (LEDOFF, LOW); // led OFF is activated only when the cube is shaked, so now is LOW } if (face5 == true) { // SOUND face digitalWrite (LEDOFF, LOW); // if this face is true the OFF face led is LOW // sound sensor is activated, led brightness regulated by the sond // this code comes from brightness regulation example long sum = 0; for (int i=0; i<32; i++) { sum += analogRead(soundSENSOR); } sum >>= 5; brightness = (sum*255)/1024; // calculate the brightness value analogWrite(soundLED,brightness); // green led brightness intensity is regulated by the noise delay(50) ; //end brightness example } if (face2 == true) { // TEMPERATURE face digitalWrite (LEDOFF, LOW); // if this face is true the OFF face led is LOW if (central.connected() == true) { // if the cube is BLE connected // read temperature value int val = analogRead(pinTemp); // get analog value resistance=(float)(1023-val)*10000/val; // get resistance temperature=1/(log(resistance/10000)/B+1/298.15)-273.15; // calculate temperature //conditions of activation if (temperature > tooHot) { // activate air conditioning digitalWrite(LEDhot, LOW); // close heating led digitalWrite(LEDcold, HIGH); // open air conditioner led termoChar.setValue(1); // set via BLE the condition 1 = cold on - hot off } if (temperature < tooCold){ // activate heating digitalWrite(LEDhot, HIGH); digitalWrite(LEDcold, LOW); termoChar.setValue(2); // 2 = cold off - hot on } if (temperature > tooCold && temperature < tooHot){ // ideal temperature: nothing is activated digitalWrite(LEDhot, LOW); digitalWrite(LEDcold, LOW); termoChar.setValue(0); // 0 = cold off - hot off } } } if (face0 == true ) { // TIMER face activated digitalWrite (LEDOFF, LOW); // if this face is true the OFF face led is LOW // this calculate the time to show in the display SHOWmillis = (CountdownInMillis - (currentMillis - TIMERmillis))/1000; SHOWminute = SHOWmillis/60; // minutes value to show in the LCD SHOWseconds = SHOWmillis%60; // seconds value to show in the LCD lcd.setRGB(50, 100, 70); // open LCD with RGB blue color if (prevSHOWsecond != SHOWseconds){ // refresh the screen every second (because refresh at every loop is too fast) lcd.clear(); lcd.setCursor(0, 0); lcd.print("TIMER "); lcd.setCursor(7, 0); lcd.print(SETminute); // writes the minutes that you set lcd.setCursor(8, 0); lcd.print(":"); lcd.setCursor(9, 0); lcd.print(SETsecond); // writes the seconds that you set lcd.setCursor(0, 1); lcd.print(SHOWminute); // write the current remaining minutes lcd.setCursor(1, 1); lcd.print(":"); lcd.setCursor(2, 1); lcd.print(SHOWseconds); // write the current remaining seconds KEEPtime = true; prevSHOWsecond = SHOWseconds; // to refresh every second } if (SHOWminute == 0 && SHOWseconds == 0) { // when countdown ends lcd.clear(); // clear the LCD lcd.setCursor(4, 0); lcd.setRGB(180, 40, 0); // LCD RGB become red lcd.print("TIME OUT"); tone(BUZZER,1000,500); // three sounds delay (900); tone(BUZZER,1000,500); delay (900); tone(BUZZER,1000,1000); delay(1500); lcd.clear(); // clear and close the LCD lcd.setRGB(0, 0, 0); face0 = false; // TIMER face is now closed (false) KEEPtime = false; } } } // loop end 

Bagian dan Enclosure Kustom

Ini adalah file (.dxf) yang dapat Anda unggah pada pemotong laser Anda. Saya menggunakan papan serat kepadatan menengah (MDF) tebal 3mm. Potong garis hitam dan ukir garis merah. Penting: jika ketebalan bahan Anda berbeda Anda harus memodifikasi sketsa ini.smart_cube_8sVCflFmhM.dxfFile yang sama dengan kotak tetapi dalam format berbeda: .pdf

Skematik

Ini adalah .jpeg dari skema Fritzing (kabel kuning terhubung ke komponen Grove)Smart Cube: Hub Kendali Rumah Pintar Generasi DepanIni adalah skema koneksi di Grove Shield_cI0IwUsPVZ.Base%20shield%20connections

Proses manufaktur

  1. Panel Surya: Investasi Bijak untuk Rumah Anda
  2. Mengapa Desain Secara Sedikit Lebih Besar Dapat Mempercepat Inovasi dan Mengurangi Risiko
  3. Bagaimana Teknologi Rumah Cerdas Mengubah Kehidupan Sehari-hari
  4. Membangun Jaringan Sensor Nirkabel Hemat Biaya untuk Rumah Anda
  5. Memantau Suhu Rumah dengan Dashboard Raspberry Pi
  6. Menyelesaikan Kesenjakan Keterampilan Rumah Cerdas: Mengapa Inggris Ketinggalan dari Eropa
  7. Evolusi Rumah Pintar: Apa yang Diholdi Masa Depan untuk Hidup Terkoneksi
  8. Keamanan Cerdas: Strategi Ahli Melindungi Perangkat IoT Rumah dari Hacker
  9. Bagaimana Memperkuat Keamanan Rumah Pintar Anda: Tips Ahli
  10. Smart Plant IoT: Bangun Rumah Hijau Terhubung dengan Arduino & Azure