I need to monitor the state of a generator. When the generator turns on ( testing or power failure) there is a relay that goes high/low. I can read from either state. I need for the pi to send email when it comes on, once, and then a different email when it turns off. I have found code that is close, but not sure how to configure to work the way i need it to. I presume i will need 2 seperate .py files one for power on and one for power off... at least i presume i will. I have a similar setup that monitors a ups (APCUPSD) sends email. I may use this in conjunction with the relay monitor as to tell me there is actually a power outage, and that the generator comes on.

I am looking to install this setup at 4 different locations for monitoring backup generators. Would also like to work on other sensors such as battery voltage, temperature and oil pressure sensors ect.. but that can wait..lol

I have been using the code within this post, Raspberry Pi to email when power outage occurs

I have UPS for pi and internet router etc..

Any help would be greatly appreciated!

  • 1
    Please specify the problem. It might be preferable to ask multiple smaller questions, whose answers might be more globally useful. Eg: How do I send an email from python? This isn't really an RPi question, and might be better suited to the Python Stack. Another apparent question is: how do I detect a relay change on a Raspberry Pi? This is an PRi question, but it's answered many times in on the net. The possible third question is on general python scripting. I don't believe you'll need two separate scripts. One will be enough to detect a relay toggling and send an email depending on its state.
    – KDM
    May 3, 2016 at 21:13
  • Realistically, does your internet work even half the times you loose power?, please be more specific about where your problem is? Do you have the hardware done? Has it been tested? Is the email client connecting? Does it send email? May 4, 2016 at 13:54

1 Answer 1


If you generator is a Generac Model with an Evolution controller this project may be useful:


  • Hello and welcome! Please take the tour and visit the helpcenter. Whilst this may theoretically answer the question, it is preferable to include the essential parts of the answer here, and provide the link for reference. In fact we're enforcing this policy: please edit so that the answer stands on its own should the link break in the future. If it is not edited within 48 hours it will be converted to Community Wiki.
    – Ghanima
    Mar 19, 2017 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.