Sensor node with somfy window shutter

After a recent renovation I wanted to be able to control my newly installed window shutters from my home automation setup using Home Assistant. I found out the installed system is Somfy RTS so after a bit of searching online I found out someone had already reverse engineered the protocol. The transmitter transmits on 433.42Mhz instead of the usual 433.92Mhz that most devices on 433Mhz use. So for optimal range and reception I had to switch the resonator on the tx pcb. This is no issue as the resonator only has three pins:

433.42 Mhz resonators

As I would have an ESP8266 running permanently to control the window shutters I thought it would be nice to add some sensors. I found the excellent ESP MQTT JSON Multisensor project that adds the sensors for temperature, humidity, motion and light.

I combined this with the Somfy Remote project as it has support for multiple window shutters.

So I ended up with the following setup:

schematic

Parts list:

Case

I found a nice case on thingiverse, it comes in two variants with the USB cable on the front or the back.

Components ready to be installed in the case
Everything mounted inside the case except the nodemcu, coil on the bottom left is the 433Mhz antenna
Case closed

Home assistant config

Home assistant configuration is quite simple, just add the following for sensors and control, as you can see I am not displaying motion at this moment.

sensor:
  - platform: mqtt
    name: "Attic front"
    state_topic: "home/atticfront"
    unit_of_measurement: '<C2><B0>C'
    value_template: "{{ value_json.temperature }}"
    icon: mdi:temperature-celsius
  - platform: mqtt
    name: "Attic front"
    state_topic: "home/atticfront"
    unit_of_measurement: '%'
    value_template: "{{ value_json.humidity }}"
    icon: mdi:water-percent
  - platform: mqtt
    name: "Attic front"
    state_topic: "home/atticfront"
    unit_of_measurement: 'lux'
    value_template: "{{ value_json.ldr }}"
    icon: mdi:lightbulb
cover:
  - platform: mqtt
    name: "Blinds left"
    command_topic: "home/attic-back/blinds-left"
    state_topic: "home/somfy-remote-attic-back/state"
    qos: 0
    retain: true
    payload_open: "u"
    payload_close: "d"
    payload_stop: "s"
    state_open: "open"
    state_closed: "closed"
    payload_available: "online"
    payload_not_available: "offline"
  - platform: mqtt
    name: "Blinds right"
    command_topic: "home/attic-back/blinds-right"
    state_topic: "home/somfy-remote-attic-back/state"
    qos: 0
    retain: true
    payload_open: "u"
    payload_close: "d"
    payload_stop: "s"
    state_open: "open"
    state_closed: "closed"
    payload_available: "online"
    payload_not_available: "offline"

Software

I combined the two projects I found into one to run it on the ESP8266, that is all I did so all the credits go to the original authors. Code can be found here.

Posted in Uncategorized | Tagged , , , , , , , | 6 Comments

A Light Conversation

In this project I converted an old desk telephone into a lamp. It’s an old black bakelite/metal desk phone made by Heemaf type Norm 1938 made under Siemens license in The Netherlands for PTT (Dutch telecom company):

As can be seen in the video it is possible to control the phone both physically and virtual using a mobile phone for example. I was also able to make the bell ring again, I might hook it up as my next doorbell.

The build

To accomplish this I opened up the phone when I bought it and first removed all unnecessary parts, including a mechanism that turns back the phone dial upon releasing it. The process was quite interesting as I don’t take apart something that was made in  1952 every day.

Original phone internals

Original phone internals – bottom side

phone internals

Original phone internals

I didn’t expect to get the bell working again as it is suppose to run on a 60V AC signal, but by alternating the voltage in the same frequency on one of the outputs of the H-bridge I got the desired effect (you can hear the bell at the end of the video).

Now that I wanted the bell to keep working I had another problem. The space I thought I could use by removing the bells and the coils was no longer available and I could no longer connect the potmeter and motor combo inline with the phone dail centre shaft. To resolve this I used a cross coupling so I could mount the potmeter under an angle. If the potmeter has any friction while turning the motor will slip so the potmeter will stop turning, so mounting the potmeter at exactly the right angle proved to be quite a difficult task.

