Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this lab exercise, you will create programs to implement 3 independent functionalities 1.using the ESP8266 NodeMCU and 2,3.using ARM mbed microcontroller 1.Assuming you have

In this lab exercise, you will create programs to implement 3 independent functionalities 1.using the ESP8266 NodeMCU and 2,3.using ARM mbed microcontroller

1.Assuming you have connected a LDR (light dependent resistor) to the analog input of a NodeMCU ESP8266 board (it has only one Analog input), write a program to display light readings on the Arduino Serial Monitor.

2.The SD Card uses a SDFileSystem library to use SD cards with the mbed microcontroller. Based on the memory management technique learnt in class and having imported the necessary files and libraries, and connected the SD card as suggested, write a program that writes a test text file to the card.

MicroSD Breakout

mbed Pin

CS

8 (DigitalOut)

DI

5 (SPI MOSI)

Vcc

40 (Vout)

SCK

7 (SPI SCLK)

GND

1 (GND)

DO

6 (SPI MISO)

CD

No connection

3. Using the mbed microcontroller, read the acceleration in three axes from the ADXL345 accelerometer and output the data to a host computer screen. Use the second SPI port (i.e. pins 11, 12 and 13) for connecting the accelerometer, applying connections shown in Tables below. Use either the ADXL345 (Analog Devices) data sheet at the link or the Table 2 below.

https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf (Page 23) (50 points)

The steps you should take while developing your code:

-set up the Master SPI port and call it acc

-set up USB link to the host computer

-declare a buffer to hold the data read from the accelerometers registers, two for each axis

-declare a data array with a int16_t specifier to hold the full accelerometer axis values, each combined from 2 bytes received from the registers

Table 1: ADXL345 Pin connections to mbed

ADXL345 signal name

mbed Pin

Vcc

Vout

Gnd

Gnd

SCL

13

MOSI

11

MISO

12

CS*

14

Table 2: Selected ADXL345 Registers

aAddress

Name

Description

0x00

DEVID

Device ID

0x1D

THRESH_TAP

Tap Threshold

0x1E/1F/20

OFSX, OFSY, OFSZ

X, Y, Z axis offsets

0x21

DUR

Tap duration

0x2D

POWER_CTL

Power saving features control. Devic epowers up in standby mode; setting bit 3 causes it to enter Measure mode.

0x31

DATA_FORMAT

Data format control Bits

7: force a self-test by setting to 1

6: 1=three-wire SPI mode; 0=four-wire SPI mode

5: 0 sets interrups active high, 1 sets them active low

4: always 0

3: 0=output is 10-bit always; 1=output depends on the range setting

2: 1=left justify result; 0=right justify result

1-0: 00= +/-2g; 01=+/-4g; 10=+/-8g; 11=_+/-2g

0x33:0x32

DATAX1:DATAX0

X Axis Data, formatted according to DATA_FORMAT, in 2s complement

0x35:0x34

DATAY1:DATAY0

Y Axis Data, as above

0x37:0x36

DATAZ1:DATAZ0

Z Axis Data, as above

aIn any data transfer the register address is set first, and formed:

bit 7 = R/W* (1 for read, 0 for write); bit 6: 1 for multiple byte, 0 for single; bits 5-0: the lower 5 bits found in the Address column.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions