Categories

A 1.8 inch TFT Full Color LCD Display Module with Adapter Board for Arduino UNO

In this article we look a shield which allows you to connect an Arduino Esplora TFT LCD to an Arduino Uno or Mega

The Graphic LCD screen is a backlit TFT LCD screen with headers. You can draw text, images, and shapes to the screen with the GLCD library.
There is an onboard micro-SD card slot on the back of the screen that can, among other things, store bitmap images for the screen to display.
The screen is 1.77″ diagonal, with 160 x 128 pixel resolution.
The TFT library interfaces with the screen’s controller through SPI when using the TFT library.
The screen runs on +5 VDC
The micro-SD slot is accessible through the SD card library.
The LED backlight is dimmable by PWM.

Here is a picture of the shield and TFT

Parts

Only $6 for the shield and TFT

PartLink
Arduino UnoArduino UNO R3
TFT shield and LCD1.8 inch TFT Full Color LCD Display Module with LCD Adapter Board Expansion Board

Code

The TFT uses the built-in TFT library which comes with many examples that you can use to test with. The easiest one is the TFTDisplayText example

#include <TFT.h> // Arduino LCD library
#include <SPI.h>
// pin definition for the Uno
#define cs 10
#define dc 9
#define rst 8
// pin definition for the Leonardo
// #define cs 7
// #define dc 0
// #define rst 1
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
// char array to print to the screen
char sensorPrintout[4];
void setup() {
// Put this line at the beginning of every sketch that uses the GLCD:
TFTscreen.begin();
// clear the screen with a black background
TFTscreen.background(0, 0, 0);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255, 255, 255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("Sensor Value :\n ", 0, 0);
// ste the font size very large for the loop
TFTscreen.setTextSize(5);
}
void loop() {
// Read the value of the sensor on A0
String sensorVal = String(analogRead(A0));
// convert the reading to a char array
sensorVal.toCharArray(sensorPrintout, 4);
// set the font color
TFTscreen.stroke(255, 255, 255);
// print the sensor value
TFTscreen.text(sensorPrintout, 0, 20);
// wait for a moment
delay(250);
// erase the text you just wrote
TFTscreen.stroke(0, 0, 0);
TFTscreen.text(sensorPrintout, 0, 20);
}
Share

Arduino and BMA400 acceleration sensor example

In this article we look at another acceleration sensor – this time its the BMA400

The BMA400 is the first real ultra-low power acceleration sensor without compromising on performance. Featuring 12-bit digital resolution, continuous measurement and a defined selectable bandwidth combined with ultra-low power the BMA400 allows low-noise measurement of accelerations in three perpendicular axes. The BMA400 thus senses tilt, orientation, tab/double tab, and enables plug ’n’ play step counting with activity recognition especially suited for wearable devices, which need a long-lasting battery lifetime.

Thanks to the continuous measurement principle and always-defined bandwidth, the BMA400 is the ideal solution for smart home applications such as smart indoor climate systems and smart home security systems. In the latter, the BMA400 can distinguish between real alarm situations like broken glass and false signals coming from random vibrations. Thereby, the new acceleration sensor avoids false alarms.

Features

ParameterTechnical data
Measurement range±2 g, ±4 g, ±8 g, ±16 g
Digital resolution12 bit
Output Data Rate (ODR)12.5 Hz to 800 Hz
Low path filter bandwidthSelectable 0.48xODR or 0.24xODR
Current consumption (independent from ODR due to continuous measurement)Max. performance: 14.5 μA
Typical use case: 5.8 μA
Low power use case: 3.5μA
Noise densityMax. performance: 180 μg/√Hz (Z: x 1.45)
Typical use case: 300 μg/√Hz (Z: x 1.45)
Low power: 415 μg/√Hz (Z: x 1.45)
Ultra low power / Auto-wake-up mode800 nA @ 25 Hz ODR
Embedded features
  • Step counter (< 4 μA overall)
  • Activity recognition (walking, running, standing still)
  • Activity change
  • Orientation
  • Tab/Double tab (< 8 μA overall)
  • General interrupt 1 and 2 (programmable via thresholds, timer, logical AND/OR operations)
  • 1 kB FIFO
Offset±80 mg
TCO±1 mg/K
InterfaceSPI & I²C & 2 Interrupt pins
Supply voltage1.71 V up to 3.6 V

Parts Required

 

NameLink
Arduino UnoUNO R3 CH340G/ATmega328P, compatible for Arduino UNO
BMA400BMA400 Acceleration Sensor
Connecting wireFree shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire
sensor shieldExpansion IO Board Sensor Shield

Schematic/Connection

 

arduino and BMA400

arduino and BMA400

 

Code Example

This uses the library from https://github.com/Seeed-Studio/Grove_3Axis_Digital_Accelerometer_BMA400

#include "BMA400.h"
float x = 0, y = 0, z = 0;
int16_t temp = 0;
void setup(void)
{
Wire.begin();
Serial.begin(115200);
while(!Serial);
Serial.println("BMA400 Raw Data");
while(1)
{
if(bma400.isConnection())
{
bma400.initialize();
Serial.println("BMA400 is connected");
break;
}
else Serial.println("BMA400 is not connected");
delay(2000);
}
}
void loop(void)
{
bma400.getAcceleration(&x, &y, &z);
temp = bma400.getTemperature();
Serial.print(x);
Serial.print(",");
Serial.print(y);
Serial.print(",");
Serial.print(z);
Serial.print(",");
Serial.print(temp);
Serial.println();
delay(500);
}

 

Output

Open the serial monitor and you should see something like this

BMA400 is connected
564.45,808.59,201.17,23
1029.30,-105.47,400.39,23
908.20,-189.45,359.38,23
902.34,-265.63,345.70,23

 

Links

https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMA400-DS000.pdf

https://github.com/BoschSensortec/BMA400-API

https://www.bosch-sensortec.com/bst/products/all_products/bma400_1

 

 

Share

Arduino and LIS3MDL magnetic field sensor example

In this article we look at another sensor – this time its the LIS3MDL which is a 3-axis MEMS magnetic field sensor, digital output, I2C, SPI, low power mode, high performance

The LIS3MDL has user-selectable full scales of ±4/±8/±12/±16 gauss.
The self-test capability allows the user to check the functioning of the sensor in the final application.
The device may be configured to generate interrupt signals for magnetic field detection.
The LIS3MDL includes an I2C serial bus interface that supports standard and fast mode (100 kHz and 400 kHz) and SPI serial standard interface.
The LIS3MDL is available in a small thin plastic land grid array package (LGA) and is guaranteed to operate over an extended temperature range of -40 °C to +85 °C.

Features

  • Wide supply voltage, 1.9 V to 3.6 V
  • Independent IO supply (1.8 V)
  • ±4/±8/±12/±16 gauss selectable magnetic full scales
  • Continuous and single-conversion modes
  • 16-bit data output
  • Interrupt generator
  • Self-test
  • I2C/SPI digital output interface
  • Power-down mode / low-power mode

Parts Required

 

NameLink
Arduino UnoUNO R3 CH340G/ATmega328P, compatible for Arduino UNO
LIS3MDLTaidacent LIS3MDL High Precision 3 Axis Magnetometer Sensor Compass Module Tilt Compensated Compass Replacement HMC5883L
Connecting wireFree shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire
sensor shieldExpansion IO Board Sensor Shield

Schematic/Connection

Couldn’t find a good fritzing part or image to use, this is the sensor I bought

 

As an added bonus here is the schematic for one of these modules

ArduinoSensor
3.3vVcc
GndGnd
SDA (A4)SDA
SCL (A5)SCL

 

Code Example

This uses the library from https://github.com/pololu/lis3mdl-arduino

/*
The sensor outputs provided by the library are the raw 16-bit values
obtained by concatenating the 8-bit high and low magnetometer data registers.
They can be converted to units of gauss using the
conversion factors specified in the datasheet for your particular
device and full scale setting (gain).
Example: An LIS3MDL gives a magnetometer X axis reading of 1292 with its
default full scale setting of +/- 4 gauss. The GN specification
in the LIS3MDL datasheet (page 8) states a conversion factor of 6842
LSB/gauss (where LSB means least significant bit) at this FS setting, so the raw
reading of 1292 corresponds to 1292 / 6842 = 0.1888 gauss.
*/
#include <Wire.h>
#include <LIS3MDL.h>
LIS3MDL mag;
char report[80];
void setup()
{
Serial.begin(9600);
Wire.begin();
if (!mag.init())
{
Serial.println("Failed to detect and initialize magnetometer!");
while (1);
}
mag.enableDefault();
}
void loop()
{
mag.read();
snprintf(report, sizeof(report), "M: %6d %6d %6d",
mag.m.x, mag.m.y, mag.m.z);
Serial.println(report);
delay(100);
}

 

