Friday, October 20, 2017

ESP8266 Computer

I really love the ESP8266. It is a real versatile devellopment platform with loads of possibillities and potential. My favorite module is the NodeMCU version with loads of memory, all its I/O ports available a build in power regulator and ready to program over USB or even OTA (Over The Air).

For many purposes, especially in the Internet Of Things world, the I/O ports are needed to control relays, leds, temperature sensors, light sensors etc. etc. etc.

However I am doing some projects for which I just need the processing power and the Wifi. And sometimes I need it to be portable. One of the projects I am working on is a vault for my all my passwords. I do not need any I/O ports for that. Another project I am working on has to do with wardriving. No I/O ports needed for that either.

So what I wanted was a small casing in which I could secure my ESP module and that had a small opening for a USB cable to power it be it from a computer or from a power-bank.







I started by designing a casing and the lid in 123D-design.


Printing was quick and no problems occurred. I had to do a tiny bit of sanding afterwards. But the result was very satisfactory.






My NodeMCU V.09 (I still have a few of them) snuggles nicely in and the USB cable fits exactly.

And then........

As I was surfing the net a nice story came up on from favorite hack(st)er Lady Ada.


 
Just look at this beauty.



I just had to print one as the Commodore PET was one of my first computers when I was a kid (well I was 18 back then). Pink is an issue. I bougth 8 kilo pink PLA at an unbeatable price (20 euro for the lot), so most things I print have to be pink now..........




And look the ESP nicely fits in.

So now I have two choices. The small package and the retro version.

For those interested in printing one of my cases for themselves I herebye give you the link to my Gitbub page. You can import the STL files in 123D-design to edit them and make them fit for the newer NodeMCU versions.


https://github.com/Lucvolders/ESP8266-case

For those interested in the Lady Ada  version is here the link to her website:

https://learn.adafruit.com/mini-commodore-pet-with-charlieplexed-led-matrix

I am going to scale the PET version up and put an Oled-screen inside and some leds and a buzzer and neopixels and make the I/O ports accessible from the outside so I have a full-blown test ESP available. But that's for another story. So much ideas, so little time.




UPDATE
 



There it is. I found the time. Inside is a NodeMCU. The blue square is a small 0.96 inch Oled screen attached to D3 and D4. Beneath that there is a strip of 8 neopixels attached to D8.
The keyboard has been substituted by 4 switches that connect 4 i/o (D2, D5, D6 and D7) ports either to the 4 leds or to a header which allows me to attach several other sensors, switches, servo's etc etc etc. A small buzzer attached to D1 is placed into the casing.

If you want to build one for yourself just go to the above mentioned Adafruit website and scale the STL files up 1.5 times. That will be enough.


If you are interested in the story about wardriving, the password vault or my other projects keep coming back frequently.

Till next time
Have fun

Luc Volders

Friday, October 13, 2017

Phone Speak to me

This is going to be a small project which can have many uses in your Android projects. We are going to make your phone speak to you !!

Now why is this of importance. Well simply said this can give an audible feedback to any commands you are going to give to your phone in future IOT projects. And I am going to show you how easy it is to make an Android APP with the fabulous MIT App-Inventor. Mind you this is not a total instruction from scratch. I presume you know the basics of working with App-Inventor and otherwise I advise you to look at the tutorials on the web as App Inventor is really easy to work with.



Look at the picture above and most steps below will be easily understandable.

So first start a new project and call it "Say it for me".
Next add some labels that will contain just plain text. I made 3 labels.
First label is the pink one containing the name of the app in a 30 points fontsize, a magenta backgroundcolor and bold black text.
The second label (Label 2) contains the name of my weblog and has a fontsize of 20,
The third and last label (Label 3) gives the instruction  to type your text in the field below it.

Then there is a textbox, obviously called Textbox 1, in which you can type any text you like. I set the fontsize at 14. Just make sure you check the multiline option so you can actually fill in multiple lines of text. If you do not check the multiline option all text will scroll on just one line which will make things inconvenient.

Then the last visible thing on the App's page is a large green button (Button 1) with a rounded shape and a bold font size 20.

There is one last very important item but that will be working in the background and therefore has no visible part on the screen and that is the TextToSpeech function which you can find on the left part of the screen in the "media" section. Drag this to your workspace and it will be put at the bottom as a non-visible component.



