Home automation

This post is a update of my previous post. I ditched the idea of replacing my remote with a fixed touchscreen remote. Instead I wanted to be able to control everything through the internet. I decided to start with using the Adafruit IO service. The hardware used for this project are a Raspberry Pi 3, Pi camera, remote controlled switches, ESP8266 NodeMCU and a 433MHz transmitter.

The NodeMCU was used to make a wireless connection to the internet. It uses the MQTT protocol to get feed data from my Adafruit IO dashboard. This feed data determines if the transmitter needs to turn off or on a specific switch. Currently the switches are only controlled by the online commands (or manual override with a remote control). But automation scripts can easily be made, which can be handy when going on vacation. As can be seen in Figure 1 there are still a lot of IO pins unused on the MCU so upgrades can be connected.

Figure 1 - NodeMCU
Figure 1 – NodeMCU

 

 

 

 

 

 

As can be seen in Figure 2 the online dashboard also contains a live camera feed. This camera feed runs from a Raspberry Pi 3 with a Pi camera. Currently the camera is in a testing location. But when properly placed it will see my complete room. Because there is no QOS support from the online dashboard a different solution had to be created. That’s why the status of the received input feeds is send by the NodeMCU to the dashboard. This way we can make sure that the feed update was received and processed correctly. The ESP8266 is programmed with a last will and testament, so if the connection is lost the broker sees this and publishes the testament which donates that the module is OFFLINE. If the connection is open then the ESP8266 status is set to ONLINE.

Figure 2 - Online dashboard
Figure 2 – Online dashboard

Energy and measurements project

The second project of my Mechatronics education was to build a cart that could sens and record acceleration data and predict the carts path. The acceleration data also needed to be collected for post processing and analysis. My part of the project consisted of programming the Arduino and creating the python Gui and data analysis program. It also consited of designing and building of the hardware.

The setup can be seen in Figure 1. The cart gets accelerated over a predetermined path until it reaches the ramp. After it reaches the ramp the carts needs to give a visual indication if the carts turning point is between point a and b or not. This indication has to be done before the return point of the cart is reached.

 

 

 

The on-board hardware consists of a battery, a RGB-led, a Arduino Pro mini, a MPU6050 and a APC220. This can be seen in Figure 2. This electric circuit was turned into a PCB as can be seen in Figure 3.  The MPU6050 consists of a 3-axis accelerometer and a 3-axis gyroscope, for this project only the accelerometer was used. The APC220 is a transceiver operating on 433Mhz, which is used to send and receive serial data from the Arduino to the PC. Because of the Arduino’s limited processing power and the need for a quick calculation, the Arduino uses two setpoints to determine if the carts return point is between a and b. The setpoints are compared to the measured acceleration of the cart during the acceleration phase. These two setpoint where calculated in advance. This was possible due to the fact that the tracks position was known and the friction coefficients where derived from a test setup. If the cart was not able to reach point a, then the RGB-led would turn orangje. If the cart would pass a but not b the RGB-led would turn green and if the cart would pass point b the RGB-led would turn red.

 Electric circuit
Figure 2 – Electric circuit

 

 

PCB
Figure 3 – PCB

 

 

 

 

 

 

 

Data sample
Figure 4 – Data sample

 

 

 

 

 

 

The acceleration data also needed to be recorded for later use. All groups decided to store their data onto an SD-card. Except for our group, we decided to transmit the data to a pc. We did this so that in order to processes the data the cart did not needed to be removed from the setup and analysis of the data could be a lot quicker. The pc used a python script to record the data from the card and store it in a CSV file. This CSV file could also be read by python so that recorded session could be easily analysed. See Figure 4 for recorded session. A other benefit of using python and wireless data acquisition is that it was also possible to give a life plot of the data.

DIY helicopter electronics replacement

Introduction

Because there was a hardware problem with the Exceed X8 PRO helicopter of a friend, we decided to remove all the hardware and replace it with custom build hardware. The first thing I did was replace the hardware in the remote controller, here is the blog about that part. In that blog there is also a part about the receiving end, but the hardware used there has been taken out of commission for my newly designed hardware.

 

