Guillermo Perez Guillen
Published © Apache-2.0

Neptune

IR Remote Control for TV & Portable Lamp, and Light Monitor with Fire Alarm by Using Blues Notecarrier-A, Cardputer and XIAO ESP32S3

AdvancedFull instructions provided10 hours136

Things used in this project

Hardware components

Blues Notecarrier A
Blues Notecarrier A
×1
Cardputer
×1
Seeed Studio XIAO ESP32S3 Sense
Seeed Studio XIAO ESP32S3 Sense
×1
Seeed Studio XIAO SAMD21 (Pre-Soldered) - Seeeduino XIAO
Seeed Studio XIAO SAMD21 (Pre-Soldered) - Seeeduino XIAO
×1
Grove Shield for Seeeduino XIAO - with embedded battery management chip
Seeed Studio Grove Shield for Seeeduino XIAO - with embedded battery management chip
×1
Grove - Light Sensor
Seeed Studio Grove - Light Sensor
×1
Grove - Piezo Buzzer
Seeed Studio Grove - Piezo Buzzer
×1
Grove - Flame Sensor
×1
Grove Red LED
×1
IR receiver (generic)
×1
LED, Low Power
LED, Low Power
×1
L9110s Driver
×1
Rechargeable Battery, 3.7 V
Rechargeable Battery, 3.7 V
×2

Software apps and online services

Arduino IDE
Arduino IDE
Blues Notehub.io
Blues Notehub.io
ThingSpeak API
ThingSpeak API
Webhook.site

Hand tools and fabrication machines

Box, General Purpose
Box, General Purpose
Tape, Velcro® Stick On Tape/Strip
Tape, Velcro® Stick On Tape/Strip
Wrist cuff

Story

Read more

Schematics

Lamp Remote Control

Schematic Diagram

Light Monitor With Fire Alarm

Schematic Diagram

Code

seeeduino_xiao_ircodes.ino

Arduino
Lamp Remote Control, code 1
#include <IRremote.h>

int RECV_PIN = 10; // define input pin on Arduino 
IRrecv irrecv(RECV_PIN); 
decode_results results; // decode_results class is defined in IRremote.h

void setup() { 
	Serial.begin(9600); 
	irrecv.enableIRIn(); // Start the receiver 
} 

void loop() { 
	if (irrecv.decode(&results)) {
		Serial.println(results.value, HEX); 
		irrecv.resume(); // Receive the next value 
	}
	delay (200); // small delay to prevent reading errors
}

seeduino_xiao_recv.ino

Arduino
Lamp Remote Control, code 2
#include <IRremote.h>			
#define Button_1 0x10 // key_1 hex value
#define Button_2 0x810 //key_2 hex value
#define Button_3 0x410 // key_3 hex value

int SENSOR = 10; 			// IR receiver sensor to pin 10
IRrecv irrecv(SENSOR);			
decode_results codigo;			// decode_results class

int LEDLAMP_PIN1 = 1;
int LEDLAMP_PIN2 = 2;
int SENSOR_GND = 9;

void setup() {
  Serial.begin(9600);			
  irrecv.enableIRIn();			// initialize data reception
  pinMode(LEDLAMP_PIN1, OUTPUT);		// pin 1 as output
  pinMode(LEDLAMP_PIN2, OUTPUT);		// pin 2 as output
  pinMode(SENSOR_GND, OUTPUT);		// pin 3 used as gnd
} 

void loop() {
  digitalWrite(SENSOR_GND, LOW);
  digitalWrite(LEDLAMP_PIN2, LOW);  
  if (irrecv.decode(&codigo)) {			// if there is already decoded data
    Serial.println(codigo.value, HEX);		// print the value on monitor - hex
      if (codigo.value == Button_1){
      analogWrite(LEDLAMP_PIN1, 255);
      }			// if code is button 1

      if (codigo.value == Button_2){
      analogWrite(LEDLAMP_PIN1, 0);
      }			// if code is button 2

    if (codigo.value == Button_3){
      for(int i=0; i<=2; i++){
        for(int i=0; i<=255; i++) {
            analogWrite(LEDLAMP_PIN1, i);
            delay(10);
        }
        for(int i=255; i>=0; i--) {
            analogWrite(LEDLAMP_PIN1, i);
            delay(10);
        }
      }  
    }			// if code is button 3
    irrecv.resume();				// summarizes data acquisition
  }
  delay (100);					
}

notecarrier_xiao_esp32s3.ino

