More Particle Internet Button Projects

I posted a few months ago about the Particle Internet Button I’m playing with (link). I’ve created another 2 projects in the mean time.

Adjustable Timer

The first is an adjustable timer. The lights on the Internet Button are used to indicate 30s steps, ranging from 30s to 5min. When it turns on you specify the length of time you want to run it for by either increasing or decreasing the steps. When running the 30s that are currently active flashes. At the end of the time, the Internet Button beeps and flashes red. It can be easily adjusted and reset.

particle timer

Left: select length of time
Right: Timer running

I made this back in November, but actually had a problem with it that I couldn’t figure out. I had intended to post to the Particle forums for help but never got round to it. I had in the mean time uploaded the offending code to Github. I recently reinvestigated the code with the intention of this post, and found that someone else had found my code, and solved my problem, so thanks to Github user mseneshen. Working code can be found here: source

Dice

The second project was a set of dice. Playing Catan and having people complain about how there were no 3s rolled in a game gets old, so why not create a set of dice that keep track of this and tell you facts. Apps are available for this, but then the screen turns off and it becomes a hassle. So I wrote some code to mimic a set of dice.

particle dice

Left: Dice being rolled
Right: Dice have been rolled

To roll the dice you gently shake the Internet Button sideways. The code randomly generates two numbers between 1 and 6, adds them, and outputs them by lighting up the appropriate number of LEDs. To make it easier to read, LEDs are colour coded in groups of 3. The Internet Button only has 11 LEDs, so I if a 12 is rolled, the 11th LED changes colour. Because a 1 is never rolled, I could have used that LED, but it seemed less intuitive. Also, because we play Catan, if a 7 is rolled, all the lights go red.

The whole time the dice are running, a tally is kept of how many times each number is rolled. At any time you can click a button and a distribution is published to the console. I might update this later to automatically graph the data and tweet it, but haven’t tried that yet.

When I first tested the code, I was getting reproducible random numbers, so I introduced a seed from one of the analogue pins which appears to have solved that problem. Because it uses an accelerometer to trigger a throw, when it is on it’s side, gravity is enough to trigger a throw and allows me to get thousands of throws without destroying my wrists.

Some plotted results can be seen here, with actual roll percentage (bars) vs statistical roll percentage (dots).

Code is available here: source

Temperature and Altitude

I recently bought an Adafruit BMP180 that I’m trying to get running with the Internet Button. Will post details once it’s active.

New SA Traffic Laws 2017

Recently in the news there has been some talk about new intended traffic laws. According to this article they are supposed to come into effect on 11 May 2017.  The laws are:

  • Bakkie drivers may not transport children in the back.
  • Bakkie drivers may not transport more than 5 people in the back
  • Heavy goods vehicles will be speed limited by weight, and require a sticker indicating the speed

This is going to happen. It has been published in the government gazette. Further laws that they wish to implement at a later stage, but have no due date, include:

  • Practical driving re-evaluation when renewing licence
  • Re-examine K53 (update it)
  • Lowering of speed limits in certain areas.
  • Goods vehicles with GVM > 9 tons banned during peak hours.

These laws were first discussed in 2015, but similar to the laws the DoT tried to pass in 2011, have been very poorly communicated to the public, and with any luck will be reconsidered. Both the laws that are changing and the proposed ones were published in the Government Gazette of 11 May 2015. And the Justice Project South Africa submitted some excellent commentary. To what it seems was mainly deaf ears.

I wanted to find more information about these topics, so tried looking around a bit. I first went to the eNATIS website, but their news page was returning a 404 error. The Department of Transport website didn’t go to their homepage (first google result), but asked me for login details. After getting to their proper home page, I couldn’t find any info on any upcoming changes to the NRTA. I then looked through Arrive Alive’s website and couldn’t find any news, and my browser warned me that the AA’s website was untrustworthy.

Let’s look at what’s been published though. On 11 November 2016, the 24th amendment to the NRTR was published in the Government Gazette, it had some definition changes, but ultimately the important parts were that as of 6 months after the Gazette was published, the following will come into effect. paraphrased:

school children may not be conveyed in the goods compartment of a motor vehicle for reward on public roads.

No one may be conveyed in the goods compartment of a motor vehicle for reward unless complying with NTLA provisions.

The amendment also immediately specified the inclusion of the following vehicles into the category not allowed to travel more than 100kmph, paraphrased:

vehicles between 3.5 and 9 tons

So what does all this mean? Basically what I put in the first half of this article. It means the law has and is changing. It means that there quite likely will be more changes later on, but there’s no new information.

The DoT really needs to reconsider the laws it’s implementing and take into count the excellent comments they receive back from the public, specifically organisations such as the Justice Project. They also need to do a better job of publicizing changing laws, and not rely on news outlets to publish these details. Very few people read the government gazette, and even fewer can make sense of what gets published.

US (CA) vs SA driving licences

