Categories

Follow Us

CCS811 digital gas sensor and Arduino example

In this example we will connect a CCS811 gas sensor to an arduino, lets look at the sensor

CCS811 is a low-power digital gas sensor solution, which integrates a gas sensor solution for detecting low levels of VOCs typically found indoors, with a microcontroller unit (MCU) and an Analog-to-Digital converter to monitor the local environment and provide an indication of the indoor air quality via an equivalent CO2 or TVOC output over a standard I2C digital interface.

Features

Integrated MCU
On-board processing
Standard digital interface
Optimised low power modes
IAQ threshold alarms
Programmable baseline
2.7mm x 4.0mm LGA package
Low component count
Proven technology platform

Specs

Interface I²C
Supply Voltage [V] 1.8 to 3.6
Power Consumption [mW] 1.2 to 46
Dimension [mm] 2.7 x 4.0 x 1.1 LGA
Ambient Temperature Range [°C] -40 to 85
Ambient Humidity Range [% r.h.] 10 to 95

Parts List

 

 

Amount Part Type
1 CJMCU-811 CCS811 Air Quality Gas Sensor
1 UNO R3 CH340G/ATmega328P, compatible for Arduino UNO R3

 

 

Schematics/Layout

 

Remember and connect WAKE to gnd

arduino and ccs811 layout

arduino and ccs811 layout

 

arduino and ccs811 schematic

arduino and ccs811 schematic

Code

Again we use a library this is the adafruit one – you can use the library manager and add this.

And this is the out of the box example

#include "Adafruit_CCS811.h"
Adafruit_CCS811 ccs;
void setup() {
Serial.begin(9600);
Serial.println("CCS811 test");
if(!ccs.begin()){
Serial.println("Failed to start sensor! Please check your wiring.");
while(1);
}
//calibrate temperature sensor
while(!ccs.available());
float temp = ccs.calculateTemperature();
ccs.setTempOffset(temp - 25.0);
}
void loop() {
if(ccs.available()){
float temp = ccs.calculateTemperature();
if(!ccs.readData()){
Serial.print("CO2: ");
Serial.print(ccs.geteCO2());
Serial.print("ppm, TVOC: ");
Serial.print(ccs.getTVOC());
Serial.print("ppb Temp:");
Serial.println(temp);
}
else{
Serial.println("ERROR!");
while(1);
}
}
delay(500);
}

 

Output

Open the serial monitor – this is what I saw. The higher CO2 level was when I breathed on the sensor

CO2: 400ppm, TVOC: 0ppb Temp:28.28
CO2: 400ppm, TVOC: 0ppb Temp:47.75
CO2: 400ppm, TVOC: 0ppb Temp:25.00
CO2: 400ppm, TVOC: 0ppb Temp:26.49
CO2: 1228ppm, TVOC: 126ppb Temp:25.68
CO2: 575ppm, TVOC: 26ppb Temp:9.59
CO2: 400ppm, TVOC: 0ppb Temp:26.49
CO2: 400ppm, TVOC: 0ppb Temp:105.81

 

Video

In this video we import the library, we compile and program the Arduino and then we open the serial monitor. The higher reading is when I blew on the sensor

Links

ccs811 datasheet

CJMCU-811 CCS811 Air Quality Gas Sensor

Share

CC3000 WiFi shield mDNS and LED example

In this article we look at the CC3000 WiFi shield. We will use the aRest example for CC3000, and we will then use a web address to manipulate some LED’s on and off.

Lets look at the CC3000 chip

The TI CC3000 module is a self-contained wireless network processor that simplifies the implementation of Internet connectivity. TI’s SimpleLink Wi-Fi solution minimizes the software requirements of the host microcontroller (MCU) and is thus the ideal solution for embedded applications using any low-cost and low-power MCU.

The TI CC3000 module reduces development time, lowers manufacturing costs, saves board space, eases certification, and minimizes the RF expertise required. This complete platform solution includes software drivers, sample applications, API guide, user documentation, and a world-class support community.


Features

  1. Arduino Uno and Arduino Mega  compatible
  2. Supports SD card sizes 2GB and 4GB
  3. Wireless network processor
    • IEEE 802.11 b/g ( 2.4GHz)
    • Embedded IPv4 TCP/IP stack
  4. Best-in-class radio performance
    • TX power: +18.0 dBm at 11 Mbps, CCK
    • RX sensitivity: –88 dBm, 8% PER, 11 Mbps
  5. Operating temperature: –20°C to 70°C
  6. SmartConfig technology enables simple Wi-Fi configuration using a smartphone, tablet or PC

