Friday, November 17, 2017

Oh no, not another wifi thermometer.

I know. It is stupid. And at first I was not even sure why I was building it. As the internet is paved with ESP-Weatherstations and thermometers. And why on earth is the weather so interesting. Just look outside and you know what it is like. And then a reason came up. For testing all kind off IOT cloud services I needed a device that would constantly provided some data and what is easier as a thermometer to provide data.  However I had some demands.

It should be really low cost. and it is !!! I used an ESP-01 (1.57 euro) a Dallas 18b20 temperature sensor (0.98 euro) a LM317 voltage regulator (0.08 euro) , some resistors (about 0.05 euro) and a USB cable (about 1 euro). That sums up to 3,68 euro. Add some stripboard and wire and there is your complete thermometer for about 4 euro.
Naturally I printed the casing myself.

This project should not take more as a few hours to build. I made a prototype on a breadboard and when that worked I transferred it to some stripboard. Programming was done in the unmatched easy ESP-Basic language.

Before we start.
Before we really start with this project I want to point out some basic knowledge articles I wrote that helps you understand how all fits together.
First read about the LM317T voltage regulator which allows you to provide your project with any voltage you might need. Read that story by clicking here.

And please read the introduction article to ESP-Basic which makes developping ESP8266 projects a piece of cake. The introduction article runs you through flashing ESP-Basic and using the web-based editor to writing your first programs.

Let's go.

Powering the project.

The ESP-01 works at a 3.3Volt power level. And the Dallas Temperature sensor fortunately also does so. I am going to power this project from a USB power source (be it a computer, mains adapter or powerbank). So the USB power, which is 5 volt has to be reduced to 3.3 volts.

As stated above I am doing this by the use of a LM317T voltage regulator. 5 Volt is supplied and reduced to 3.3 Volts.

As you can see from the schematics above we will need a resistor of 1.2K and a resistor of 2K to achieve this. Like  I said above: for more information about this read the article about the LM317T.

The breadboard shows you the setup.

The ESP side

For flashing ESP-Basic and programming I used my ESP-01 programming board which I described in detail in the story you will find by clicking here.

As you know the Dallas 18B20 needs a pull-up resistor of 4K7 to function. So I attached my programming board to a small breadboard on which I placed the resistor and connected the Dallas temperature sensor.

At first to make life easy I soldered some paperclip wire to the Dallas 18b20 wires so I could easily fit them on the breadboard. The paperclip trick is one I use often. For those of you not familiar with it click here to read the story. Later on I replaced them with dupont wires cut in half and soldered to the Dallas 18B20 wires.

 So when this all functioned I completed the setup on the breadboard.

And when all functioned as it should I put it on two left-over pieces off stripboard.

The program.

 Timer 5000, [start]  
 wprint "<!DOCTYPE html>"   
 wprint "<html> <body>"  
 wprint |<body style="background-color:greenyellow;">|  
 wprint |<H1><span style="color: red;">|  
 wprint " A thermometer"  
 wprint "</H1>"  
 wprint "</span>"  
 wprint |<H2><span style="color: blue;">|  
 wprint "Temperature is now "  
 textbox test  
 a = "background-color:greenyellow;"  
 a = a & "display:block;width:80px;"  
 a = a & "border-style: hidden;"  
 a = a & "font-size: 22px;"  
 a = a & "font-weight: bold;"  
 a = a & "color: fuchsia ;"  
 cssid htmlid(), a  
 wprint "</span>"  
 wprint "</H2>"  
 test = temp(0)  
 test = ((int(test*10))/10)  

The program may look complicated but regard it closely and you will see that in reality it is not. There are some neat tricks in it though.

Let's simplify it first.

There are just 3 lines that actually are the real program core:

test = temp(0)
test = ((int(test*10))/10)

The first line reads the Dallas 18B20 temperature sensor. And the second line rounds it to 1 decimal.

textbox test

This line actually puts the temperature on the screen. Those are the three core lines. All that follows is just pimping it up.

Timer 5000, [start]

To make the program check the temperature each 5 minutes we use the Timer command as you can see in the line above.

wprint |<body style="background-color:greenyellow;">

This sets the background of the web-page in the color "greenyellow"

a = "background-color:greenyellow;"
a = a & "display:block;width:80px;"
a = a & "border-style: hidden;"
a = a & "font-size: 22px;"
a = a & "font-weight: bold;"
a = a & "color: fuchsia ;"
cssid htmlid(), a

That is an important block of CSS code.
What it actually does is to hide the contour of the textblock, give the textblock the same background as the webpage has and gives the text in the textblock a contrasting colour.
All this together hides the textblock from the screen and makes it look as if the text is printed direct on the webpage. And that is a really nice trick.

And here is the end-result.


The casing is identical to the casing I made for the PIR alarm (click here to look at that project).

 The difference is that the lid has no opening for the PIR. It is just massive

As you can see the case is far to large for such a small stripboard and therefore has one advantage: you can also power this project  with AA batteries.

That's it.

All that rests is to give you the links to the STL files so you can replicate or adapt this to your own needs.

Till next time, have fun

Luc Volders

Friday, November 10, 2017

9 volt power plug salvage

I bought this fantastic piece of equipment. it is a kind of multi-tester. Not like any ordinary multimeter, no a multitester.

Not only does it tests resistors but also capacitors, transistors (PNP and NPN) fet's, diodes etc. It can be found on all the well-known chinese web-shops for just a few dollar. But that is a different story all together. It has only one flaw: it works on 9 volt batteries. The availability of the 9 volt batteries is not such a problem as well as the cost and lifespan.

After some examining of the multiteter I realised it was powered by a 7805 5 volt regulator. Powering it with a slightly divergent power supply would therefore not lead to problems. And I had such a power supply at hand. It is a 9 volt power supply.

However my multimeter showed it supplies 11 volts when unencumbered. No sweat: the 7805 should be able to handle that.

I could cut the 9 volt plug and solder the wires direct to the multitester. But I wanted a more flexible solution that would permit me to use the power supply also for different purposes. Therefore I needed a 9 volt contra plug. And that was easily found.

There is a 9 volt plug on top of the battery. Now I have seen instructions on how to decap the battery and salvage the plug. I have never done such a thing myself and looking at pictures on the internet is not the same as doing it yourself.

I examined the battery slosely and saw that there was a juncture. So I started tweaking at the juncture and to my surprise it was the start of a label that was glued to the casing. So the label came off easily and beneath it was a plasic casing. You might not be so lucky as I know that many cases are made of metal so cutting them up might be more tedious.

Next step was to carefully saw the bottom off. And when I made a big enough cut I ripped it with some pliers.

Inside was a pack of 3 batteries soldered together with some long flat leeds.

I removed the batteries and the remains of the casing until just the plug was lying in front of me.

Then I cut the long flat leads off.

Next step was examining the battery and looking which pole was corresponding with VCC and which corresponded with GND. The small round pole is the VCC side and the large split pole is GND.

The only remaining step was then to solder the wires of the power supply to the poles and all was done.

A final test with my multimeter showed that everything was fine and indeed when I plugged it to my multitester it worked as expected.

This is an excellent way to save on batteries.
Just make sure that anything you plug this power supply into has to be capable of handling the supplied voltage which is in my case about 11 volts.

Till next time.
Have fun.

Luc Volders

Friday, November 3, 2017

Watch your cables

I was doing a project with a Raspberry Pi 3 when I encountered a strange problem.

I installed the Raspberry OS and wrote my software. next I tested it thoroughly until I was convinced everything worked as I planned. Next step was to move the Raspberry to its working location.

The location I planned for the raspberry had no wall power outlet. So I used a 5 meter long (16 foot) USB cable as a power source. Should be no problem as this cable powered a NodeMCU before.

But then the trouble started.

The Raspberry started as planned and then suddenly resetted. So I detached the power cable and re-attached it to reboot the Raspberry. That worked, however after a few seconds it resetted again.

I was sure I had a decent USB power supply attached: 5 Volts, 2.1 Amps. More as sufficient. And then I got an idea. I relocated the Raspberry and attached the original USB cable (1.8 meter) again. And everything worked as normal. So I replaced the 1.8 meter USB cable with the 5 meter cable and the problems started again: fault located !!!
The cable obviously had to much resistance which reduced the power.

I had used this cable with a NodeMCU before but obviously that draws less power as A Raspberry Pi 3 does.

So if you have power problems with your Raspberry Pi do not automatically suspect the power supply, but check the cables also.

Till next time,
Luc Volders

Friday, October 27, 2017

Powering your project

In the beginning of this year I was asked to give a demonstration about using electronics in gardening. For this I made a small setup in which I used an ESP8266 (a Wemos D1 mini version) to test soil humidity. As soon as humidity dropped below a certain value a water pump would irrigate the soil.

As a soil humidity tester I just used two wires attached to the analog input of the ESP8266. And I purchased a nice small pump that is nevertheless capable of pumping 80 liter water within an hour. The ESP's datapin is not powerfull enough to run the motor of the pump so I used a TIP120 as a signal amplifier. In theory everything worked as planned. However in reality not exactly.

I was powering all this from the ESP itself. I used a Wemos D1 mini version. The Wemos D1 can be powered by a USB cable and has both 3.3volts and 5 volts output as you can see on the picture. The 5 volts is on the right side and the 3.3 volts on the left side.

Well actually everything did work however the pump was not pumping constantly but it was stuttering. It took me a while to realise that when the pump started working it influenced the reading from the analog port. And that was due to the fact that the voltage regulators on the Wemos D1 mini where not able to supply enough current.

So what to do.
Well the solution is obvious. I needed to power the pump circuit (pump with TIP120) with a separate power supply.

Now I could make a cut in the USB cable and drain some power seperately to my circuit. However there is an easier solution.

At the local dollar store (called Action in the Netherlands) they sell a wall plug with a double USB outlet.

And on my Chinese suppliers site I had bought a few weeks before a micro USB connector for PCB mounting that easily fits on a breadboard.

As you can see this makes life much easier. The only thing is that you need to use 2 usb cables.

An even easier solution was something I found later on the Chinese suppliers website: a USB splitter cable. That is even easier as you will not need to purchase a special wallplug with a double USB connection. I haven't bought one of these yet but I am surely going to.

Just make sure that your wall plug delivers enough Amps to power your circuit. Mines supply 2.1 amps which is more as sufficient for ESP projects.

Till next time.
Have fun.

Luc Volders

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.

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

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.


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 ( told you some general info on wiring and software for this technique
The second story ( eleborated a bit more on the software specifics
And the third story ( 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