Planning to be in the US for a while still, I figured I might as well try get a US driver’s licence. It makes life a lot easier, and means I get to leave my passport at home more often. Each state has its own testing procedures, and for California (CA), as a foreign driver, you are required to go through the whole process. That means write a theory based learner’s permit, and then do a practical driving test. If you’re from another state in the US and want a CA driver’s license, you are required to only do a theory test.

Overall I’ve found the admin side of things to be far better in the US, and the actual testing to be easier. Firstly I booked online for both my learner’s and driver’s tests. For the learners you can go in person any day and write the licence immediately, but will wait in queues. For the driver’s test I waited a week for the earliest booking. For the learner’s I probably sat about 40min waiting for my number to be called, 10min answering¬† multiple choice questions on a computer, and that was it. This website (not official) says there are 46 questions, and you can get 8 wrong. I don’t remember answering that many questions, but anyway, I passed.

Also the eye-test you do is amazing. None of this fancy machinery, no, they have a board hanging behind the counter, they ask you to read a few letters, close one eye, repeat, close other eye, repeat. That’s it. None of this struggling to make out vague squares, pressing your forehead up to try get closer.

Example of eye test board – source

When studying for the learners, at first I was a bit intimidated. The material is a 100+ page PDF referred to as the California Driver Handbook. I read it through once, then did some test questions. After getting a feel for the questions, I scanned through it again, memorised some values, and went and wrote the test. I got one question wrong.Unlike the SA learners test, the CA questions are much more straightforward, have more logical answers and were less less ambiguous. The material itself can also be read like a book, and not hard learned like the SA ‘pass your driver’s first time’ style books. And is set out for learning as opposed to the official eNATIS documentation, which is literally extracts from the National Road Traffic Act. The CA driver handbook explains the laws, why they exist, and goes on to give best-practices and consequences of not following the law (not getting a fine, but the direct result).It’s hard to say which is better. SA test makes sure you know the laws better, and sets a higher barrier to pass, but the material for the CA test was better, although the test was much easier. If you are under 18 years old, before you can get your licence you are subject to completing a driver’s ed course at school, and also a certain amount of hours driving (think 50 hours).

The driver’s test for CA is also easier. There is no pre-inspection like the SA one, you merely need to show that you know all the controls within the car: lights, hooter etc.

There is no yard test. That means no parallel parking, no alley-docking, no hill start, and no 3-point turn. At some stage during your behind-the-wheel test, you will be asked to pull up next to the curb and reverse three car lengths in a straight line. That’s as hard as it gets.

The on the road section is very similar to back home, with a list of actions you need to perform throughout the test, and a minimum amount of points you’re allowed to lose, with a list of instant fails. The test is slightly more relaxed, they are not as strict about order of things done. Handbrake never has to be used throughout the test. Push-pull steering method is lenient. You don’t need to check every mirror every time you do anything, but must check behind you when braking, check blind spots when turning, and constantly scan road.

You are only allowed to lose 15 points (compared to 120+ in SA), but the rules aren’t as strict. Personally I feel like it is an adequate test to ensure that someone can drive, and negates a lot of fluff in the SA test (although I understand the reasoning).

What I found funny out of the whole experience is that, besides the points I lost during the test, the only recommendation the tester had for me is that I drive too slowly. And that she hopes I will speed up in the future :)

Overall a relatively straightforward and painless experience, especially having already had a driver’s licence for almost 10 years.

Octane Ratings (in America)

Besides Americans calling petrol gas (and gas propane, diesel is still diesel (when you can find it)), their octane ratings are different to what I was used to. Back home (in South Africa), the standard octane rating at the coast was 95, and 93 at higher altitudes. If I recall correctly my Audi’s manual told me to always use the highest octane possible, but at least 91.

So I was quite surprised when going through our Tucson’s manual and came across the statement:

Fuel Grade: Pump Octane Rating of 87 or higher

This seemed oddly low to me. When we went to go fill up at the gas station in the US, we were greeted by a choice of Regular, Mid or Premium fuel. Referring to fuel with an octane level of 87, 89 or 91 respectively. Another surprise, as by the coast in SA, all you get is 95. No choice.

At the end of the day, it’s actually rather boring. Basically there are different ways to to calculate a fuel’s octane rating, and different countries use different methods. It can be summarised like this:

US shows the average of the Research Octane Number (RON) and Motor Octane Number (MON) rating, which is the Anti-Knock Index (AKI) while Europe just shows the RON rating which gives a higher number than the MON rating – source

If you want to know more about octane, spend two and a half minute’s of your life watching this guy’s video. If you want to know more about measurement methods, RON and MON, check out Wikipedia.

But what it boils down to is an 89 Octane in the US, is actually equivalent to around a 94 octane back home. You also have price discrepancies between fuel grades:

Fuel prices at our local garage

We are also fortunate enough to live in California, who have the second highest gas price in America, after Hawaii. At an average price of $2.80 per gallon (ZAR10.17 per litre), it is $0.70 more per gallon than South Carolina.

Gas prices also fluctuate tremendously within a city. In South Africa, petrol prices are basically fixed, meaning you pick a garage by convenience. In LA, I can pay anywhere from $2.60, to almost $4.00 per gallon! That makes petrol almost as expensive as in SA!