ESP-01 and 07 progress

After a few weeks of playing with them I finally have something worth writing about!

For the 07 nothing much more than I finally made a breakout board, as you can see here:

image

Its raised on a random SMD electro cap, and connected to the perfbpard with zero ohm resistors.
(The cap has only one purpose, raise the module)

As for the 01,
I rewired the serial lines up to pins 10 & 11, for software serial, then using the EasyIoT library have it connected to the Easy IoT server running on a raspberry pi elsewhere in the house!

At the moment it’s got a relay, but when I get some more sensors and modules I’ll make a while bunch of things. Need some of those temperature and humidity combo sensors, and some of that 2.4ghz rf transceivers for low power nodes. Also need some 3.3v pro minis ๐Ÿ˜€

Here’s the 01:

image

External 5v goes in, relay feeds It’s VCC off this, then it goes through an 13337 based regulator down to 3.3v for the esp, (have to wire in a selection switch for powering the arduino also from this 5v source. Then a proper power connector.

Will update soon with any changes ๐Ÿ™‚

ESP8266 Arrives!

Good news everyone!
My first two ESP8266 modules have arrived!

First thing I did was hook one up to my USB serial adapter and poke around inside.
They are REALLY annoying so far hahaa

I found a good way to mount it on the breadboard is using one or two rows of stackable headers to raise/bend so it fits.
This leaves plenty of room underneath for the wires too!
wpid-wp-1417556621430.jpeg
I got one connected to my WiFi, but I can’t figure out how to do anything else haha…

10818585_354546261385472_1682648906_n 10841528_354546254718806_1924527517_n 10834160_354546271385471_227573354_n 10818842_354546231385475_435118054_n

I made up a sketchy little arduino protoshield, but I think I did the voltage dividers wrong as when I monitor the tx lines I can see the arduino trying to talk, but the esp module isn’t saying anything….
I think maybe I lowered the voltage too much. A friend has some things I could try, or I’m contemplating modding an arduino to 3.3v for this shield.

10814108_354546164718815_1377251317_n 10822264_354546224718809_1872469390_n 10846800_354546184718813_771261920_n

I’ll post up some photos soon, I need to get a digital temp sensor today if I can, trying to make a test little data logger with thing speak. If I can get this working I’ll make one to monitor the letter box and make graphs of what time the mail arrives! ๐Ÿ˜€

Will update as I do things!
And I may put a whole bunch of reference material here too.

 

I GOT IT WORKING!!!
I did the 3.3v conversion on one of my arduino Unos, and now its uploading data!! ๐Ÿ˜€

10822715_354546398052125_1390798376_n 10818677_354546354718796_937293101_n 961471_354546924718739_10215617_n10836393_354546331385465_1665828002_n

see:

 

The code im using is:

 

 

 

See below for formatting.diy_bloke

#define SSID “xxxxxxxx”
#define PASS “xxxxxxxx”
#define IP “184.106.153.149” // thingspeak.com
String GET = “GET /update?key=xxxxxxxx&field1=”;
void setup()
{
digitalWrite(0,LOW);
Serial.begin(9600);
Serial.println(“AT”);
delay(5000);
if(Serial.find(“OK”)){
// connectWiFi();
}
}
void loop(){

int t=analogRead(0);
String tempC=String(t);
updateTemp(tempC);
//char buffer[10];
//String tempF = dtostrf(tempC, 4, 1, buffer);
//updateTemp(tempF);
delay(4000);
}

void updateTemp(String tenmpC){
String cmd = “AT+CIPSTART=\”TCP\”,\””;
cmd += IP;
cmd += “\”,80″;
Serial.println(cmd);
delay(2000);
if(Serial.find(“Error”)){
return;
}
cmd = GET;
cmd += tenmpC;
cmd += “\r\n”;
Serial.print(“AT+CIPSEND=”);
Serial.println(cmd.length());
if(Serial.find(“>”)){
Serial.print(cmd);
}else{
Serial.println(“AT+CIPCLOSE”);
}
}

//
//boolean connectWiFi(){
// Serial.println(“AT+CWMODE=3″);
// delay(2000);
// String cmd=”AT+CWJAP=\””;
// cmd+=SSID;
// cmd+=”\”,\””;
// cmd+=PASS;
// cmd+=”\””;
// Serial.println(cmd);
// delay(5000);
// if(Serial.find(“OK”)){
// return true;
// }else{
// return false;
// }
//}

 

 

reference area:

 

 

https://nurdspace.nl/ESP8266

https://github.com/guibom/ESPTempLogger/blob/master/ESPTempLogger.ino

http://www.instructables.com/id/ESP8266-Wifi-Temperature-Logger/?comments=all#CZEPCA4I36LFMYG

http://www.esp8266.com/viewtopic.php?f=8&t=390

http://zeflo.com/2014/esp8266-weather-display/

http://www.ebay.com.au/itm/USB-Micro-B-Micro-Breakout-Board-For-Arduino-AVR-PIC-Prototyping-/231367421713?pt=AU_Gadgets&hash=item35de92af11

https://learn.sparkfun.com/tutorials/voltage-dividers

http://www.ebay.com.au/itm/Arduino-Pro-Mini-ATmega328-3-3V-8M-Compatible-Board-FAST-Shipping-SYDNEY-/281368337443?pt=LH_DefaultDomain_15&hash=item4182dc1c23

https://anibit.com/sites/default/files/product_files/ESP8266_Specifications_English.pdf

http://www.seeedstudio.com/document/pdf/ESP8266%20Specifications(Chinese).pdf

https://github.com/aabella/ESP8266-Arduino-library/wiki/ESP8266-AT-Commands-Set

 

http://www.esp8266.com/viewtopic.php?f=6&t=553&p=2908&hilit=channel#p2908

RGB fading coaster

For a while now I’ve wanted a coaster to take to parties that makes my vodka (alcohol of kings) glow fancy pretty colors!

Yesterday I finally got around to it while on Skype with someone.

Didn’t take any photos but its pretty darn self explanatory,
The Pro Mini drives the single 5050 RGB LED ( common annode )
That’s connected to +5v through a resistor (I forget the value haha)
And PWM pins 3, 5 and 6.

I searched instructables and found a random sketch (LINK) that fades through colours, uploaded it, then wired up a switch, and a lithium charging circuit, to a err… What I THINK is a LiPo battery. Searching its name brings up references to other LiPo batteries…
Charger *seems* to work on it and voltages look normal sooooo….

I’m not sure if the Pro Mini can run off 3.3v (I have some spare 3.3v regulators)
So the battery is currently connected to GND and RAW.
Seems to work okay ๐Ÿ˜€

I’ll seal around the switch later with hot glue in case of spills, and the rest of the circuit is raised on some foam.

Its all shoved inside the enclosure that some apple ear buds came in, I removed the plastic inside with great difficulty, and it all fits in quite well.

Powershell For loops

For loops have three parts:

For ($1; $2; $3){

}

$1 is the initial value
$2 is the condition
$3 is what to loop

first, $1 is checked against the condition ($2) then, $3 is run and checked against the condition, if it still matches the condition, the loop continues.
if it no longer matches the condition, the loop exits.

refer to le dodgy diagram

dodgediagram

 

Broken Example Code:

 

#I couldnt figure out the factorials and it kept getting me confused and stuck so ill use addition instead. >dealwithit.gif

clear-host
$nums [email protected]()
$array [email protected]()

[int]$times = read-host “how many sums will you do”

For ($i=0; $i -lt $times; $i++)
{

$num1 = read-host “enter a number”
$num2 = read-host “enter a second number”

$num3 = [int]$num1 + [int]$num2

$array = @($num1,$num2,$num3)
write-host $num1″+”$num2″=”$num3
}
For ($i=0; $i -lt $times; $i++){
write-host “Nums”`t”Sum”
write-host $array[-$array.count]$array[-2] `t $array[-1] write-host $array[$i]`t$
}

Arrays in powershell

Reference sheet for my powershell class

Arrays seem to be like small temporary databases ? ๐Ÿ˜€

 

Creating an Array:

C:\PS>$numbers = @(4,7,9,11,20)ย ย ย ย  //creates array and populates entries with data
C:\PS>write-host $numbersย ย ย ย  //prints entire array

Number 9 can be retrieved with

C:\PS>$numbers[2]ย ย ย  //prints 3rd item in array (integers start at 0

similarly

C:\PS>write-host $numbers[2] “this is the second item in the array”ย ย ย  //includes text at the end and uses the write-host command

C:\PS>$names = @(“Martin”, “Emma”, “Alan”, “Laura”)
ย ย ย  //this is how words are stored into an array.

Or you can ย can create an empty array and then add elements later:

C:\PS>$MoreNames = @()ย 
C:\PS>$MoreNames += “Emma”ย 
C:\PS>$MoreNames += “John”ย 
C:\PS>$MoreNames += “Gerald”

The size of the array can be retrieved with the commands

C:\PS>$ArrayName.countย 

OR
C:\PS>$ArrayName.length

(Both these seem to return the same values)

An array can be auto populated with a number range by using double dots to tell powershell to fill in the gap. eg:

C:\PS>$range = @(10..50)

Will create an array containing the numbers 10, through to and including 50.

To retrieve the last item from the array, you can use either

C:\PS>$array[$array.Length-1]

OR

C:\PS>$array[-1]

To retrieve the FIRST item in an array, you first get the length, you substitute the [-1] with [-$array.count] . Or any variation of these to your desired item.

ย To store the output from a command to an array, use cmdlets:

C:\PS>$array = Get-Process

To create an array that already has item spaces for a set amount of items, you can use:

C:\PS>$NameArray = New-Object String[] 8ย 
C:\PS>$IntArray = New-Object Int[] 12

Beginning Assignment:

CLSย  #clears all the crap off the screen from the last thing i ran ๐Ÿ˜€

write-host “Press any key to Start”
$x = $host.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown”) #waits for a key to be pushed before continuing
write-host “”
write-host “Generating random numbers”

$Item0 = Get-Random -minimum 0 -maximum 99 #Generates a random number between 0 and 99 and stores it in $Item0
$Item1 = Get-Random -minimum 0 -maximum 99
$Item2 = Get-Random -minimum 0 -maximum 99
$Item3 = Get-Random -minimum 0 -maximum 99
$Item4 = Get-Random -minimum 0 -maximum 99
$Item5 = Get-Random -minimum 0 -maximum 99
$Item6 = Get-Random -minimum 0 -maximum 99
$Item7 = Get-Random -minimum 0 -maximum 99
$Item8 = Get-Random -minimum 0 -maximum 99
$Item9 = Get-Random -minimum 0 -maximum 99

$RandomArray = @($Item0, $Item1, $Item2, $Item3,$Item4,$Item5,$Item6,$Item7,$Item8,$Item9) #stores the randomly generated numbers into $RandomArray
write-host “”
write-host “Now all the numbers are generated and stored in the `$RandomArray` array,”
write-host “we will use a sort that puts the largest into the”
write-host “variable until its reached the end of the array.”
write-host “”
[array]::sort($RandomArray) #sorts the array ?

write-host “”
write-host “The largest number in the array is” $RandomArray[-1] #writes out the last item of $RandomArray
write-host “”

 

update: next exercise involved those freaking factorials, i am once again lost and unsure how to continue <,<

WHY DO I GET STUCK ON THESE

also, i cant get loops into my head in this stupid language, why is C/C++ easier than this ?

isn’t powershell meant to be a baby language or something?

DIY Project: Home Automation

Update: This project died when I got a job and can afford off the shelf automation stuff :’)

It might come back when I start adding stuff like blinds and air conditioning control!

 

This project is basically me wanting to be able to automate my house but not wanting to fork over heaps of money for pre made systems.

I’m a bit lazy with details so if there’s any questions you have please comment below!

Newer Update v2.5

Ok, so it just occured to me that I could have bent the antenna down flat so that I wouldn’t have had to make any holes….

 

image
As you can see its all in a box now because reasons plus annoying bright light

I got around to making a few changes, I’ll let the images do the talking for me:

image
Used spare LEDs to attach the fan, deal with it. Box had a USB 125khz RFID reader in it heh
image
Melted the hole for the antenna with soldering iron, then cleaned tip and sliced off excess plastic with stanley knife
image
single channel relay board now in use to save space
image
my god i did a crappy solder job on this one D:
image
dem pro cut outs
image
don’t tell me how crappy the fan cut out is. i know.
image
cables kept getting caught in the fan so i fixed them.
image
close-up of ParaShield with the fan header, and RF module shown.
image
the area that I cut out of the proto shield to fit it over the ethernet jack
image
used a resistor leg for GND to the RF module, now i can tap into GND from that line as well B)
image
blob of blue tack was used to hold things in place while i soldered
image
finally, a nice and snug fit, that looks not like shit! xD

 

A few notable things, white LED on ParaShield (I’m calling it that now) has been replaced with a less bright red one. Transmitter repositioned and wired a little nicer, Ethernet hole cut (Stanley knife, metal cutters and pliers).
Proper helical antenna added to both units, Rx unit now has single channel relay.
Also, I shoved it all in a box and added a 12v fan running off 5v from the ParaShield (may add fan controls/monitoring later) so nothing goes wrong with summertime here.
I’m just waiting for the other 433mhz things to add a manual light switch, and the infrared control unit. Codes all ready but need the RF receiver D:

.

Also, on the app side of things,
I added an all on/off section so when this projects complete, I’ll be able to stand out the front of my house, say something awesome, hit a button, and the whole house lights up or goes dark ๐Ÿ˜€ XD

image

image

New update V2
So I discovered this thing:
http://www.ebay.com.au/itm/291262467339

I remember reading about this a while ago but didn’t care for arduino or anything much then.
But now I’m looking at this and seeing
This+Relay+PSU = self contained without need for base controller!
Plus, did I mention ITS FOUR FREAKING DOLLARS
how could I NOT order two!

When they arrive I’ll have a play around see if I can figure out how to control them ๐Ÿ™‚
Will post here when I do!
In other news: I ordered proper 433mhz antennas for the things, and found the PS move squigy ball.
Will get a box soon for it all haha,
I’m also preparing some LED strip on the front veranda to be controlled by my UI. And I’m developing an android app (will design a tablet version later)
Using Tasker app factory!
Early screenshot attached!

image
Other photos:

image
the two channel relay is sooo bigg D:

Newer update:
I found chunks of a broken PlayStation move controller, for now I’ve soldered some resistor legs to the rgb led breakout board, and have the rgb led on the base station for reasons,

Hopefully further down the track I’ll be able to turn on a mood light fading through, (although once it starts fading how do I stop it…?)

Or even notifications for things!

It also acts as a status light,
On sending an on command it flashes green twice, the off command has two red flashes.
An unused but implemented command gives three orange flashes.

I need to figure out how to flash an error if an unrecognized command is received…

Also I hope to find the sphere from the PS move. And to mount the led on the proto shield, maybe move the rf transmitter to make a cut out for the Ethernet jack,
And then try my luck at designing a special case for it all.
Either adapting an etherten case, or making a shitty one from scratch.
YouTube video showing on/off light
Signal light: http://youtu.be/ejXlYe17N8U

————————————————————-

New update: I got it working again ๐Ÿ™‚
Not sure what was wrong but I rewrote the code and now it works hahaha

image

 

image

Its a bit slow probably because of the speed I have the radios set to, but oh well doesn’t matter.
I soldered everything together into a little clump, minimising wires, and made a shield for the transmitter so it sits neatly atop the etherten.

image

I’ll be able to add other things to the proto shield later ๐Ÿ™‚

Also. Found a leostick under my bed but I’m having issues uploading code to it. Going to use it to make that light switch if I get it working ๐Ÿ˜€

LOOK AT ME I BROKE IT SOMEHOW
Went for a trip to jaycar and bought some supplies, and a smaller soldering iron
When I got home I took down the roof unit, attached shorter cables so it would fit in the little box, and put it back together,
But just my luck, it’s not working now!

I send commands but it doesn’t trigger the relay….

I’ll have to connect it and look at serial monitor to see if it’s getting the command

I’ll also add some code and an LED that blinks when it gets a command….
Oh, and maybe the code to light that emergency light if a pin goes low?

I should probably remove all the pin headers and solder right to the board actually…

Or to a proto shield….

The current state of the project consists of an arduino pro mini clone, that listens on the 433mhz band for a command, and turns on a relay depending on the command.

There is a Freetronics Etherten acting as base station, connected to my LAN, and a 433mhz transmitter, this responds to http requests by sending various commands to the ceiling unit.

Its easy to add additional remote units and set up controls for them, which I plan on doingย  when I get blinds for my windows.

image

image

I also have a raspberry pi running Rasbian that listens for a button press, which is wired to our 20 year old retro doorbell, when the button is pushed the Pi sends a pushover notification to my phone/pebble, as well as plays a doorbell sound throughout the houseย  directly connected speakers.

I’m also going to be setting up Asterix or something on this to add Cisco VoIP phones around the house.

I have plans for an analog control panel too, that has physical buttons connected to an arduino, to send commands to the various other arduino around the house.

For example, a light control panel, push one button to send off commands to all lights in the house, or indivuaul etc.

I also will be adding a sensor to the mailbox, probably solar powered, that sends a command in to the house when mail goes in, either emailing me, maybe a photo?
Sending my pebble/phone a notification, or just lighting up an LED on the control panel to indicate new mail!

image

Harvesting components!

Last night I had my first go at harvesting electrical components from junk PCBs I had lying around my room.
I found what used to be an optical mouse. But was now just sitting on a pile of junk and cables

I was hoping to find a 0.1microFarad capacitor to perform a mod on a USB to serial adapter I have for programming my arduino mini pro clones, to add auto reset.
While I’m getting pretty damn good at releasing the reset button at the right time, I would prefer to just hit upload!

So I looked all over this little PCB and was in luck! I found a 104 capacitor!
(I had looked over an old PCI fax modem before this and no luck)

So how I went about it was by holding components upright with needle nose pliers,
Then heating / melting the solder on their connections, until the weight of the PCB pulls the components through.
This kept the legs pretty free from excess solder too. ๐Ÿ™‚

I got some switches, an LED, some resistors and some capacitors!
I’ll put a photo on this post showing my haul.

It was easier than I expected and makes me want to just… Collect old junk, to harvest what I want so I don’t keep buying a cap here, a diode there, etc.

image

dump of plans, thoughts and ideas

Backup battery for ceiling arduino, mount to proto shield, put in case

AC to 5v transformer.

Emergency lighting

Crude Diagram:

AC>5vDC>Batt>Arduino>LED
>—->3.3v^

5v power supply also connects to 3.3v regulator, which arduino reads, when this drops to 0v turn on led_pin.

Ping method won’t work on light because its offline! Doh!

if(ping 192.168.1.1 = reply){

digitalWrite(4, HIGH);

else({

digitalWrite(4, LOW);

}

Arduino pro mini based light switch

Send same on/off signals as http requests (30/31)

3 indicates start bit

Second bit is state to switch relay.

Purchase or make two position momentary wall mount switch and wire buttons up to send signals to light.

Ethernet arduino add motor shield and use directly for blinds control or use separate mini arduino ?

Undecided. Probably mini.

Can adapt existing code for light to operate blinds servo or stepper motor.

And can easily send different control bits from existing code in etherten. Easy to add more sections ! ๐Ÿ˜€