• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Create a VM ($25 Credit)
  • Buy a Domain
  • 1 Month free Back Blaze Backup
  • Other Deals
    • Domain Email
    • Nixstats Server Monitoring
    • ewww.io Auto WordPress Image Resizing and Acceleration
  • About
  • Links

IoT, Code, Security, Server Stuff etc

Views are my own and not my employer's.

Personal Development Blog...

Coding for fun since 1996, Learn by doing and sharing.

Buy a domain name, then create your own server (get $25 free credit)

View all of my posts.

  • Cloud
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • How to buy a new domain and SSL cert from NameCheap, a Server from Digital Ocean and configure it.
    • Setting up a Vultr VM and configuring it
    • All Cloud Articles
  • Dev
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • How to setup pooled MySQL connections in Node JS that don’t disconnect
    • NodeJS code to handle App logins via API (using MySQL connection pools (1000 connections) and query parameters)
    • Infographic: So you have an idea for an app
    • All Development Articles
  • MySQL
    • Using the free Adminer GUI for MySQL on your website
    • All MySQL Articles
  • Perf
    • PHP 7 code to send object oriented sanitised input data via bound parameters to a MYSQL database
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • Measuring VM performance (CPU, Disk, Latency, Concurrent Users etc) on Ubuntu and comparing Vultr, Digital Ocean and UpCloud – Part 1 of 4
    • Speeding up WordPress with the ewww.io ExactDN CDN and Image Compression Plugin
    • Setting up a website to use Cloudflare on a VM hosted on Vultr and Namecheap
    • All Performance Articles
  • Sec
    • Using the Qualys FreeScan Scanner to test your website for online vulnerabilities
    • Using OWASP ZAP GUI to scan your Applications for security issues
    • Setting up the Debian Kali Linux distro to perform penetration testing of your systems
    • Enabling TLS 1.3 SSL on a NGINX Website (Ubuntu 16.04 server) that is using Cloudflare
    • PHP implementation to check a password exposure level with Troy Hunt’s pwnedpasswords API
    • Setting strong SSL cryptographic protocols and ciphers on Ubuntu and NGINX
    • Securing Google G Suite email by setting up SPF, DKIM and DMARC with Cloudflare
    • All Security Articles
  • Server
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • All Server Articles
  • Ubuntu
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • Useful Linux Terminal Commands
    • All Ubuntu Articles
  • VM
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • All VM Articles
  • WordPress
    • Speeding up WordPress with the ewww.io ExactDN CDN and Image Compression Plugin
    • Installing and managing WordPress with WP-CLI from the command line on Ubuntu
    • How to backup WordPress on a host that has CPanel
    • Moving WordPress to a new self managed server away from CPanel
    • Moving a CPanel domain with email to a self managed VPS and Gmail
    • All WordPress Articles
  • All

Adafruit BME680 (Adafruit BME680 – Temperature, Humidity, Pressure and Gas Sensor) on a Wemos D1 Mini (ESP8266)

March 8, 2020 by Simon

Here is a short post to help document communicating a Adafruit BME680 (Adafruit BME680 – Temperature, Humidity, Pressure and Gas Sensor) on a Wemos D1 Mini (ESP8266). 

Yes this is normally a Security/Server blog but I needed a break (and an excuse to teach my 10 year old son how to code).  I have promised my son I will make an IoT Easter Hat for school this year.  Why not have an 80Mhz ESP8266 and a few sensors in his hat.

A few years back before I got into Server’s and Security I was developing a weather related mobile app IoT device and . n have always had a hardware and coding bug.

I have played with Arduino’s in the past but I wanted a micro controller with WiFi, enter the ESP8266

Arduino Mega with a Ethernet Shield

WeMos Mini D1

Maybe it is time to upgrade to the ESP8266 with WiFi

I was temped to order a cheaper Wemos D1 Mini from China (eBay) but delivery is usually 2 months.

Ebay listing for WeMos D1 Mini (ESP8266) from CHina for $4.27 AUD

