This week our ultimate goal was to connect an external accelerometer to the Arduino and transmit the X, Y, Z accelerations through bluetooth. We were not able to do it but we had partial success in both tasks.
Accelerometer
For the accelerometer we used the LIS3DH Triple-Axis accelerometer and followed an online tutorial and an example in the Adafruit LIS3DH library (link). We were successful in getting and plotting the signal but a few questions remain:
!questions/comments!
- What are I2C vs. SPI wiring? Which one is better for our application?
- Is this the right accelerometer for us to use or are there better ones?
- How many accelerometers can we use with one Arduino? Is it possible to use multiple accelerometers with I2C wiring?
Bluetooth
Bluetooth was certainly more of a struggle, even following the bluetooth lab. We didn’t quite understand how to send three float numbers (x,y,z accelerations) using characteristics. I was also confused about how to select UUID and alsoset characteristics.
We were able to turn on the Arduino LED using p5.ble.js library and also read a button output from a pin. However, we stopped short of sending accelerometer readings via bluetooth since we didn’t know how. There are many questions remaining.
!questions/comments!
- a very important note was that bluetooth does not connect using p5.js editor. We learned that the hard way. We were only able to connect when we made a local server with Visual Studio Code.
- The Arduino code from p5.ble.js website was not working (we could find the peripheral Arduino). But when we tried the example Arduino BLE codes form the Arduino library, they worked.
- What characteristic would the LIS3DH readings be?
- What is the difference between read, write and notify?