Progressing slowly with the arduino and the Raspberry Pi

Jan 6, 2014 | Arduino, Linux, Personal, Raspberry Pi, Scripting and programming, Technology | 0 comments

Work on the Arduino and the Raspberry Pi is ongoing. So far, I’ve made Led’s flash, used a light meter to determine when the LED’s are on and off, taken the temperature of the room and moved a camera using a Servo. On the Pi side, I’ve set up Email alerts when motion has been detected by the phone and I even found an application that supports push on the IOS platform so I may even be able to get the Pi to send alerts directly to my iPhone.

I’ve encountered a few challenges of course. Almost all of the tutorials for the Arduino use a delay function to pause when the servo is running or when the motor is spinning but that’s no good when you need the loop to continue processing while all of this happens. So, I looked into a few alternatives. Using a counter to count the milliseconds since the device was turned on was fine but this would need to reset after 34 days which would cause a problem with the timing of the loop. I then tried a library called ElapsedMilis. This works fine but I had a lot of problems figuring out the logic. I got there in the end though but unfortunately my approach wasn’t completely sound.

After asking a question on the Arduino forum I was pointed in the direction of another library called Delay Timer. I don’t think it’s released because when I included it first in one of my projects I had a bit of debugging to do to get it working. I must subscribe to Git Hub to suggest my changes. Unlike my previous approach, with this library, I can use as many timers as I want. The last time, I was using one hardware timer and a number of intervals to try to mark when functions should be executed. This should have worked fine in theory but the problem is that the loop is processed so quickly that it can run through the process too quickly and miss an important event. With this new approach, I can have different timers running concurrently and I can check each one. When it is time to execute that function, the timer resets again and its place in the loop is never lost.

Of course, it’s not all programming. Some of this work is also about putting the components together and making it sit properly. One problem I was having is that the servo was generating too much vibration. This would cause the camera to constantly think it was detecting motion. I came up with the great idea of using a bit of Velcro to help mount the servo to the side of the Raspberry Pi and then Velcro the camera board to the moving part of the servo. Now, the vibration is absorbed by the servo. It’s funny the solutions that show themselves when you’re stuck.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.