Electronics

The brain of the operation is the ESP8266 WiFi SoC by Espressif Systems mounted on a NodeMCU board. It connects to a Dual H-bridge board that drives both the Potmeter motor and the coils that drive the bell. The LED’s are driven via a TIP122 darlington transistor. The power supply voltage is stepped down to around 8V using a Step down module as 12V is too much for the potmeter motor.

Schematic overview

Schematic overview

Software

I installed the Arduino core on the ESP8266 and added the OTA Update library for easy updates to the code. The aspect of two different input methods that have to work together and keep each other in sync was quite interesting. I found out that if you read the analog input A0 too frequently the ESP8266 will actually drop it’s wifi connection as this adc is also used to monitor wifi output power internally, simply adding a delay between reads on A0 fixed this issue.

The client on mobile phone was made in html/javascript using jQuery and websockets to connect to the rotary phone. Upon rotating the dial on the rotary phone updates are send via the websocket connection to keep the mobile phone dial in sync. The values from the potmeter are mapped to degrees between 0 and 300 (physical limit of the rotary phone dial).

Photos

img_20161204_022734 img_20161204_023039 img_6669

Parts

Posted in Uncategorized | 14 Comments

GameBoy Zero

IMG_20160709_114331

Intro

I came across this post on Reddit and thought it was a great idea so I wanted to make one as well. I used to play games on a NES and the C64 so this would be a great DIY retro hand-held that is able to emulate these and a lot more. Later on I found the great guide series by wermy on YouTube, highly recommended if you would like to build this yourself. His guide gives a lot of information, however I did not follow it exactly and used some different parts to build my version. A college found a set of broken GameBoy’s online that looked ok but that were missing the the battery cover, we later found out. Luckily you can buy separate battery covers for the GameBoy on Aliexpress.

Build

I started by modifying the case. Drilling the extra holes for the extra buttons and expanding the hole for the display is imho the most scary part of the adjustments to the case. After quite some fiddling with my dremel and filing by hand I ended up with this:

IMG_20160702_011954

Next thing I did was remove the internals and cut the original motherboard in half so I could use the lower part for the controls. Following wermy’s guide I removed all the unnecessary parts and connected wires to all the button traces and connected all the ground traces together. Be sure to use thin wires and glue them down to avoid them breaking off the board.

IMG_20160702_012007I also added tape and put copper tape over it to create support for the extra X and Y buttons. I bought a NES controller clone to get the extra buttons and the rubber support beneath it. I also cut out the round spacers around the buttons that guide the button and make sure it stays in place. I glued them to the back of the case in the same configuration. For the rest see wermy’s guide for details on this. Instead of using the Teensy LC mentioned in his guide I used an Arduino Leonardo clone as it is also able to emulate a keyboard and it is a lot cheaper and easier to get. After modifying the code (that turns button presses into keyboard keys) that wermy used to work with the Leonardo it works great.

Next up was the screen. I used my multimeter to find the 5V section of the driver board so I could power the screen from 5V instead of the 12V it normally runs on. Be careful when handling the brown ribbon cable as it is quite fragile. The white wire in the picture is not needed.

IMG_20160703_231851

Next I removed the metal enclosure around the screen so I could spray paint it black so it will nicely blend in with the screen as part of it is visible when the screen is inserted into the GameBoy.

IMG_20160703_131604

I used a different battery charger and booster board (it boosts the battery voltage to 5V). And found out that with a bit of dremeling I could fit the board directly behind the original charging port that I also made a bit bigger so the micro USB cable will fit.

IMG_20160704_150900I removed the big USB connector and soldered wires directly to it. The battery is connected by soldering wires to the battery + and – terminals on the board and to the battery (be very careful when doing this).

IMG_20160704_150934On top is the original on/off switch that I removed from the original motherboard and glued into place using a piece of plastic on the left side for extra support so it won’t move.

IMG_20160705_005353Here I test-fitted the screen with the driver board for the screen and the Arduino Leonardo and the button board. I later moved the Arduino down and the driver board a bit to the left to make room for the plastic mounts for the top part of the GameBoy that are removed earlier on to make room for the screen (this is described in detail by wermy).

I had quite some difficulty sourcing a cheap and small 4 port USB hub. The issue is that the Raspberry Pi Zero seems to be quite picky when it comes to USB hubs. It detects the hubs I got earlier fine but as soon as you connect a keyboard via the hub it just does not show up at all (no output in dmesg or lsusb). However when connecting the same hub to my laptop it worked fine. I found a hub based upon the FE1.1s USB hub IC by Terminus Technology Inc that works really well and does not have the keyboard issue. I removed all the USB plugs on the hub to save space and placed one of these connectors in the ext. connector port in the case.

IMG_20160707_223450I added the Raspberry Pi Zero it self and used some plastic spacers to align it perfectly to the original hole in the case where the contrast control was. This however required to de-solder a capacitor from the screen driver board as it as in the way of the micro sd card placed into the Rpi. I connected it back using some wires so I could move it out of the way.

IMG_20160709_113614I removed all connectors from the audio amplifier board and placed it with the pot meter (aka volume control wheel) nicely behind the original port in case. I connected it via a USB audio card and the original headphone jack so it will interrupt the speaker when plugging in the headphones. I added L and R buttons in the back of the case inside the screw holes. I mounted the battery inside the game cartridge as it fits perfectly and it would even be possible to quickly swap batteries this way. It is a 2500mAh battery so it should last for over 4 hours on a single charge. In the future I would like to clean up the mess of wires that is currently inside the GameBoy but it works great as it is 🙂

Parts list

Posted in Uncategorized | 2 Comments

DIY Micro FPV Quadcopter

So what do you do if you want to fly FPV but the winter weather is really bad?
You build a micro FPV quadcopter you can fly around the house!
It is an easy build and the parts are cheap. This is what it looks like:

IMG_20151225_125621

DIY micro FPV quad ready to fly

It consists of a 5.8 Ghz video transmitter and a small camera and an antenna. It is build on top of a standard Eachine H8 Mini Quadcopter. This setup is cheap and still flies for a couple of minutes depending on the type of battery that is connected.

Power regulation

The H8 Mini is a quadcopter with brushed motors so if you would try to connect the video transmitter (vtx) directly you would lose signal due to the power noise from the brushed motors so that needs to be filtered. The vtx runs on 3.3v and the 1S LiPo
puts out 4.2V when fully charged so that would kill the vtx.

Therefore I decided to first boost the voltage to 5V and then use a regulator to bring it back to 3.3v. This way you always provide 3.3v regardless of the exact voltage in the 1S LiPo.

Schematic

You end up with the following diagram:

Schematic showing connections to power regulators

Schematic showing connections to power regulators

Update: there is a small error in the schematic above: the camera ground wire is not connected to ground but audio out, I will fix this soon. Use the labels on the pcb: the gnd wire is the one below the audio out wire.

Please note that the tab on top of the 3.3v voltage regulator (top part of the image above) is not ground (GND) but the output voltage (v-out) so make sure you isolate the whole part well.

Build

I started by connecting a power and ground wire to the H8 mini pcb. It is quite easy to solder a wire to the pads when you remove the battery, you don’t even need to take the quadcopter apart. See this picture:

IMG_6215

Upside down view: ground and power wire directly soldered to the h8 mini pcb

Next step is to the solder wires to the input side of the Matek board and to the output.The latter are directly connected to the input and ground pin of the AMS1117 3.3v regulator (see schematic above).  next I isolated this regulator using shrink wrap and
place it on top of the Matek board. This board was also isolated with shrink wrap and hot glued to the H8 mini. I connected the boscam vtx and the camera to the output and ground wire of the 3.3v regulator. I shortened  the antenna wire a bit to save weight and connected the centre wire to the antenna output of the vtx and the outer mesh to the antenna ground pins. This results in the following:

H8 mini with Matek regulator on top (3.3v regulator inside) and vtx on top of that

H8 mini with Matek regulator on top (3.3v regulator inside) and vtx on top of that

