Gerrit Niezen

Maker of open-source software and hardware.

Feature image

I'm taking a break from my USB host shield on Espruino series, as my hack week ended and I now have to find time in the evenings and weekends to continue working on it.

I've been blogging every day for more than 5 weeks now, so I wanted to receive an automatic reminder if I haven't posted anything by 20:30 in the evening. I while back I was using the app Streaks to keep track of daily habits, so I decided to reinstall it on my phone to use for this purpose.

I took inspiration from Federico Viticci's[1] post on exercise, mindfulness and gratitude where he mentions using Streaks to start using it again. I've got four habits on Streaks at the moment:

  • Write blog: If I don't complete this task before 20h30, I get sent a notification reminder.
  • Walk 12k steps: If I walk at least 12 500 steps per day, I get the maximum 8 Vitality[2] points. This is linked to Apple Health, so gets updated automatically.
  • Work out for 30 minutes: If I run for at least 30 minutes, I also get the maximum 8 points. This is also linked to Apple Health. Note that I either get points for running or for walking, not both.
  • Read for 10 minutes: I try to read for around 30 minutes in the evening, but set the bar a bit lower for being able to complete this habit every day. I'm not always successful ;)

  1. He's the guy behind MacStories. ↩︎

  2. life insurance and health insurance ↩︎

Comment on this post

Feature image

A week ago I wrote about getting the USB host shield working on Arduino. This week it's my Tidepool hack week, for which my goal is to get the USB host shield working on the Espruino Pixl.js, so that I can build a USB-to-BLE bridge.

After plugging in the USB host shield into the Pixl.js, I had to figure out how the pins were mapped. This was easy enough, as the Sparkfun website has a schematic for the shield that shows the pin mappings:

mappings

So now we know the SPI pins are on D10 to D13. The SPI setup to talk to the board is as then simple as:

SPI1.setup({mosi:D11, miso:D12, sck:D13, order:'msb', baud: 26000000});

The order and baud parameters can be found by looking at the Arduino library's usbhost.h file. On Espruino, SPI mode 0 is the default mode.

To properly read values from the chip took me longer than necessary, as I didn't realise you have to send a second empty byte when reading a register:

function readRegister(register) {
   const result = SPI1.send([register, 0x00], D10);
   return result[1];
}

Note that we have to specify the SS pin D10 as the second parameter to the send command, and that the result is returned in the second byte that is returned. So now reading the revision of the chip you have can be done using:

console.log('Revision', readRegister(0x90));

Now were do we get the 0x90 from? If you have a look at Table 2 in the MAX3421E datasheet, you'll see that register 18 contains the chip revision number. According to the MAX3421e header file in the Arduino library, 0x90 is 18 shifted left by three bits. I still have to figure out why it has to be shifted.

If you enter the above command on the Espruino command-line interface, it should return the chip revision number – 19 in my case. This is 0x13 in hex, where the 3 is indicating it is the third revision. Version 1 is 0x01 and version 2 is 0x12.

#Electronics #Tidepool

Comment on this post

Feature image

As it's Sunday and we've been having really great weather here in Wales lately, I spent most of the day in the garden and on the beach and not in front of the computer. This means there's no new code today, but I did want to jot down a few notes on why I decided to use a USB host controller chip (and not a Raspberry Pi) for connecting to USB devices.

I think it would be pretty easy to connect to USB devices from the Raspberry Pi's USB On-The-Go (OTG) port, and there are existing USB drivers for most serial port chips in the Linux kernel. The Pi Zero W also has Bluetooth LE and WiFi, so you can transmit data read from the USB device to a server or to a phone.

I guess I am looking for a bit more of a challenge and want to answer the question: Can a bare-metal approach to connecting USB devices work more reliably than building something on top of an operating system? Since the USB controller chip lets me develop both my own USB stack and USB drivers without having to mess around with an operating system, I'm hoping that it will result in something more reliable than the sometimes flaky USB support on desktop computers.

Modern computers are optimised for USB 3, with USB 2 support usually quite buggy, especially on new MacBooks. Many diabetes devices are still USB 2, due to the long product life cycles of medical devices, so not having good USB 2 support can be a problem.

Of course, there is power consumption as well. A Raspberry Pi consumes a significant amount of power compared to a little microcontroller with a USB controller chip. I want to see if I can build something that runs off a small LiPo battery, or maybe even a couple of coin cell batteries, that can eventually fit into a small dongle form factor. Let's see what happens.

#Electronics #Tidepool

Comment on this post

Feature image

Hey, I made it one month with blogging every single day! I told myself that I could buy a professionally designed theme for my blog if I made it through the month, so except to see some design changes in the next couple of days.

