This is a close up of my Raspberry Pi + WittyPi (RTC and auto startup/shutdown hat) + MoPi (dual power and safe shutdown on low battery hat).

I am not going to detail how to setup the MoPi but here is the MoPi output from the MoPi configured to be run from Lead Acid batteries.

The default 6 cell Lead Acid battery profile says there is a low power condition when the battery is at 10.42v and the minimum charge s 9.48v.

Status Screen.

This is the battery reading I have from the Pi itself.

After 3 days of 24/7 use (saving an image every minute) and running a web server for the camera the battery has fallen from 12.73v to 12.28v.

Cheap multimeter reading (after 2 days use).

Mopi Reading (after 3 days use)

I will ignore my multimeter and trust the Mopi to decide when to power down the Pi.

I would expect the MoPi to shut down the pi when the battery falls another 2,456mv (that may be i n 18~25 days based on current trends (pun intended)).

Step 2: Have the battery in Standby and top up the battery with Solar.

I have a cheapie “2 Watt 12 Volt Solar Panels – Amorphous 2 Watt 12 Volt Solar Panels – Amorphous”. I have no idea if this will be enough to charge up the battery during the day? I have no idea about the solar stuff.

Ian.M at EEV Blog informed me that the lowest the battery should be discharged to is 10.5v. I have edited the “/etc/default/simbamond” file to now specify safer low and shutdown power levels. The “Sinabamond” service is a battery monitoring service (read about it here)

If you edit the “/etc/default/simbamond” you may need to run the following command before and after you edit the file

sudo service simbamond stop

sudo service simbamond restart

Now when the MoPi detects the battery is below the low level the lights flash and broadcast messages appear on the terminal.

If the battery gets below the critical it shuts down the pi (safely).

Testing it (letting the battery getting below the critical limit).

The good think about the MoPi it shuts down the Pi safely and turns off the power (all power).

I must be getting a few low power spikes as the spikes because the Pi seems to be shutting down early.

I adjusted my max, good, low and critical values to 1200 11500 11100 and 11000 to test the levels of where my battery was at and the MoPi flashed to say it was shutting down then decided not to. I ran a few volt outputs and the voltage detection was dipping.

You may want to space your voltages enough to prevent voltage dipping triggering an early shutdown.

I did things a bit out of order and I think I needed to power up the MoPi/Pi from batteries (and no mains power) for 2iC to detect. But all is god, I can power up and shutdown my Pi from 6xAA batteries.

On reboot I noticed warning on boot up about GPIO pin conflicts with my MoPi. Maybe the MoPi and Witty Pi are clashing? I changed GP17 on the Witty Pi and rebooted. I still had a conflict so I set GP4 on the Witty Pi to also be custom. After a reboot I still had MoPi warning.

Do’h, I just realised that the Pi is powered by Mains USB on the pi and the MoPi warning may just be a warning about the MoPi not controlling the external power. I removed the mains power ad instead connected up the MoPi to a 9v DC supply.

I reset the Witty Pi pins to their defaults and powered up the Pi via the Pi MoPI power button. All MoPi warnings have gone. Now to resume the WittyPi setup.

I will possibly use the MoPi to power down the Pi when battery gets low and use the Witty Pi to boot up the Pi every day and to use the Realtime clock.

tip: Make sure the folder you install witty pi to is spelled exactly like “%HOME%/wittyPi” and not “%HOME%/WittyPi”. My daemons would not start because it way looking for “/home/pi/wittyPi” and not “/home/pi/WittyPi”.

Now I configured the Witty Pi’s time.

sudo ./wittyPi.sh
1
7

34. SD Card Check

Ok run the following command to get the location of your boot filesystem

df

Now run this command to check your boot disk (replace the boot disk with the one identified above).

fsck -fy /dev/mmcblk0p5
reboot

You may notice potential corrupted files and fixes from the output above.

I am building an augmented reality app that needs to know when the user tilts and rolls a phone around so it can update the user interface with augmented reality elements. Corona already has the accelerometer acquisition code but now I want to display this data in human readable degrees (e.g if you were looking half way up the sky you would expect 45° and the horizon 0°)

This does not look too handy to some but this is gold in plotting the horizon and calculating far away objects with trigonometry.

Don’t forget to detect what orientation the mobile device is in (portrait, landscape, upside down portrait and upside down landscape). You will need to factor these display modes into the calculation before converting to degrees. Sometimes it is easier to just develop portrait or landscape apps (not both).

I have been searching for a solution to calculate the distance and bearing of a target gps location for a while now. This page always popped up but my brain hurt every time I tried to convert this to lua.

print("Bearing between Tamworth and Armidale: "..tonumber(GeoAngle(-31.1063157,150.9307341,-30.5143425,151.66696439999998)))print("Distance between Tamworth and Armidale: "..tonumber(GeoDistance(-31.1063157,150.9307341,-30.5143425,151.66696439999998)).."km")