Categories

Follow

QRE1113 IR reflectance sensor and ESP8266 example

The QRE1113 features an easy-to-use analog output, which will vary depending on the amount of IR light reflected back to the sensor. The QRE1113 IR reflectance sensor is comprised of two parts – an IR emitting LED and an IR sensitive phototransistor.

When you apply power to the VCC and GND pins the IR LED inside the sensor will illuminate.

Because dark colors will bounce back less light, the sensor can be used to tell the difference between white and black areas and can be used in robots as a line follower

qre113

qre113

Schematic/Connection/Layout

 

Code

int QRE1113_Pin = A0; 
 
void setup()
{
Serial.begin(9600);
}
 
void loop()
{
int QRE_Value = analogRead(QRE1113_Pin);
Serial.println(QRE_Value);
delay(1000);
}

 

Output

Open the serial monitor, the lower example readings were when I put a white piece of paper near the sensor

889
871
76
85
75
76
871
890
81

 

Links

http://www.onsemi.com/pub/Collateral/QRE1113-D.PDF

QRE1113 Linear Sensor Breakout Board Infrared Reflective Sensor Module Digital Output 3.3V 5V For Line Following Robots

MAX30102 pulse and heart-rate monitor sensor and ESP8266

The MAX30102 is an integrated pulse oximetry and heart-rate monitor biosensor module. It includes internal LEDs, photodetectors, optical elements, and low-noise electronics with ambient light rejection. The MAX30102 provides a complete system solution to ease the design-in process for mobile and wearable devices.

The MAX30102 operates on a single 1.8V power supply and a separate 5.0V power supply for the internal LEDs. Communication is through a standard I2C-compatible interface. The module can be shut down through software with zero standby current, allowing the power rails to remain powered at all times.

Key Features

Heart-Rate Monitor and Pulse Oximeter Biosensor in LED Reflective Solution
Tiny 5.6mm x 3.3mm x 1.55mm 14-Pin Optical Module
Integrated Cover Glass for Optimal, Robust Performance
Ultra-Low Power Operation for Mobile Devices
Programmable Sample Rate and LED Current for Power Savings
Low-Power Heart-Rate Monitor (< 1mW)
Ultra-Low Shutdown Current (0.7µA, typ)
Fast Data Output Capability
High Sample Rates
Robust Motion Artifact Resilience
High SNR
-40°C to +85°C Operating Temperature Range

 

Parts List

This module will cost less than $2

Amount Part Type
1 MAX30102
1 D1 mini V2

 

Schematics/Layout

 

esp8266 and max30102

esp8266 and max30102

Code

Again we use a library and again its an sparkfun one – https://github.com/sparkfun/SparkFun_MAX3010x_Sensor_Library

 

 

#include <Wire.h>
#include "MAX30105.h"
 
#include "heartRate.h"
 
MAX30105 particleSensor;
 
const byte RATE_SIZE = 4; //Increase this for more averaging. 4 is good.
byte rates[RATE_SIZE]; //Array of heart rates
byte rateSpot = 0;
long lastBeat = 0; //Time at which the last beat occurred
 
float beatsPerMinute;
int beatAvg;
 
void setup()
{
Serial.begin(115200);
Serial.println("Initializing...");
 
// Initialize sensor
if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) //Use default I2C port, 400kHz speed
{
Serial.println("MAX30105 was not found. Please check wiring/power. ");
while (1);
}
Serial.println("Place your index finger on the sensor with steady pressure.");
 
particleSensor.setup(); //Configure sensor with default settings
particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low to indicate sensor is running
particleSensor.setPulseAmplitudeGreen(0); //Turn off Green LED
}
 
void loop()
{
long irValue = particleSensor.getIR();
 
if (checkForBeat(irValue) == true)
{
//We sensed a beat!
long delta = millis() - lastBeat;
lastBeat = millis();
 
beatsPerMinute = 60 / (delta / 1000.0);
 
if (beatsPerMinute < 255 && beatsPerMinute > 20)
{
rates[rateSpot++] = (byte)beatsPerMinute; //Store this reading in the array
rateSpot %= RATE_SIZE; //Wrap variable
 
//Take average of readings
beatAvg = 0;
for (byte x = 0 ; x < RATE_SIZE ; x++)
beatAvg += rates[x];
beatAvg /= RATE_SIZE;
}
}
 
Serial.print("IR=");
Serial.print(irValue);
Serial.print(", BPM=");
Serial.print(beatsPerMinute);
Serial.print(", Avg BPM=");
Serial.print(beatAvg);
 
if (irValue < 50000)
Serial.print(" No finger?");
 
Serial.println();
}

 

 

 

Output

Open the serial monitor – this is what I saw, it took a little bit of time for the readings to appear

IR=110798, BPM=93.46, Avg BPM=74
IR=110791, BPM=93.46, Avg BPM=74
IR=110879, BPM=93.46, Avg BPM=74
IR=110899, BPM=93.46, Avg BPM=74
IR=110969, BPM=93.46, Avg BPM=74
IR=111070, BPM=93.46, Avg BPM=74
IR=111021, BPM=93.46, Avg BPM=74
IR=110997, BPM=93.46, Avg BPM=74
IR=111116, BPM=93.46, Avg BPM=74

 

Links

https://datasheets.maximintegrated.com/en/ds/MAX30102.pdf

Low Power MAX30102 Heart Rate Oxygen Pulse Breakout for Arduino

PAJ7620 gesture sensor and ESP8266

