Add a red led to warn that the mosquitoes hunter is on

When log in :

debarm:~# cat .bashrc

echo “toto”
python /root/new/led_on.py&

debarm:~# cat /root/new/led_on.py
from ablib import Pin
import time
led = Pin(‘W16′,’OUTPUT’)
led.on()

When log out :

debarm:~# cat .bash_logout
python /root/new/led_off.py

debarm:~# cat /root/new/led_off.py
from ablib import Pin
import time
led = Pin(‘W16′,’OUTPUT’)
led.off()

GPS + aria G25

GPS module
GPS module

 

20150111_150432

 

20150111_150444

 

Set date :
date -s “11 JAN 2014 13:46:00”
hwclock –systohc

Install CRON : apt-get install cron

root@acmeboard:~# cat check.sh gps.py

#!/bin/sh
SERVICE='gps.py'

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo "$SERVICE service running, everything is fine"
else
echo "$SERVICE is not running"
cd /root/
nohup python ./$SERVICE > /dev/null &
fi

[python]
import serial

import logging
import logging.handlers

# set up logging to file – see previous section for more details
logging.basicConfig(level=logging.DEBUG,
format=’%(asctime)s %(name)-12s %(levelname)-8s %(message)s’,
datefmt=’%y-%m-%d %H:%M’,
)

log = logging.getLogger(‘toto’)

formatter = logging.Formatter(‘%(asctime)s %(name)-12s %(levelname)-8s %(message)s’)
handler = logging.handlers.TimedRotatingFileHandler(‘test.log’,’midnight’,1)
handler.setFormatter(formatter)
log.addHandler(handler)

ser = serial.Serial(‘/dev/ttyS4’, 9600, timeout=1)
print("connected to: " + ser.portstr)

while True:

line = ser.readline()
log.debug(str(line.strip()))
[/python]

root@acmeboard:~# crontab -l
*/2 * * * * /root/check.sh >> /root/toto

Convert NMEA lat, lon to decimal lat,lon :

NMEA Decimal
latitude 0302.78469 03 + (02.78469/60) = 3.046412
longitude 10141.82531 101 + 41.82531/60) = 101.6971