Hardware – circuit boards

MOSFET board
On the MOSFET board there are two identical MOSFET circuits. Each circuit controls one output which is an amplified version of the input for that circuit. By putting the two circuits on one board space could be saved and the heat dissipation capabilities are enlarged. It also means less wire clutter in the helicopter. The board is designed to be used with IPU06N03LA MOSFETS, but any TO251 package N-channel MOSFET can be used as long as it meets the requirements needed for your motor and controller. Because I’m using brushed DC motors a flyback diode is incorporated in the design. Each MOSFET has its own pull-down resistor to make sure the MOSFET is in the off position when it’s supposed to and to protect the Arduino there is a current limiting resistor placed between itself and the MOSFET. I use 47 Ohm 0805 resistors for R1 and R2  and 10kOhm 0805 resistors for R3 and R4.

Figure 1: MOSFET motor control board Top
Figure 1: MOSFET motor control board Top
Figure 2: MOSFET motor control board Bottom
Figure 2: MOSFET motor control board Bottom
Figure 3: MOSFET motor control board
Figure 3: MOSFET motor control board

 

 

 

 

 

Arduino control board

The control board was designed for this project but is released as “wireless board V2.0” on OSH Park shared projects. Because it was difficult to get 3.3v Arduinos with the right pin-out the board is now designed to accept 2 different Arduino pin-outs. Namely the “deek-robot” pin-out found in figure 6 and the cheap “ebay” pin-out found in picture 7. Accept being able to handle two different pin-outs the board is upgraded to accept 3.3v Arduinos and 5v Arduinos. That’s also why there is a 5v regulator and a 3.3v regulator onboard so that the Arduino can be controlled by a unregulated or higher voltage power supply. The nRF24L01+ module is powered by the separate 3.3v regulator so long range nRF24L01+ modules can be used, without asking too much power from the Arduino and so that a 5v Arduino can be used. After having having not enough PWM outputs on my previous wireless boards I’ve decided to change the routing, the new pins are the one used in the Mirf library and can be found in table 1. On the bottom side you can see that there are 3 resistors so the voltage applied to the BATT header can measured thru a simple voltage divider network. Having to voltage regulators makes it also easy to have a 5v and a 3.3v line broken out.

Figure 4: Control board Top
Figure 4: Control board
Top
Figure 5: Control board Bottom
Figure 5: Control board
Bottom

 

 

 

 

 

 

 

Figure 6: "deek-robot" Arduino pro mini pin-out
Figure 6: “deek-robot” Arduino pro mini pin-out
Figure 7: "ebay" Arduino pro mini pin-out
Figure 7: “ebay” Arduino pro mini pin-out

 

 

 

 

 

 

 

 

Table 1: nRf24L01+ routing.

Signal: RF module pin: Arduino pin:
GND 1 GND
VCC 2 VCC
CE 3 8
CSN 4 7
SCK 5 13
MOSI 6 11
MISO 7 12
IRQ 8

H-bridge
The H-bridge is the only circuit board that was not custom built but bought. The board is called “Mini VNH2SP30 Monster Moto Shield Stepper Motor Driver ” and uses the VNH2SP30 H-bridge motor driver chip. This board is a bit overkill, but was chosen because of it’s light weight, it needs just one PWM input and it has advanced protection features.

Figure 8: H-bridge board
Figure 8: H-bridge board

 

 Hardware – helicopter

As mentioned above the helicopter used for this product is an Exceed X8 PRO. This is a coaxial helicopter, which means that going forward and backwards is controlled by the tail rotor and rotation is controlled by the ratio of the rotor speed.

Figure 9: Exceed X8 PRO helicopter
Figure 9: Exceed X8 PRO helicopter

Calibration

As of now the helicopter is still being calibrated for stable flight. Because the main rotors are not identical the amount of throttle for each rotor still needs to be adjusted. The other thing that needs to be adjusted is the center of gravity that needs to be beneath the main rotors.

Arduino pro mini 3.3V wireless nRF24L01+ board – Remote control project

Transmitter:

After I made the wireless boards I wanted to find a project to use the boards in.

Because a friend had a non functional remote controllable helicopter we wanted to make it work again.

So I figured that fixing the remote controller, by replacing the original PCB with the wireless board was a nice project.

After hooking up the hardware I started coding. The first and easiest thing I coded was the code to read all the potentiometers. The coding of the transmitter was A bit more challenging. Because I wanted to transmit all 5 the potentiometer values in one sequence. I ended up putting the values in a array which was a success. Because I couldn’t test the transmitter code without a receiver code I had to code an other wireless board as a receiver. The transmitted data that the receiver receives can be seen on the serial monitor in figure 4. The finished code can be found on my github. To ensure the controller can be updated and debugged without having to open the controller I created a FTDI port on the outside of the controller (figure 6). The FTDI port can be hidden behind a cover as shown in figure 7.

Receiver:

The receiver code enables the receiving Arduino to receive data from the nRF24L01+ chip and process that data. Because the analog-to-digital converters (ADC) have a resolution of 10 bits  and the ‘normal’ analogWrite function only has a resolution of 8 bits the data values need to be remapped. The remapping of value ranges is easily done with the function map. After these values have been remapped the can be used to control the motors of the helicopter. Because the tail rotor needs to rotate in both direction a h-bridge is required. For this project I used a L298N dual h-bridge board, although we only use 1 h-bridge but this was the cheapest and fastest option to get. Because the board also has an 5 Volt regulator on board, we can use it to power the Arduino in the helicopter from the LiPo-battery. The L298N board is no longer in use because it would fail at random. My friend designed a PWM controller board to power the main rotors. The board uses 2 IRF540 MOSFETs to channel the power from the battery to the motors. These MOSFETS unfortunately need a drain to source voltage of at least 4.5 V which our 3.3v Arduino doesn’t supply. This is solved by using two NPN transistors for each MOSFET to power the MOSFETS with a high enough voltage.

After successfully testing the helicopters lift capability we decided to design a new board (Figure 8) which integrates all the different components in 1. The new board uses different MOSFETS for easier and more powerful motor control. These MOSFETS are easier because the can be directly controlled with 3.3V and thus do not need extra bipolar transistors to boost up the voltage. The new MOSFETS are IPU06N03LA MOSFETS and are made by infineon. A small comparison can be seen in Table 1. Because the new MOSFETS have a lower Rds(on)  they have lower power losses due to lower Drain-source on-state resistance, which also has the benefit that the MOSFETS become less hot.

Table 1: MOSFET comparison.

IRF540N 06N03LA Desired
Vds 100V 25V Min 7V
Rds(on) 44 mΩ 5.7 mΩ Max 10 mΩ
ID continuous 33A 50A Min 20A
ID pulse 110A 350A Min 50A
Id at 3.3V and 25°C 23A+ Min 20A
Id at 5V and 25°C ±27A 100+ Min 20A
Figure 1: Original non-functional PCB
Figure 1: Original non-functional PCB
Figure 2: Wireless board placement testing
Figure 2: Wireless board placement testing
Figure 3: Remote wired to the Arduino
Figure 3: Remote wired to the Arduino
Figure 4: Transmitted data from the remote
Figure 4: Transmitted data from the remote
Figure 5: Finished remote
Figure 5: Finished remote
Figure 6: Uncovered FTDI port
Figure 6: Uncovered FTDI port
Figure 7: Covered FTDI port
Figure 7: Covered FTDI port
Figure 8: OSHPark render of the integrated board
Figure 8: OSHPark render of the integrated board

Arduino pro mini 3.3V wireless nRF24L01+ board REV1.3

I’ve created a REV 1.3 version of my nRfL01+ board for the arduino pro mini 3.3V. This board still uses the same ports for connecting the nRF24L01+ module as REV 1.2 and 1.2.2. It also has the potentiometer and dip-switches that REV 1.2 and 1.2.2 have. But now there are separate I2C and a SPI connections. And the Raw input voltage can be measured using analog input A6 (as long as it is below 6.6 volts). The brd file can be found here.

Figure 1: TOP, render by OSH Park
Figure 1: TOP, render by OSH Park
Figure 2: BOTTOM, render by OSH Park
Figure 2: BOTTOM, render by OSH Park
Figure 3: Testing the board
Figure 3: Testing the board

Simple Home Automation

The project

I’m currently working on automating my remote outlets. To start I’m going to build a central remote control unit. The first step is controlling my Impuls outlets (Figure 3) and if that’s successful I’m going to try and add some automated features like shutting all my power outlets off when leaving the room. Controllin my Beamish BY-7E light switch (Figure 2) is also in the planning. I bought the Impuls outlets in the Action, a series of shops in the Netherlands. For 10 euros you get 1 remote and 3 outlets which is a seriously low price. The Beamish BY-7E was bought on dx.com for about 13,50 dollar.

Hardware

Before opening the remote outlets I was planning on adding an nRF24L01 module or a Bluetooth module to each outlet. But after opening the outlets I found the relatively unknown and badly documented … chip in them. But in the transmitter I found the commonly used and good documented HX2262 chip. The HX2262 chip is also compatible with the SC5262 and PT2262 chips and can be replaced by an Arduino running the right software. These chips make my projects a lot easier, cheaper and safer, because the receiving units are already finished when buying them. The only thing I need to build is my own transmitter. This is done by connecting a 443.29 MHz super-regeneration transmitter that uses On-Off Keying (OOK) to an Arduino. The module I used (Figure 4) costs about 2 dollar on dx.com and can be bought on many different sites.

Because I find using normal buttons a bit boring and because you can’t change the button layout easily I decided to add a touchscreen to my control unit. The touchscreen I’m using is a Nintendo ds lite touchscreen, because these are easy to read out and are about 3 dollar per unit. I use the BOB-0917 break outboard from Sparkfun to connect the touchscreen to my Arduino. I’m not really happy with this board because it needs a piece of paper between the touchscreen cable ribbon and the connector to make a good connection. And this board also lacks pull-up resistors for a stable analog read out. But for now I don’t have an other option so I use a breadboard to connect the pull-up resistors. The current test rig can be seen in figures 5 and 6. The next challenge for me was powering the Arduino without using a power cord. I chose a 18650 battery and a solar panel combination because this combination can power the Arduino for a long time. Well that was the theory at least, so I began testing. After testing I concluded that this was a good combination if the Arduino could be in power down mode most of the time. In graph 1 you can see the result of my testing. You can also see that if the Arduino isn’t in power down mode most of the time that the power consumption of the Arduino is to high for these power sources. But extra power saving measures like desoldering the power led have not been done yet, but may be included in the future.

Software

For transmitting the right codes with the Arduino the best library to use is the Remote Switch library (not written by me). And for the touchscreen I have written my own library based on this tutorial. I think that using libraries makes the code better readable. Update: The library and Arduino code now work in perfect harmony together.  Here is the beta version of my touchscreen library and here is the beta Arduino code that goes with it. You also need the RemoteSwitch library which can be found in the link above. I’ve created a github repository for this project here and will be using this to update my code and not the links from above.

Update 10-02-2014:
I created an other library to get the Arduino file smaller and more clearer. This library wasn’t working at first but Boris a friend of mine fixed the library for me. The new code and a movie demonstrating the setup will be uploaded this week, but currently I’m to busy to do that.

Update 14-02-2014:
New code was uploaded to Github and the video is uploaded here.

Hardware enclosure
All the hardware from the main control unit is going to be enclosed in a custom box that I’m going to make. The boxed is going to be made by gluing plates of PMMA that are cut with a laser cutter. Renderings of the box can be seen in Figure 7 and Figure 8. The cutouts in the box are for placing the solar panel, touchscreen, PIR-detector and two potiontiometers. The potentiometer and PIR-detector are for enhancements that are going to be added later on.

