The Wemos PIR shield

A new wemos shield and this time its based on a  passive infrared sensor

An overview of a PIR

A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view. They are most often used in PIR-based motion detectors. A PIR-based motion detector is used to sense movement of people, animals, or other objects. They are commonly used in burglar alarms and automatically-activated lighting systems. They are commonly called simply “PIR”, or sometimes “PID”, for “passive infrared detector”.

If you want to read more basics – https://en.wikipedia.org/wiki/Passive_infrared_sensor

The shield uses D3 so that will be unavailable for any other components or shields you may want to use, here is a picture of the shield

The PIR is an AS312

Code

Very simple stuff here, we will output via the serial monitor.

const int PIR = D3;
int PIRState = 0;
 
void setup() 
{
  Serial.begin(9600);
  pinMode(PIR, INPUT);
}
 
void loop() 
{
  PIRState = digitalRead(PIR);
 
  if (PIRState == HIGH) 
  {
    Serial.write("INTRUDER DETECTED\n");
  } 
  else 
  {
    Serial.write("NOWT GOING ON\n");
  }
  delay(1000);
}

Output

Open the serial monitor and move your hand in front of the PIR and then move away

NOWT GOING ON
NOWT GOING ON
NOWT GOING ON
INTRUDER DETECTED
INTRUDER DETECTED
INTRUDER DETECTED
INTRUDER DETECTED
INTRUDER DETECTED
NOWT GOING ON
NOWT GOING ON
NOWT GOING ON
INTRUDER DETECTED
INTRUDER DETECTED

 

 

Links

https://datasheet.lcsc.com/szlcsc/Nanyang-Senba-Optical-Elec-AS312_C90465.pdf

 

Goouuu-S1 ESP8266 RGB led examples

In a previous post we looked at the Goouuu-S1 ESP8266 , on the board you will have seen that there is an RGB led

The board uses the following pins for the LED

int redpin = 12; // select the pin for the red LED

int bluepin = 14; // select the pin for the blue LED

int greenpin =13; // select the pin for the green LED

Code Examples

int redpin = 12; // select the pin for the red LED
int bluepin = 14; // select the pin for the blue LED
int greenpin =13; // select the pin for the green LED
 
int val=0;
 
void setup () 
{
  pinMode (redpin, OUTPUT);
  pinMode (bluepin, OUTPUT);
  pinMode (greenpin, OUTPUT);
  Serial.begin (9600);
}
 
void loop () 
{
  for (val=255; val>0; val--)
  {
    analogWrite (redpin, val);
    analogWrite (bluepin, 255-val);
    analogWrite (greenpin, 128-val);
    delay (50);
  }
  for (val = 0; val <255; val++)
  {
    analogWrite (redpin, val);
    analogWrite (bluepin, 255-val);
    analogWrite (greenpin, 128-val);
    delay (50);
  }
  Serial.println (val, DEC);
}

 

And another example

 

int redpin = 12; // select the pin for the red LED
int bluepin = 14; // select the pin for the blue LED
int greenpin =13; // select the pin for the green LED
 
int val=0;
 
void setup () 
{
  pinMode (redpin, OUTPUT);
  pinMode (bluepin, OUTPUT);
  pinMode (greenpin, OUTPUT);
  Serial.begin (9600);
}
 
void loop () 
{
  LEDOff();
  REDOn();
  LEDOff();
  GREENOn();
  LEDOff();
  BLUEOn();
}
 
void LEDOff()
{  
  digitalWrite(redpin,HIGH);
  digitalWrite(greenpin, HIGH);
  digitalWrite(bluepin, HIGH);
  delay (500);
}
 
void REDOn()
{
  digitalWrite(redpin,LOW);
  digitalWrite(greenpin, HIGH);
  digitalWrite(bluepin, HIGH);
  delay (500);
}
 
void GREENOn()
{
  digitalWrite(redpin,HIGH);
  digitalWrite(greenpin, LOW);
  digitalWrite(bluepin, HIGH);
  delay (500);
}
 
void BLUEOn()
{
  digitalWrite(redpin,HIGH);
  digitalWrite(greenpin, HIGH);
  digitalWrite(bluepin, LOW);
  delay (500);
}

 

ESP8266 and Ambient light Shield example

This was another new shield for the Wemos called the Ambient light Shield , this time its based around the BH1750FVI digital Ambient Light Sensor

Lets look at some info about the sensor

BH1750FVI is an digital Ambient Light Sensor IC for I2C bus interface. This IC is the most suitable to obtain the ambient light data for adjusting LCD and Keypad backlight power of Mobile phone. It is possible to detect wide range at High resolution. ( 1 – 65535 lx ).

