Thursday, October 3, 2019

Wednesday, August 14, 2019

python

Here is my  python script. Let me know if you have any ideas why it crashes when log_data() is called?

import time
import serial
import smtplib

from email.message import EmailMessage

def log_data(filename, line):
    file_handle = open(filename, 'a+')
    file_handle.write(line)
    file_handle.close()


print('Hello World!')

ser = serial.Serial(
    '/dev/ttyAMA0',
    baudrate=57600,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS)

time.sleep(.1)

try:
    ser.write('H\r')
    time.sleep(.25)
    ser.write('2\r')
    time.sleep(.25)
    ser.write('6\r')
    ser.reset_input_buffer()
    kludge = 0
    while True:
        data = ser.read_until('\n', 120)
        if kludge > 2 and len(data) > 12:
            log_data('log.txt', data)
            parse = data.split()
            print(parse[0]
                  + ' ' + parse[1]
                  + ' Amps ' + parse[8]
                  + ' ~ ' + parse[9]
                  + ' Volts ' + str(int(parse[10]) * 9.0 / 5 + 32)
                  + ' ~ ' + str(int(parse[11]) * 9.0 / 5 + 32)
                  + ' degF')
        kludge = kludge + 1

except BaseException:

    # email logged data before quitting
    print("Emailing data...")
    textfile = 'log.txt'
    with open(textfile) as fp:
        # Create a text/plain message
        msg = EmailMessage()
        msg.set_content(fp.read())

    msg['Subject'] = 'The contents of %s' % textfile
    msg['From'] = 'chrisdarilek@gmail.com'
    msg['To'] = 'chrisdarilek@gmail.com'

    username = 'chrisdarilek@gmail.com'

    # Send the message via our own SMTP server.
    s = smtplib.SMTP('smtp.gmail.com:587')
    s.starttls()
    s.login(username, password)
    s.send_message(msg)

    s.quit()
    print('Blow up the spacestation!')


finally:
    ser.close()
    pass

Tuesday, August 13, 2019

pi

I found a use for an old Raspberry Pi I had. I paired it with a small LCD display and wrote a Python script to poll the BMS for battery data.
















I added WiFi to it and now I can SSH into it from my phone to monitor my charge without having to go outside.




















My goal is to have the Pi write the data to a file and email it to me when it detects WiFi.

heat

It is getting hot this summer. The AC is working like a champ. I've run out of charge a handful of times over the past 6 years. Each time it was due to my charger turning Off due to high temperature. The model I have appears to need to be reset to recover from this condition. However, if I don't pay attention I do not notice that I'm heading out with less than full charge.

I picked up a Manzanita Micro PFC20 charger with forced air cooling. It's the green box at the bottom of this picture. The previous charger only had fins for cooling.
















Sure enough, this charger overheats as well. At least it continues to charge, only at a lower rate. The BMS is wired to give it the Off signal when charge is complete. This charger will half my charge time, in the winter at least. 1 hour of charge per ~12 miles.

My water cooled motor controller is overheating as well. I may need a bigger radiator.
















My battery has been at 120 degF by the time I get home from work lately.

Monday, June 24, 2019

disc flexin' once again

I'm now on my 5th flex disc in just under 6 years. The Meyle brand lasted almost 1 year. That's an improvement from the last candidate. Again I'm switching brands, finding one that is slightly more expensive this time.
I'm beginning to believe the issue is the high starting torque of the DC motor. I don't use 1st gear because it is very jumpy. I start out in 2nd gear and usually nail it.
I can tell the unit goes under a lot of force. The grade 5 bolts in the pic below were new 1 year ago. Notice how a shoulder has been worn on the ones at the bottom. I lost the 8th bolt on a turn, that's how I knew it was time to swap a new one in.

mirror failure

My driver's side mirror fell off underway. I was able to turn around and retrieve it. The part that it holds onto the door with had worn away and no longer provided a purchase.
I fabricated a replacement for this part in aluminum and made a gasket from inner-tube.