I’ve connected the LSM9DS0 9 degrees of Freedom Breakout Board made by sparkfun with an arduino micro like I’ve described in a previous post, wrote a little rosserial sensor_msgs::Imu publisher and visualized everything using the rqt plugin manager for further experimenting.
Here a screenshot while moving the setup:
a screenshot while not touching:
As you see all data is still moving a lot. So the next step beside finding out what the units really mean, will be stabilizing by using a kalman filter like its provided in the robot_pose_ekf package.
By the way: the arduino is currently using around 25000 of its 28 672 bytes memory just providing the IMU data to ros. So the motorshield will require another micro or we switch it to something else like an wiimote.
Soldering, Soldering, Soldering 🙂 Everything else had been following the amazingly well written guides of the LSM9DS0 made by sparkfun. Nine degrees of freedom at a rate of “a few per second”(currently 9Hz) since I’ve followed just the basic setup without fancy interrupt usage.
One thing thats really important to mention is the different signal voltage level of the SDA and SCL pins between the Micro(5V) and the IMU Breakout Board(3.3V) – which in case you connect them together without bi-directional level shifting, as you might expect since i2c is designed for exactly that, would lead to blue chip burn.
So wiring on the bread board (and not removing the wires used by the arduino motor shield v2, so do not get too confused by that):
and applying the library to the arduino IDE, leads to a working live example with 2 outputs per second:So the next step is to increase the rate by improving the setup wiring, parse that data into ROS Hydro by a SensorMsg/Imu publisher, kalman and combining these with other odom sources like my currently used (and sadly poor) or even an GPS source to a exact and really usable Odometry by the robot_pose_ekf package for later Simultaneous Localization and Mapping (SLAM) – a real autonomous mapping and navigation. Sounds easy right?
Today is sensor day, so I’ve managed to get the [amazon &title=DHT11&text=DHT11] working:
DHT11connected to the Arduino Micro
DHT11, only three wires are required
Wire it like that:
([amazon &title=DHT11&text=DHT11] -> Arduino Micro )
- Pin 1 (orange cable) to 5V
- Pin 2 (yellow cable) to GND
- Pin 3 – not needed
- Pin 4 (yellow again -.-) to A0
Use the following code I’ve found here:
#define dht_dpin A0 //no ; here. Set equal to channel sensor is on
delay(300);//Let system settle
Serial.println("Humidity and temperaturenn");
delay(700);//Wait rest of 1000ms recommended delay before
//This is the "heart" of the program.
Serial.print("Current humidity = ");
Serial.print("temperature = ");
delay(800);//Don't try to access too frequently... in theory
//should be once per two seconds, fastest,
//but seems to work after 0.8 second.
}// end loop()
Getting you a result like that:
It doesn’t seem to be very accurate, but that’s expectable rated by its low price (<2€)
I’ve experimented with the [amazon &title=BMP180&text=BMP180]. Since its a 3,3V breakout board which is I²C capable I had concerns since the Micro usually uses 5V on its Pins. But without a reason: the I²C on the[amazon &title=BMP180&text=BMP180] needs to get a voltage of 5V and the arduino micro also provides 3.3.
So wiring all together:
BMP180 and Arduino Micro
BMP180 and Arduino Micro
Breakout Board -> [amazon &title=Arduino Micro&text=Arduino Micro]
DA -> SDA (Digital 2)
CL -> SCL (Digital 3)
+ -> 3.3 (do NOT plug this to 5V!)
– -> GND
Sparkfun offers very good tutorials and source code. The library you’ll need to run this board can be found here
Getting this into your Arduino IDE leads to:
Since its an I²C device it should be stackable with any other I²C device in case they do not have the same BUS-address.
Using the LM35 with the Micro is quite easy.
Arduino Micro and LM35
LM35 soldered on a Board
Arduino Micro wired to the LM35
(LM35 -> [amazon &title=Arduino Micro&text=Arduino Micro] )
- 5V to positiv
- GND to –
- S to A4
And run the following code (should run on every arduino):
int tempPin = 4;
temp = analogRead(tempPin);
temp = temp * 0.48828125;
Serial.print("TEMPRATURE = ");
Getting this result:
Please note its you might need to adjust the 0.48828125 to a value thats verified with another temperature sensor (or just a normal celsius thermometer) .
The next step for me is to write a little ROS publisher for this sensor.