The PAJ7620 integrates gesture recognition function with general I2C interface into a single chip forming an image analytic sensor system. It can recognize 9 human hand gesticulations such as moving up, down, left, right, forward, backward, circle-clockwise, circle-counter clockwise, and waving.

It also offers built-in proximity detection in sensing approaching or departing object from the sensor. The PAJ7620 is designed with great flexibility in power-saving mechanism, well suit for low power battery operated HMI devices.

The PAJ7620 is packaged into module form in-built with IR LED and optics lens as a complete sensor solution.

Gesture Mode : Single-Object Detection
Image Array Size : 60 x 60
Sampling Rate : 240fps
Operating Distance : 20cm
Output Types : 9 types of Gestures: Up, Down, Left, Right, Forward, Backward, Circle-Clockwise, Circle-Counter Clockwise, and Waving)
Cursor Mode : Yes
Interface : I2C/SPI
Light Source : Integrated IR LED with optics

 

Schematics/Layout

esp8266 and PAJ7620

esp8266 and PAJ7620

 

Code

 

Again we use a library – https://www.elecrow.com/wiki/images/7/72/Paj7620.zip

 

 

#include <Wire.h>
#include "paj7620.h"
 
void setup()
{
Serial.begin(9600);
paj7620Init();
}
 
void loop()
{
uint8_t data = 0; // Read Bank_0_Reg_0x43/0x44 for gesture result.
 
paj7620ReadReg(0x43, 1, &data);
 
if (data == GES_UP_FLAG)
{
Serial.println("GES_UP_FLAG !");
}
 
if (data == GES_DOWN_FLAG)
{
Serial.println("GES_DOWN_FLAG !");
}
 
if(data == GES_FORWARD_FLAG)
{
Serial.println("GES_FORWARD_FLAG !");
}
 
if(data == GES_BACKWARD_FLAG)
{
Serial.println("GES_BACKWARD_FLAG !");
}
 
if(data == GES_RIGHT_FLAG)
{
Serial.println("GES_RIGHT_FLAG !");
}
 
if(data ==GES_LEFT_FLAG)
{
Serial.println("GES_LEFT_FLAG !");
}
 
}

 

 

 

Output

Open the serial monitor – this is what I saw, move your hands in various directions

INIT SENSOR…
Addr0 =20, Addr1 =76
wake-up finish.
Paj7620 initialize register finished.
GES_LEFT_FLAG !
GES_UP_FLAG !
GES_UP_FLAG !
GES_FORWARD_FLAG !
GES_BACKWARD_FLAG !
GES_UP_FLAG !
GES_UP_FLAG !

 

Links

http://www.pixart.com.tw/upload/PAJ7620U2_GDS_v1.0_29032016_20160623194552.pdf

The Wemos IR controller shield

In this small article we take a look at the IR controller shield, this is a shield which can act as an IR receiver and sender, here are some details about the shield

  • 1x IR receiver (38kHz)
  • Configurable IO (Default: Sender – D3/GPIO0, Receiver – D4/GPIO2)

Lets see a picture of the shield, you can see the IR reciever and the 4 emitters around the outside, so quite a good design this.

 

The shield uses the follwoing pins, so they would be unavailable for other devices that you use

D1 mini Shield
D3 Send
D4 Receiver

 

Code

You need to install the IRremote ESP8266 Library first. There are a few test examples but i simply wanted to see the code returned from a keypress. The default test examples had a bit more data than I really wished.

I have also noticed false codes getting returned at times, I have not figured this out yet. Looking at possible solutions although a few mention capacitors and noise.

#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRutils.h>
#if DECODE_AC
#include <ir_Daikin.h>
#include <ir_Fujitsu.h>
#include <ir_Gree.h>
#include <ir_Haier.h>
#include <ir_Kelvinator.h>
#include <ir_Midea.h>
#include <ir_Toshiba.h>
#endif  // DECODE_AC
 
#define RECV_PIN D4
#define BAUD_RATE 115200
#define CAPTURE_BUFFER_SIZE 1024
 
 
#if DECODE_AC
#define TIMEOUT 50U  
#else  
#define TIMEOUT 15U  // Suits most messages, while not swallowing many repeats.
#endif  
 
#define MIN_UNKNOWN_SIZE 12
 
 
// Use turn on the save buffer feature for more complete capture coverage.
IRrecv irrecv(RECV_PIN, CAPTURE_BUFFER_SIZE, TIMEOUT, true);
 
decode_results results;  // Somewhere to store the results
 
 
void setup() 
{
  Serial.begin(BAUD_RATE, SERIAL_8N1, SERIAL_TX_ONLY);
  while (!Serial)  // Wait for the serial connection to be establised.
    delay(50);
  Serial.println();
  Serial.print("IRrecvDumpV2 is now running and waiting for IR input on Pin ");
  Serial.println(RECV_PIN);
 
#if DECODE_HASH
  // Ignore messages with less than minimum on or off pulses.
  irrecv.setUnknownThreshold(MIN_UNKNOWN_SIZE);
#endif  // DECODE_HASH
  irrecv.enableIRIn();  // Start the receiver
}
 
 
void loop() 
{
  if (irrecv.decode(&results)) 
  {
    // print() & println() can't handle printing long longs. (uint64_t)
    serialPrintUint64(results.value, HEX);
    Serial.println("");
    irrecv.resume();  // Receive the next value
  }
  delay(200);
}

 

Testing

Go ahead and press various keys on your remote, this is a couple of keys that I tested. They were 3, 4 and 5 and I did press them multiple times this was not bounce or multiple return codes

FF7A85
FF7A85
FF7A85
FF7A85
FF10EF
FF10EF
FF10EF
FF38C7
FF38C7