Figure 1: Impuls remote
Figure 1: Impuls remote
Figure 2: Beamish BY-7E light controller
Figure 2: Beamish BY-7E light controller
Figure 3: Impuls remote outlet
Figure 3: Impuls remote outlet
Figure 4: 433 MHz transmitter
Figure 4: 433 MHz transmitter
Figure 5: Hardware setup
Figure 5: Hardware setup
Figure 6: Power usage test
Figure 6: Power usage test
Figure 7: Main hardware enclosure non see true
Figure 7: Main hardware enclosure non see true
Figure 8: Main hardware enclosure see true
Figure 8: Main hardware enclosure see true
Figure 9: Painted body
Figure 9: Painted body
Figure 10: The master control box
Figure 10: The master control box

Arduino pro mini 3.3V wireless nRF24L01+ board REV1.2, updated to include REV 1.2.2

The first batch of Arduino pro mini 3.3V wireless nRF24L01+ REV 1.2 boards has finally arrived.

This is the first board I ever designed and a good learning experience. The board was designed with Eagle 6.5 and manufactured by OSH Park. Making the design in Eagle was a bit more complicated then I at first thought it would be, because I couldn’t find any existing library that fulfilled my criteria. So I ended up creating a library for every different component in the design. Because I find that using autorouter in Eagle is quite useful if you have given it good design rules I created my own design rules for the autorouter. The dru file can be found here.

Hardware

The nRF24L01+ board is connected according to the RF24 library, see table 1. The IRQ pin of the nRF24L01+ can easily be disconnected from the D2 pin of the Arduino, this is especially useful because the D2 pin is one of the interrupt pins of the Arduino. The IRQ pin is connected when using a jumper connector on the IRQ connect pins.

Table 1: nRf24L01+ routing.

Signal: RF module pin: Arduino pin:
GND 1 GND
VCC 2 VCC
CE 3 9
CSN 4 10
SCK 5 13
MOSI 6 11
MISO 7 12
IRQ 8 2

As can be seen in Figure 2 the board has a 10 kΩ potentiometer and 4 dip-switches on it. The potentiometer also uses a connection with a jumper connector but now on the Pot connect pins. This means you can also disconnect the potentiometer from the Arduino freeing up the A7 pin. The 4 dip switches are wired to pins D3, D4, D5 and D6.

Figure 1: Render by OSH Park
Figure 1: Render by OSH Pak
Figure 2: Board without nRF24L01+ module and without Arduino
Figure 2: Board without nRF24L01+ module
and without Arduino
Figure 3: Board with nRF24L01+ moudule and Arduino
Figure 3: Board with nRF24L01+ moudule and Arduino

Progamming
The pro mini doesn’t have a built in USB connection, that is why you need some extra hardware to program the Arduino. I use Arduino Uno with the ATmega328 removed from the board, you could also buy an FTDI programmer which aren’t expensive. But if you already have an Arduino Uno lying around its free.


Software

The first thing you need to do is make sure you get a library for the nRF24L01 or nRF24L01+. I personally prefer and use the Rf24 and RF24Network library from maniacbug which can be found here. There are also a few examples that can be found in the library.

Update
On REV 1.2 I unfortunately made a mistake, which renders the dip switches useless. This was because I didn’t check how to properly connect the switches. I”m currently at the end stage of a REV 1.3 where the dip switch problem has been resolved and a few other enhancements where made. If REV 1.3 is finished I will upload them to this blog. REV 1.2 can be found here.

REV 1.2.2 upgrades
The REV 1.2.2 is the improved version of REV 1.2. The dip switches are now correctly connected to the Arduino, but require a 10k 0805 SMD resistor per switch. The IRQ connect and nRF24L01+ connections have switched places to ensure that the v, g, A7 and A6 connections are easily accessible when the nRF24L01+ module has been attached. Also a few minor silkscreen changes have been made. The REV 1.2.2 brd file can be found here.

Top view 1.2.2
Figure 4: Top view 1.2.2
Bottom view 1.2.2
Figure 5: Bottom view 1.2.2