A day of toying around with my Arduino sensors

I bought (already a couple of years ago!) several sensor and communication boards to learn a bit more about Arduino and eventually bring to life my idea of wireless juggling balls with accelerometer and gyroscope on board that can track and identify the juggling pattern you are executing.

I had this idea about 4 years ago and still I haven’t successfully implemented it, which is quite sad, since it means I wasted hours and hours reading tech and geek blogs and never actually spent real time realising it (apart for a time in which my brother put together half the project in just an evening and after which I basically stopped doing anything).

Today (San Valentine’s!) I decided to play around with a few of the sensor boards I have bought to see if they work and here’s a bit of a summary of how it went. (I updated more recently, April 2017, the page with a few more easy examples).

The GPS module

I have this module (PmodGPS) I got from the Makerspace in Tyndall that I actually never used. It was quite simple to make it work since there are a few very good libraries (TinyGPS, AdafruitGPS, PmodGPS) that do all the heavy lifting for parsing the results.

To have simple communication you literally just need VCC, GND, RX and TX hooked up with an Arduino. I hooked it up to 5V (if I remember right) and then used the following code from the AdafruitGPS library.

After around 40 minutes of leaving the gps module connected to the Arduino and close to the window, it actually managed to get a fix (FIX = 1), which means it got a good signal from a satellite, and it output Google Maps readable coordinates, which I did put in Google Maps to verify it’s accuracy.

To understand a little bit more about Global Positioning System, there are two very interesting introductions which can be found here (Garmin) and here (Trimble).

The DS18B20 and LM35 Temperature sensors

This cheap sensor (OneWire Arduino library  and it’s fairly easy to make it work if you use the already provided OneWire example for this sensor.

For some reason today it was just going nuts. I did extract the sensor from it’s breakboard during operation, which might have killed it….

Here a link for the OneWire library and here another one (on Arduino website).

While for the DS18B20 I bought a cheap breakout board with a couple of resistors, the LM35 just needs supply, ground and data out pins, so you can connect it directly to your Arduino. I used the TO-92 package version for both of them.

The code for the LM35 was very easy as well, I referenced from these two pages: 1 and 2, where in the second page they explain how to change the Arduino’s ADC reference voltage to 1.1V instead of 5V so that you can you use a much larger dynamic of the ADC, since the maximum output voltage of the LM35 is only 1V.

Here are both codes

The Servo

I tried the Servo in the past and it did work, I have some sample code (I will add it here soon) that worked. It’s some super cheap servo I got from eBay (I think for less than a euro each).

#include <Servo.h>

Servo myservo;

void setup() {
// put your setup code here, to run once:
pinMode(9,OUTPUT);
myservo.attach(9);
myservo.write(90); // information in degrees
}

void loop() {
// put your main code here, to run repeatedly:
myservo.attach(9);
myservo.write(90);
delay(1000);
myservo.write(180); // give it a 90 degrees twist
delay(1000);
myservo.write(0); // give it a 180 degrees twist
delay(1000);
}

The HC-05 Bluetooth module

This module gave me headaches and I still haven’t managed to make it work the way I want. This is what is going to be the heart of the juggling balls communication.

The default pairing code is 1234, so I paired it with the macOS bluetooth and then I connected to it trying 3 different methods:

  1. using CoolTerm
  2. using the terminal and the ‘screen port baudrate’ command after listing all the ports with ‘ls /dev/tty.*’
  3. using the serial library in processing

None of them gave me the results I want.

I connect the BT module to the Arduino and initialize a virtual serial between the two using pins 2,3 on the Arduino.

I was trying to put together information from different tutorials such as this one, this one, this, this, this.

The ESP8266 modules

I have a bunch of ESP8266 modules (ESP-01 and ESP-12), that I never managed to make work. I already have them since a couple of years for my initial juggling balls idea and I still get confused every time I try to use them for a reason or the other: firmware version and required update, difference in pinout, required supply voltage, code problems. Hope to solve this one soon. Update: luckily my try today with the FTDI converter to flash and upload on the esp8266 module worked, so I was able to use it as a simple webserver page. I talk more about it here. So now I need to understand how to connect it to the accelerometer board and print the data on the page, or maybe just how to grab the data from the page and make a nice plot.

Here are the two links I will follow to continue this project: one and two.

The MPU6050 accelerometer+gyroscope module

Here the basic code to get the raw data out of the board after connecting to SDA and SCL pins (A4 and A5 on the Arduino Uno). Now that we have the raw data, we have to think about how to handle it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s