In some ways it has been much easier than I expected. The only downside is that feeling when I realize late in the day that I still need to write something. Let's see if I can continue to write every day for another month.

Comment on this post

Feature image

We just got a Sammy Screamer motion sensor from Bleep Bleeps. It's a small alarm that you can attach to your baby's stroller, bag or other valuables. You turn it on and off via an app, and it sends you a notification when it goes out of range.

It was the first in a series of connected products made for parents from Bleeps Bleeps. Their second product, Suzy Snooze, is a baby monitor and sleep trainer. They also just launched Benjamin Brush, a smart musical toothbrush.

I first got interested in Bleep Bleeps when they released one of their first designs, a baby ear thermometer, as an open-source hardware design. I can't find it online anymore, but I still have the enclosure that I 3D printed. I never got around to buying and installing the electronics though.

I hope that Bleep Bleeps does well. It's hard being a small company that manufactures hardware, and they've been setting a good example so far.

#Making

Comment on this post

Feature image

A Dutch technology podcast I enjoy listening to, De Appels en Peren Show, mentioned in one of their episodes that it's possible to see the first apps you ever downloaded on your iPhone or iPad in the App Store.

If you go to the App Store, tap on your profile in the upper right corner and tap on Purchased, you can see all your purchases and downloads back to the first day you got an iOS device.

For me it was on 23 July 2010, and these are the first ten apps I downloaded:

  1. Nu.nl – A Dutch online newspaper that I still use on my iPad today.
  2. Flipboard – Provided a novel way of reading articles and blogs made specifically for the iPad. I now use Feedly instead.
  3. Wired – I stopped reading Wired after I realised that they really don't know what they're talking about.
  4. Dropbox – Yep, still using it.
  5. Google Earth – Removed it as just using Google Maps is fine.
  6. Evernote – Stopped using Evernote as Apple Notes work fine too.
  7. Read It Later – renamed to Pocket, and yes, I still use Pocket.
  8. Epicurious – Was nice to get recipes, but nowadays it's easier to just google a new recipe.
  9. NYTimes – Don't think I used this for long.
  10. Kindle – Yep, still using it.

So, still using four out of the first ten apps I ever downloaded. Not bad.

Comment on this post

Feature image

I've been looking for a LoRa module since I helped to install the first Things Network gateway in Swansea:

Today we installed the first @thethingsntwrk gateway for our region. We are actively contributing to the 100% open source #IoT network 😎 #ThingsConnected #Swansea #LoRaWAN #geeks pic.twitter.com/duQKy0WwWb

— TechHub Swansea (@TechHubSwansea) May 29, 2018

The Things Network is an open, community-built network using LoRaWAN technology, which allows for long-range (up to 10km) low-power wireless communication without needing a special license or monthly subscription.

This morning I saw a tweet from Tod Kurt (maintainer of the excellent node-hid Node.js library):

Cool ESP32-based LoRa module w/display for $26! as described by @VinduinoReinier at @hackaday meetup @SupplyframeDL https://t.co/CZ9vz2uPZP

— Tod E. Kurt (@todbot) June 29, 2018

The ESP32 is the successor to the ESP8266 microcontroller and contains a 32-bit microcontroller with both WiFi and Bluetooth LE. Add LoRa and an OLED screen and this is a very impressive package for less than £20. Compare this to The Thing Network's own Arduino-compatible Things Uno that only has LoRa and costs more than double the price.

I had a quick look at The Things Network forums and it looks like a lot of people are already using these, as they were released towards the end of last year. There seems to be some antenna issues, but that these can probably be fixed if you do need longer range.

#Electronics

Comment on this post

Feature image

In a previous post I started playing around with Bluetooth LE on blood glucose meters. This post is a quick look at Bluetooth LE's diabetes device profiles.

Bluetooth LE is an open specification, meaning anyone can download it from the website and read it, compared to most ISO standards where you have to pay and arm and a leg just to read the spec[1]. So I started by looking through the list of Bluetooth profiles to see which ones are specific to diabetes.

There is a Glucose Profile (GLP) for blood glucose meters and a Continuous Glucose Monitoring Profile (CGMP) for continuous glucose monitors. However, it looks like the Insulin Delivery Profile (IDP) is still under development, as the only public mention I can find on it is in their list of acronyms. I did however, find a medication field in the Glucose Profile, so if you want to record the insulin dose as part of a blood glucose measurement, that should work without having to wait for the Insulin Delivery Profile to be released.

I tried to see if I could find out what the progress of the Insulin Delivery Profile was. However, to do that it looks like you have to join the Medical Devices working group, and to do that you need to be an “Associate or Promoter” member. That costs $7.5k/year if your annual revenue is less than $100 million. Probably worth it if you want to influence what the standard looks like, but not worth it if you're just looking for some info. Hey, if you know the current status of the Insulin Delivery Profile, please get in touch! ;)


  1. or proprietary specs, where you usually have to set up a partnership and sign an NDA to read it ↩︎

