Firmware

Now we need to program our microcontroller’s firmware so that it knows it’s a sensor (and not a toaster, media player, …).

Firmware is a program that is placed on non-volatile memory (memory that keeps it’s contents even without power) that can be directly accessed by the CPU when it first starts. Commonly this is ROM, EEPROM (Flash) memory. On a PC this is often called the BIOS or UEFI.

We’ll create our firmware using the Arduino programming environment.

But first, we’re going to set it up in such a way that we have both history, and the ability to collaborate via GitHub.

Create a GitHub Repo

Login to the GitHub website.

Create a new repository, call it something like MIZEnvSensor.

Clone the Repository to Your Computer

Run the GitHub desktop app.

Login to the app and you should see your online repository that you just created.

Clone that to your computer.

You should find a new directory (try looking in your Documents folder.)

Create a New Arduino Sketch

Start the Arduino IDE.

Create a new blank Arduino project.

Save this project- with a name like MIZEnvSensor but make sure you change the destination to be the folder you created with the GitHub Desktop app!

Check-in and Push Your First Commit

Switch back to GitHub Desktop.

You should see the changes you’ve just made (the addition of the empty Arduino project.)

Add a description of the change and commit it.

Then push the new changes to the GitHub website.

Go to the GitHub website and find the page for your repository- you should see what you’ve just added!

Add Your Code!

Go to https://github.com/MakeItZone/CommunitySensorsHardware and look in the Firmware folder.

Start with MIZEnvSensor1-Screen.ino (you can view it directly on the GitHub webpage!)

Copy the code into your Arduino sketch.

Don’t forget to save regularly!

Compile and upload it to your ESP32 LoRa board- check things are working!

When you’re happy, don’t forget to go to the GitHub Desktop app and commit your changes, and push them to GitHub!

Now look at MizEnvSensor2-addingBME280.ino and copy in the changes.

Suggestion: actually type out the code, rather than using copy & paste – at least for parts of it. Physically typing it out does help in both understanding and memorization!

Challenge

Although you don’t have GPS modules, look at MizEnvSensor3-addingGPS and see if you can understand how the display is managed to cycle between showing temperature and humidity and the GPS location.

See if you can create your own version that shows temperature, humidity, and barometric pressure as three separate screens!

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top