In the future I will try to use a wire antenna as it will be lighter and I may still get good range as the vtx is 200mw.

Parts list

You will also need some wires and shrink wrap and hot glue.

Control (optional)

I use the FrSky Taranis 9XD Plus to control my larger quads so I found a great project online that enables you to control your mico FPV quad using this controller instead of the controller that is provided with the quad, see the nrf24-multipro project on github. You can of course also use the controller that comes with the H8 mini quad.

 

Posted in Uncategorized | 19 Comments

Fixing a Topfield single tuner TF6000COK (Digitenne)

For a couple of years I have been using this Topfield single tuner TF6000COK tuner to watch Digitenne (Dutch DVB-T service). Recently the reception got really bad and I tried to find out what was wrong with it. After rescanning all channels didn’t help I googled and came across a great page describing my problem.

The Topfield tuner

The page is in Dutch and explains the bad reception can be caused by a faulty capacitor in the power supply. It would not be the first time for me to find a dead capacitor causing trouble. Some years ago there was a huge issue with motherboards and power supplies failing due to a bad series of capacitors, known as the capacitor plague. Measuring the 5V on the antenna output of the tuner confirmed the power supply issue, as I only measured about 3.5V.

So I opened up the box and voided the warranty like I love to do 🙂

The guts

I replaced the capacitor C206 with a 470µF/25V one and reseated the psu board and measured the antenna output again, it as 5.02V this time. I tried out the tuner and voila, it worked fine again!

The new capacitor in place

In just 5 minutes of soldering and in about half an hour total if you include searching for the page and waiting for the soldering iron to heat up the problem was fixed. It makes me wonder how many devices are thrown away every day that might be as easy to fix as this one if only more information would be available and more stuff would be open source with schematics available online. Maybe more people would try to fix stuff instead of throwing it away. This fix required simple soldering but I have had ‘broken’ TV’s that just required a new internal fuse to operate fine again, a fix that took less time than this one actually.

This one capacitor is all it took to fix the tuner

It reminds me of an initiative called Repair Cafe, it’s a cafe where you can bring broken household electronics (amongst other things) and skilled people will try to fix it for you. It is the only one of it’s kind as far as I know in the Netherlands. It would be great if more electronics would (tried to) be fixed and less thrown away in the future, but I don’t see that happening any time soon.

Posted in Uncategorized | 6 Comments

Halftone Hebe

For a Dutch tradition called Sinterklaas I made a friend of mine a gift; a halftone picture of his daughter Hebe in wood using my CNC router.

I found some great software online called Halftoner by Jason Dorie that allows you to make a halftone pattern out of any picture. I think pictures with a good amount of contrast work best however. The software outputs G-code directly and only one statement needs to be removed for it to work in EMC2.

Original photo

Original photo

Halftone pattern output of same image.

Halftone pattern output of same image.

Halftoner creates a pattern of holes which vary in size. You start off by spraying a panel of wood black. The smaller the hole is the darker that spot will be. By slightly varying the depth of the holes you get darker or lighter spots.

Halftone in progess

Halftone in progess

A video of my CNC machine in progress:

Nothing to see yet.

Nothing to see yet.

A timelapse of the CNC router to speed things up:

CNC machine finished

CNC machine finished

The pattern of holes.

The pattern of holes.

The result!

Posted in Uncategorized | Leave a comment

DIY CNC Router

I have always wanted my own CNC router but they are really expensive to buy. After seeing some people build them online I thought it would be great to build my own. I found a great site called buildyourcnc.com by Patrick Hood-Daniel. He shows how to build a CNC router from scratch in 36 video’s on YouTube. So I decided to watch these video’s and learn how to build my own CNC. It turned out to be quite a challenge…

Linistepper version with TIP122's on the edges.

I first worked on the electronics, while doing research on stepper drivers a college/friend/fellow hacker of mine suggested to check out Linistepper V2. It’s a great open source driver based on the PIC16F628A. We decided to build the version that had the TIP122’s on the opposite edges on the board so they would be easy to mount to some old Intel CPU cooling blocks of which we had plenty in the dumpster at my work. He also etched the pcb’s for me and they turned out really nice (thanks Arnd!).

 

 

