Home ESP8266 ESP8266 : a look at another five wemos mini shields

ESP8266 : a look at another five wemos mini shields

by iainhendry

In this article we look at another five Wemos shields and will have examples of their usage. The shields we are looking at are the BMP180 Shield, DS18b20 Shield, RGB LED Shield, buzzer Shield and the OLED Shield.

Some of these are not official wemos shields but they work perfectly with it

So lets go.

BMP180 Shield example

An overview of a PIR

this was another shield that did not appear on the Wemos site, this time it was for the BMP180 sensor

Here is a picture of the shield

Lets talk about the BMP180.

The BMP180 is the new digital barometric pressure sensor of Bosch Sensortec, with a very high performance, which enables applications in advanced mobile devices, such as smartphones, tablet PCs and sports devices. It follows the BMP085 and brings many improvements, like the smaller size and the expansion of digital interfaces.

The ultra-low power consumption down to 3 μA makes the BMP180 the leader in power saving for your mobile devices. BMP180 is also distinguished by its very stable behavior (performance) with regard to the independency of the supply voltage.

Parameter Technical data
Pressure range 300 … 1100 hPa
RMS noise expressed in pressure 0.06 hPa, typ. (ultra low power mode)
0.02 hPa, typ. (ultra high resolution mode)
RMS noise expressed in altitude 0.5 m, typ. (ultra low power mode)
0.17 m, typ. (ultra high resolution mode)
Relative accuracy pressure
VDD = 3.3 V
950 … 1050 hPa/ ±0.12 hPa
@ 25 °C/ ±1.0 m
700 … 900 hPa/ ±0.12 hPa
25 … 40 °C/ ±1.0 m
Absolute accuracy
p = 300…1100hPa
(Temperature = 0…+65°C, VDD = 3.3. V)
Pressure: -4.0 … +2.0 hPa
Temperature: ±1 °C, typ.
Average current consumption (1 Hz data refresh rate)

Peak current

3 μA, typical (ultra-low power mode)
32 μA, typical (advanced mode)650 μA, typical
Stand-by current 1.62 … 3.6 V
Supply voltage VDDIO 1.62 … 3.6 V
Supply voltage VDD 1.8 … 3.6 V
Operation temp.
Range full accuracy”
-40 … +85 °C

 

Code

This example uses the adafruit bmp085 library, you can add this via the library manager

 

[codesyntax lang=”cpp”]

#include <Wire.h> 
#include <Adafruit_BMP085.h>  

Adafruit_BMP085 bmp;

void setup() 
{
  Serial.begin(9600);
  //Wire.begin (4, 5);
  if (!bmp.begin()) 
  {
    Serial.println("Could not find BMP180 or BMP085 sensor at 0x77");
    while (1) {}
  }
}

void loop() 
{
  Serial.print("Temperature = ");
  Serial.print(bmp.readTemperature());
  Serial.println(" Celsius");

  Serial.print("Pressure = ");
  Serial.print(bmp.readPressure());
  Serial.println(" Pascal");


  Serial.println();
  delay(5000);

[/codesyntax]

Output

Open the serial monitor and you should see something like this

Temperature = 27.30 Celsius
Pressure = 99934 Pascal

Temperature = 32.20 Celsius
Pressure = 99965 Pascal

Temperature = 32.90 Celsius
Pressure = 99968 Pascal

 

DS18b20 Shield Example

I was interested to see that searching through popular electronic component sites a DS18B20 shield for the Wemos mini, I couldn’t find a link on the Wemos site so I was intrigued and purchased one.

Here is what the shield looks like
DS18B20 Shield for Wemos D1 mini DS18B20

Looking at the shield I could see that it used D2 as the input

Lets look at some info about the sensor

The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements and has an alarm function with nonvolatile user-programmable upper and lower trigger points.

The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central micro-processor.

In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.

Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area

 

Code

[codesyntax lang=”cpp”]

#include <OneWire.h> 

// OneWire DS18S20, DS18B20, DS1822 Temperature Example

OneWire  ds(D2);  // on pin D4 (a 4.7K resistor is necessary)

void setup(void) 
{
  Serial.begin(9600);
}

void loop(void) 
{
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
  
  if ( !ds.search(addr)) 
  {
    ds.reset_search();
    delay(250);
    return;
  }

  if (OneWire::crc8(addr, 7) != addr[7]) 
  {
      Serial.println("CRC is not valid!");
      return;
  }
 
  // the first ROM byte indicates which chip
  switch (addr[0]) 
  {
    case 0x10:
      type_s = 1;
      break;
    case 0x28:
      type_s = 0;
      break;
    case 0x22:
      type_s = 0;
      break;
    default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
  } 

  ds.reset();
  ds.select(addr);
  ds.write(0x44, 1);        // start conversion, with parasite power on at the end  
  delay(1000);
  present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE);         // Read Scratchpad

  for ( i = 0; i < 9; i++) 
  {           
    data[i] = ds.read();
  }

  // Convert the data to actual temperature
  int16_t raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) 
    {
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } 
  else 
  {
    byte cfg = (data[4] & 0x60);
    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
    
  }
  celsius = (float)raw / 16.0;
  fahrenheit = celsius * 1.8 + 32.0;
  Serial.print("  Temperature = ");
  Serial.print(celsius);
  Serial.print(" Celsius, ");
  Serial.print(fahrenheit);
  Serial.println(" Fahrenheit");
}

[/codesyntax]

 

