Showing posts with label IOT. Show all posts
Showing posts with label IOT. Show all posts

Monday, April 10, 2017

ESP01 Break-in board

I created several projects with EPS8266 wifi modules.
The small cheap ESP01 module has only a few IO pins so i did not used it until now.
In one of my recent Aliexpress China orders i also added a small cheap ESP01S module to my shopping list. I also ordered some boards to easy test and use of this module: ESP01 has 2x4 pins close to each other.
 Not easy to use on a breadboard therefore i also added to my shopping list.
(Right to left. [First is the ESP01 module itself] ) 
  • ESP01 - Breadboard interface. 
  • ESP01 - TTL interface
  •  ESP01 - USB interface
My plan was to use the ESP01 - USB interface board to program an test the ESP8266 module.
Then the disappointment : to program the small ESP01 module you need to pull GPIO0 to ground. My cheap interface USB module has no jumper or switch to do that!
A reset button would also be nice.
And perhaps easy access to all the pins to experiment.
If i would use the TTL interface wired this to a USB TTL / RS232 (FTDI) interface cable i would have the same problem.
An option would be start from zero, using a breadboard interface, and make my own interface.
 (Later i found there are some ESP01 USB modules with programming switch. I did not find one with programming switch and reset button!)
ESP01 with USB Module 

But what is the use of these cheap "ready to use" interfaces. For programming, testing and debugging I decided to make my "ESP01 Break-in board". A board to put between the ESP01 and the boards with the 2*4 connector.
(I decided to call it "Break in board". It is not a "Break out board" to use and get access to chip pins but a "Break in" to put between the existing connections to add features.)
It needed (minimal) a programming switch, a reset button and access to the pins.
Later on i decided to add also some additional features. (See photo, final specs/feature list below.) This are additional features but not really needed.
I used a small double Side Prototype PCB Bread board Tinned Universal 20x80 mm FR4 28*6 holes.
ESP01 "Break in board"
 with EPS and USB
connected.
 (All holes are plated through). I added pins to fit in a 2*4 pin connector (on bottom) and additional 2 times 4 pins to get easy access to all pins and a female 2*4 connector for the ESP01 module (on the top). On my (current) laptop free USB connectors are at the left side. I wired my "Break-in board" with this in mind. (USB connector pointing to the right when using this board).