Arduino
Light Monitor With Fire Alarm
#include <Notecard.h>
#include <HardwareSerial.h>
#include <math.h>

#define RED_LED D5 //Connect the LED Grove module to Pin 5
#define FLAME_SENSOR D2 //connect FLAME SENSOR to digital pin 2
#define BUZZER D0 //connect Grove - BUZZER to pin 0

#define NOTE_PRODUCT_UID "com.your-company.your-name:your_product"

#define usbSerial Serial

HardwareSerial txRxPinsSerial(0);

int flameValue;
const int thresholdvalue=10;         //The threshold for which the LED should turn on. 
float Rsensor; //Resistance of sensor in K
int getSensorInterval();

Notecard notecard;

void setup() {
  pinMode(FLAME_SENSOR, INPUT);
  pinMode(RED_LED,OUTPUT);            
  pinMode(BUZZER,OUTPUT);
  digitalWrite(RED_LED,LOW);
  digitalWrite(BUZZER,LOW);

  // And configure txRxPinsSerial on pins RX=D6, TX=D7
  txRxPinsSerial.begin(9600, SERIAL_8N1, 8, 9);
  txRxPinsSerial.print("MySerial1");

  usbSerial.begin(115200);
  while (!usbSerial) {
      ; // wait for serial port to connect. Needed for native USB
  }
  usbSerial.println("Starting...");

  notecard.begin(txRxPinsSerial, 9600);
  notecard.setDebugOutputStream(usbSerial);

  J *req = notecard.newRequest("hub.set");
  if (req != NULL) {
      JAddStringToObject(req, "product", NOTE_PRODUCT_UID);
      JAddStringToObject(req, "mode", "continuous");
      JAddBoolToObject(req, "sync", true); 
      notecard.sendRequest(req);
  }
}

void loop() {
  int sensorValue = analogRead(A9); 
  Rsensor=(float)(4095-sensorValue)*10/sensorValue;
  if(Rsensor>thresholdvalue)
  {
    digitalWrite(RED_LED, HIGH);
  }
  else
  {
    digitalWrite(RED_LED, LOW);
  }

  if(isFlameDetected())
  turnOnBUZZER();
  else turnOffBUZZER();

  usbSerial.print("Flame = ");
  usbSerial.println(flameValue);
  usbSerial.print("Resistance = ");
  usbSerial.println(Rsensor);

  J *req = notecard.newRequest("note.add");
  if (req != NULL) {
    JAddStringToObject(req, "file", "sensors.qo");
    JAddBoolToObject(req, "sync", true);
    J *body = JAddObjectToObject(req, "body");
    if (body) {
        JAddNumberToObject(body, "flame", flameValue);
        JAddNumberToObject(body, "resistance", Rsensor);
    }
    notecard.sendRequest(req);
  }
  //delay(15000);
  int sensorIntervalSeconds = getSensorInterval();
  usbSerial.print("Delaying ");
  usbSerial.print(sensorIntervalSeconds);
  usbSerial.println(" seconds");
  delay(sensorIntervalSeconds * 1000);
}

void turnOnBUZZER()
{
    flameValue=1;
    analogWrite(BUZZER,150);
}

void turnOffBUZZER()
{
    flameValue=0;
    analogWrite(BUZZER,0);
}

boolean isFlameDetected()
{
    if(digitalRead(FLAME_SENSOR))
    return false;
    else return true;
}

// This function assumes you’ll set the reading_interval environment variable to
// a positive integer. If the variable is not set, set to 0, or set to an invalid
// type, this function returns a default value of 60.
int getSensorInterval() {
  int sensorIntervalSeconds = 60;
  J *req = notecard.newRequest("env.get");
  if (req != NULL) {
      JAddStringToObject(req, "name", "reading_interval");
      J* rsp = notecard.requestAndResponse(req);
      int readingIntervalEnvVar = atoi(JGetString(rsp, "text"));
      if (readingIntervalEnvVar > 0) {
        sensorIntervalSeconds = readingIntervalEnvVar;
      }
      notecard.deleteResponse(rsp);
  }
  return sensorIntervalSeconds;
}

neptune-project

1. IR Remote Control for Smart TV and Portable Lamp; 2. Light Monitor With Fire Alarm

Credits

Guillermo Perez Guillen

Guillermo Perez Guillen

57 projects • 63 followers
Electronics and Communications Engineer (ECE) & Renewable Energy: 12 prizes in Hackster / Hackaday Prize Finalist 2021-22-23

Comments