If you click this component you can choose on the right side in the Properties section which language will be spoken and at what pitch and speechrate. The last two are less important as the first. By choosing a different language as the filled-in Default option your phone will pronounce the words in that language. Be aware that by changing the language the speech of for example your navigation system will alter also to the new setting. So most of you will leave this at the default settings.

To finish things off in a professional way I added a nice looking Icon to the screen You can do that by clicking on the black strip in your workspace. App Inventor shows you on the right side of the screen the settings for your App and you can fill in (amongst others) the App-name, screen orientation, title and the icon you want for your app. You can upload any picture from your computer and most formats (JPG, PNG etc) are accepted.

That's it for the layout.

Lets look at the code in blocks.



Well this is all.
When the button is clicked we call TextToSpeech and let the App pronounce the Text in TextBox1

In Real Life

Usage is very simple. You just put any text you like in the textbox by typing it in or by copying it from a webpage, note or whatever and press the green "Say it for me" button. A nice female voice will pronounce whatever you typed.

Now go and get a flush on some people's faces by having your phone speak all kinds of texts like "Yes master I will obey you in every way you want."

And for a more serious note.
App Inventor really makes it easy to make all kinds of app's for your Android Phone, and we are going to use this speech synthesizes in some upcoming apps. So stay tuned.

All that rests is a link to the App and the source file (ending on .aia) which you can alter as you like with your own App-inventor account.

Speak to me sources

Copy the files to your own computer. The file ending in .aia can be loaded in App-Inventor to alter to your own needs. The file ending in .apk can be transferred to your Android-phone. clicking on it will install it and you are ready to go.

Till next time, and make sure to have some fun

Luc Volders

Friday, October 6, 2017

Charlieplexing 4 - Larson Scanner

This is the fourth article in the series about Charlieplexing. I'll summerise it up for you.

