element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog [Upcycle It] Hermes 3000 - Post #5
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jofas
  • Date Created: 22 May 2017 7:41 PM Date Created
  • Views 2429 views
  • Likes 5 likes
  • Comments 16 comments
  • upcycled_hermes3000
  • hermes3000
Related
Recommended

[Upcycle It] Hermes 3000 - Post #5

jofas
jofas
22 May 2017

Hello again! I had to delay this project for a little bit because I had final exams. Now that they're over, I've got some catching up to do. But it has been great to see the progress the other challengers are making!

 

In case you missed my previous posts, you can see them all here.

 

In my previous updates, I have discussed my progress in getting the Edison to recognize which key is being typed. As we have seen, there have been some issues. Remember how each type bar rests on a loop of copper wire to indicate that it is not being pressed? Well there is actually a lot of vibration that occurs when you type and this causes the type bars to momentarily lift off the copper wire, indicating a false positive. This is bad enough by itself, but also sometimes the type bar does not come back down to rest directly on the wire which makes the Edison think that the key is always being pressed. Basically, the Edison keeps reading multiple keys when I only want it to read one. I am going to continue investigating the best way to remedy these issues but it is possible that I will have to abandon this method altogether and try a different approach.

 

In the meantime however, I decided to work on some of the email-sending code for the Edison. I initially tried using python's smtplib to send an email through a gmail account I set up specifically for this project. While I was browsing stackoverflow to see if anyone else had accomplished this, I came across another method of sending an email that was much simpler. It involves using a service called mailgun. Mailgun is a good way of automatically sending emails using HTTP requests and it's free if you're sending under 10,000 emails a month. Below is the python code I used to send a sample email.

 

import requests
import email
def send_email():
    fp = open('sample_email', 'r')
    msg = email.message_from_file(fp)
    fp.close()

    return requests.post("https://api.mailgun.net/v3/MY_DOMAIN_NAME/messages", 
       auth=("api", "MY_API_KEY"), 
       data={"from": "MYEMAIL@EMAIL.COM", "to": msg.get('to'), "subject": msg.get('subject'), "text": msg.get_payload()})

if __name__ == '__main__':
    print send_email()

 

Notice I'm using another library called requests. This gives me an easy way to send HTTP requests and I would definitely recommend it if you're ever using python to communicate via HTTP. The send_email() function returns a Response which is basically just a code that tells me if the request was successful. If I get a response code of 200 then it worked fine.

 

I should also mention that I am using python's email library to turn a file into an email message. This is a little easier than manually parsing the file myself. The sample_email file looks like this:

To: MYEMAIL@EMAIL.COM

Subject: Sample email

This is a sample email to test the email

function of the hermes 3000 project.

 

 

End.

Lastly, I wrote some code that will wait for a button press, then call the send_email() function, then light an LED if I get a response code of 200 (so I know the request went through).

 

import mraa
import time
import send_email

LED_IO = 13
BTN_IO = 12
led = mraa.Gpio(LED_IO)
led.dir(mraa.DIR_OUT)
button = mraa.Gpio(BTN_IO)
button.dir(mraa.DIR_IN)

led.write(0)

while 1:
    if(button.read() == 1):
        time.sleep(0.5)
        r = send_email.send_email()
        if(r.status_code == 200):
            led.write(1)
            time.sleep(1)
            led.write(0)
    else:
        continue

 

 

When I run this code and then push the button, I see the LED light up for a second and then I get this in my email:

 

image

 

So the email sending function works! Here's how it will all go together: the user types an email which will have the same format as the sample email above. These characters will get written to a file as the user types. Then the user will press a button, the send_email() function will be called (but it will create the email from the file the user was modifying - not the sample_email file). The email will be sent off and the file will be erased so the next email can be typed.

 

Now that that's out of the way, I can get back to working on the key-detection mechanism. Once I have that fixed, I will try to incorporate some additional features if time permits. I hope you enjoyed this update, stay tuned for my next post! Let me know if you have any questions, comments, concerns, or criticisms.

  • Sign in to reply

Top Comments

  • mcb1
    mcb1 over 8 years ago in reply to balearicdynamics +2
    the solution can be conductive paint. That was one thought I had, but the paint is usually not flexible enought to last long. In an ideal world, some form of bent contact pin (like a Cat 5 plug) would…
  • mcb1
    mcb1 over 8 years ago in reply to balearicdynamics +2
    just there the vibrations are higher so probably the paint is the only reliable and relatively cheap solution. The issue I see is that the lever part of the type comes down and rests on the conductive…
  • ntewinkel
    ntewinkel over 8 years ago in reply to mcb1 +2
    Surprisingly a fax is considered a legal document and is still useful in some applications. So is paper My contracts are now just emailed PDFs. I used to print, sign, scan - but most recently started just…
Parents
  • jasonwier92
    jasonwier92 over 8 years ago

    I would like this to send tweets! 

     

    Given the realm of the device, faxing would be an update too. I am sure you could email a fax gateway and have it tweet each time an email/fax was sent!

     

    Finals really put a crunch on the fun parts of life.  Back to it!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jofas
    jofas over 8 years ago in reply to jasonwier92

    I never even though about faxing! Maybe after the project is finished I'll add on those features. Thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jasonwier92
    jasonwier92 over 8 years ago in reply to jofas

    I wouldn't bother. Do not feed the fire of those who think fax is still a useful tool for today and tomorrow.  image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • jasonwier92
    jasonwier92 over 8 years ago in reply to jofas

    I wouldn't bother. Do not feed the fire of those who think fax is still a useful tool for today and tomorrow.  image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • mcb1
    mcb1 over 8 years ago in reply to jasonwier92

    Do not feed the fire of those who think fax is still a useful tool for today and tomorrow

    Surprisingly a fax is considered a legal document and is still useful in some applications.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ntewinkel
    ntewinkel over 8 years ago in reply to mcb1

    Surprisingly a fax is considered a legal document and is still useful in some applications.

     

     

    So is paper image

     

    My contracts are now just emailed PDFs.

    I used to print, sign, scan - but most recently started just using the sign feature of Mac Preview to skip the whole print/scan step.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 8 years ago in reply to ntewinkel

    You were doing well until you mentioned the three letter word ... wait cat has three letters as well image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube