Neto Carrer
Published © GPL3+

IoT Aquarium Light Controller

Controlling your aquarium lighting with cron, Android, web-browsers and others.

AdvancedWork in progress10,291
IoT Aquarium Light Controller

Things used in this project

Story

Read more

Schematics

Circuit Diagram

Boards wiring diagram

Code

nrf.ino

C/C++
Source of the software running on the Arduino Pro Mini. Keeps listening on single channel and activates the LED strip when receiving RGB data.
#include <SPI.h>
#include <Adafruit_NeoPixel.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

#define RF_CE    7
#define RF_CSN   8
#define PIN 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(6, PIN, NEO_GRB + NEO_KHZ800);

RF24 radio(RF_CE,RF_CSN);

byte myID = 0x01;
byte lastR = 0xFF, lastG = 0xFF, lastB = 0xFF;

struct payload_request_t
{
  uint8_t number;
  uint8_t destination;
  char message[14];
};

payload_request_t incoming;

byte last = 0;

void setup() {

  Serial.begin(9600);
  strip.begin();
  setLED();  
  strip.setBrightness(0xFF);
  delay(1000);
  printf_begin();
  radio.begin();   
  radio.setAutoAck(1); // Ensure autoACK is enabled
  radio.openReadingPipe(1,(uint8_t *) "master");
  radio.startListening();
  radio.printDetails();   
  lastR=lastG=lastB=0x00;
}

void setLED()
{
  for(byte i=0;i<6;i++)
    strip.setPixelColor((uint16_t) i, lastR, lastG, lastB);
  
  strip.show();
}

long int temp;

void loop(void)
{
    if(radio.available())
    {
        radio.read(&incoming, sizeof(payload_request_t));
        if (incoming.destination==myID)
        {
          temp = (long int) strtol( incoming.message, NULL, 16);
          lastR = temp >> 16;
          lastG = temp >> 8;
          lastB = temp;
          Serial.println(incoming.message);
        }
    }
    setLED();
}

AquariumLightController.tar.gz

Java
Android App source code. Shows an image with a set of colors; identifies and extracts the color of the pixel touched by the user and sends it to a domestic WebService hosted on the Raspberry.
No preview (download only).

setRGB.zip

C/C++
Software that runs on the Raspberry and sends information over RF using the nrf24L01 module connected to it.
No preview (download only).

WebInterface.tar

HTML
Web Interface (HTML+Javascript) for the ColorPicker + "WebService" (PHP) which invokes the setRGB software
No preview (download only).

Credits

Neto Carrer

Neto Carrer

3 projects • 6 followers

Comments