Tuesday, August 15, 2017

Painting packaging

As some of you will know my girlfriend is a painter. She makes oil-paintings in all kind of sizes and one of my favorite sizes are the miniatures.

She started with small paintings on cardboard of about 2 by 1,5 inch which you can find at her website by clicking here.

Now she has found an even smaller object to paint on: crown-caps

In the pictures above you can see an example of what she makes of a normal crown-cap. She uses oil-paint for durability. As you can imagine it takes a lot of work, a sharp eye and a steady hand to create one of these.

She sells them (for really moderate prices) and therefore we needed to find some kind of packaging for these miniatures.

Thats where the 3D printer comes in.

I designed a small holder to put the paintings in and printed it.

Don't look at the color. My 3D printer supplier delivered 8 spools of pink filament a for a ridiculous low price so at this time near all my designs will be in pink.

Pink is not the best color to display these and therefore she painted them black with acrylic paint which works magnificent with PLA.

Here is the end result when it is all put into a small jewellery case.

Till next time
have fun

Luc Volders

Tuesday, August 1, 2017

Learn Python

We are back from our annual holliday, and hollidays are special for us. Three weeks a year without friends, relatives and obligations. We do not plan where we go to, we just put all our stuff in our car and drive south. And each year we end up in a different part of France which is beautifull.

Three weeks without newspapers, magazines, television, radio, computers, internet and even our smart-phones are put off.

We are totally incommunicado, and we love it. We love camping, read a lot, walk for miles, visit historical villages and nature sites, eat in local restaurants and just have the time of our lives.

Only this year I sinned a bit: I took my Android Tablet with me. And a computer book !!!

The reason for this was that I have several Raspberry Pi's at home. They are being used as a Domotics system, an IP camera, a Media Station and a printer server. None of these are projects I devellopped myself. I just download the code and use it.

However I wanted to learn to use the Raspberry for my own projects. Especially the humble Pi-Zero which just costs 6 euro would be an excellent starting point. It is a full fledged Linux computer with I/O ports. Ideal for IOT projects.
Where to start.


Python is a versatile programming language that is fully supported by the Raspberry. In the Raspberry Operating System: Raspbian (a spacial branch of Debian linux) Python 2.7 and 3 are incorporated as well as the Geany programming editor.

Python supports the Raspberry's I/O ports and has a library for the special raspberry camera. So the easiest way to start projects with a Raspberry would be by programming in Python.

Few years ago I wrote a G-Code interpreter (for 3D printing) in Python and a program that displayed Google Maps on a PC screen.

So I had some experience with Python on my Desktop PC but never really got a good grip on it. I searched for functions on the internet and stumbled on things by accident. That allowed me to write programs and see how wonderfull Python is. However I never really learned it the right way.

Python on an Android Tablet

