Introduction: HackerBoxes 0016: Cellular Metal
CELLULAR METAL: This month, HackerBox Hackers are exploring cellular mobile communication for embedded IoT (Internet of Things) and M2M (Machine-to-Machine) systems. We are also exploring the beauty of working close to the bare metal of a computing machine.
This Instructable contains information for working with HackerBoxes #0016. If you would like to receive a box like this right to your mailbox each month, now is the time to subscribe at HackerBoxes.com and join the revolution!
Topics and Learning Objectives for this HackerBox:
- Compiling and Uploading Code onto an Arduino Board
- Connecting a GSM Mobile Radio Module to an Arduino
- Communicating on a Global Mobile Cellular Network
- Building a Breadboard-Based Arduino from Scratch
- Using an Existing Arduino as a DIY In-System-Programmer
- Exploring an Online Microcontroller Course
- Implementing a Minimal 8-Pin ATtiny Arduino
- Dropping Down into Assembly and Machine Languages
- Considering Machine Architecture through Assembly Language
HackerBoxes is the monthly subscription box service for DIY electronics and computer technology. We are hobbyists, makers, and experimenters. And we are the dreamers of dreams.
Step 1: HackerBoxes 0016: Box Contents
- HackerBoxes #0016 Collectable Reference Card
- Hologram Global IoT/M2M SIM Card
- SIM800L 5V GSM Module with Rubber Ducky Antenna
- RobotDyn Arduino UNO R3 Microcontroller Board
- CP2102 MicroUSB-Serial Module
- Solderless Breadboard
- 65 Piece Jumper Wire Set for Breadboard
- ATmega328P 28-Pin DIP Microcontroller Chip
- ATtiny85 8-Pin DIP Microcontroller Chip
- Various Discrete Components for Breadboard Arduino
- Various Discrete Components for Microcontroller Course
- Exclusive Tux "Hack The Planet" Stress Toy
- Exclusive Apple Hacker Fan Art Decal
Some other things that will be helpful:
- Soldering iron and solder
- Computer for running development tools
Most importantly, you will need a sense of adventure, DIY spirit, and hacker curiosity. Hardcore hobbyist electronics aren't always easy, but when you persist and enjoy the adventure, a great deal of satisfaction may be derived from persevering and getting your projects working. Just take each step slowly, mind the details, and don't hesitate to ask for help.
Step 2: Setting Up the Arduino UNO
Arduino Veteran:
If you are already up to speed with using an Arduino UNO, already have the Arduino IDE installed, and already have the CH340 USB driver installed, you can skip to the next step. However, you should probably at least plug in your UNO and make sure you can compile and upload an example (such as blink.ino) just to make sure everything is ready to go.
Less of a Veteran:
Check out Step 12 of the instructions for the HackerBoxes Starter Workshop. There, you will find an overview of the Arduino ecosystem, the RobotDyn UNO in particular, and most importantly details on installing the CH340 USB drivers.
Next, proceed to Step 13 of the instructions for the HackerBoxes Starter Workshop. There, you can grab a free copy of the Introduction to Arduino book by Alan Smith, Install the Arduino IDE, wire up your first Arduino circuit, and write your first Arduino program.
Optional Extra:
Continue on to Step 14 of the instructions for the HackerBoxes Starter Workshop to explore the world of Arduino even further. The components in this HackerBox #0016 happen to include everything needed to work through section 3.2 of the book. This is worth doing if you are new to Arduinos. You may also want to look at section 5.1 to learn about the serial monitor. While it is well beyond the scope of this current Instructable, the components for the remaining chapters list in Step 14 are included in the HackerBoxes Starter Workshop.
Step 3: Wire Up the SIM800L Module to the Arduino UNO
Of course we've all had times when we would like to have a project communicate over the cellular communications network. Sometimes Wi-Fi is not available or just doesn't have enough range.
For example, maybe you want your project to send you a text message when a sensor is triggered. Or perhaps it needs to report data to another system from various mobile locations not serviced by Wi-Fi.
The SIM800L module (datasheet) is a great solution. It has a quad-band radio (850/900/1800/1900MHz) supporting 2G Global System for Mobile Communications (GSM) including data packet transport via General Packet Radio Services (GPRS).
The SIM800L can be simply wired to an Arduino UNO as shown here. The SIM800L is fairly easy to control using an AT command set or function from an existing library. Examples for both of these options are outlined in this quickstart tutorial.
As a first step, you might want to wire the SIM800L to the Arduino without the antenna feed line or the SIM card, just to make sure that you can get a response to an "AT" or an "AT+CFUN?" command. In the next step we will move on to using the SIM card.
Reference Links:
Step 4: Hologram - the Global IoT SIM Card
HackerBoxes is very excited to partner with Hologram to bring you this ready-to-use, global IoT/M2M SIM along with a $5 promotional balance.
To mitigate the various challenges in putting your project or product online anywhere, Hologram has built a global SIM and cell network built for IoT and M2M data with simple activation and transparent pricing. The Global Hologram Cellular Network support connectivity in over 100 countries allowing us to connect our IoT devices seamlessly from one country and carrier to another.
Follow the links here to activate your SIM. You will see a link to "Apply Promo Code" where you can enter the activation code: HACKERBOX5.
The Hologram SIM card is a triple SIM. Be sure to only pop out the microSIM, which is the size used by the SIM800L modules.
Hologram has put together a wonderful Cellular IoT Tutorial and library that leverages the components in this HackerBox. Definitely check it out!
Step 5: Bare Metal
Programming on the "Bare Metal" or "Near the Metal" or "Close to the Metal" is defined by Wikipedia as programming a machine without an operating system, which is a bit of an over-simplification. After the development of programmable computers, which did not require physical changes to run different programs, but prior to the development of operating systems, programs were fed to the computer system directly using machine language by the programmers without any system software support. This bare metal approach bootstrapped the development of operating systems. Modern operating systems evolved through various stages, from quite elementary to the present day complex, highly-sensitive, real-time systems.
Today, bare metal work is mostly applicable to embedded systems and firmware, while everyday programs are executed by a runtime system within an operating system. That said, even the Arduino platform that has become almost ubiquitous in the embedded world, uses a bootloader and various libraries to abstract us away from the metal of the AVR microcontroller. It is time to dig deeper.
Step 6: DIY Arduino From a Bare AVR Micrcontroller Chip
Starting with a stock (completely blank) ATmega328P chip, you can do some amazing things. This the same chip that is used on the Arduino UNO R3 boards. The ATmega328P is a high-performance 8-bit AVR RISC-based microcontroller. It combines 32KB ISP flash memory with read-while-write capabilities, 1024B EEPROM, 2KB SRAM, and 23 general purpose I/O lines.
Take a look at the schematic shown here with the components needed from the HackerBox.
This video tutorial from PyroElectro shows how to wire up a DIY Arduino on a breadboard from components.
Notice that the schematic we are using here has a slight variation from the one in the video. While the video shows use of a battery and a regulator circuit as the power supply, we are simply using the 5V supply from the Serial-USB module. The Serial-USB Module uses the CP2102 bridge chip. If you do not have drivers installed for this chip, they may be found here.
Another important difference is that the video tutorial assumes that the ATmega328P chip already has an Arduino bootloaded burned onto it. Since we are starting from a blank chip, we will need to need to program the bootloader onto the ATmega328P chip. We can use the UNO as an In System Programmer (ISP) as shown under the Burning The Bootloader heading on this page.
Step 7: Online Course for Microcontrollers From PyroElectro
The PyroElectro video in the last step is actually just one part of an entire ten lesson online course covering microcontrollers. You may wish to work through the other lessons as well. You have all of the necessary components in HackerBox #0016 to do these lessons aside from some of the extra "user interface" components used in lesson 8. As an added exercise, see if you can replace these hardware interface elements with a user interface leveraging the serial monitor.
Lesson 10, AVR vs Arduino, covers precisely the "bare metal" issue we are addressing here, so we definitely recommend that you at least watch the video for Lesson 10.
Much respect for the work done by PyroElectro on these lessons.
Step 8: Minimal Arduino With the 8-pin ATtiny85
The ATtiny85 is a great option for running simple Arduino programs. It’s small, cheap, and relatively easy to use. Compared to the ATmega328P (from the Arduino UNO), the ATtiny85 has fewer pins, meaning you can’t connect as many components. It has less flash memory (8KB instead of 32KB), meaning your programs can’t be as big. It has less RAM (512 bytes instead of 2KB), meaning you can’t store as much data. And there’s no hardware serial port or I2C port, so communication can be a little trickier. However, if your project requires only a few simple inputs and/or outputs, you’re probably fine using an ATtiny85.
This tutorial from High-Low Tech can show you how its done!
Step 9: Assembly Language for AVR Microcontrollers
Now that we've used bare AVR micros to build up DIY Breadboard Arduinos, we can go a step further and drop down to writing machine code directly on the chip. This is an advanced topic, but there is no better way to learn the deep details of how processors work. Luckily, there is an entire online book covering the subject of AVR Assembly Programming.
Note that you can also embed inline assembly code within a traditional Arduino program when added efficiency or tight execution is called for.
Further down the rabbit hole, you might want to explore more of a general or academic view of assembly/machine programming and how it relates to the underlying computer architecture. If so, check out the CMU lectures on Computer Architecture or the lectures and slides for CS24 at Caltech.
Step 10: Hack the Planet
Thank you for joinging our adventures into mobile cellular IoT/M2M communications and bare metal computing. If you have enjoyed this Instrucable and would like to have a box of electronics projects like this delivered right to your mailbox each month, please join us by SUBSCRIBING HERE.
Reach out and share your success in the comments below and/or on the HackerBoxes Facebook page. Certainly let us know if you have any questions or need some help with anything. Thank you for being part of HackerBoxes. Please keep your suggestions and feedback coming. HackerBoxes are YOUR boxes. Let's make something great!