First driver assembled and running!

We also found a great set of steppers online at a great price. After all of the electronic parts were gathered we had a fun evening of  soldering and pizza and pretty soon we had the first pcb assembled. You can see the heat sinks in the background.

The linistepper is a great driver that provides different stepping modes: full, half and microstepping. It supports a lot of stepper motors and provides the standard direction and step pins as input pins. Allowing it to be used on the printer port of the computer directly with software like EMC2.

 

 

Three stepper drivers assembled.

That evening we completed all six pcb’s (three per person) and tested them all out. The only thing we ended up spending most time on was figuring out the right current limiting resistors to use for the steppers we bought.

An oops I made was to try to make the stepper driver turn the stepper by pulsing the step pin by hand but that does not provide clean step pulses of course. So after figuring that out I connected the drivers to an old printer cable and ran a test program in EMC2 to drive them.

 

 

The cut MDF sheets

The cut MDF sheets

Next thing I did was figuring out what dimensions I wanted my CNC to be. I didn’t want to make it too small because I wanted to use it for more stuff than just pcb’s but also not too big, I should be able to carry it on my own, and of course the steppers don’t provide infinite power. So I made a sketch of the dimensions and went to a local hardware store and asked for them to cut the MDF sheets.

 

 

 

 

The 'Ikea system' for connections

The 'Ikea system' for connections

I used the ‘Ikea system’ for holding the structure together, it makes for a really nice strong connection and I didn’t have to use any glue or anything. You just make a hole in the piece of wood you would like to attach and drill a hole in the connecting piece that you put a nut in and then just fasten the bold.

 

 

 

Buildyourcnc.com had a really nice method of creating linear bearings using skate bearings and aluminum corner sheet. It is quite easy to use but you need t make a template using another piece of aluminum with holes in it to make sure you make the four holes in exactly the right places. After that you need to make the holes threaded to be able to attach the screw that holds the bearings in place. The end result will look like this:

 

Z-gantry under construction

Z-gantry under construction

After this I build the Z gantry using more linear bearings and using a router to cut the edges of the MDF at a 45 degree angle at both sides so the aluminum rail would stay in place. You really don’t want to use a router in your house so I did that on my balcony 🙂

It is kind of hard to measure the with of the piece of MDF plus the two sets of rails with the bearings in between them so for the Y gantry I made a mistake and went back to the hardware store to have them cut the piece to correct size. This is not something I could do myself using a handsaw and without proper tools.

 

I went on to create mounts for my stepper motors and holes in the Z-gantry to support the axis. I did this by taking it apart again and drilling a hole thru both the bottom and top piece at once to make sure I did not mess up the alignment. There is no room for error.

I used a drill to carefully make a hole for a hollow worm wheel I found at the hardware store that has an M8 thread inside it. Using two of these on the same M8 thread removes any play the M8 thread has. After reassembling the Z-gantry I gave it a test run:

I was very pleased with the result and the stepper motor ran really smooth and quietly. I then build the other gantries using the same principle and tried them out, at first without the X and Y gantry steppers attached.

 

CNC router assembled. Coke can for size.

CNC router assembled. Coke can for size.

It was very nice to see it assembled for the first time and it had no play or friction. I repeated the motor steps for the other axis and added a mount for my Dremel. I first attached a pen to and made my CNC draw some stuff.

 

 

 

 

 

 

First test run.

First test run.

It went ok but the stepper couplings were slipping so I found another solution that worked better and I attached my Dremel and did a first test run.

 

 

 

 

Logo test cut.

Logo test cut.

I played around a bit with the settings and made a logo and cut it. The first couple of tries did not end up well as I either cut to deep for a single pass or had the speed to high for the Dremel so it would not cut fast enough. After some tweaking I got the settings right.

 

 

 

With the CNC working nicely I looked for a nice set of software that allowed me to design first and then have G-code at the end that I could let my CNC work on and EMC2 would understand. I tried alot of opensource tools to create DXF files and tried tools to convert it to G-code. Some of them worked and some of them were horrible.