The first story (http://lucstechblog.blogspot.nl/2017/09/charlieplexing.html) told you some general info on wiring and software for this technique
The second story (http://lucstechblog.blogspot.nl/2017/09/chalieplexing-2.html) eleborated a bit more on the software specifics
And the third story (http://lucstechblog.blogspot.nl/2017/09/charlieplexing-3-hardware.html) told you more about how to put it all on a stripboard.

And now we are going to build a practical implementation.

A bit of background.
One day in the week I walk to my work and back. It is a 5km (about 3 mile) walk and it takes me about 45 minutes to get to my work. In the evening it takes again 45 minutes to walk the 3 miles back. During the summer that is no problem. But during the winter months I start walking when it is dark and in the evenings it is dark again. Next to that my stroll takes me through some roads where there is no streetlights at all. So I decided to place some light on my rucksack. But I did not wanted ordinary lights. I wanted a Larson scanner.

Larson Scanner ???
 

Well not all of you might know what a Larson scanner is. In the seventies of the last century there was a (now) cult TV series called Battlestar Galactica. Not to be confused with the remake from 2004 which in my opinion was to politically, less humoresque and to sophisticated. In the original series the bad guys where the Cylons. Robots that had no eyes but a series of leds that lit up from left to right and then back again. This was invented by the producer Glen A. Larson. He used the same running leds in a series called Knight Rider in which there was a car, called Kit, that had the same sequencing leds in his nose cone. So in honor of its inventor the name Larson Scanner is still used for a sequencing range of leds.

Lets build one.

I decided that a Larson scanner with twelve leds was enough. So here is the schematic for that.




I first build a prototype on breadboard and here I give you a neat trick for this kind of project. I really want to advise you that you'll make a prototype on a breadboard to. It helps to track errors.





Put all the leds on the middle section of the breadboard. That keeps things neat and clear.

On each side of a breadboard there are lines for ground and power. Now in our setup we do not need ground and power because the Arduino (Attiny´s) pins are going to supply the needed power. So we can use those as leads for the pins where the leds will be attached to. Just like the four leads on the stripboard.



So here is the stripboard layout.
I left the Attiny out for clarity.

Just antother small advise. Put the Attiny85 on a socket so it is easy to remove and re-program.

The leds I used where scavenged from Christmas decorations just like I described in this article.

So let's have a look at the software.


The software starts with an array that contains all the led connections as they are connected to the Attiny85.

Next in the main loop there is a loop that counts from 1 to 12 and puts one led at a time on. When that loop has finished a second loop starts which counts backwards from 12 to 1 and puts the according led on again. This way the leds sequence forwards and backwards again. This is repeated endlessly.

The alloff() routine puts all leds at the same time off by setting all Attiny85 pins as an Input.

The ledon() routine takes a numer from 1 to 12 (coming from the main loop) and looks it up in the array. In the array it finds which Attiny85 pin should be set HIGH and which pairing pin should be set LOW. It waits a short time and returns to the main loop in which another led is choosen.

That's all. Pretty simple.

The power supply.

This all uses just a small amount of power. In my January entry I showed you a cheap USB power meter. This measured just 0.03 amps.



So this could easily be powered using some AA batteries. However I soldered an USB connector to the stripboard and power the Larson Scanner from an USB power bank.
My stroll to my work takes about 45 minutes. And offcourse 45 minutes again in the evening when I walk homewards. My powerbank can feed the Larson scanner for about 60 hours calculated by the values found with the USB power meter. So I am on the safe side.

The housing.

As I was going to mount this on my rucksack I needed a sturdy housing that was somewhat waterproof (hey it rains here sometimes, this is the Netherlands you know). So I designed a housing in Tinkercad which you can see here:






The box is deep enough to house the stripboard with arduino and all the leds.

I glued the lid on with hot melt glue, and did the same with the handles.

The end result looks like this.






And a small video that shows you how it functions:


So what rests is the STL file for your convenience and the Arduino source file. Here you go.

Larson Scanner box
Lid for Larson scanner box

Arduino source file

Till next time
have fun
Luc Volders

Friday, September 29, 2017

Charlieplexing 3 - hardware

This is the third installment about Charlieplexing.

After my first two stories which you can find by clicking here: http://lucstechblog.blogspot.nl/2017/09/charlieplexing.html and here: http://lucstechblog.blogspot.nl/2017/09/chalieplexing-2.html I got some questions about wiring this all up.

First lets look at the schematics again:




So we are looking at 5 pins from an Attiny85 or Arduino. At trhese 5 pins we will be soldering 20 leds !!! Now that sounds complicated but in real life isn't. So what's the trick.

Well I solder all to a stripboard like this:




Now look closely:




And it's obvious isn't it. The stripboard I am using and that I can strongly advise has long leads just like we need to solder all leds to. It resembles the schematics closely, which makes it easy to follow. The brand name is Velleman and their article number is 3164 however it can also easily be found at our favorite chinese suppliers.
We will solder one pin of the arduino to one end of a strip and another pin to another end of a strip.

Next we will have 5 lanes on which we can solder the leds accoriding to the schematic. Really a piece of cake.

 
As the stripboard is long enough we can easily use this for attaching 20 leds to an Attint85.
This will get more complicated if you want to make your project as compact as possible. But for the projects I am going to describe this setup is more as sufficient.

Next time I will give you a real project using this technique complete with a 3D printed housing.
So until then start soldering and make a prototype and start playing with the software to see what you can get out of this.

Till next time.
Have fun

Luc Volders

Saturday, September 23, 2017

Chalieplexing 2

This is the seond tutorial on Charlieplexing.
In the first story, which you can find by clicking here, I told you why Charlieplexing is such a wonderfull technique and how to do the wiring.

This chapter is going to delve deeper into the software.

So let us first look again at the wiring. Here is the setup for using 5 pins to adress 20 leds.



I am using an Attiny85 here because an Arduino would be overkill. You can however substitute the Attiny85 with an Arduino as the code stays the same. Only thing you will have to do is to substitute the right pinnumbers in the program.

The previous story told you how to adress a single led. Lets resume that here.

We start with putting all pins of the Arduino (or Tiny) in 3-state mode to make sure no leds are on:

int led1 = 0; // pen PWM0
int led2 = 1; // pen PWM1
int led3 = 2; // pen ADC1
int led4 = 3; // pen ADC3
int led5 = 4; // pen ADC2
pinMode(led1, INPUT)
pinMode(led2, INPUT);
pinMode(led3, INPUT);pinMode(led4, INPUT);
pinMode(led5, INPUT);


Now to put on led number 13 you adress it as follows:

pinMode (led2, OUTPUT);
digitalWrite (led2, HIGH);
pinMode (led5, OUTPUT);
digitalWrite (led5, LOW);


This way we can adress all leds individually. However it takes a lot of coding (as you saw in the previous story) and that is prone to errors. So we need to find an easier way.

Best thing to do is to put all led wiring in an array. Then we just need to access the array index to have all data present. Sounds more difficult as it is.

Lets start with defining an array with 20 entries, one for each led, and 2 elements per entry for each pin per led. So the array would look like this:

const int ledpins[20][2] ={
  // this array contains the pins per led
  // edit the pin numbers to your own wiring
  {1,0},
  {0,1},
  {2,0},
  {0,2},
  {3,0},
  {0,3},
  {4,0},
  {0,4},
  {2,1},
  {1,2},
  {3,1},
  {1,3} ,
  {4,1},
  {1,4},
  {3,2},
  {2,3},
  {4,2},
  {2,4},
  {4,3},
  {3,4}
};


So how does this work. Lets start easy. Led number 1 is attached to pins 1 and 0 just like it is punt in the array:

{1,0}. Led number two is wired the other way round and you can find that in the array to: {0,1}. Well let us now look at led number 12. In the wiring schematic you can see it is attached to Arduino pin number 1 and pin number 3. And that is exactly what you will find in the array entrance number 12 being {1,3}.
Lets take another example. Led number 17 is attached to pins 4 and 2 just like array entrance number 17 describes

{4,2}

That is easy isn't it. The array just describes how the pins are wired.

In your code always start with putting all leds off:

void alloff()
// this puts all leds off
{
  for(int i = 0; i < 5; i++)
  {
    pinMode (pins[i], INPUT);
  }
}


That is easy. Just like in the previous story. We set all pins in the INPUT mode so they are in tri-state which turns all leds off.

Next step is to make a function that turns a certain led ON.

void ledon(int lednr)
// choose a led from the array on put it ON
{

  pinMode (ledpins[lednr][0], OUTPUT);
  digitalWrite (ledpins[lednr][0], HIGH);

  pinMode (ledpins[lednr][1], OUTPUT);
  digitalWrite (ledpins[lednr][1], LOW);
  delay(slowdown2);

}


That's all that is to it.

Now if you want to put LED 13 ON for a certain amount of time (determined by the variable slowdown2)you just have to use the next code:

ledon(13);
alloff();


Now lets make a loop in which we put all leds (one by one) on

  for(k=0; k<10; k++)
    {
    ledon(k);
    delay(1000);
    alloff();
     }


The complete code would look like this:

// Charlieplexing on an Attiny 85
// Code by Luc Volders 2014

int pins[] = {0,1,2,3,4};
int i;
int j;
int k;
int slowdown2 = 2; // this delay should have a lower value when using less leds.
                              // for example 4 when using 12 leds
long int start=0;
long int eind=0;

const int ledpins[20][2] ={
  // this array contains the pins per led
  // edit the pin numbers to your own wiring
  {1,0},
  {0,1},
  {2,0},
  {0,2},
  {3,0},
  {0,3},
  {4,0},
  {0,4},
  {2,1},
  {1,2},
  {3,1},
  {1,3} ,
  {4,1},
  {1,4},
  {3,2},
  {2,3},
  {4,2},
  {2,4},
  {4,3},
  {3,4}
};

void setup()
{
  // start with putiing all leds off
  alloff();
}

void loop()
{

  for(k=0; k<10; k++)
    {
    ledon(k);
    delay(1000);
    alloff();
    }
}

void alloff()
// this shuts down all leds
{
  for(int i = 0; i < 5; i++)
  {
    pinMode (pins[i], INPUT);
  }
}

void ledon(int lednr)
// choose a led from the array on put it ON
{

  pinMode (ledpins[lednr][0], OUTPUT);
  digitalWrite (ledpins[lednr][0], HIGH);

  pinMode (ledpins[lednr][1], OUTPUT);
  digitalWrite (ledpins[lednr][1], LOW);
  delay(slowdown2);

}



And this makes programming the individual leds a lot easier and a lot less prone to errors.

I describe here the version for 20 leds but it can easily be adapted to 12 leds by just using pin numbers 0 to 3 and limiting the array to 12 items. That would give you an extra pin for attaching a button or sensor.

Nice all this theory. But what can you do with this.
The next episode shows you how to make a Larson scanner.

So till next time
have fun

Luc Volders

Friday, September 15, 2017

Charlieplexing

I really love the Attiny85 processor. This small processor has a lot of processing power (8 Mhz without any tricks) 5 I/O pins (6 if you do not need to reprogram the processor) and 8K memory. More as sufficient for a lot of projects. And best of all it only costs about a dollar.

However sometimes you run out of I/O pins. I needed to control 20 leds for a project I was making. The Tiny only has 5 I/O pins so that raised a problem. I could move over to a larger processor like the Atmega 328 which has 19 free to use I/O pins.But I wanted to stick by the Attiny85.


So here comes a technique that makes it possible to attach 20 leds to an Attiny 85, provided you can use all 5 I/O pins. The technique is called charlieplexing named after its evangelist Charlie Allen. 

First I'll give you the formula which enables you to detremine how many I/O ports you need for controlling a certain amount of leds:

X * X-1 =  number of leds that can be controlled

So with 3 I/O pins you can control  3 * 3-1 = 6 leds
Using 5 I/O pins you can control 5 * 5-1 = 20 leds.

How does charlieplexing work.

An I/O port can have the digital values 0 or 1. But there is a third state and that is called 3-state. This puts the port in a high-impedance state. So if we put an I/O port in 3-state modus it's value is not 0 and not 1.  We will use that with charlieplexing.

So lets first have a look on how we attach 2 leds to an Attiny 85



Nothing special here. Just 2 I/O ports with each a led attached.

So to connect 5 leds to an Attiny85 you can use the following circuit.



Again nothing dramatic.

But now we are going to do things differently. Lets first start simple and attach 2 leds to an Attiny85 using the Charlieplexing technique. The wiring is now completely different.



So we do not attach both leds to ground but we connect the leds to the I/O pins and one led the other way round.

Now if we put a LOW singnal (0) to pin 5 and a High signal (1) to pin 6 one of the leds will light up. If we switch the HIGH and LOW signals the other led will light up. That is still easy to comprehend.

And here comes the trick. Look at the next scheme:



There you go. 6 Leds attached to 3 pins. Remember the formula: 3 * 3-1 = 6.

However there is a problem using this. We can put a HIGH signal at pin 5 and a LOW signal to pin 7. The current will however run through Led 1 and further to Led 3. And both Leds will light up. That is not what we want. We want to be able to light them up individually. Further problem is that the Attiny85 is not capable of supplying enough current for all leds at the same time. So how are we going to solve that ??? And that is where the software comes in.

How to adress the leds.

So let's get back to the first example with two leds Charlieplexed. 


  



Ok the circuit speaks for itself but now I am going to show you how to adress the individual leds.

Normally we put PWM0 to HIGH to set the first led on and put it to LOW to put the Led off. For the second led we would set PWM1 to HIGH to set the second led ON and LOW to put it off.

With Charlieplexing we need to do that differently. We are going to use the Attiny I/O pins to supply the needed current to the leds.


First step is to define the PINS as INPUT to make sure both leds are off.

int led1 = 0; // pen PWM0
int led2 = 1; // pen PWM1
pinMode(led1, INPUT)
pinMode(led2, INPUT)



Now to put the first led on use the following code:


  pinMode (led1, OUTPUT);
  digitalWrite (led1, HIGH);
  pinMode (led2, OUTPUT);
  digitalWrite (led2, LOW);


And to put led 2 on we use the following code:

  pinMode (led2, OUTPUT);
  digitalWrite (led2, HIGH);
  pinMode (led1, OUTPUT);
  digitalWrite (led1, LOW);


Really quite simple. We just reverse the + and Ground on the pins so that first the first led will turn on and then the second one.

This shows that it is impossible to have both leds on at the same time. For that problem is a solution that I will show you later on.

Ok, nice. But what is the practical use.

Well things change if we use 3 Pins of the Attiny. This gives us a lot more possibillities. With 3 pins we can attach 6 leds. Let's look at the schematics again.




As you can see we can attach 6 leds to 3 pins and even have 2 pins left on the Attiny85 to attach buttons or sensors etc.

LED 1 and LED 2 are attached to pins 5 and 6, LED3 and LED 4 are attached to pins 6 and 7 and LED 5 and LED 6 are attached to pins 5 and 7.

Using software we can adress the individual leds.

First step is to define all pins as an INPUT

int led1 = 0; // pen PWM0
int led2 = 1; // pen PWM1
int led3 = 2; // pen ADC1
pinMode(led1, INPUT); 
pinMode(led2, INPUT);
pinMode(led3, INPUT);


To put Led 1 on we use the next code:

pinMode (led1, OUTPUT);
digitalWrite (led1, HIGH);
pinMode (led2, OUTPUT);
digitalWrite (led2, LOW);

Led 2 can be put on with the following code:

pinMode (led2, OUTPUT);
digitalWrite (led2, HIGH);
pinMode (led1, OUTPUT);
digitalWrite (led1, LOW);


For putting Led 3 on we need the next code:

pinMode (led2, OUTPUT);
digitalWrite (led2, HIGH);
pinMode (led3, OUTPUT);
digitalWrite (led3, LOW);


And putting Led 4 ON done the reverse way as putting Led 3 ON.

pinMode (led3, OUTPUT);
digitalWrite (led3, HIGH);
pinMode (led2, OUTPUT);
digitalWrite (led2, LOW);



Led 5 is adressed in the following maner:

pinMode (led1, OUTPUT);
digitalWrite (led1, HIGH);
pinMode (led3, OUTPUT);
digitalWrite (led3, LOW);



And Led 6 is put on by the reversed code of Led 5

pinMode (led1, OUTPUT);
digitalWrite (led1, HIGH);
pinMode (led3, OUTPUT);
digitalWrite (led3, LOW);


After each led has been set on you NEED to use the following code to put it off again.

pinMode(led1, INPUT); 
pinMode(led2, INPUT);
pinMode(led3, INPUT);

You really need to use this last bit off code each time after putting a led ON. If you don't do that the leds will be ON in an uncontrollable way. More as one pin will be HIGH and that put's leds on in places where you do not want them to be on.

You will surely have noticed by now several things.

Firstly the leds are attached in pairs which makes it simple by reversing polarity on the Attiny pins to put them on and off.

Next you will have noticed that the software to control the leds is getting more complex. In this stage it is manageable. However when you are using 4 pins you can control 4 x 3 = 12 leds and with 5 pins we can control 5 x 4 = 20 leds. The code to adress all these leds individually will be very complicated and that is what we are going to adress in the next part of this story.

Before we go to the next part I am going to show you the circuit in which 5 pins of the attiny85 are used.

If you use just 4 pins of the Attiny85 there is 1 pin left to attach a button or a sensor (LDR, Temperature sensor or whatever). The advantage is obvious. However you can 'only' attach 4 x (4 - 1) = 12 leds.

Using all 5 pins of the Arduino we can control 5 x (5 - 1) = 20 leds. The disadvantage is that there are no pins left to measure something or attach anything else. The only control we can use is to attach a button to the RESET pin of the Attiny85 to restart the program.

The next circuit shows you how to attach 20 leds to the 5 pins of the Attiny85.





As you will understand, the software to control the leds will be much longer if we keep on using the methods described above.

I'll give you an example.

Let's first set all pins of the Arduino in the 3-state mode to make sure nu leds are on.

int led1 = 0; // pen PWM0
int led2 = 1; // pen PWM1
int led3 = 2; // pen ADC1
int led4 = 3; // pen ADC3
int led5 = 4; // pen ADC2
pinMode(led1, INPUT)
pinMode(led2, INPUT);
pinMode(led3, INPUT);pinMode(led4, INPUT);
pinMode(led5, INPUT);


First let us put Led 1 on.

pinMode (led1, OUTPUT);
digitalWrite (led1, HIGH);
pinMode (led2, OUTPUT);
digitalWrite (led2, LOW);


Next step is to put Led 2 on

pinMode (led2, OUTPUT);
digitalWrite (led2, HIGH);
pinMode (led1, OUTPUT);
digitalWrite (led1, LOW);


And now Led 13
pinMode (led2, OUTPUT);
digitalWrite (led2, HIGH);
pinMode (led5, OUTPUT);
digitalWrite (led5, LOW);


Turning Led 14 on is again the reverse from Led 13

pinMode (led5, OUTPUT);
digitalWrite (led5, HIGH);
pinMode (led2, OUTPUT);
digitalWrite (led2, LOW);

Again the rule applies that we have to turn every led off after we have put it on so that all lines are in 3 state mode again and no 2 leds can be uncontrolled on at the same time. Forget to do that and you are in for some really unpredictable results.

So to put 1 particular led on (and off again) we need 9 program lines. For putting all 20 led's on we will need therefore 20 x 9 = 180 program lines. That surely is prone to errors and typo's so that unpredicatble things can happen. There must be a simple solution to that.

And there is !!!

The next part of this story will show you how to simplify the software and how to have multiple leds on at the same time.At this time however you have enough background to start experimenting. Try for instance to make a program that puts all odd leds on and off again.

Till next time

Have fun

Luc Volders

Monday, September 4, 2017

IFTTT 4 - send a notification to my phone

This is the last in a 4 part story. And I urge you to read the previous stories before you go on if you did not have done so yet.

First tutorial was a general introduction to IFTTT Click here to read it.
Second tutorial was how to activate the Maker Channel on IFTTT so you can trigger it with an ESP8266. Click here to read the second tutorial.
Third tutorial tells how to attach a motion-sensor (PIR) to an ESP8266 and trigger IFTTT to publish a Tweet when someone entered your room. Here you can find that tutorial.
In this last story I am going to show you how you can send a notification to your phone if someone entered your room.



So that third story showed you how you can publish a tweet when someone entered your room. That worked flawlessly however as you can see from the screenshot Twitter will clutter up in a hurry when loads of motions are detected. And that's no fun. You might not determine anymore which is which. Besides that, you will have to have Twitter installed and active on your smart-phone to get the messages. And that might not always be the case. So let's see if we can get a more significant notice.


UPDATE:
 

IFTTT has evolved and looks now more as APP's on your phone. But do not be put off basically it is just the same. There is one change that is significant: the maker channel is now called Wehooks and the icon has changed into:



So everywhere in this story where the name Maker Channel is used change it into webhooks.

We are going to make a new recipe in IFTTT for this purpose.

So first log in at IFTTT (https://ifttt.com/)  like I showed you in the previous story you can read by clicking here.




First choose to make a new recipe.




Choose the Maker channel just like we did in the previous story. The difference is that you are already connected to the channel so you already have a key.



Choose the trigger just like last time. There is only 1 trigger for the Maker channel and that is "receive a web request"



Now give the trigger a name. Let's keep it easy. Last time we choose Motion Detected so call this trigger Motion detected 2. Chose create trigger and on to the next screen.



Choose the action channel for the "THAT" function and chose "If Notifications"



Here also we only have 1 choice for the action that follows and that is "Send a notification"

Complete the action by filling in an appropriate text that is going to be send. Just like last time I included the time stamp in the notification.


In this last step you can see the complete action scheme:
If "maker event Notion detected 2" then Send a notification.
Chose for create recipe.

That's it.


Now make sure that you have installed IFTTT on your smart-phone and as soon as movement is detected in your room you will see the led on your phone blink and you will here a notification sound. On the primary screen on your phone you will see in the upper-left corner that there was an "IF" message.



Now open the notification screen on your phone and you can see what the fuzz is all around.

The difference with the previous project is that this notification will only be send to YOUR phone. There is no cluttering up in Twitter anymore.
The drawback is that if you wipe the notification away there is no prove that something happened. In the previous project you would have prove to show that someone was in your room. And that prove would stay safely on Twitter for as long as you like. So chose which option is best for you. However you can instruct IFTTT to do both !!! Send a message to your phone and post a Tweet. Experiment and I am sure you will figure out how to do that with IFTTT.

Amazing isn't it. A two dollar device like the ESP-8266 is capable of sending a notification around the globe so you will know that some-one was in your room. And I am sure you can find lots of other purposes for this technique too. A few ideas come directly to my mind:
- Send a notification when someone opens the fridge door
- Send a notification when someone is at your front door
- Send a notification with the rain-sensor (read how to make one here)

Till next time
Have fun

Luc Volders