Skip to content

snaptec/EVNotiPi

 
 

Repository files navigation

EVNotiPi

Python Version of EVNotify

Needed Hardware

Wemos Sketch

Use Arduino IDE to program the Wemos with the following sketch

/*
  
  ESP8266 Wemos by Kevin Wieland for EVNotiPi
  adjusted by Mario Mueller
  Recognizes voltage above 12.75V and turns Relay on (Rpi).
  Shutdown and turns off
  Relay Hat on Wemos D1 Mini.
  D0 to GPIO24 Rpi
  A0 with 1.2MOhm resistor to +12V
  
*/
#include <ESP8266WiFi.h>
const int relayPin = D1;
const int shutdownPin = D0;
int pistat = 0;
int counter = 0;
void setup() {
  Serial.begin(9600);
  pinMode(relayPin, OUTPUT);
  pinMode(shutdownPin, OUTPUT);
  digitalWrite(shutdownPin, LOW);
  WiFi.mode(WIFI_OFF);
  WiFi.forceSleepBegin();
}
void loop() {
  delay(2000); 
  int sensorValue = analogRead(A0);
  float voltage = sensorValue * (0.0144);
  Serial.print("Sensor Value: ");
  Serial.println(sensorValue);
  Serial.print("Voltage: ");
  Serial.println(voltage);                  
  if ( voltage > 12.75 )
  {
    if ( pistat == 0 )
    {
      counter == 0;
      Serial.println("Power up Rpi");
      digitalWrite(relayPin, HIGH);
      delay(60000 );
      pistat = 1;
    } 
  }
  else
  {
      if ( pistat == 1)
      {
        counter = counter + 1;
        Serial.print("Counter: ");
        Serial.println(counter);
        if ( counter > 150 )
        {
          Serial.println("initiate sutdown");
          digitalWrite(shutdownPin, HIGH);
          delay(3000);
          digitalWrite(shutdownPin, LOW);
          delay(40000);
          counter = 0;
          Serial.println("Rpi off"); 
          digitalWrite(relayPin, LOW);
          pistat = 0;
        }
      }
   }
}

Drawings

Drawing

Prerequisites

  • Python 3
  • Python Serial
  • Python GPS
  • GPSd
  • EVNotify API Python Library

Installation

Raspberry Pi

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get install python python-serial python-gps gpsd

EVNotiPi

  • Copy config.template.json to config.json. Adjust the values for your needs

About

Python Version of EVNotify

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 68.6%
  • HTML 28.3%
  • Shell 3.1%