Later on I found a really great plugin for Google Sketchup called Phlatscript by www.phlatforum.com. It is a really handy plugin that exports G-code directly and Sketchup lets you draw almost anything quite fast after you figure out how to use it. That however does not take long as it is very intuitive ans has a lot of online help.

I still use this workflow for my own designs. I have replaced the couplings again recently by couplings I bought on Ebay as mine kept on slipping after a while.

Using tools the proper way can be quite hard. Using simple tools to create a CNC router with no room for errors in either software, electronics or any mechanical aspect was quite a challange, but I am happy with the result.

Posted in Uncategorized | 3 Comments

Burning Man RGB LED Suit

I went to Burning Man in 2010 for the first time and knew I had to have some lights at night as it can be really dark out on the playa. So I bought some EL-wire and attached it to the side of my trousers while I was there. I thought it would be really cool, until I actually went out during the night and found out everybody had EL-wire attached to their clothes.

For Burning Man 2011 I needed something way cooler. So after doing some research I decided to build an RGB LED suit. I found a factory in China that actually sold addressable modules that had 3 5050 smd LED’s on them and that would enable you to control these modules individually, something I wanted to be able to do for a long time.

After an exciting period of waiting if my shipment would actually arrive I was happy to find a box in the mail full of modules.

I decided to use an Arduino to control the LED’s and found a great library called the Fast SPI library by  Daniel Garcia. The library is fast enough to drive the 200 modules I wanted use.

Due to to limited amount of SRAM in the Arduino Nano (2Kb) coding the controlling software was quite a challenge as the three levels of color per LED take up 1 bit each so that sums up to 3bits x 200 modules = 600 bytes just to store the current state of the LED’s.

Another issue was storing the patterns in SRAM. I created a two dimensional array to map the number of the LED module to it’s physical location on my clothes. The Flash library by Mikal Hart allows you to use flash memory (PROGMEM) and read it when you need to in an easy way, so that saved me quite a bit of SRAM space.

I first build a prototype of the hardware:

Prototype of the RGB LED controller, using a Boarduino.

Prototype of the RGB LED controller, using a Boarduino.

I added an LCDisplay and some buttons so I would be able to navigate thru the different patterns I coded and added an MSGEQ7 IC and a microphone. The MSGEQ7 chip is a seven-band audio spectrum analyzer chip. You just pulse a reset pin and then clock out seven analog values that correspond the spectral content in seven bands.

As the LED’s would be all over my body I created a controller what would be mounted to the back of my hand.

 

So here is another picture of both the prototype and the pcb’s of the hardware I build:

The control panel for the suit

The control panel for the suit

Prototype and build pcb's

Prototype and build pcb's

Controller inside enclosure

Controller inside enclosure

Prototyping the pants

Prototyping the pants

I took the suit to the CCC camp to beta test it but forgot the controller so I rewrote the software while I was there to show a rainbow pattern.

I was surprised that I had no issues bringing the LED suit and the battery packs on a plane
to the states did not give me any questions at airport security.

I programmed quite a lot of patterns for the suit, most of them speed and color adjustable:

– a vertical scan pattern, going up or down or up/down (see video below)

– random fading up and down

– white sparks on/of random also

– rainbow (see video below)

– a special pattern that I can trigger when someone shakes my hand that makes my suit start to glow from that hand to the rest of my body

The reactions to the suit were amazing I had so many people wanting to take a picture with me or just thanking me for the suit. Using the pattern with the handshake to thank them back was alot of fun, seeing the amazement in their eyes 🙂

Here is me in my suit at Burning Man 2011:

Posted in Uncategorized | 28 Comments

Hello world!

I normally don’t write about the projects I work or have worked on but I noticed people are interested in some of my projects or they would like to know about  stuff I work on, so I decided to create a place where people can see all the crazy stuff I do 🙂

I have documented some of my recent projects and I hope to be able to post about them soon.

So stay tuned, projects to follow…

Posted in Uncategorized | Leave a comment