This week we finally got hardware, which means that we can try and actually move things and use actual sensors instead of mocking them. We got wemo and Arduino parts, I am responsible for making a door module. 

Arduino is quite hard, and since I am not a hardware person it was hard for me to get used to it. The first problem I encountered was choosing the right resistors. I had no idea what I am supposed to use and also wiring things together was a challenge. 

Movement Sensor

The door module needs two movementsensors to check if there is movement near the door and if it is the motor should open the door. As a movement sensor I used a PIR sensor. Since I had not much experience I decided to try with one sensor first, to see how it goes and learn from it. Arduino has this advantage that it has a lot of support on the internet and I was able to find a good tutorial to help me out. 

Thankfully, after all my worries, I did not need a resistor, which was a relief. However the PIR has 3 pins, +, - and output, and I did not know which is which. The specification was here of help. After that I connected the right pins to the right things (or so I hoped) and I started to try and use the Arduino IDE. I only copied the code from the tutorial, and the IDE helps a lot with compiling it and putting it on the Arduino. It was fairly easy to do, and after I did that, the Movement sensor worked. 

 Reed Sensor

The next thing I looked at was a reed sensor, this is used to check if the door is opened or closed. I again had some worries about it… the specification said that the sensor can handle 250V, whereas the Arduino operates at 5V. I wasn’t sure if that was not too little for it.

The pins were however marked more clearly and since I already had experience from the movement sensor it was quite easy to setup. As for the code… I could not find a tutorial for it. Therefore I used code for a normal switch and it works ok, but I still need to work on it.

WiFi Library

The Arduinos will communicate with RaspberryPi through WiFi. It was my task to make a WiFi library for everyone to use. This proved challenging as well. Arduino is written mainly in C, however I wrote the library in C++, which I do not know. So I had to learn some basics about it first to be able to use it. But I have to admit C++ is so much better than C for writing libraries. 

Arduino IDE has a nice interface for the libraries , which I used, I also made an example for other to refer to. They just need to put the library in the right folder (..\Documents\Arduino\libraries) and it will show in the drop down menus in the IDE. This makes importing and using a lot easier. 

Next Steps

Next I need to look at actually making the door module. I need to integrate two movement sensors and two reed sensors together so that it can tell what exactly is happening. I also need a motor to actually move a door, however we do not have motor shields yet, and Terrence is supposed to look into that, since he is doing a blind module. It might be that I will use his code to certain extent, since they are similar.