Output

Open the serial monitor and you should see something like this

M: -1934 5556 6732
M: -2222 5096 6958
M: -1508 5329 7391
M: -1174 5782 7194
M: -119 6447 6429
M: 447 6333 4702
M: 92 6073 4256
M: -1190 6107 5068
M: -1401 5808 6758
M: -502 5195 7839
M: 740 4453 8173
M: 1327 3639 8161
M: 1421 3006 4294

 

Links

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

 

 

 

Share

Arduino and LPS22HB absolute pressure sensor example

In this article we look at another absolute pressure sensor – this time its the LPS22HB

The LPS22HB is an ultra-compact piezoresistive absolute pressure sensor which functions as a digital output barometer. The device comprises a sensing element and an IC interface which communicates through I2C or SPI from the sensing element to the application.

The sensing element, which detects absolute pressure, consists of a suspended membrane manufactured using a dedicated process developed by ST.
The LPS22HB is available in a full-mold, holed LGA package (HLGA). It is guaranteed to operate over a temperature range extending from -40 °C to +85 °C. The package is holed to allow external pressure to reach the sensing element.

Features

  • 260 to 1260 hPa absolute pressure range
  • Current consumption down to 3 μA
  • High overpressure capability: 20x full-scale
  • Embedded temperature compensation
  • 24-bit pressure data output
  • 16-bit temperature data output
  • ODR from 1 Hz to 75 Hz
  • SPI and I²C interfaces
  • Embedded FIFO
  • Interrupt functions: Data Ready, FIFO flags, pressure thresholds
  • Supply voltage: 1.7 to 3.6 V
  • High shock survivability: 22,000 g

 

Parts Required

 

NameLink
Arduino UnoUNO R3 CH340G/ATmega328P, compatible for Arduino UNO
LPS22HBSemoic Lps22Hb Pressure Resistance Pressure Sensor Module for High Intensity Industrial Control
Connecting wireFree shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire
sensor shieldExpansion IO Board Sensor Shield

Schematic/Connection

 

arduino and LPS22HB

arduino and LPS22HB

 

Code Example

This uses the library from hhttps://github.com/adrien3d/IO_LPS22HB

/***************************************************************************
This is a library for the LPS22HB Absolute Digital Barometer
Designed to work with all kinds of LPS22HB Breakout Boards
These sensors use I2C, 2 pins are required to interface, as this :
VDD to 3.3V DC
SCL to A5
SDA to A4
GND to common groud
Written by Adrien Chapelet for IoThings
***************************************************************************/
#include <Wire.h>
#include "IO_LPS22HB.h"
IO_LPS22HB lps22hb;
void setup()
{
Serial.begin(9600);
Serial.println("IoThings LPS22HB Arduino Test");
lps22hb.begin(0x5D);
byte who_am_i = lps22hb.whoAmI();
Serial.print("Who Am I? 0x");
Serial.print(who_am_i, HEX);
Serial.println(" (expected: 0xB1)");
if (who_am_i != LPS22HB_WHO_AM_I_VALUE) {
Serial.println("Error while retrieving WHO_AM_I byte...");
while (true) {
// loop forever
}
}
}
void loop()
{
Serial.print("P=");
Serial.print(lps22hb.readPressure());
Serial.print(" mbar, T=");
Serial.print(lps22hb.readTemperature());
Serial.println("C");
delay(300);
}

 

Output

Open the serial monitor and you should see something like this

IoThings LPS22HB Arduino Test
Who Am I? 0xB1 (expected: 0xB1)
P=982.52 mbar, T=18.21C
P=982.56 mbar, T=18.25C
P=982.51 mbar, T=18.26C
P=982.52 mbar, T=18.27C
P=982.54 mbar, T=18.27C
P=982.55 mbar, T=18.27C
P=982.51 mbar, T=18.26C
P=982.55 mbar, T=18.26C
P=982.55 mbar, T=18.26C

 

Links

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

 

 

Share