I ordered a Wemos D1 Mini from Australia (eBay) but it did not turn up after 10 days (6 days after the estimated delivery), I got a refund from the seller.

ebay listing for a Wemos D1 Mini (ESP8266) from Australia for $7.99 AUD

I ended up visiting my new Jaycar store and purchased a WeMos D1 Mini.

Wemos D1 Mini from Jaycar.com.au ion Australia for $24.95

$24.95 is a lot but they have it in stock (and are open on Sundays).

#win #win

Soldering the Wemos D1 Mini

This is what it looked for before I soldered the pins on.

Picture of a Wemos D1 MIni with no legs soldered on

I decided to solder the board this way.

Picture of a Wemos D1 MIni with no legs soldered on (flipped)

It had been a while since I soldered (was previously Leaded solder).

I got some Lead Free solder from Jaycar and tested some soldering (lead free is harder than leaded solder).

Picure of lead free solder from Jaycar.

I got some new Flux from Jaycar as the flux I had was old and dry.

Picture of Rosion Flux from jaycar.com.au

I practices some soldering again.  Lead free solder needs good flux and a higher solder temperature.

Even though my short sight is an issue (I am getting old) solder joints seem ok (for Lead Free).  New flux did the trick. Thank’s JayCar

Picture of 3x soldered points, looks good enough for me.

(Now I need to get some reading glasses for close up activity)

Sensors

I had a few DHT11 and DHT22 sensors laying around but they don’t measure barometric pressure so time to upgrade.

Picture of old Temperature and Humidity sensors (DHT11 and DHT22) sensors.

I ordered a BME280 (GYBEMP) from eBay but it did not like the Arduino IDE and I could not get any data from the device.

Picture of a 4 pin BMP280 sensor from eBay (GYBMEP)

I looked for tutorials on YouTube and the newer 6 pin BMP280 seemed to be the device to get (Smarter Home Things).

Picture of a 6 pin BMP280 sensor from eBay

This sensor was no good either, I could not get any data from it. Libraries were installed too???