Participated in the
Microcontroller Contest 2017
71 Comments
6 years ago
My box contained two "220" ceramic caps instead of the "22" indicated in the tut and images. If I use these 220 in place of the 22 is this going to hurt my board or PC? If so is it possible to mail me the 22's I was supposed to receive? My local Radio Shaq doesn't carry 22's so this is mildly inconvenient for me.
Reply 6 years ago
Those should be 22pF caps which should be correct for the timing crystal.
http://m.wikihow.com/Read-a-Capacitor
Reply 6 years ago
These are the caps that came with my package in place of the 22pF.
Reply 5 years ago
This confused me as well, apparently 22pf capacitors can be marked either 22, or 220.
http://www.elecraft.com/Apps/caps.htm
Reply 6 years ago
Those look like 22pF caps to me :)
Reply 6 years ago
To clarify, youve got the correct parts. ?
6 years ago
I'm not sure what the issue is, I've done both the HackerBox way and jasper_fracture's way, and I can't get it to send an SMS. Every AT comes back as OK and it has good reception and connectivity and all that happy blah blah blah.The power is hooked up externally from my PC, not through the USB port. In the Serial Monitor I get an error after inputting /032 from the jasper tutorial, but I get the SMS Sent! from the HackerBox one. I'm lost, frustrated, annoyed. Yes, I'm putting my personal cell number in the code...
Reply 5 years ago
Hi Grant -
Regarding my tutorial, it sounds like you might have an incorrect setting in the Serial Monitor. Check out the subreddit thread at: https://www.reddit.com/r/hackerboxes/comments/61sj...
Can't guarantee it's the exact same problem Anand was having, but it sounds similar.
Good luck with it. :)
Reply 6 years ago
I am in the same boat. Everything acts like it should send normally, I get an Error in the same spot as you. So I found some info on getting more than just "Error" put AT+CMEE=1 or 2 for verbose error output with an error code. Then try your sending again.
AT+CMEE=1
OK
AT+CMGS="1###"
> HELLO
>
+CMS ERROR: 2172
Reply 6 years ago
Allow me to share the burden of frustration my brother! ;)
I have been struggling with the same issues where I've finally got to the point where everything appears to be sending correctly from the GPRS module but I could not see anything on the Hologram Dashboard to corroborate that anything was being sent.
Yesterday, I noticed that my Hologram card account balance was dropping which led me to the billing section of the Dash. I can see the transactions that prove that I am communicating to Hologram correctly but I am not receiving these text messages. I'm pretty DANG happy that I at least see the transactions but the text message would be nice too.
You should verify in the billing details too. It may bring clarity.
All the best!
Sean
Reply 6 years ago
I just saw this in the Hologram Community Forum. This might help!
https://community.hologram.io/t/sim800l-connection-problems-with-hologram/609
6 years ago
I have an issue, and according what I was reading is the power issue, the D2 light just keeps hold for a little, it blinks every 5 seconds, so I guess I'll need a external power supply. thanks to @jasper who made a lot better tutorial that the one here.
Well, likes last one, a lot of little issues. Not really exited by this last two boxes, hope next one be better.
Reply 6 years ago
Hi Martinez -
Thank you!
You may have a problem with cell reception. Try the AT command: AT+COPS=?
It should return something like: +COPS: (2,”T-Mobile USA”,”TMO”,”310260″),,(0-4),(0-2).
If you get something like: (0-4),(0,2), I think you might have reception issues.
Reply 6 years ago
I'm going to try this tonight, thanks for the answer. Quick question, when I activate the hologram I choose region 1, do you think is better option choose region 2? I'm on the United States and both shows in the map.
Reply 6 years ago
I'm really not sure on the zones. Hologram has a "Live Chat" feature on their website which would probably get you fastest answer. If you're in a rural area like me, reception might be a problem until you get closer to a tower that the SIM800L can work with.
Also, if you have a big cap like a 470uF, try putting it across the power rails supplying the SIM800L. That really seemed to help me. Either way, good luck with it - be interested to hear if you get it working.
6 years ago
OK this is driving me nutz!!! It's not connecting to the cellular network it seems. I activated the SIM ok. I have everything wired properly. I tripple checked wiring and code. Then I ate a Nutty Bar and checked it again! AT command responds "OK"
But - AT+CREG? = 0. I assume that's meaning its not connected. The Hologram Dashboard doesn't show any data either.
Reply 6 years ago
Was this ever resolved? Having the exact same issue.
Reply 6 years ago
I got this response from Ryan @ Hologram as the proposed fix. I have been so busy I have not had a chance to try it myself. I hope to give it a whirl within the next few days and will post my results back here.
Hi @TimGTech
For some reason the SIM800 sent requires a SMS config. This blog post explains the steps http://www.smssolutions.net/tutorials/gsm/sendsmsat/
Basically run this command: AT+CSMP=17,167,0,16 . The post explains things in more detail.
If you could try this, then we can go from there. @benstr
Thanks,
Ryan
Reply 6 years ago
I saw that answer on their forums and i tried it with no success. I opened another topic with hologram to see if i can get any success. It is strange I can receive sms fine but I cant send any.
Reply 6 years ago
Hey Tim, what does `AT+COPS=?` return?