Parts List

CC3000 WiFi Shield 1PCS CC3000 WiFi Shield for R3 With SD Card Supports MEGA2560
Arduino Mega 1pcs MEGA 2560 R3 ATmega2560 AVR USB board +free USB cable (ATMEGA2560 /CH340 ) funduino 2560
Dupont Wire 40PIN Dupont Line 10CM 20CM 30CM Male to Male + Female to Male and Female to Female Jumper Wire Dupont Cable for arduino DIY KIT
Traffic LED 5V Traffic Light LED Display Module for Arduino Red Yellow Green 5mm LED

Schematic

We used a traffic light LED example connected to our CC3000 shield, something like this

cc3000 and MDNS led example_bb

cc3000 and MDNS led example_bb

Code

This example requires several libraries to be installed

https://github.com/marcoschwartz/aREST

https://github.com/adafruit/Adafruit_CC3000_Library

https://github.com/adafruit/CC3000_MDNS

 

// Import required libraries
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include <CC3000_MDNS.h>
#include <aREST.h>
#include <aREST_UI.h>
#include <avr/wdt.h>
 
// These are the pins for the CC3000 chip if you are using a breakout board
#define ADAFRUIT_CC3000_IRQ   3
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
 
// Create CC3000 instance
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);
// Create aREST UI instance
aREST_UI rest = aREST_UI();
// Your WiFi SSID and password                                         
#define WLAN_SSID       "iainhendry"
#define WLAN_PASS       "iain061271"
#define WLAN_SECURITY   WLAN_SEC_WPA2
// The port to listen for incoming TCP connections 
#define LISTEN_PORT           80
// Server instance
Adafruit_CC3000_Server restServer(LISTEN_PORT);
// DNS responder instance
MDNSResponder mdns;
 
 
void setup(void)
{  
  // Start Serial
  Serial.begin(115200);
 
  // Give name and ID to device
  rest.set_id("1");
  rest.set_name("cc3000");
 
  // Set up CC3000 and get connected to the wireless network.
  if (!cc3000.begin())
  {
    while(1);
  }
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    while(1);
  }
  while (!cc3000.checkDHCP())
  {
    delay(100);
  }
  Serial.println();
 
  // Start multicast DNS responder
  if (!mdns.begin("arduino", cc3000)) 
  {
    while(1); 
  }
 
  // Start server
  restServer.begin();
  Serial.println(F("Listening for connections..."));
  // Enable watchdog
  wdt_enable(WDTO_4S);
}
 
void loop() 
{
  // Handle any multicast DNS requests
  mdns.update(); 
  // Handle REST calls
  Adafruit_CC3000_ClientRef client = restServer.available();
  rest.handle(client);
  wdt_reset();
  // Check connection, reset if connection is lost
  if(!cc3000.checkConnected()){while(1){}}
  wdt_reset();
}

 

Testing

Open your favourite web browser

http://arduino.local/digital/7/1

You should see the following displayed in your browser and the LED should switch on

{"message": "Pin D7 set to 1", "id": "1", "name": "cc3000", "hardware": "arduino", "connected": true}

Now type in the following

http://arduino.local/digital/7/0

{"message": "Pin D7 set to 0", "id": "1", "name": "cc3000", "hardware": "arduino", "connected": true}

You can repeat this for the other LEDs that you have connected to your CC3000 shield
Share

MLX90615 infrared thermometer and Arduino

The MLX90615 is a miniature infrared thermometer for non-contact temperature measurements. Both the IR sensitive thermopile detector chip and the signal conditioning ASIC are integrated in the same miniature TO-46 can.

The infrared thermometer comes factory calibrated with a digital SMBus output giving full access to the measured temperature in the complete temperature range(s) with a resolution of 0.02 °C. The sensor achieves an accuracy of ±0.2°C within the relevant medical temperature range. The user can choose to configure the digital output to be PWM.

Features and benefits

Factory calibrated in wide temperature range: -20 to 85°C for sensor temperature and -40 to 115°C for object temperature
High accuracy of 0.5°C over wide temperature range (0..+50 C for both Ta and To)
Medical accuracy of 0.2°C in a limited temperature range
Measurement resolution of 0.02°C
SMBus compatible digital interface for fast temperature readings and building sensor networks
Customizable PWM output for continuous reading
3V supply voltage with power saving mode

 