From now on I will only use Adafruit sensors as they are well supported libraries and they have fritzing compatible parts (https://github.com/adafruit/Fritzing-Library)

Adafruit BME680 sensor

I purchased a Adafruit BME680 and an Adafruit Analog UV Sensor.

Adafruit BME680 and UV Reader Board

ESP8266 Board (Arduino IDE)

You will need to add ESP8266 Boards added to the Arduino IDE (read more here: https://github.com/esp8266/Arduino).

Open the Ardiono IDE and click, File then Preferences and add this URL to the Additional Boards Manger URLs.

https://arduino.esp8266.com/stable/package_esp8266com_index.json
Add additional boards to Arduino IDE

Re-open your Arduino IDE and click Tools, Boards, Boards Manager and add the “ep8266” boards

Add ESP8266 Boards to ArduinoNIDE

Now I can choose ESP8266 Boards in the Arduino IDE

View of all boards in Arduino IDE

I have a WeMos D1 Mini (ESP8266) so I will choose it.

Adafruit BME8266 Arduino IDE Libraries

Now I need to add the Adafruit BME680 library to the Arduino IDE.

I added the Adafruit BME680 librarary to Android IDE (I restarted the IDE)

Adafruit BME680 libraries added to Android Studio

In the Android IDE I clicked on File, New then Adafruit BME680 Library then eme680test

Picture of the New Adafruit BME680 project menu

Code

This is the code in the sketch

  /***************************************************************************
  This is a library for the BME680 gas, humidity, temperature & pressure sensor

  Designed specifically to work with the Adafruit BME680 Breakout
  ----> http://www.adafruit.com/products/3660

  These sensors use I2C or SPI to communicate, 2 or 4 pins are required
  to interface.

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing products
  from Adafruit!

  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ***************************************************************************/

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME680 bme; // I2C
//Adafruit_BME680 bme(BME_CS); // hardware SPI
//Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO,  BME_SCK);

void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println(F("BME680 test"));

  if (!bme.begin()) {
    Serial.println("Could not find a valid BME680 sensor, check wiring!");
    while (1);
  }

  // Set up oversampling and filter initialization
  bme.setTemperatureOversampling(BME680_OS_8X);
  bme.setHumidityOversampling(BME680_OS_2X);
  bme.setPressureOversampling(BME680_OS_4X);
  bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
  bme.setGasHeater(320, 150); // 320*C for 150 ms
}

void loop() {
  if (! bme.performReading()) {
    Serial.println("Failed to perform reading :(");
    return;
  }
  Serial.print("Temperature = ");
  Serial.print(bme.temperature);
  Serial.println(" *C");

  Serial.print("Pressure = ");
  Serial.print(bme.pressure / 100.0);
  Serial.println(" hPa");

  Serial.print("Humidity = ");
  Serial.print(bme.humidity);
  Serial.println(" %");

  Serial.print("Gas = ");
  Serial.print(bme.gas_resistance / 1000.0);
  Serial.println(" KOhms");

  Serial.print("Approx. Altitude = ");
  Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
  Serial.println(" m");

  Serial.println();
  delay(2000);
}

Connecting the WeMos D1 Mini to the Adafruit BME680

This is the wiring guide. My wire colours are in the brackets 

Wemos D1 MiniAdafruit BME680
3V3 (RED)3V
Ground (BLACK)Ground
D1 (BLUE)SCK
D2 (YELLOW)SDI
Schematic of the Adafruit BME680 and the Wemos D1 Mini

I used the Fritzing program to make the above circuit diagram.

Adafruit make available Fritzing compatible parts (https://github.com/adafruit/Fritzing-Library) for their products.

Here is the Fritzing Sketch (you may need to add “Adafruit BME680.fzpz” from the Adafruit parts library

Full credit for this wiring goes to esp8266learing.com for the original diagram (I redid it to make the labels on the BME680 visible (OCD))

I used the Adafruit parts library for Fritzing.

Adafruit parts for Fritrzing (visual) circuit documenting app (https://github.com/adafruit/Fritzing-Library)

Wemos D1 Mini (JayCar) Driver

I had to install the CP210x USB to UART Bridge VCP Drivers from Silicon Labs (CP210x_Windows_Drivers.zip) tpo get the JayCar WeMos D1 Mini working

The supplied “setup.exe” program did not work for me (it kept crashing) so I added the driver by manually to Windows.

Add Hardware

Click Start then type Run and press Enter.

Type “hdwwiz.exe” and click OK

WIndows run box screenshot

The Add Hardware Wizard will show, click Next

Windows add hardware wizard

Click Next (Show All Devices is selected)

Add hardware wizard, show all devices

Click Have Disk

Add New Hardware Have DIsk

I selected the “slabvcp.inf” from the extracted “CP210x_Windows_Drivers.zip“

File Select dialog

I clicked Open then OK, I selected “Silicon Labs CP210x USB to UART Bridge” and clicked Next

Silicon Labs CP210x USB to UART Bridge

The driver installed.

I rebooted (to be sure) then checked in device manager for the device.

Device manger showing the Silicon Labs CP210x USB to UART Bridge is setup as port 10

I can see the “Silicon Labs CP210x USB to UART Bridge” is setup as port 10

Wiring

Make the wiring as pictured below.

Adafruit BME680

Here is the Fritzing Sketch (you may need to add “Adafruit BME680.fzpz” from the Adafruit parts library

Close enough

Wemos D1 Mini and the Adafruit BME680 wired up.

I doubled checked the wiring.

Wemos D1 Mini and the Adafruit BME680 wired up. (diffrent angle)

I plugged in the USB cable.

USB Plugged into the WeMos D1 Mini

Wait until you hear the add new hardware sound (if you have sounds in Windows)

Arduino IDE Setup

In the Arduino IDE make sure you choose the same COM port as the previously installed UART Bridge and ensure “WeMos D1 R1” is selected as board type and check that the programmer is “AVRISP mkII“

Arduino IDE board and COM port selection

I clicked Upload Sketch in the Arduino IDE

Upload to device button.

I can now get Temperature, Pressure, Humidity and Gas readings over 3 wires 🙂

Working sensor data (via serial)

Conclusion

  • Don’t use cheap sensors or ESP8266 micro controllers from eBay.
  • Use Lead free solder (practice soldering).
  • Use fresh Flux (not old stuff)
  • JayCar is convenient

From now on I will use Adafruit sensors. It’s a shame Jaycar don’t have Adafruit sensors.

Now I need to output the information to a screen.

Ardiunio OLED and LCD screens

Maybe I connect this to https://blynk.io/

Maybe create a local web server?

Thanks for reading.

 

 

v1.3 New Featured Image

v1.1 Moved Heading.

v1.0 Initial Draft

Filed Under: Uncategorized

Advertisement:

Copyright © Fearby.com - Do not copy or duplicate (that means you laptrinhx.com)

Primary Sidebar

Poll

What would you like to see more posts about?
Results

Support this Blog

Create your own server today (support me by using these links

Create your own server on UpCloud here ($25 free credit).

Create your own server on Vultr here.

Create your own server on Digital Ocean here ($10 free credit).

Remember you can install the Runcloud server management dashboard here if you need DevOps help.

Advertisement:

Tags

2FA (9) Advice (17) Analytics (9) App (9) Apple (10) AWS (9) Backup (21) Business (8) CDN (8) Cloud (49) Cloudflare (8) Code (8) Development (26) Digital Ocean (13) DNS (11) Domain (27) Firewall (12) Git (7) Hosting (18) IoT (9) LetsEncrypt (7) Linux (21) Marketing (11) MySQL (24) NGINX (11) NodeJS (11) OS (10) Performance (6) PHP (13) Scalability (12) Scalable (14) Security (45) SEO (7) Server (26) Software (7) SSH (7) ssl (17) Tech Advice (9) Ubuntu (39) Uncategorized (23) UpCloud (12) VM (45) Vultr (24) Website (14) Wordpress (25)

Disclaimer

Terms And Conditions Of Use All content provided on this "www.fearby.com" blog is for informational purposes only. Views are his own and not his employers. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. Never make changes to a live site without backing it up first.

Advertisement:

Footer

Popular

  • Backing up your computer automatically with BackBlaze software (no data limit)
  • How to back up an iPhone (including photos and videos) multiple ways
  • Add two factor auth login protection to WordPress with YubiCo hardware YubiKeys and or 2FA Authenticator App
  • Setup two factor authenticator protection at login on Ubuntu or Debian
  • Using the Yubico YubiKey NEO hardware-based two-factor authentication device to improve authentication and logins to OSX and software
  • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
  • Monitor server performance with NixStats and receive alerts by SMS, Push, Email, Telegram etc
  • Speeding up WordPress with the ewww.io ExactDN CDN and Image Compression Plugin
  • Add Google AdWords to your WordPress blog

Security

  • Check the compatibility of your WordPress theme and plugin code with PHP Compatibility Checker
  • Add two factor auth login protection to WordPress with YubiCo hardware YubiKeys and or 2FA Authenticator App
  • Setup two factor authenticator protection at login on Ubuntu or Debian
  • Using the Yubico YubiKey NEO hardware-based two-factor authentication device to improve authentication and logins to OSX and software
  • Setting up DNSSEC on a Namecheap domain hosted on UpCloud using CloudFlare
  • Set up Feature-Policy, Referrer-Policy and Content Security Policy headers in Nginx
  • Securing Google G Suite email by setting up SPF, DKIM and DMARC with Cloudflare
  • Enabling TLS 1.3 SSL on a NGINX Website (Ubuntu 16.04 server) that is using Cloudflare
  • Using the Qualys FreeScan Scanner to test your website for online vulnerabilities
  • Beyond SSL with Content Security Policy, Public Key Pinning etc
  • Upgraded to Wordfence Premium to get real-time login defence, malware scanner and two-factor authentication for WordPress logins
  • Run an Ubuntu VM system audit with Lynis
  • Securing Ubuntu in the cloud
  • No matter what server-provider you are using I strongly recommend you have a hot spare ready on a different provider

Code

  • How to code PHP on your localhost and deploy to the cloud via SFTP with PHPStorm by Jet Brains
  • Useful Java FX Code I use in a project using IntelliJ IDEA and jdk1.8.0_161.jdk
  • No matter what server-provider you are using I strongly recommend you have a hot spare ready on a different provider
  • How to setup PHP FPM on demand child workers in PHP 7.x to increase website traffic
  • Installing Android Studio 3 and creating your first Kotlin Android App
  • PHP 7 code to send object oriented sanitised input data via bound parameters to a MYSQL database
  • How to use Sublime Text editor locally to edit code files on a remote server via SSH
  • Creating your first Java FX app and using the Gluon Scene Builder in the IntelliJ IDEA IDE
  • Deploying nodejs apps in the background and monitoring them with PM2 from keymetrics.io

Tech

  • Backing up your computer automatically with BackBlaze software (no data limit)
  • How to back up an iPhone (including photos and videos) multiple ways
  • US v Huawei: The battle for 5G
  • Check the compatibility of your WordPress theme and plugin code with PHP Compatibility Checker
  • Is OSX Mojave on a 2014 MacBook Pro slower or faster than High Sierra
  • Telstra promised Fibre to the house (FTTP) when I had FTTN and this is what happened..
  • The case of the overheating Mac Book Pro and Occam’s Razor
  • Useful Linux Terminal Commands
  • Useful OSX Terminal Commands
  • Useful Linux Terminal Commands
  • What is the difference between 2D, 3D, 360 Video, AR, AR2D, AR3D, MR, VR and HR?
  • Application scalability on a budget (my journey)
  • Monitor server performance with NixStats and receive alerts by SMS, Push, Email, Telegram etc
  • Why I will never buy a new Apple Laptop until they fix the hardware cooling issues.

Wordpress

  • Replacing Google Analytics with Piwik/Matomo for a locally hosted privacy focused open source analytics solution
  • Setting web push notifications in WordPress with OneSignal
  • Telstra promised Fibre to the house (FTTP) when I had FTTN and this is what happened..
  • Check the compatibility of your WordPress theme and plugin code with PHP Compatibility Checker
  • Add two factor auth login protection to WordPress with YubiCo hardware YubiKeys and or 2FA Authenticator App
  • Monitor server performance with NixStats and receive alerts by SMS, Push, Email, Telegram etc
  • Upgraded to Wordfence Premium to get real-time login defence, malware scanner and two-factor authentication for WordPress logins
  • Wordfence Security Plugin for WordPress
  • Speeding up WordPress with the ewww.io ExactDN CDN and Image Compression Plugin
  • Installing and managing WordPress with WP-CLI from the command line on Ubuntu
  • Moving WordPress to a new self managed server away from CPanel
  • Moving WordPress to a new self managed server away from CPanel

General

  • Backing up your computer automatically with BackBlaze software (no data limit)
  • How to back up an iPhone (including photos and videos) multiple ways
  • US v Huawei: The battle for 5G
  • Using the WinSCP Client on Windows to transfer files to and from a Linux server over SFTP
  • Connecting to a server via SSH with Putty
  • Setting web push notifications in WordPress with OneSignal
  • Infographic: So you have an idea for an app
  • Restoring lost files on a Windows FAT, FAT32, NTFS or Linux EXT, Linux XFS volume with iRecover from diydatarecovery.nl
  • Building faster web apps with google tools and exceed user expectations
  • Why I will never buy a new Apple Laptop until they fix the hardware cooling issues.
  • Telstra promised Fibre to the house (FTTP) when I had FTTN and this is what happened..

Copyright © 2023 · News Pro on Genesis Framework · WordPress · Log in

Some ads on this site use cookies. You can opt-out if of local analytics tracking by scrolling to the bottom of the front page or any article and clicking "You are not opted out. Click here to opt out.". Accept Reject Read More
GDPR, Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT