Posts Tagged ‘fun’

1. I have minions!

2. My minions are AWESOME!

3. While I am away from my minions, I wanna make sure that they are safe and happy.

Hence, I am preparing a super (duper) tiny project to alert me of movement around my minions (as I said, only I am allowed around my minions).

Parts

1. Motion detector (PIR sensor)

2. Wires (the sensor needs 3: ground, out, vcc)

3. Arduino board

4. I had Python on my mac-mac, but I also had to install pyserial, in order to communicate to the Arduino board, via the serial port. In my case, the Arduino board is reachable via /dev/cu.usbmodem1421, on other systems it’s probably different.

Picture

20150408_200557

A bit of explanation

Basically, the “plan” is to log something to Serial port from Arduino, everytime I detect movement around my Minions. If that happens, I log “Movement!” to the Serial port. Then, from Python, I monitor the serial port, and if I read “Movement!”, then I send an email to myself, using my Gmail account, alerting me that the safety of the Minions has been compromised 🙂

Code

1. Arduino code

int pirPin = 7;

int spamInterval = 60; // send email max every 1 min

long lastSend = -spamInterval * 1000l; // measured in milliseconds

void setup()
{
pinMode(pirPin, INPUT);
Serial.begin(9600);
}

void loop()
{
long now = millis();
if (digitalRead(pirPin) == HIGH)
{
if (now > (lastSend + spamInterval * 1000l))
{
Serial.println(“Movement!”);
lastSend = now;
}
else
{
Serial.println(“Let’s not spam”);
}
}
delay(500);
}

2. Python code

import time

import serial

import smtplib

import io

TO = ‘cristina.vintila@gmail.com’

GMAIL_USER = ‘cristina.vintila@gmail.com’

GMAIL_PASS = ‘no, you cannot get this one ;)’

SUBJECT = ‘Intrusion!!’

TEXT = ‘Watch the Minions! The Minions are not safe!’

ser = serial.Serial(‘/dev/cu.usbmodem1421’, 9600)

def send_email():

    print(“Sending Email”)

    smtpserver = smtplib.SMTP(“smtp.gmail.com”,587)

    smtpserver.ehlo()

    smtpserver.starttls()

    smtpserver.ehlo

    smtpserver.login(GMAIL_USER, GMAIL_PASS)

    header = ‘To:’ + TO + \n + ‘From: ‘ + GMAIL_USER

    header = header + \n + ‘Subject:’ + SUBJECT + \n

    print header

    msg = header + \n + TEXT + \n\n

    smtpserver.sendmail(GMAIL_USER, TO, msg)

    smtpserver.close()

while True:

    message = ser.readline()

print(message)

    if message[0] == ‘M’ :

        send_email()

    time.sleep(0.5)

#ser.close()

3. Output

rbh:Arduino cristina$ python safeMinions.py

Let’s not spam

Let’s not spam

Movement!

Sending Email

To:cristina.vintila@gmail.com

From: cristina.vintila@gmail.com

Subject:Intrusion!!

Let’s not spam

And I have the email 🙂

Happily, I am right next to the Minions, and I know they are safe

Arduino – making pretty sounds

Posted: April 8, 2015 in technical
Tags: , ,

Cristina is girlie and she likes PINK! Unfortunately, the LED part is the only one I couldn’t make work 😦 😦 hence no pink display for me.

The next best thing: we make pretty sounds!

Parts

1. Piezo (I have no proper speaker): well, I use it to make the (pretty) sounds

2. Light sensor + 1K Ohm resistor

I used this only in the beginning, as I wanted to make the piezo play sounds based on the light intensity. As I am not able to control the light intensity in my room in a good-enough way to make sounds, I decided to use the distance variation to play different tones (see 3).

3. Ultrasonic sensor: well, I use it to measure the distance from the sensor to my palm and based on this variation I scale the distance from CM to Hz and play the tones within a range of musical notes:

int tones[] = {261, 277, 294, 311, 330, 349, 370, 392, 415, 440, 450};
// mid C, C#, D, D#, E, F, F#, G, G#, A, higher

How did I end up with these values?

Well, I have not. That’s just how they are. The frequency of Mid C is 261.6 Hz, and the others as above. What I tried then to ensure is that I map the distances from the Ultrasonic reader to a range of frequencies which “make sense” (between 200 and 300 Hz). As I would just flip my hand around the sensor to no longer than 100 cm, I just decided to add 200 to the distance computed by the sensor, in order to create the pitch (I am sure there are much better ways to do this).

4. Wires (the Ultrasonic sensor needs 4 – as it has 4 PINs: VCC, Trigger, Echo, Ground)

5. Yeah, and the Arduino board and breadboard, otherwise: no magic

Picture

20150408_191513

Code

v0.1 (using the Light sensor)

int speakerPin = 12;
int photocellPin = 0;

int numTones = 11;
int tones[] = {261, 277, 294, 311, 330, 349, 370, 392, 415, 440, 450};
// mid C C# D D# E F F# G G# A others

void setup()
{
for (int i = 0; i < numTones; i++)
{
tone(speakerPin, tones[i]);
delay(500);
}
noTone(speakerPin);
}

void loop()
{
int reading = analogRead(photocellPin);
int pitch = 200 + reading / 4;
if (pitch <= 261)
{
tone(speakerPin, tones[0]);
}
else if (pitch > 261 && pitch <= 277)
{
tone(speakerPin, tones[1]);
}
else if (pitch > 277 && pitch <= 294)
{
tone(speakerPin, tones[2]);
}
else if (pitch > 294 && pitch <= 311)
{
tone(speakerPin, tones[3]);
}
else if (pitch > 311 && pitch <= 330)
{
tone(speakerPin, tones[4]);
}
else if (pitch > 330 && pitch <= 349)
{
tone(speakerPin, tones[5]);
}
else if (pitch > 349 && pitch <= 370)
{
tone(speakerPin, tones[6]);
}
else if (pitch > 370 && pitch <= 392)
{
tone(speakerPin, tones[7]);
}
else if (pitch > 392 && pitch <= 415)
{
tone(speakerPin, tones[8]);
}
else if (pitch > 415 && pitch <= 440)
{
tone(speakerPin, tones[9]);
}
else
{
tone(speakerPin, tones[10]);
}
}

v0.2 (using the Ultrasonic sensor)

int speakerPin = 12;
int trigger=7;
int echo=6;
long time=0;
long dist=0;

int numTones = 11;
int tones[] = {261, 277, 294, 311, 330, 349, 370, 392, 415, 440, 450};
// mid C C# D D# E F F# G G# A others

void setup()
{
Serial.begin(9600);
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);

for (int i = 0; i < numTones; i++)
{
tone(speakerPin, tones[i]);
delay(500);
}
noTone(speakerPin);
}

void loop()
{
digitalWrite(trigger, LOW);
delay(5);
digitalWrite(trigger, HIGH);
delay(10);
digitalWrite(trigger, LOW);
time = pulseIn(echo, HIGH);
dist = (time/2) / 29.1;

if ( dist >= 500 || dist <= 0)
{
Serial.println(“No measurement”);
}
else
{
Serial.println(dist);

int pitch = 200 + dist ;
if (pitch <= 261)
{
tone(speakerPin, tones[0]);
}
else if (pitch > 261 && pitch <= 277)
{
tone(speakerPin, tones[1]);
}
else if (pitch > 277 && pitch <= 294)
{
tone(speakerPin, tones[2]);
}
else if (pitch > 294 && pitch <= 311)
{
tone(speakerPin, tones[3]);
}
else if (pitch > 311 && pitch <= 330)
{
tone(speakerPin, tones[4]);
}
else if (pitch > 330 && pitch <= 349)
{
tone(speakerPin, tones[5]);
}
else if (pitch > 349 && pitch <= 370)
{
tone(speakerPin, tones[6]);
}
else if (pitch > 370 && pitch <= 392)
{
tone(speakerPin, tones[7]);
}
else if (pitch > 392 && pitch <= 415)
{
tone(speakerPin, tones[8]);
}
else if (pitch > 415 && pitch <= 440)
{
tone(speakerPin, tones[9]);
}
else
{
noTone(speakerPin);
}
} // end distance measurement
delay(1000);
}

Yes, I did use the Serial.println for debugging, printing is the best form of debug 🙂 🙂 🙂

So it seems that I am back on “blogging”. Long time no see, my friends 🙂 and thanks for all the messages I got in the meantime.

Most probably I won’t be able to keep up blogging as in the past (not enough time to do all the geeky stuff), but I will not abandon it anymore.

The past few days I’ve found out about the passing of a friend, one of the geekiest people I know, an elderly gentleman, who has spent most of his life in the search for knowledge (he was speaking 11 foreign languages), curiosities and geeky stuff (a BSD passionate and founder of the foundation behind EuroBSDCon). I was very sad to get the news from Gavin and Henning this week, posted via the OpenBSD lists.

RIP Paul!

So, given the fact that for the past few weeks I can only sleep till 2AM every night, with occasional nights when I can fall asleep somewhere close to the morning, I have decided to spend this time on something useful, rather than with thinking and worrying about purpose of life and ponies and butterflies. First thing at hand: my new Arduino kit.

First time playing with this toy, I’ve went through the Startup Guide, and made the lights blink, the buzzer go off etc. The ones I am going to use later on though are the following:

1. Distance detector

https://drive.google.com/file/d/0By4rOXj_UNlEdVZMVHBjb2tJOGs/view?usp=sharing

2. Light sensor

https://drive.google.com/file/d/0By4rOXj_UNlEVnpaaXJQRUQweVE/view?usp=sharing

3. Movement detector

https://drive.google.com/file/d/0By4rOXj_UNlETzN6aUhkcGhNZzQ/view?usp=sharing

4. Temperature sensor

https://drive.google.com/file/d/0By4rOXj_UNlEeUpaSHJiRTZOZ0k/view?usp=sharing

5. (for the future) Servo engine

https://drive.google.com/file/d/0By4rOXj_UNlET0FfMW90bkFRMUk/view?usp=sharing

Indeed, these are just playing around with the very basics, but at least now I get the logic of how this works, and the code itself looks a lot like C programming, with libraries you can include and work with (and have the Arduino board become unresponsive when the libraries folder has a different name than the .cpp file inside it).

https://drive.google.com/file/d/0By4rOXj_UNlEamhKOTluZllPVDA/view?usp=sharing

Aaah, the sweet smell of burned plastic when you placed the Temperature sensor backwards on the breadboard!! 😛

TemperatureSensor

This week my sister and her boyfriend took me to Oktoberfest. I say “took”, because I was a fancy pansy this time – my sister is a manager at URSUS, one of the main sponsors of the fest, therefore we’ve got central seating and a lot of other perks.

Unemployed. Back to Romania.

Posted: October 1, 2013 in personal
Tags: , , , , ,

Today was the second day of unemployment. Bad weather in Bucharest, therefore spending time on the Internet (which is best of the world, and I’ve done some heavy travelling in the past 5 years) and meeting friends.

This evening was the “Evening Tea” event, with my former colleagues from Ixia, more specifically part of the LTE team. Couple of hours of geeky talks, spiced up with hobbies of each of us.

InfiniTea were awesome, as they usually are. Couldn’t miss out on ordering the chesnut puree (second best in Bucharest, after Excalibur – metropotam).

For people without Facebook account, here are the pictures.

537051_10151957303826807_2140863448_n 1377473_10151957303481807_1319012982_n 625528_10151957303231807_1725746920_n 1375001_10151957302971807_144573456_n 1374253_10151957302786807_1052953300_n 1376370_10151957302536807_1554599126_n 734116_10151957302326807_498502506_n

Thank you very much for showing up and for the lovely roses!

Check Point R77

Posted: September 20, 2013 in technical
Tags: , , ,

Yes, 77, nice number – I said.

Besides that, though:

New Threat Emulation Software Blade
New Check Point Compliance Blade
HyperSPECT Technology
Gaia Operating System Enhancements
Enhanced Gaia Software Updates
Enhanced Identity Awareness
Enhanced Endpoint Security
Note: Endpoint Security E80.50 clients will be available only by end of September 2013.
– Full Disk Encryption
– Endpoint Security Client – General
– Anti-Malware
– Firewall
– Media Encryption & Port Protection
Security Gateway Virtual Edition
Enhanced VSX
Enhanced SAM Card Support
Mobile Access

full list at the CKP UserCenter

CheckPoint_R77

Book of Bad Arguments

Posted: September 9, 2013 in reading, thoughts
Tags: ,

lovely reading

https://bookofbadarguments.com/

“The first principle is that you must not fool yourself and you are the easiest person to fool.”

– Richard P. Feynman

Cristina gets bored very quickly.

Cristina is bored now.

What Cristina does when she gets bored… hrm… let’s see. I wanna build the best PRNG (pseudo-random number generator) function ever!

The first question is: what does it take a PRNG to make it “the best ever”. I had no idea. A bit of googling and bugging some specialised friends about it, I narrowed it down to 3 main things:

1. Statistical randomness

(more…)

Before you panic: it is just a PHILOSOPHY course! Free on YouTube

http://oyc.yale.edu/philosophy/phil-176

Link to the YouTube playlist of this course

About the Course

There is one thing I can be sure of: I am going to die. But what am I to make of that fact? This course will examine a number of issues that arise once we begin to reflect on our mortality. The possibility that death may not actually be the end is considered. Are we, in some sense, immortal? Would immortality be desirable? Also a clearer notion of what it is to die is examined. What does it mean to say that a person has died? What kind of fact is that? And, finally, different attitudes to death are evaluated. Is death an evil? How? Why? Is suicide morally permissible? Is it rational? How should the knowledge that I am going to die affect the way I live my life?

kidz :)

Posted: August 22, 2012 in personal
Tags:

ce misto ma simt cand mai vorbesc cu lumea si imi zice ca e fain ca au gasit (si folosit) chestiile facute de mine

ps: inca exista /home/cristina pe toate debianele :))

stiu, si tu ai fost la ipsec :))
ti-am gasit prezentarile 🙂