#Tidepool

Comment on this post

Feature image

A week ago I wrote about building a USB host to Bluetooth LE bridge. I then ordered a Sparkfun USB Host Shield from one of the UK distributors, CPC Farnell.

The shield doesn't come without any headers, which prompted me to start organising the electronic components I have at the Swansea Hackspace, as I knew I had a spare set of headers there. I managed to find the headers last week, and soldered them on at the hackspace last night.

This morning I wanted to see if it works, so I plugged it into my old Arduino Duemilanove, released in 2009 and still going. I installed the USB Host Shield Arduino library[1] and loaded up the board_qc self-test sketch. The Arduino sketch uploaded without any problems. On the shield, I first had to connect the D7 pin to the RESET pin[2]. Also, note that there is a little power switch on the shield that you have to turn on ;)

The self-test ran without any issues. Note that to skip the GPIO test, you have to enter any character into the serial monitor and press Send. You also need to have a USB device (like a keyboard) connected during the self-test. As part of the self-test it connects to the device and displays the USB descriptor in the serial monitor. Very cool!

I then loaded up a HID keyboard sketch, and it worked flawlessly! I was able to type letters on the keyboard connected to the shield and see them appear in the serial monitor. It's pretty impressive that I could just plug a shield into a piece of hardware almost a decade old, load some code on it and it just works. Open-source hardware FTW!

usbShield2

If you'd like even more details on getting started with the USB host shield, see this great tutorial.


  1. See the README file for how to install the library ↩︎

  2. Why? I have no idea, but it was mentioned in the comments on the Sparkfun website ↩︎

#Electronics

Comment on this post

Feature image

I was listening to my “Discover Weekly” playlist on Spotify this morning, when the song Open Door Policy by Beans on Toast started playing. I've never heard of him before, but I feel like the song summarises this moment in time pretty well.

The world is dying
Shit is getting serious
Everybody's lying
It's impossible to tell the truth
It's worry, worry
Worry, worry
Worry, worry
Worry, worry
All the time
That don't solve anything
I never used to be the worrying type
But I'm not exactly sure
What I'm supposed to say
When it feels like Armageddon
Is a stone's throw away
And everybody voted for the greedy in charge
Well if this is a fight
Then maybe we lost
But, me I'm a pacifist
Eternal optimist
I'll keep on singing
Stating the obvious

Simple subject matter
Over-analysing a cup of tea
Where did the milk come from?
I bet it was a tragedy
There's Fluoride in the water
It's blurring the vision of my third eye
But still I put the kettle on
What a time to be alive

And I'm not even sure
If the facts are true
Cause I'm constantly bombarded by so many points of view
And, I am my own propaganda machine
I believe what I believe I am supposed to believe
And I'll believe in anything
So show me everything
I'm dancing like a puppet
Not knowing who is pulling the strings

Dark money and big data
And the mass manipulation of the human race
Advertising's Frankenstein
Knows me better than I know myself
Every website that I visit
Every bit of porn I watch
And every shred of news I read
They analyse, hypothesise
Then use it as a weapon
To brainwash me

And now I'm almost convinced
That all the news is fake
But I've been staring at the screen so much
That I fucked up my neck
And, I am my own propaganda machine
I believe what my computer
Wants me to believe
Oh, I sit and stare at it
Think I'm above that shit
Hook, line and sinker
Fell for the internet

It was always gonna happen
The robots are coming now to take our jobs
3D printers printing 3D printers
3D printers printing jails and guns
Well this car needs a driver
And these brains need reality
Not just a phone strapped to your face
While immersing yourself
In a world of make-believe

But I've kind of come accustomed
To the, 360 view
Because it's almost realistic
And kind of believable
And, I am content as long as I am entertained
And walking off a cliff is one hell of a game
So, I'll put my headset on
Say “See you later folks”
I can't even hear you while you're
Stating the obvious

But what is life if not
A brilliant barricade of obstacles
I'll carry a stranger's bag down the stairs
But I can't carry the weight of the world
And so I watch the flowers grow
And I listen for the beauty
As it shines from in-between the gaps
There's a light at the end of the tunnel my love
So don't you ever give up

And they've discovered seven planets
Orbiting a distant sun
They are light years away
But they remind us of home
They remind us to hope
They remind us to dream
And all the wonderful things
Human-beings can achieve
So, quit your worrying
Start your partying
One door is closing
And another one is opening

#Music

Comment on this post

Enter your email to subscribe to updates.