Mark on the PCB with an arrow the direction of the ESP01 module.
A push button is used for the reset, (Bottom of the PCB) wired to ground and reset.
While uploading a program i do not want to continuously press a button. I decided to use a small slide switch (Top).
In stock i had a three position switch. If you have a small two position slide switch you use that. The three position switch i used has 6 pins: (and two shield pins)
Left no pins are connected
Middle pin 1 and 4 are connected ' / pin 3 and 5 connected "
Right pin 1 and 4 are connected '
Pin 2 and 6 have no use (n.c.), i did bend them away and soldered the switch on the PCB. I decided to use the middle position as programming position and wired pin 2 and 5 ' to ground and GPIO0.
3 position switch
At this point my basic minimal "ESP01 Break-in board" was ready.
ESP01 "Break in" board. (top view)
 On my board i also added some other things i had in stock:

  • 6 female pins connected to to ground (and next to it a) 
  • 25 Points Mini Solderless Prototype Tie-point Breadboard 
  • A micro switch (three pins Common, Normal open, Normal closed ) with connections to pins to easy wire them for experiments. (on bottom next to reset pushbutton).
  • Passive electromagnetic impedance 16 ohm AC buzzer/2KHz 3V 5V universal buzzer (- connected to ground, other side to a pin and 100 ohm resistor with a second pin. -
On my slide switch at pin 1 and pin 4 ' contacts available are (Left open, Middle and Right closed), i wired them to two pins on the PCB.
The condensator on the ESP01 - USB interface board comes very close to PCB. Some insulation tape was added. As a final touch i used cable ties to join some cable bundles.

ESP01 "Break in" board (bottom view)
RESULT: "ESP01 Break-in board":
Switch for programming the ESP01,
Reset button,
Easy access to all pins of the ESP01.
Some additional switches.
A mini buzzer (One side connected to ground. Connect the other side e.g. with a Dupont cable to GPIO2)
Mini solderless prototype board for additional components/experiments.
ESP01 "Break in" with ESP01 and USB (bottom view)

Wednesday, July 27, 2016

Hacking USB power socket

Hacking a USB power socket.
For less than 7 euro's i bought this power socket with 220V and USB (inbouw stopcontact met USB aansluiting) at the Action in Almere (The Netherlands).


On Aliexpress you can find similar wall power sockets with USB

 If opening this socket at the front (to pace it on the wall) you will see this:
It is always nice to have USB power ( e.g. for home automation projects) and i also wanted to know if it is easy to modify the circuit to control the 220V socket with a relay.
I decided to open it on the backside, here are some photos's

As i already expected these is not much space to interrupt the 220 Volt power circuit safe. This to add a relay for controlling the main power. Finally i decided only to add two wires, and make a hole to tap the (low voltage) USB power and bringing it to back of the wall socket for powering a (hidden) IOT device.

Friday, July 22, 2016

Presenter / Laser pointer IOT DIY (4)

This is a picture of the laser pointer / presenter.

I only added one button at the outside of the box. With more buttons the presenter perhaps could be more easy controlled. With only one button you can send different triggers to a program by pressing the button for a long or a short time.
The box is transparent. With this transparent box you can still use the RGB led and the LDR on ESP8266 module.

ESP8266Basic demo program for testing and using the laser pointer:

'   *** UseLaser.bas ***  
'   demo laser pointer
'  2016 -  JanJeronimus

cls
' Pin Button1 16 GPIO16
let PinButton1 = 16

' PinLaser    5 GPIO4
let PinLaser = 5

' Pin Reed / Button4 0 GPIO0
let PinReed = 0

' Pin Shake / Button5 2 GPIO2
let PinShake = 2

u = 0 
' u = use status 

html | <h1>Select item to control the laser</h1> |

html | <br> |
button "Button1", [Button1]
html | <br> |
button "On / Off with Button1", [ButtonT]
html | <br> |
button "Reed", [Reed]
html | <br> |
button "Shake", [Shake]
html | <br><br> |
button "On", [On]
html | <br> |
button "Off", [Off]
html | <br><br> |
button " Exit ", [Exit] 

timer 1000 ,[SetLaser]

wait 

[Button1]
u = PinButton1
wait

[ButtonT]
u = 980
wait

[Reed]
u = PinReed
wait

[Shake]
u = PinShake
wait

[Off]
u = 990
wait

[On]
u = 991
wait

[SetLaser]

' **  GPIO controlling the laser
'  * <30  u is GPIO number

if u < 30 then
io(po,PinLaser, io(pi,u) )
endif

'  ** Status Toggle with Button1
'  * u = 980  On if Button1
'  * u = 981   wait for release button
'  * u = 982  Off if Button1
'  * u = 983   wait for release button
if u = 980 then
 if io(pi,PinButton1) = 0 then
   io(po,PinLaser, io(pi,1) )
   u = 981        ' set status wait for release 
 endif
endif

' if wait for release
if u = 981 then
 if io(pi,PinButton1) = 1 then
   u = 982 
 endif
endif

if u = 982 then
 if io(pi,PinButton1) = 0 then
   io(po,PinLaser, io(pi,0) )
   u = 983        ' set status wait for release3 
 endif
endif

' if wait for release3
if u = 983 then
 if io(pi,PinButton1) = 1 then
   u = 980 
 endif
endif

'  ** Status Toggle
'  * u = 990 - 991 On / Off
if u = 990 then
io(po,PinLaser, io(pi,0) )
endif

if u = 991 then
io(po,PinLaser, io(pi,1) )
endif
wait

end

Besides the laser pointer some things you can do with this hardware:

- Presentation inside the presenter as webpages
- Wifi scan
- A simple alarm that starts if the switch vibration / tilt switch / shaking ball switch to detects if the module is moved with the next program:
- The Alarm can be switched off by pressing the Button1
- Alarm can be switched off with a magnet (using reed contact)
- The Light Detecting Resistor is currently inside the box. I have plans to move the LDR to the outside (on front of the box) for better sensibility.



Plans for modifications and adding other hardware
- Infra red led
- Infra red sensor / detector
- Move LDR outside the box
- Move RGB led outside the box (?)
- A second reed contact ???
- Connector for a headphone or other external devices
- .....

Thursday, July 21, 2016

Presenter / Laser pointer IOT DIY (3)

In this third article about my DIY IOT laser pointer / presenter programming examples/programming ideas to use this presenter / laser pointer.
You can also use the programs from earlier posts that i used to test the hardware with ESP8266Basic

Laser
Buzzer
DHT11
Input signals

1) Button1Laser.bas

A simple program to switch the laser on with Button1.
You need to keep the button pressed to leave the button on:

' Button1Laser.bas
cls
' Pin Laser    5 GPIO4
let PinLaser = 5

' Pin Button1 16 GPIO16
let PinButton1 = 16

html | <h1>Test Laser</h1> |
html | <br> |
html | <br>Use Button1 to control the laser<br> |
button " Exit ", [Exit]
html | <br> |
timer 1000 ,[Button1Chk]
html | <br> |

wait

[Button1Chk]
io(po,PinLaser, io(pi,PinButton1) )

wait

end

2) UseLaser.bas

This program gives a simple webpage to control the laser.
With the buttons [On] and [Off] you can switch the laser On or Off with the web interface.
The three buttons [Button1], [Reed] or [Shake] are to select other input to control the laser.

' UseLaser.bas
cls
' Pin Button1 16 GPIO16
let PinButton1 = 16

' PinLaser    5 GPIO4
let PinLaser = 5

' Pin Reed / Button4 0 GPIO0
let PinReed = 0

' Pin Shake / Button5 2 GPIO2
let PinShake = 2

u = 0

html | <h1>Select item to control the laser</h1> |

html | <br> |
button "Button1", [Button1]
html | <br> |
button "Reed", [Reed]
html | <br> |
button "Shake", [Shake]
html | <br><br> |
button "On", [On]
html | <br> |
button "Off", [Off]
html | <br><br> |
button " Exit ", [Exit]

timer 1000 ,[SetLaser]

wait

[Button1]
u = PinButton1
wait

[Reed]
u = PinReed
wait

[Shake]
u = PinShake
wait

[Off]
u = 990
wait

[On]
u = 991
wait

[SetLaser]

if u < 30 then
io(po,PinLaser, io(pi,u) )
endif

if u = 990 then
io(po,PinLaser, io(pi,0) )
endif

if u = 991 then
io(po,PinLaser, io(pi,1) )
endif
wait

end









Wednesday, July 20, 2016

Presenter / Laser pointer IOT DIY (2)

This blog article describes how i hardware configured my laser pointer / presenter.

PCB board connections (top down component side) are
-  DHT11
-  Buzzer
Button1  (down)      
Button1  (up)  [not connected]
Button2         [not connected yet]
Button3         [not connected yet]
Reed    ( Button4 )
Shake   (Button5)

' The "other side" of the Button1-5 connected to GND with DIP Switches (A) (1).
'  DIP switches all can be connected to GND (1) or (and!!!) VCC (2)

' To save power consumption DHT11 power can be switched off with DIP switches (B)
'  switch (1) VCC and (2) GND

There is one black (GND) female dupont cable that needs to be connected to GND of the ESP module
There are two red VCC female dupont cables one needs to be connected to VCC on the ESP8266 board.

The laser module needs to be connected to the other red VCC female dupont cable.

The other side of the  laser module is directly connected to the ESP8266 module. I used KY-nnn laser modules (  37in1 arduino module kit ) . As some of these modules are wired reverse you need to check yourself if you need to connect S to VCC or to a GPIO  line of the ESP8266.
The ESP8266 module has the following connections.

'  (left)
' -

' Pin ADC is (currently) connected to Light Detecting Resistor

' -

' Pin Button1 16 GPIO16
let PinButton1 = 16

' Pin... 14 GPIO14

' Pin... 12 GPIO12 / RGB

' Pin... 13 GPIO13 / RGB

' VCC (Red)

' (right)
' PinLaser    5 GPIO4
let PinLaser = 5

' PinDHT11    4  GPIO5
PinDHT11 = 4

' Pin Reed / Button4 0 GPIO0
let PinReed = 0

' Pin Shake / Button5 2 GPIO2
let PinShake = 2

' PinBuzzer  15  GPIO15   /  RGB Red
let PinBuzzer = 15

' GND (Black)

I the programming examples i will try to use the same name for the devices and pins. ( PinButton1 , PinDHT11 ... )


Tuesday, July 19, 2016

Presenter / Laser pointer IOT DIY (1)

This week i will dedicate some blog posts to a presenter / laser pointer that i made.
With a laser led module and a battery you can easy make a simple own laser pointer.
 To make it a real IOT laser pointer / presenter i added a ESP8266 module, a button and as a bonus some other spare parts.
The hardware is partly configurable with dupont wires and DIL switches (More hardware details see part 2.)
ESP8266Basic is used to program the module and configure it over Wifi (See part 3 and 4)
The plastic box was a small box containing some nuts and bolts
 bought in an hardware store that i wanted to give a second life.
With superglue i glued the battery pack ( 3x AA ) included with
 my ESP8266 module on the back of the box.
 I made a hole for the laser led, a push button and
 a opening to for the wires of the battery.

I added a little PCB for some other components. For the power i added two dupont wires with female connectors to connect to the ESP8266 unit.

One additional dupont wire with female connectors is added for the Laser led. The other side of the Laser led is connected directly to the ESP8266 module.

For this version i wanted only one pushbutton on the outside of the box. ( Button1 ). As the button that i had in stock had 3 connections ( push and notPushed  and common). I connected pushed and notPushed to a jumper, so perhaps i can use his later on.
On the inside there are 4 more push buttons from top to down
Button2
Button3
Button4  ( Reed )
Button5 ( Shake )
from this button i also connected one side to the jumper.
The other (common) side of the buttons i all connected to a DIL switch with two switches.
Using this switch i can connect this common side of all switched to VCC ( 3.3.V) or all to ground.
(You must keep one of these switches in the Off position, otherwise you will short the power!!)
For a simple version you can also skip this dip switch and connect the common to ground. (If using a similar ESP8266 module).

Parallel to Button5 i added a switch vibration / tilt switch / shaking ball switch to detect if the module is moved.

Parallel to Button4 i added a reed contact switch. With this switch you can detect a magnet. A reed switch is not needed for a presenter / laser pointer but i had one in stock it is a cheap add-on feature.

I added a passive buzzer connected to GND and a jumper.

In stock i also have some DHT11 temperature humidity sensors. They are not expensive so i decided to add one also with a DIL switch to disconnect the DHT11 from the power lines for a "hardware low power mode". (In that case you can not read temperature and humidity!) The signal line of the DHT11 sensor is also connected to a jumper.

The power On / Off switch is deliberate missing. To turn the power off remove the batteries. This prevents accidentally turning of the device and keeping the batteries in a not used device for long time.

.

Wednesday, May 13, 2015

Review van mijn eerste ESP8266

In een vorige post melde ik de ontvangst van mijn pakje uit China. Ook beloofde ik een korte review van mijn ESP8266 module.
Een groot voordeel is wat je krijgt voor 4 euro: een 3x AA batterij houder, een ESP-12 gesoldeerd op een printje met spanningsregelaar, RGB led een aantal rode leds en een lichtsensor. Ook zijn alle pinnen van de ESP8266 toegankelijk.
Het bordje kan "out of the box" direct bestuurd worden via een Android app beschikbaar via de AI-Thinker website.
https://translate.google.com/translate?sl=zh-CN&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Fai-thinker.com%2Fforum.php%3Fmod%3Dforumdisplay%26fid%3D40&edit-text=
Hoewel het achteraf erg simpel bleek duurde even voor ik het printje met de Android App werkend had.
Er is veel info over de ESP8266 beschikbaar over op internet. Helaas voor een groot deel in het Chinees. Ook staat de info vaak erg versnipperd.
Daarom dit recept met 5 stappen om het geheel eenvoudig werkend te krijgen:
1) Plaats het APK bestand in de Google drive van je Android telefoon.
2) Open met je Android telefoon de Google drive en kik op het APK bestand om de app te installeren.
Helaas zit de APP niet in de Google App Store maar tot mijn verrassing blijkt installeren van APK bestanden vanuit je google drive heel eenvoudig!
3) Open het draadbrugje (Draadbrug is om te flashen niet voor standaard gebruik) en plaats 3 AA batterijen.
Ja batterijen zijn in verhouding tot de electronica een grote kostenpost.)
4) Verbind je telefoon met het Wifi netwerk van je printje door het netwerk AI-THINKER_xxxxxx te kiezen met wachtwoord ai-thinker.
Ieder printje heeft een eigen netwerk beginnend met AI-THINKER_ gevolgd door een (unieke) code. Het wachtwoord is in kleine letters.
5) Start de App (helaas met Chineese interface maar de knoppen voor de Leds en RGB led zijn relatief eenvoudig te vinden).
Het is even puzzelen welke ledjes aan welke poorten zitten maar gelukkig vond ik dit plaatje op internet.
Ook verwarrend is dat de RGB led op de schuiven als op de knoppen (GPIO15=rood, GPIO13=blauw, GPIO12=groen) in de (helaas chinees-talige) app reageerd.
Achter op de printjes geschreven heb ik met een stift de AI-THINKER_xxxxxx code geschreven om ze uit elkaar te houden.
Hoe je een ander systeem in de ESP8266 kan flashen met andere firmware staat ook op diverse plaatsen (gelukkig ook in het Engels) beschreven. Voor bovenstaande test is dit nog niet nodig.
Maar om iets meer met deze module te doen wel. Helaas bevat deze module geen USB aansluiting. Voor flashen is wat extra (gelukkig goedkope) hardware nodig om de module met je computer te verbinden.

Tuesday, April 21, 2015

Een pakje uit China.


Binnen een paar weken werd mijn bestelling uit China netjes thuisbezorgd! Eigenlijk al veel sneller dan ik verwacht had. Dit zonder verzendkosten of bijkomende inklarings/douane kosten of BTW.
Vijf test printjes met een ESP8266 (inclusief 3xAA batterij houder,) Samen voor een bedrag onder de 20 euro! Daardoor nog geen 4 Euro per ESP8266 experimenteer setje.
Zie ook foto hiernaast.  De baterijhouder (3x AA) en de twee 2 euro munten en geven een idee van de afmetingen.
Maar wat is een ESP8266, wat kan je ermee en waarom heb ik dit gekocht?
Een ESP8266 is betaalbare Wifi-module die draadloos netwerk
kan toevoegen aan elk microcontroller-project. De ESP8266 is bovendien zelf ook een microcontroller en kan daardoor zelf als ook stand-alone module gebruikt worden. Dus een goedkope bouwsteen voor IoT, domotica en andere projecten.
Er zijn verschillende (experimenteer) printjes met de ESP8266 leverbaar.
Een goed nederlandstalig verhaal met nuttige links over de ESP8266 staat op Tweakers. Op Nurdspace.nl en Hackaday.com is ook veel nuttige (engelstalige) info te vinden.
Een review van het ESP8266 experimenteer printje en hoe ik het werkend heb gekregen zal ik binnenkort posten.