I had an idea to combine the new Arduino Nano 33 BLE Sense with an SD card and GPS module for a side project that logs GPS and IMU data.
I decided to purchase the Nano 33, the MKR Mem Shield, and the MKR GPS Shield and connect them all together. Unbeknownst to me at the time, these boards aren’t footprint-compatible, so I combined them with a breadboard 😐.
It took a little while to get all the libraries installed and everything connected appropriately. The biggest challenge was the GPS module. It really helps to start debugging the GPS’ example code outside; where satellite signal is available 😉.
Prototype CodeThe full Arduino sketch for the above connected system is here. But, might as well have a quick overview of the code. Throwing the imports and definitions below:
Next, we need to do all the GPS and SD card setup. The tricky part here was making sure to remove the DATALOG.csv
file every time we start up.
Now we can log all of the data to the SD Card. Note that we could use the Gesture sensor to stop and start recording (in the main loop).
So this is all fine and good. Prototype concept has been vetted! Time to build a custom PCB with the same functionality.
PCB DesignPCB design was definitely an experience, with a decent learning curve. I used easyeda to build my custom PCB. My first step was obtaining the schematics from the Nano 33, the MKR Mem Shield and the MKR GPS Shield. These were easy enough to find in the tech links and via Github. As they are Eagle schematic files, I downloaded the Eagle trial version to analyze in depth.
I basically copied the whole Nano 33 BLE schematic as is, including matching up the component names and numbers. I then added the GPS module (top center) and had to think about how to program via J-Link (top right):
Hoping for the best, I went ahead and sent off the design to PCBWay to be built and assembled. It was a decently smooth process, with some questions about a part name and orientation.
After a couple of weeks I got the plain PCB boards in the mail:
And a few more weeks later (6 weeks) I got the fully assembled PCB boards back!
I bought the J-Link EDU Mini cable to be able to program the custom board. I also installed all the J-Link drivers, etc. A similar tutorial can be found here.
You can find the Arduino bootloader.bin
binary file here:
/Users/<username>/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/bootloaders/nano33ble/bootloader.bin
I ended up flashing the bootloader via nRF Connect. Fingers crossed everything would work🤞.
And it did! An Arduino Nano would pop up and connect to my MacBook when I plugged in the USB cable.
Turns out I had made a few mistakes in my reverse engineering, though.
- The Nano 33 schematic has a Do Not Populate (DNP) for a pull up resistor on the RESET pin. I should have added test points for this resistor as well. I ended up hand-soldering a 4.7K. This stopped my board from auto-resetting every second (could also adjust the UICR to disable the RESET pin).
- The schematic shows a 1M Ohm resistor connecting the USB shield to ground. But the Eagle file shows 330 Ohm — should be 330 Ohms. There is tons of debate and trade-offs here.
- I messed up a wire with the gesture sensor, so that didn’t work. However it still measured RGB colors.
I ended up fixing these issues. To make this device portable, I added a battery connection and LiPo charging, as well as load sharing. I also added a 5V and 3.3V power rail to power external devices.
Having learned from more research, I decided to add more decoupling capacitors and various connectors (including GPIO).
I sent the new design with a more compact PCB layout to PCBWay! Currently waiting on those boards to get back 😎.
Comments