Connection

 

arduino and mlx902615 layout

arduino and mlx902615 layout

 

Code

This particular example comes from the following library which I installed – https://github.com/skiselev/MLX90615

 

#include <Wire.h>
#include <mlx90615.h>
MLX90615 mlx = MLX90615();
void setup()
{
Serial.begin(9600);
Serial.println("Melexis MLX90615 infra-red temperature sensor test");
mlx.begin();
Serial.print("Sensor ID number = ");
Serial.println(mlx.get_id(), HEX);
}
void loop()
{
Serial.print("Ambient = ");
Serial.print(mlx.get_ambient_temp()); //ambient temperature
Serial.print(" *C\tObject = ");
Serial.print(mlx.get_object_temp()); //object temperature
Serial.println(" *C");
delay(500);
}

 

Output

Open the serial monitor and you should see something like this.

Ambient = 30.85 *C Object = 25.67 *C
Ambient = 30.85 *C Object = 25.71 *C
Ambient = 30.79 *C Object = 25.81 *C
Ambient = 30.75 *C Object = 25.67 *C
Ambient = 30.71 *C Object = 25.43 *C
Ambient = 30.63 *C Object = 25.57 *C
Ambient = 30.57 *C Object = 25.95 *C
Ambient = 30.53 *C Object = 25.95 *C
Ambient = 30.49 *C Object = 26.15 *C
Ambient = 30.45 *C Object = 26.25 *C
Ambient = 30.45 *C Object = 26.19 *C
Ambient = 30.41 *C Object = 26.01 *C

 

Video Link

Here is a video where I import the library, compile the example and upload it. I then open the serial monitor, note that one of the I2C connections came loose hence the rubbish readings at first

 

Links

https://www.melexis.com/-/media/files/documents/datasheets/mlx90615-datasheet-melexis.pdf

1PCS MLX90615 Digital Infrared Temperature Sensor for Arduino

Share

Arduino and VL53L0X Time-of-Flight example

The VL53L0X is a new generation Time-of-Flight (ToF) laser-ranging module housed in the smallest package on the market today, providing accurate distance measurement whatever the target reflectances unlike conventional technologies. It can measure absolute distances up to 2m, setting a new benchmark in ranging performance levels, opening the door to various new applications.

The VL53L0X integrates a leading-edge SPAD array (Single Photon Avalanche Diodes) and embeds ST’s second generation FlightSenseTM patented technology.

Here is a typical module

The VL53L0X’s 940 nm VCSEL emitter (Vertical Cavity Surface-Emitting Laser), is totally invisible to the human eye, coupled with internal physical infrared filters, it enables longer ranging distances, higher immunity to ambient light, and better robustness to cover glass optical crosstalk.

 

Schematics/Layout

 

arduino and VL53L0X

arduino and VL53L0X

 

Code

 

You will need to install the adafruit library – https://github.com/adafruit/Adafruit_VL53L0X

#include "Adafruit_VL53L0X.h"
 
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
 
void setup() {
  Serial.begin(115200);
 
  // wait until serial port opens for native USB devices
  while (! Serial) {
    delay(1);
  }
 
  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
    while(1);
  }
  // power 
  Serial.println(F("VL53L0X API Simple Ranging example\n\n")); 
}
 
 
void loop() {
  VL53L0X_RangingMeasurementData_t measure;
 
  Serial.print("Reading a measurement... ");
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
 
  if (measure.RangeStatus != 4) {  // phase failures have incorrect data
    Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");
  }
 
  delay(100);
}

 

Output

Open the serial monitor, move the sensor nearer and farther away from objects for example your hand

VL53L0X API Simple Ranging example

Reading a measurement… Distance (mm): 70
Reading a measurement… Distance (mm): 70
Reading a measurement… Distance (mm): 71
Reading a measurement… Distance (mm): 72
Reading a measurement… Distance (mm): 71
Reading a measurement… Distance (mm): 71
Reading a measurement… Distance (mm): 70
Reading a measurement… Distance (mm): 71
Reading a measurement… Distance (mm): 67
Reading a measurement… Distance (mm): 114

 

Links

https://www.st.com/resource/en/datasheet/vl53l0x.pdf

1pcs GY- 530 VL53L0X World smallest Time-o f-Flight (ToF) laser ranging sensor 10 orders

Share