Output

Open the serial monitor

Temperature = 26.81 Celsius, 80.26 Fahrenheit
Temperature = 27.81 Celsius, 82.06 Fahrenheit
Temperature = 28.44 Celsius, 83.19 Fahrenheit
Temperature = 28.81 Celsius, 83.86 Fahrenheit
Temperature = 29.19 Celsius, 84.54 Fahrenheit

 

Buzzer Shield Example

This time we look at the Buzzer shield from Wemos.

The shield uses D5/D6/D7/D8 and can output a Frequency: 1kHz-3kHz

The shield is based on the mlt-8540 buzzer

Code

[codesyntax lang=”cpp”]

int buzzer=D5; //Buzzer control port, default D5

int freq[]={1047,1175,1319,1397,1568,1760,1976,2093};//Note name: C6 D6 E6 F6 G6 A6 B6 C7
String note[]={"C6", "D6", "E6", "F6", "G6", "A6", "B6", "C7"};

void setup() 
{
  pinMode(buzzer, OUTPUT);
  digitalWrite(buzzer, LOW);
  Serial.begin(115200);
  Serial.println("Buzzer Test...");
}

void loop() 
{
  for(int i=0; i<8; i++)
  {
    analogWriteRange(freq[i]);
    Serial.print("Note name: ");
    Serial.print(note[i]);
    Serial.print(", Freq: ");
    Serial.print(freq[i]);
    Serial.println("Hz");
    
    analogWrite(buzzer, 512);
    delay(1000);
    analogWrite(buzzer, 0);
    pinMode(buzzer, OUTPUT);
    digitalWrite(buzzer, LOW);
    delay(1000);
  }
  Serial.println("STOP");
  delay(5000);

}

[/codesyntax]

 

 

RGB Shield example

In this example we connect a RGB LED shield to a Wemos mini, this is similar to another Wemos shield but this time it has 7 RGB LEDs

 

The WS2812 is an intelligent control LED light source that the control circuit and RGB chip are integrated in a package of 5050 components. It internal include intelligent digital port data latch and signal reshaping amplification drive circuit.

Also include a precision internal oscillator and a 12V voltage programmable constant current control part, effectively ensuring the pixel point light color height consistent.

The data transfer protocol use single NZR communication mode. After the pixel power-on reset, the DIN port receive data from controller, the first pixel collect initial 24 bit data then sent to the internal data latch, the other data which reshaping by the internal signal reshaping amplification circuit sent to the next cascade pixel through the DO port.

After transmission for each pixel,the signal to reduce 24 bit. pixel adopt auto reshaping transmit technology, making the pixel cascade number is not limited the signal transmission, only depend on the speed of signal transmission.

LED with low driving voltage, environmental protection and energy saving, high brightness, scattering angle is large, good consistency, low power, long life and other advantages. The control chip integrated in LED above becoming more simple circuit, small volume, convenient installation.

 

Code

You will need to add the Adafruit Neopixel library to your Arduino IDE – https://github.com/adafruit/Adafruit_NeoPixel

[codesyntax lang=”cpp”]

#include <Adafruit_NeoPixel.h>

#define PIN   D4
#define LED_NUM 7

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_NUM, PIN, NEO_GRB + NEO_KHZ800);


void setup() 
{
  leds.begin(); // This initializes the NeoPixel library.
}



void led_set(uint8 R, uint8 G, uint8 B) 
{
  for (int i = 0; i < LED_NUM; i++) 
  {
    leds.setPixelColor(i, leds.Color(R, G, B));
    leds.show();
    delay(150);
  }
}

void loop() {

  led_set(10, 0, 0);//red
  led_set(0, 0, 0);

  led_set(0, 10, 0);//green
  led_set(0, 0, 0);

  led_set(0, 0, 10);//blue
  led_set(0, 0, 0);

}

[/codesyntax]

 

 

OLED Shield example

In this example we look at another terrific little low cost shield for the Wemos mini, this time its the OLED shield. Lets look at the shield and some specs

 

  • Screen Size: 64×48 pixels (0.66” Across)
  • Operating Voltage: 3.3V
  • Driver IC: SSD1306
  • Interface: IIC(I2C)
  • IIC Address: 0x3C or 0x3D

 

The shield uses the I2C pins, so you can still connect another I2C device (if it uses a different address) and the other pins are available

D1 mini Shield
D1 SCL
D2 SDA

 

Code

You will need to add the https://github.com/mcauser/Adafruit_SSD1306 library

The following code example is a simple hello world type example

[codesyntax lang=”cpp”]

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// SCL GPIO5
// SDA GPIO4
#define OLED_RESET 0  // GPIO0
Adafruit_SSD1306 display(OLED_RESET);

#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2


#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH  16


void setup()   {
  Serial.begin(9600);

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 64x48)
  // init done

  display.display();
  delay(2000);

  // Clear the buffer.
  display.clearDisplay();

  // text display tests
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Hello, world!");
  display.display();
  delay(2000);
  display.clearDisplay();

}


void loop() {

}

[/codesyntax]

 

Product Links

Shield for WeMos D1 mini V2 DS18B20 Single-bus digital temperature and humidity sensor module sensor

For Wemos BMP180 Digital Barometric Pressure Sensor Module

Buzzer Shield V1.0.0 for WEMOS D1 mini

0.66″ inch 64X48 IIC I2C OLED LED LCD Display Shield for Arduino Compatible WeMos D1 mini

 

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More