Yes, indeed. There is a Python interpreter readily available for Android. Just download it from the Google Play store (it's free) and start programming.
You can find it here: https://play.google.com/store/apps/details?id=org.qpython.qpy3

Learning Python

So I wanted a thorough course in Python programming. And a few weeks before my holliday I bought the following book:

Sams Teach Yourself Python Programming for Raspberry Pi in 24 hours.

And I did !!!
I really learned to understand Python programming in 24 hour.

If you have no real structured experience in Python and, like me, have just been messing around, searching things on the internet, this book is just great.

There are 24 chapters. Each chapter is a lesson full with demo programs and excercises that can be done within an hour. Hence the name. Every evening when my girlfriend went to bed I spend an hour studying Python and I learned a lot !!

You learn Python from the beginning working with variables, strings and artithmetics. Then it goes on with loops.
You learn about the different types of arrays that are called Tuples, Lists and Dictionaries. You will learn about writing your own functions and using libraries and modules. And also about GUI programming and Game programming.

The book will teach you how to use internet functions like writing a mail program, parsing HTML pages and using web-sockets.

And last but not least important you will learn how to write your own web-server and how to use the Raspberry I/O pins. This last part makes it very interesting to use the Raspberry Pi for IOT projects.


I had no Raspberry Pi with me on my holliday (my girlfriend would shoot me). However I was able to follow most of the lessons on the Android Tablet.
I learned a lot during these 3 weeks especially about structuring my programs and about the different array structures. Every evening I was sitting in my tent and followed one lesson

The book is also full of tricks and tips that you can otherwise only find by hours searching on the internet.

I do not allow advertisements on this web-log and I do not normally promote / plug products. This book has learned me a lot in a short time and that is why I want to mention it to you.

Highly Recommended

Now I want one of these:


Till next time.
Have fun

Luc Volders

Tuesday, June 6, 2017

Visible Feedback for Raspberry Assistant

Still playing with the Google Home Assistant that runs on one of my Rapberry Pi's. And while playing I realised I missed something. I am planning to build the Assistant into a dummy mannequin head or into a mirror. However when I speak the words 'OK Google' I do not have a visible feedback telling that the Raspberry Assistant is actually reacting, so I have no way to see if it was triggered.

What I need therefore is a led that goes on whenever the Assistant starts listening and goes off when the last sentences have been spoken by the Raspberry Assistant. That's a good way of getting a feedback.

The Google Assistant kit that was supplied by the Raspberry Magazine MAGPI does have a visible feedback in the form of a led. I am however using the Google SDK version which works different.

So switch over to the Magpi version you would say. However the Magpi version is triggered by a button and not by speaking to it and further it has a rather nasty voice when it does not understand something. Overall it is a lesser quality version as the Google SDK is.

So let's attach a led.

First step is to attach a LED to the Raspberry Pi.

The LED is attached to IO pin 18 and through a limiting resistor of 1K to ground. Thats all.
The Magpi version uses pin 25. So for avoiding future compatibility issues you could use pin 25. However make sure that you alter the software accordingly.

The Software Patch

The Raspberry Assistant is for the main part written in Python which is great for us, as this can be altered easily.

To adress the I/O pins of the Raspberry, what we need to do to control the LED, you will need to use the Python GPIO library.

There is however a small problem.

The Raspberry assistant runs from within an ENV. The GPIO library is not directly available in that ENV. So we first have to make it available.

Open the file-manager which can be found at the top-right part of your screen.

Goto  /home/pi/env/lib/python3.4/site-packages/

Make a new folder called RPi and copy the contents of  /usr/lib/python3/dist-packages/RPi to the new RPi folder.

The last step is to alter __MAIN___.PY so that it turns on the led when the conversation starts and turns it off again when it ends.
You can find this file here: /home/pi/env/lib/python3.4/site-packages/google/assistant

Double click on __main__.py and it will open in an editor. Now alter the file as in the source code below.  Do NOT copy the file below as it may have wrong indents.

Python is very picky about indenting.
The indents in this listing are SPACES not TABS !!!
If you mix the indenting the program will not work, so only use SPACES for indenting.

#!/usr/bin/env python

# Copyright (C) 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the 

# you may not use this file except in compliance with the 

# You may obtain a copy of the License at
#     http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, 

# distributed under the License is distributed on an "AS 


either express or implied.
# See the License for the specific language governing permissions 

# limitations under the License.

from __future__ import print_function

import argparse
import os.path
import json
import RPi.GPIO as GPIO



import google.oauth2.credentials

from google.assistant.library import Assistant
from google.assistant.library.event import EventType
from google.assistant.library.file_helpers import existing_file

def process_event(event):
    """Pretty prints events.

    Prints all events that occur with two spaces between each new
    conversation and a single space between turns of a conversation.

        event(event.Event): The current event to process.
    if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
        GPIO.output(18, GPIO.HIGH)

    if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and
            event.args and not event.args['with_follow_on_turn']):
        GPIO.output(18, GPIO.LOW)    

def main():
    parser = argparse.ArgumentParser(
    parser.add_argument('--credentials', type=existing_file,
                        help='Path to store and read OAuth2 

    args = parser.parse_args()
    with open(args.credentials, 'r') as f:
        credentials = google.oauth2.credentials.Credentials(token=None,

    with Assistant(credentials) as assistant:
        for event in 


if __name__ == 


Choose File/save and all is done.

Let's look at the listing.

23 import RPi.GPIO as GPIO
24 GPIO.setmode(GPIO.BCM)
25 GPIO.setup(18, GPIO.OUT)
26 GPIO.output(18, GPIO.LOW)

Line 23 to 26 are new entered lines.
First the GPIO library is imported. The GPIO mode is set to BCM so the IO pins will match the Raspberry's layout. And then GPIO 18 is defined as an OUTPUT and set in LOW state so the LED will initially be off.

44    if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
45        print()
46        GPIO.output(18, GPIO.HIGH)
47   print(event)
49   if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and
50            event.args and not event.args['with_follow_on_turn']):
51        print()
52        GPIO.output(18, GPIO.LOW)

This is where it all happens.
As soon as the conversation starts GPIO 18 will be set HIGH (on) and when the conversation finishes the GPIO 18 is set LOW again (off).

Remember that if you have chosen to put the led on GPIO 25 you will have to later the source code accordingly.

That is all folks.

Restart your Pi and restart the Assistant

Now when you say "OK Google" the led goes on and when the conversation ends the led goes off again. A nice visual feedback that shows that you pronounced "OK Google" the right way so the Assistant understands.

OK, I am off for the summer hollidays.
New stories will be posted in August or so.

Till then: have fun !!!

Luc Volders

Saturday, May 20, 2017

Google Home and the ESP8266

A few years ago there was a (now cult) tv series called Eureka. The series is about a small village in the middle of nowhere were America's most clever minds live and work. They build the most fantastic devices and do deep research on all kinds of subjects for the US government. Then a new sherrif arrives and they have to give him a house to live in. The doors of his house open automatically and in his house is an all-present computer to which he can talk to and give orders like 'do the lights on' or 'what is the temperature' etc. etc. The series ran from 2006 to 2012 (just 5 year ago) and was science fiction at its best.

And guess what, it is no longer science fiction. A computer in your house that you can talk to: that's the present !!!!

And we owe it to Google. I hesitate to admit it but I love Google. Everybody is nagging at them and yet they give us so much free to use tools and gadgets. Just look at the search engine, google drive, Blogger (on which this weblog is written if you haven't noticed), the office suite, google cardboard (check into that really !!!), Android and just now Google Home Assistant.

For those of you living under a rock I will explain brief what Home Assistant is. It is the house computer from Eureka. It is Google's answer to Alexa. It is a stand alone speaker system with a build-in microphone. Indeed no screen, no keyboard, no mouse. The device is attached to the internet (be it wired or wireless) and the microphone listens to a command that activates it. The command is "OK Google" and that is something we know from Android Phones. However this is much more advanced.

There are lists with questions (easily found on the internet) you can ask Home Assistant. Examples are calculations like 535 x 345 or how many kilometres in 6 miles, or who was the first president of the United Sates, or how long is the Great Chinese Wall, or count from 10 to 25 (and backwards) or how long will it take from Rotterdam to The Hague (by car, by train or by bycicle take your pick) or will I need an umbrella tomorrow. You can also ask to roll the dice, give a random number between any two figures or flip a coin. Let it play animal sounds. You can even set alarms and timers. And a really great feature is to tell it "Remember I put my keys on tha table" and ask a few hours later where your keys are.

Basically you can ask it anything you can ask Google on your computer, and then some. And all is done by speaking out the questions and you will be answered by a pleasant womens voice. Really Amazing.

Now this wonder device will set you back at the time of this writing about 129 Dollar. But it gets better.

To get things really rolling Google supplied a Do it Yourself kit based on a Raspberry free with number 57 of the MagPi magazine. Naturally the magazine is totally sold-out.

And still better. Google gave the complete SDK free, for everyone to use.

Actually it works better as the Raspberry version. There is no button needed to activate it. Hands free commanding !!! Next to that it reacts better to questions being split up in multiple frases, and it has a timer and alarm function.

So get your Raspberry Pi out. Buy a USB microphone or use a USB audio adapter, a speaker and an SD card and build yourself a Google Home Assistant for just a few Dollar. Just follow the instructions here:

I have to admit I have wasted hours of my time just asking it silly questions. And there are many pages on the internet dedicated to publishing all the questions you can ask. Just look at this sample:

At this moment there are just a few tens of millions of the original devices sold only in the US and UK as it's only language at this moment is English.

Imagine the impact this will have on society. Just think of the possibillities for disabled persons. Just command the device to set the lights on, the temperature at a certain degree, de radio at your favorite broadcaster.

Now think what we as tinkerers/hackers can do with such a device in our home. We will make our complete home automation voice commanded.

IFTTT compatibility.

You can have your Google Home (including the Raspberry DIY unit) paired with IFTTT. And then suddenly a wealth of possibillities rises.

Command your Philips Hue lights, send a tweet by voice (works flawless believe me), control your Nest thermostat, control your TV with Chromecast, keep a list of notes etc. etc. etc.

And best of all: we can control our ESP-8266 with the Google Home Assistant through IFTTT.
And that is what this entry is going to show you.

Google Home ==> IFTTT ==> ESP8266


To get this working we need to do several steps which I discuss into detail step by step.

- Install ESP-Basic on a NodeMcu or Wemos-D1
- Set up your ESP-8266 with some leds
- Program The ESP with a Basic Program.
- Open a communication port on your router
- Get a IFTTT account (if you do not have it already)
- Set up a few IFTTT recipes
- Command your ESP by voice.

Install ESP-Basic on a NodeMcu or Wemos-D1

Well I am not going to discuss that in detail here as I have already done that in a previous story on this weblog which you can re-read here.

Set up your ESP-8266 with some leds

I am using leds for demonstration purposes. But as you have seen before on this weblog you can exchange the leds for relays like in this story http://lucstechblog.blogspot.nl/2016/09/esp-relayserver.html or by transistors for controlling led-strips, pumps, motors etc.  like in this story

In this setup I am attaching 6 leds which all will be individually controlled. But as you will see in the next parts of this story you can expand this easily or use a less amount easily.

The setup is very simple.

At 6 of the NodeMcu's I/O ports (D1, D2, D3, D5, D6 and D7) is a led attached through a delimiting resistor of 1K. The breadboard layout shows it all.

Program The ESP with a Basic Program.

The program is as said before written in ESP-Basic which is a fast and easy devellopping platform for all your ESP projects. It will even work on a ESP-01 which could give you 4 output ports (I'll be demonstrating that in an upcoming story). For convenience I am using a Wemos D1 mini (clone) here. You could also use a NodeMCU or an Adafruit Huzzah.


msgbranch [mybranch]

textbox command



command = msgget("saywhat") 
command = replace(command 

, "." , " ")
print command
if command = "living room on" then
if command = "living room off" then

if command = "garage door open" then
if command = "garage door close" then

if command = "garage light on" then
if command = "garage light off" then

if command = "bathroom light on" then
if command = "bathroom light off" then

if command = "living room ceiling light on" then
if command = "living room ceiling light off" then

if command = "water pump on" then
if command = "water pump off" then


Let us look at the most important parts of the source code.

msgbranch [mybranch]

textbox command


After the init part where all IO ports are set as output and put off the program starts a MESSAGE BRANCH.
It waits till it gets a command from the internet and displays that command in a textbox on your webpage. This makes it easy to determine if your spoen commands are in the right way interpreted by Google Gome Assist.
If certain commands are always faulty interpreted you can check that here and alter the command in the IFTTT part (further on in this story).


command = msgget("saywhat") 
command = replace(command 

, "." , " ")
print command
if command = "living room on" then
if command = "living room off" then

When a command has been received from Google Home Assist the program jumps to [mybranch]

The first thing that happens is to see if  -- saywhat -- has been received. You can alter that in the program to any other word you like which would give you a bit more security. If -- saywhat -- is not received the program will not do anything.

The next line is a bit tricky:
command = replace(command , "." , " ")

Web communication has a problem with spaces. So this line replaces spaces with dots. We are going to use this program also with another way to command the same ESP chip in a future story. That is
by accessing the chip by an Android App. This way you can command the chip from within your home with Google Home Assistant and from anywhere else in the world by a voice recognition APP on your Android Phone.

To see if everything went well the received command is printed on your webpage by the print command.

The last few lines decide which command has been received and accordingly put the accompaning I/O port on or off.

That is all folks !!

Just for testing purposes I wrote a small program that only tests which command is received and prints that on your screen.

msgbranch [mybranch]

textbox command


command = msgget("saywhat") 
command = replace(command 

, "." , " ")
print command

Use this for testing purposes just to see if your commands come through well.

Open a communication port on your router

First thing to do is to give your ESP a name and a fixed IP adress on your local network.
If for whatever reason your router crashes and gets online again, or your ESP crashes or gets powered down, it will get the same IP adress when it reboots.

So delve into your router (mostly accessible by local IP adress and look at your connected devices. Mine looks like above.

The lower icons are the wired apparatus and as you can see it is my computer (Nescio), printerserver (actually a Raspberry) called Epson as it is connected to my Epson printer, my Buffalo Nas, my Domoticz domotica system and a raspberry. The last one is my DIY Google Home.

The top line icons are my wireless apparatus. There you can see a Thermometer (an ESP with a DS-18b20) and a device called 165. That last one is the ESP this all is about. I named it 165 as this is its IP adress and e4asily remembered.

By clicking on the name label I get information, can alter its name and can edit the check-box which gives it a fixed IP adress (Static DHCP).

Now all your local network settings are done.

As stated before normally you access your ESP from within your local network. However Google Home will need to access it through IFTTT fromthe outside world. This means that you should open a door (just like in your home) to get commands from the big wide world into your local ESP.
This is called port-forwarding.

This is the tricky part. I can only give you general directions on how to do this as all routers have different instructions on how to activate Port


ESP-Basic generally uses port 80 for communication with the your network.
So that means that any command you send to the ESP (or from the ESP) is coming from the following local IP adress


As it is the general communication adress for all HTTP communication you normally ommit the port number (80) and just use the IP adress when accessing the ESP on your computer or phone or tablet.

However your local IP adress is not available from the outside world.

So we need to find your global IP adress. That is the adress your router uses to communicate with the outside world.
You can find that by pointing your web-browser at: http://whatismyipaddress.com/

Now you have to dig again into the setting pages from your router.
Look at something called port-forwarding.

There you can open a new port for the outside world.

In my router I have to give it a name. Next I give it the IP adress of the ESP and the ESP's port number which is 80.
Next I instruct it to send all communication from router port no 8085 to the ESP's port.

The router will most likely ask for a starting port number and an ending port number for your local and global ports. In both cases use the same. So start local 80, end local 80, start global 8085 and end global 8085. You can use many numbers as a port number but there are some restrictions. So delve into that by checkin information on the internet about this. This method allows you to open many specific ports for all kinds of projects.

 As you can see from my setup I have my Domoticz system at port 8081 and my ESP at port 8085

That is it.

Now the only thing left is to instruct your app or whatever you are using to crontrol the ESP to send or get the info from:

The YYY part is off course the global internet adress

Be aware however that opening a port in your router might bring some security issuses as you are opening your router to the world.

The last steps

Now we have an ESP that can communicate with the outside world and a Google Home Assistant that can activate all kind of things by voice commands. The only thing to do is to have them talk to eachother.

There are two ways to do that.

First is the complicated way.
You could alter the Python code that is the motor of yout DIY Raspberry Home Assistant.  The advantage would be that you actually could use just your local IP adress and not have to connect your ESP to the outside world. This would certainly be a more secure way to achive communication.

However that would mean delving deep into the code and making a system that only works for your setup.

The second method is the easy way.
Have the Google Home Assistant talk to IFTTT and let IFTTT send through the Maker Channel commands to your ESP.

This has many advantages.
It is easy to implement. And it can not only be done by the DIY Home Assistant but actrually also by the Google Home Assistant. So wether you build a Home Assistant or buy one this will work.

This story uses the second method.

Get a IFTTT account (if you do not have it already)

I am not going to tell you how to do that as I have already wrote a detailed story on this which you can read here http://lucstechblog.blogspot.nl/2017/04/ifttt-if-this-then-that.html

Next connect to the Maker Channel. You can read how to do that here http://lucstechblog.blogspot.nl/2017/05/ifttt-part-2-maker-channel.html

Just be aware that IFTTT has altered the logo for the Maker Cahnnel and altered the total setup. But let that not frighten you as it is basically the same actions.

Set up a few IFTTT recipes

Almost done. These are the last steps.

First step is to choose New Applet on the right top of your screen. Then click on the blue IF.

Search for Google and the Google Assistant label will emerge and choose that.

Now you will be presented several options. As we want to turn switches ON and OFF choose the third option being -- Say a phrase with a text ingredient --

Fill the form in like the above example. You can use your own texts and commands as you like.
There is one special character in this App and that is the $.
The $ is required in any phrases you are going to fill in. It is later on substituted in the command that is send to the ESP by the word -- on -- or --off -- and will actually set the light on or off.

For demonstration excersises I advise you to use the setup as above.
Now choose Create Trigger at the Bottom.

Next step is to choose the then component so click the blue that.

Search for maker and Choose the Maker Webhooks.

Only one option here so choose that one.

Now complete the action field and fill in your global IP-adress which you found at http://whatismyipaddress.com/ put a column behind it immediately followed by the portnumer (being 8085) that you set in the router. Now click on the white button that says Add Ingredient and choose Textfield. Please make sure that no spaces are added in this line.
Also make sure that you really fill in the dots in living.room. and do not forget that last dot.

Some clarification.
IFTTT and your Google Home will not accept spaces being communicated. That is why I put dots in the place where the spaces would be.
And now you understand what the line in ESP-BASIC program is for.

command = replace(command , "." , " ")

This line filters out the dots and replaces them back into spaces.

And lastly alter the content type in text/plain. The method GET is the one we need. There is no body. All information is in the header.

The TextField will be substituted by the command we gave using the $ in the previous step.
Again carefully inspect the APP and make sure there is no space included between living.room. and the {{TextField}}
If there is a space your ESP-Basic program will not be able to recognise the command.

So if we say "Switch the living room light on" IFTTT will send the next command to our ESP:


Now click on the button Create Action

IFTTT gives you a quick summerisation. Now click on the big blue Finish button.

And all is done.

You can check the complete IFFF command structure by clicking on the gear on the top right side and make alterations.

In just a few seconds your APP will be activated and you are set to go.

Test this thoroughtly and try to understand what is happening.
If you do understand how it works you can make the rest of the APP's in IFTTT to get the other led's running.

Command your ESP by voice.

Every thing is set now. Above you can see my setup. I am looking for some kind of casing however I want it to be special. Like a womens head used in clothes-shops or a crystal ball or something like that.

The only thing you have to do is just say the Magic Words: OK Google
And wait a second.

Then say: Switch the living room light on

And the led should come on.

Just for fun look at the video demonstrating how it all comes together.
Ehhh and please do not comment on the mess.........

And just look at that. More fun coming up.
I connected Raspberry Home Assistant through IFTTT with my Domoticz system. So now I am not only able to connect to ESP's but also to commercial available lightning systems like Philips Hue or Klik-Aan-Klik-Uit and their cheap counterparts from the local dollar stores. These systems are commanded by a 433 Mhz frequency which is send by my domotica system that gets its commands from Raspberry Home Assistant. But that is a whole other story which I will save for a next time.

Till then.
Have fun

Luc Volders

Friday, May 5, 2017

IFTTT Part 3 - Basic alert over IFTTT

In a previous post (read it by clicking here) I gave general information about a PIR. To summerise it up: a PIR is a movement detector. So I wrote that you can make a burglar alarm with it. Well here we go.

However there is something special with this alarm. Most alarms based on movement detection will make some serious noise when activated. That will scare some people undoubtedly. However what if you are not at home. The noise will not be heard by you and so you will not know that ytour house is broken in.

So we are going to use the IFTT Maker channel like described in this article for sending you a notice on your phone when movement is detected.

Besides that we are going to do it in BASIC. Just to demonstrate how easy it is.

First let us look at the setup.

As the breadboard layout shows you I used a NodeMCU for this. The PIR is attached to D3 and gets it's power from the 5 volt line from the NodeMCU which is situated on the first pin on the left side of the board named VIN. As described in the general story about the PIR: it will not work at 3.3 Volts. So luckily the NodeMCU has a 5 volt power line.

A led is attached with a 220 ohm resistor to D2.

Overkill ???

Ok I could have done this with an ESP-01. So why use a NodeMCU for it. At the time when I write this story the price difference between the two is just 60 cents. So its economics. The ESP-01 does not like to have things attached to its GPIO's at startup. Therefore I should put a switch between the PIR and the GPIO and wait till the ESP-01 has started before flipping the switch to attach the PIR to the GPIO. Next the PIR works on 5 volts, the ESP-01 on 3.3 volts. So I would need to have a 5 volts power supply attached to the PIR and a 3.3volts voltage regulator attached to the ESP-01. Add it all up and a NodeMCU with its on board 5 Volts and 3.3 Volts and loads of I/O's which are free to use all the time is an economic better choice.

The BASIC program works as follows.

First nothing happens. That is important as the PIR has to settle for about a minute after power-up. The program will start after you press the Start button. Now the program waits for movement to be detected and when that is the case it will activate the LED and send notoice to your IFTTT maker Channel. and that will send a message to your Phone.

The led stays on even if there is further no movement detected anymore. The led will only go off when you press the Start button again. At that time the whole process will be repeated.

Now let's look at the program.

 ' this program checks movement  
 ' with a pir controller and if detected  
 ' send alert to your phone  
 wprint "<h1>Movement detector</h1>"  
 wprint "</br>"  
 wprint "</br>"  
 button "start", [click]  
 wprint "><><><><><><"  
 button "Exit", [progend]   
 wprint "</br>"  
 movement = io(pi,D3)  
 loop until movement = 1  
 print wget("maker.ifttt.com/trigger/Motion detected/with/key/PUTYOURIFTTTKEYHERE")  
 print "alert"  

Pretty straightforward.

First I define two buttons. One for starting the movement detection and another one to end the program.

Now if the START button is pressed the programs waits until it detects a HIGH signal on pin D3 meaning that the PIR was activated. The program then puts the LED on. And this single line:

print wget("maker.ifttt.com/trigger/Motion detected 2/with/key/PUTYOURIFTTKEYHERE")

is all that is needed to activate your IFTTT Maker Channel

Some HTML code was used for pimping up the page like the H1 code but that is just for looks and not for functionality. Just like the line that prints the word alert.

So I urge you to have a look at ESPbasic it is definitely worth it.

The endresult.

After thorough testing I put the breadboard setup on a striboard.

Next I made a large casing for it.

And this is how the finished project looks like.

You can find all the necesarry files being the Basic source code and STL files for the casing on my github repositry.


That's it for now.

Have fun

Luc Volders

Monday, May 1, 2017

IFTTT Part 2 maker channel

In a previous story, which you can read by clicking here, I showed you how to automate all kinds of things on your phone and computer with IFTTT. And I told you that IFTTT has a special aid for makers/tinkerers/hackers called the Maker channel.

The Maker channel is intended to trigger all kinds of events with an IOT device. My favorite IOT device is the ESP8266. So let me show you how you can trigger all kinds of events with this wonderchip. In this case we are going to send a message to Twitter when the ESP has detected motion with a PIR. To say differently, if someone enters your room in your absence you will get a notification.

First step is to login and choose channels. Then scroll down to develloppers and choose the Maker Channel.


In the Maker Channel choose connect and fill in the form. I have blacked out my personal details but you get the drift.

The important part is the Makerkey. You will need this later when setting up the softawre in the ESP-8266.

Now choose for making a new channel

The first question is to choose a trigger channel. Fill the name Maker in.

Now choose for maker.

Choose the trigger you want to activate. There is only one choice for the maker channel "Receive a web request"

Give this event a name. Choose any name you like but make it significant and something easy to recognise. If you have many triggers activated it will be easy to locate if you need to make any changes. Click on "Create Trigger"

Now move on to the next section. The IF part is ready so we have to move to the "That" section.

IFTTT asks you for the Action Channel. Type twitter and the famous logo appears.

The twitter channel has all kinds of actions that it can perform. We just want it to post a message so choose the first item "Post tweet"

In this screen you can edit the text that will be tweeted to your account. You can change that text in anything you like. As you can see in the next screen I edited it for a more meaningfull text. On the right side you see a small blue flask.

Clicking the flask will give you an option to add a timestamp. This is something you should consider as the tweet will not only tell you that there was motion detected but also at what time that was.

In this last screen IFTTT shows you the complete recipe with the text that will be tweeted. Choose create and it is ready to being used.

So the next part is building the hardware being a PIR attached to the ESP-8266 and have it send a command to IFTTT when there is motion detected. And that's the story that Is following next time.

Till then
Have fun

Luc Volders