Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!

NYX Project

Complete IoT and domotics platform that tracks the patient’s sleep via three main devices, displays the data and gives recommendations.

AdvancedFull instructions provided18 hours1,259

Things used in this project

Hardware components

Argon
Particle Argon
×1
Self-made sleep mask
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Capacitor 1000 µF
Capacitor 1000 µF
×1
RGB LED Pixel Matrix, NeoPixel NeoMatrix
RGB LED Pixel Matrix, NeoPixel NeoMatrix
×2
Seeed Studio Seeed Grove AI Hat
×1
Grove - Light Sensor
Seeed Studio Grove - Light Sensor
×1
Grove - Temperature Sensor
Seeed Studio Grove - Temperature Sensor
×1
Grove - 3-Axis Digital Accelerometer(±16g)
Seeed Studio Grove - 3-Axis Digital Accelerometer(±16g)
×1
Flash Memory Card, SD Card
Flash Memory Card, SD Card
×1
5V AC/DC adapter
×1
MiBand Xiaomi
×1
Raspberry Pi 4 Model B
Raspberry Pi 4 Model B
×1

Software apps and online services

ReactJS
Raspbian
Raspberry Pi Raspbian
Arduino IDE
Arduino IDE
Particle Build Web IDE
Particle Build Web IDE
balenaEtcher
AWS IoT
Amazon Web Services AWS IoT
AWS S3
Amazon Web Services AWS S3
AWS DynamoDB
Amazon Web Services AWS DynamoDB
AWS Lambda
Amazon Web Services AWS Lambda

Hand tools and fabrication machines

3D printer Prusa MK3S
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, 0.022" Diameter
Solder Wire, 0.022" Diameter
10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long
headers

Story

Read more

Custom parts and enclosures

Argon Base

This is a case for the Argon and the Grove base connectors.

Matix bases

This is the base for the marices.

Argon base lid

This is the Lid for the Argon Base

Schematics

Argon scheme

Raspberry scheme

Full schematic

Full system.

AI board scheme

Band Hack

Code

Argon for sleep mask demo code

C/C++
This is the code for the sleep mask. The demo code. Remember to load first the libraries. This one Published the sensor data to the particle cloud and shows the animation we will be using on the neopixels.
// This #include statement was automatically added by the Particle IDE.
#include <MMA7660-Accelerometer.h>


// This #include statement was automatically added by the Particle IDE.
#include <MQTT.h>

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>

// This #include statement was automatically added by the Particle IDE.
#include <OneWire.h>

/**
 * This is the more completely documented example! (see below)
 */

/* ======================= includes ================================= */

#include "MQTT.h"
#include "Particle.h"
#include "neopixel.h"

#include "Adafruit_DHT.h"



/* ======================= prototypes =============================== */

void colorAll(uint32_t c, uint8_t wait);
void colorWipe(uint32_t c, uint8_t wait);
void rainbow(uint8_t wait);
void rainbowCycle(uint8_t wait);
uint32_t Wheel(byte WheelPos);

MMA7660 accelerometer;

/* ======================= extra-examples.cpp ======================== */

SYSTEM_MODE(AUTOMATIC);

// IMPORTANT: Set pixel COUNT, PIN and TYPE

#define DHTPIN 4     // what pin we're connected to
#define DHTTYPE DHT11		// DHT 11 

void callback(char* topic, byte* payload, unsigned int length);

#define PIXEL_COUNT 32
#define PIXEL_PIN D2
#define PIXEL_TYPE WS2812B
#define BRIGHTNESS 1 // 0 - 255

// Parameter 1 = number of pixels in strip
//               note: for some stripes like those with the TM1829, you
//                     need to count the number of segments, i.e. the
//                     number of controllers in your stripe, not the number
//                     of individual LEDs!
//
// Parameter 2 = pin number (if not specified, D2 is selected for you)
//
//               On Photon, Electron, P1, Core and Duo, any pin can be used for Neopixel.
//
//               On the Argon, Boron and Xenon, only these pins can be used for Neopixel:
//               - D2, D3, A4, A5
//               - D4, D6, D7, D8
//               - A0, A1, A2, A3
//
//               In addition on the Argon/Boron/Xenon, only one pin per group can be used
//               at a time. So it's OK to have one Adafruit_NeoPixel instance on pin D2 and
//               another one on pin A2, but it's not possible to have one on pin A0 and
//               another one on pin A1.
//
// Parameter 3 = pixel type [ WS2812, WS2812B, WS2812B2, WS2813, WS2811,
//                            TM1803, TM1829, SK6812RGBW, WS2812B_FAST,
//                            WS2812B2_FAST ]
//               note: if not specified, WS2812B is selected for you which
//                     is the same as WS2812 or WS2813 in operation.
//               note: RGB order is automatically applied to WS2811,
//                     WS2812/WS2812B/WS2812B2/WS2813/TM1803 is GRB order.
//               note: For legacy 50us reset pulse timing on WS2812/WS2812B
//                     or WS2812B2, select WS2812B_FAST or WS2812B2_FAST
//                     respectively.  Otherwise 300us timing will be used.
//
// 800 KHz bitstream 800 KHz bitstream (most NeoPixel products
//               WS2812/WS2813 (6-pin part)/WS2812B (4-pin part)/SK6812RGBW (RGB+W) )
//
// 400 KHz bitstream (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//                   (Radio Shack Tri-Color LED Strip - TM1803 driver
//                    NOTE: RS Tri-Color LED's are grouped in sets of 3)

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

MQTT client("m12.cloudmqtt.com", 13853, callback);
DHT dht(DHTPIN, DHTTYPE);


char* string2char(String command){
    if(command.length()!=0){
        char *p = const_cast<char*>(command.c_str());
        return p;
    }
}

// recieve message
void callback(char* topic, byte* payload, unsigned int length) {
    delay(1000);
}

void setup() {
  strip.setBrightness(BRIGHTNESS);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  accelerometer.init();
 
  dht.begin();
    delay(5000);

    // connect to the server
    client.connect("Particle","ijplykav","QbPfoY8HsPP2");

    // publish/subscribe
    if (client.isConnected()) {
        //client.publish("outTopic/message","hello world");
        //client.subscribe("inTopic/message");
    }

}

void loop() {
  // Some example procedures showing how to display to the pixels:
  // Do not run more than 15 seconds of these, or the b/g tasks
  // will be blocked.
  //--------------------------------------------------------------

  //strip.setPixelColor(0, strip.Color(255, 0, 255));
  //strip.show();

  colorWipe(strip.Color(255, 85, 0), 50); // Red
  //delay(500);
  
  colorWipe(strip.Color(0, 0, 0), 50); // Black
  delay(200);

  //colorWipe(strip.Color(0, 255, 0), 50); // Green

  //colorWipe(strip.Color(0, 0, 255), 50); // Blue

  //rainbow(20);

  //rainbowCycle(20);

  //colorAll(strip.Color(0, 255, 255), 50); // Cyan
  if (client.isConnected())
    {
        client.loop();
    }
    float h = dht.getHumidity();
	float t = dht.getTempCelcius();
	float hi = dht.getHeatIndex();
	
	
	float x, y, z;
    accelerometer.getAcceleration(&x, &y, &z);

    Particle.publish("X axis: ", string2char(String(x)));
    Particle.publish("Y axis: ", string2char(String(y)));
    Particle.publish("Z axis: ", string2char(String(z)));

    client.publish("/Humd",string2char(String(round(h))));
    Particle.publish("/Humidity", string2char(String(round(h))));
	client.publish("/Temp",string2char(String(round(t))));
	Particle.publish("Temperature",string2char(String(round(t))));
	client.publish("/Hi",string2char(String(round(hi))));
	delay(5000);
	
}

// Set all pixels in the strip to a solid color, then wait (ms)
void colorAll(uint32_t c, uint8_t wait) {
  uint16_t i;

  for(i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
  }
  strip.show();
  delay(wait);
}

// Fill the dots one after the other with a color, wait (ms) after each one
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Slightly different, this makes the rainbow equally distributed throughout, then wait (ms)
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) { // 1 cycle of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

NIX github

teh github

Credits

EdOliver

EdOliver

38 projects • 74 followers
Engineer, Scientist, Maker. Entrepreneur and Futurist.
Victor Altamirano

Victor Altamirano

25 projects • 81 followers
I am a Biomedical engineer who likes to develop hardware and software solutions.
Alejandro Sanchez

Alejandro Sanchez

9 projects • 20 followers
I am a biomedical engineer working at Boston Scientific as a service engineer
JulietaAltamirano

JulietaAltamirano

2 projects • 3 followers
📍Currently in CO 🇺🇸 🧬 Physician 🥬 Vegetarian & animal lover 🐷

Comments