●Features

1) I2C bus Interface ( f / s Mode Support )
2) Spectral responsibility is approximately human eye response
3) Illuminance to Digital Converter
4) Wide range and High resolution. ( 1 – 65535 lx )
5) Low Current by power down function
6) 50Hz / 60Hz Light noise reject-function
7) 1.8V Logic input interface
8) No need any external parts
9) Light source dependency is little. ( ex. Incandescent Lamp. Fluorescent Lamp. Halogen Lamp. White LED. Sun Light )
10) It is possible to select 2 type of I2C slave-address.
11) Adjustable measurement result for influence of optical window ( It is possible to detect min. 0.11 lx, max. 100000 lx by using this function. )
12) Small measurement variation (+/- 20%)
13) The influence of infrared is very small.

Being an I2C device it uses D1 and D2 on the Wemos mini

Code

You need to install the following library for this example :  https://github.com/claws/BH1750 

#include <Wire.h>
#include <BH1750.h>
 
 
BH1750 lightMeter(0x23);
 
void setup(){
 
  Serial.begin(9600);
 
  // Initialize the I2C bus
  Wire.begin();
 
  if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) 
  {
    Serial.println(F("BH1750 Advanced begin"));
  }
  else 
  {
    Serial.println(F("Error initialising BH1750"));
  }
 
}
 
 
void loop() 
{
  uint16_t lux = lightMeter.readLightLevel();
  Serial.print("Light: ");
  Serial.print(lux);
  Serial.println(" lx");
  delay(1000);
}

 

Output

Open the serial monitor, cover the sensor, shine light on the sensor and so on to see the readings change, you can see where I covered it completely reading 0 lx

Light: 29 lx
Light: 29 lx
Light: 22 lx
Light: 0 lx
Light: 0 lx
Light: 20 lx
Light: 18 lx
Light: 28 lx
Light: 27 lx

 

Link

 

Goouuu-S1 ESP8266

This is an ESP8266 based board, in case you buy one of these here is some info I have found

Goouuu-S1 ESP8266 WiFi module is a low-power, cost-effective embedded wireless network control module. Can be satisfied
Smart grid, building automation, security, smart home, telemedicine applications such as networking needs.
The module’s core processor, the ESP8266, integrates the industry-leading Tensilica L106 ultra-low-power 32-bit microcontrollers
Type MCU with 16-bit thinning mode, clocked at 80 MHz and 160 MHz, RTOS support, integrated Wi-Fi MAC / BB / RF / PA / LNA and onboard antenna.

The module supports the standard IEEE802.11 b / g / n protocol, complete TCP / IP protocol stack. You can use this module tadd networking capabilities texisting devices or tbuild stand-alone network controllers.

Main features

Operating voltage: 3.3V
Operating ambient temperature: -20 – 70 ° C
CPU Tensilica L106
RAM 36KB (available)
Flash 32Mbit
system

802.11 b / g / n
Built-in Tensilica L106 ultra-low-power 32-bit micro-MCU, with 16-bit concise mode, frequency support 80 MHz and 160 MHz, support for RTOS
WIFI @ 2.4 GHz, supports WPA / WPA2 security mode
Ultra-small size module 18.6mm * 15.0mm
Built-in 10 bit high precision ADC
Built-in TCP / IP protocol stack
Built-in TR switch, balun, LNA, power amplifier and matching network
Built-in PLL, regulator and power management components + 20 dBm output power in 802.11b mode
Antenna diversity is supported
Deep sleep current is 20uA and shutdown current is less than 5uA
can double as the application processor SDI2.0, SPI, UART
STBC, 1×1 MIMO, 2×1 MIMA-MPDU, aggregation of A-MSDU and guard interval of 0.4 s
wake-up within 2ms, connect and transmit packets
Standby Power Consumption Less than 1.0mW (DTIM3)
Support AT remote upgrade and cloud OTA upgrade
Supports STA / AP / STA + AP working mode

 

 

How to use?

1) Download USB CH340G Driver (Click Here)
2) Open Arduino IDE and click file–>preference—>and put this link on additional board manager URLs.
http://arduino.esp8266.com/stable/package_esp8266com_index.json
3) Plug In USB Cable to MINI-S1 Board and connect to you computer.
4) wait few mininutes to auto download the driver.
5) Then click Tools–>Board( WeMos D1 R2&Mini ) –>Select the com port you detected and upload.

 

Drawbacks

Its not Wemos pin compatible, so the wemos shields will not work with this board