7 Replies Latest reply on Nov 5, 2015 4:49 AM by mhahn

    Running Python Script From Arduino IDE doesn't work for some cases (smtplib example)...


      Here is a python script named gmail.py I've made using smtplib as part of a project I'm working on:


      import smtplib
      t = open('/home/root/testLog.txt', 'a+')  #writes to a log file to confirm that the script has been started
      fromaddr = 't@gmail.com'
      toaddrs  = 't@gmail.com'
      file = open('message.txt', 'r+').read()
      #Uncomment for debugging
      #print file
      #print file.split('\n')
      username = 't@gmail.com'
      password = '***'
      server = smtplib.SMTP('smtp.gmail.com:587')
      server.sendmail(fromaddr, toaddrs, file)

      The script basically opens a text file name message.txt and sends me an email with its contents.


      When i run the code with python gmail.py, everyone works fine and after a few seconds I receive the email just like I wanted. However, when I run the code from the arduino IDE using the system command it doesn't work, i.e I don't get any email!

      void setup() {
        system(" python /home/root/gmail.py");  
      void loop() {


      The strange thing is that if I try to run any other simple python script, it works perfectly fine; I've seen this post and have tried the code that writes a "hello" into a log text file, and it works.


      IN FACT, when I run the above Arduino sketch, even though I dont get an email, i know the python code has been run because there is a new entry in the logfile (see the 3rd line of my python code). Maybe this problem is beacuse of the delay created while the python code is sending an email, but I can;t say.


      I'd be greatful to anyone who can solve the problem!



      1. Edison image version -159

      2. Windows 7 professional with Arduino IDE 1.6.5