Posts tagged hobbies
The Arduino is one of the great breakthroughs in electronic enthusiasts equipment so far (well, in my opinion anyways). I’m a Software Developer that plays more in the Web Application and back-end server space than Embedded Microprocessor Programming, so for me having to deal with a lot of nitty gritty electronic things seems like a mountain to climb for which I am severely unprepared. What the Arduino did was to give me a “foot in the door” so to speak.
I got my Arduino Uno R2 board last Christmas (yes, a year and 2 weeks ago… and yes I know it’s a year and 2 weeks ago). I played around with it a little bit during the year, switching an LED on and off here & there, playing with analog input to sense light etc, viewing the results on the serial port, but not something really useful… yet.
And thus, to do something useful I’ve created a small project as a proof of concept to see if I can get the following done:
- Hook the Arduino with an Ethernet shield up to the net, and send data out (or collect data, whichever works better)
- Communicate with a DS18B20 Temperature Sensor via the 1-Wire interface
- Take the sensor reading and publish it to a graph somewhere online
All this so I can see what the temperature change is over a 24h period in the particular room that I’ve got it set up in.
First, the end-result, and then I’ll post some code and explain how I did it. I’ll also try to share my frustrations and how I figured them out with you in a few steps. You can see my feed on cosm.com here: https://cosm.com/feeds/95874
Here is the first graph after getting everything ready and running it for almost a day:
Here’s a graph from their API for the current readings (live graph):
Pretty cool, huh?
First things first – DS18B20 Temperature Sensor
Digital vs Analog (resistance) Sensor:
So in my search for a good temperature sensor, I settled on the DS18B20 Waterproof Sensor, which I purchased form Micro Robotics (South Africa) here. It’s about 4 times as expensive as the 10k resistor based temperature sensor, but this one is digital! The great thing for me about having a digital thermometer is the distance of the wire to it. Look, even though the Arduino is really cheap, I don’t want to buy an Arduino for each remote sensor in my house, and even if I did that these boards will still have to talk to one central hub in order to send the data out to the internet or to display them. The reason the wire is a problem with a resistor based sensor, is that the longer the wire, the more resistance you have extra because of the distance of copper you’re using. Copper is a great conductor of electrical signals, but nothing comes without a price in electronics, and the price with a long piece of copper is a small resistance. Let’s say each ohm you’re measuring is a degree celcius, and you’re reading 20 Ohm, thus you have 20 Degrees temperature. Now if you had a long wire that connected to the sensor which has a 1 Ohm resistance, you’ll be readin 21 Ohm, skewing your reading of what the temperature is by that 1 degree. So, I was convinced, pay more for digital.
1-Wire (as an added bonus / curse):
With the DS18B20 comes the added bonus of using the 1-Wire protocol. Now, let’s just start off by saying I still feel I don’t have a clue what I’m doing with 1-Wire, because it’s a rather big deal for Dallas Semiconductor Corp, but here’s how I understand it from a noob’s perspective:
- You only need 1 wire (well, you need 3 wires – one is ground, one is positive 5V (or 3V), and the other “one wire” is your signal). That said, though, if you want to have two or three sensors, you don’t need more wires… you still only have ground, VCC and the “one wire” for signal.
- How do I know what sensor I’m talking with? It’s simple, they identify themselves with a 64 bit address (yes, 64 bits is rather big, it gives us the ability to talk to 1.84467441e19 devices – not sure we’ll ever run out, but then again, we’ll see 🙂 )
So, when you read the sensor measurements of say two devices, you merely start to read and your microchip sees a conversation almost like:
– Hey, I’m device A, my measurement is 20
– Hey, I’m device B, my measurement is 25… and then again…
– Hey, I’m device A, my measurement is 20… and so on.
- The cool thing about using one wire only, is that you save input pins on your Arduino. Having the UNO with only a small amount of pins, that’s rather cool.
- It’s easy to use, oh and there’s a library for the Arduino, which makes it easy to use 🙂
Secondly, Ethernet Shield:
I really wanted to go wifi with this, again… long wires and me don’t agree much… but the wifi shield is just so darn expensive, so I opted for the Ethernet Shield R3. You’ll notice though, that I have an Arduino UNO R2 but the Ethernet shield is R3 – that worried me too when the board arrived and I realised: “Oh shoot, there’s 4 extra pins, what should I do with it? Is it going to fit? Is it going to work?”. Well, not to worry if you’re in the same situation as I was… the extra pins are redundant really, so just make sure they’re out of the way (I slightly bent mine) and plug it on top of your Arduino R2. If you have an R3, then bonus 🙂
I’d suggest first playing around with a “Web Server” with the Ethernet shield, which I’ll post later on, just to familiarize yourself with how it works. It’s also nice to use for troubleshooting (if the serial port isn’t your thing).
Right… that’s all for now… my next post will show the most basic things I needed to do in order to communicate with the temperature sensor, and some cool things I did with it which was fun. Watch this space – I’ll post the link here when it’s published.
So I come back from a weeks’ vacation, and look what my Skekboom in my office is doing! 🙂
I never knew they could do this… but, you know… some people research their hobbies beforehand, I just do what looks cool 🙂
Here’s a photo! 🙂 (as they say, “photo’s or it didn’t happen”)