In this tutorial, you’ll learn how to take sensor readings from a Device and send readings to your Notecard and the Blues Wireless Notehub. You'll use CircuitPython running on a Feather wired up to Notecarrier-AL hardware. If you would like to use a different language, board, or Notecarrier, modify the dropdowns at the top of this guide.
The images in this guide use the Notecarrier-AL for reference, but this tutorial applies to the Notecarrier-AA and Notecarrier-AE. The Notecarrier-AE does not include pre-soldered female headers at its edge connector, so you'll need to add those headers before continuing.
If you get stuck at any point during this tutorial, the full source for each example is available in the note-tutorials GitHub repo.
First, you’ll need to get all of your hardware connected. Follow the instructions below to connect your Feather, BME680 sensor, and Notecard mounted on a Notecarrier-AL.
In order to complete this guide, you’ll need the following:
- Notecard mounted to Notecarrier-AL.
Any CircuitPython-capable Microcontroller (MCU) with Feather headers. We’ll be using the Adafruit Feather M4 Express, but any MCU with a CircuitPython bootloader and binary will do. If using a different device, be sure to follow the instructions for burning the bootloader and flashing the CircuitPython binary to your device.
Micro USB to USB-A cable.
Your sensor of choice. We’ll be using the Adafruit BME680, but you’re welcome to use any sensor and adapt the code in this guide to read from your sensor instead.
NOTE: For this tutorial, you’ll be powering the Notecard through the MicroUSB connection of your Feather. Some Feather-compatible devices cannot handle 2 Amp pulses from the Notecard when connected to GSM, so if you experience resets or other power-related issues, we suggest powering your separately through the USB or LiPo connector on the Notecarrier.
If you need additional help finding the correct I2C, Power, GND, and Serial pins on your Arduino, consult the Arduino documentation for your board of choice. The Arduino Nano 33, for instance, has the pin designations silk-screened on the bottom of the board, which makes it hard to find a pin while plugged into a breadboard.
So we consulted the pinout diagram here to make sure everytring was wired correctly.
First, let’s connect the BME680 sensor to your Feather.
Connect VIN from the BME680 Breakout to a 3-5V pin (for example 3V3) on your Feather.
Connect GND from the BME680 Breakout to a GND pin on your Feather.
Connect the SCK pin to the I2C SCL pin on your Feather.
Connect the SDI pin to the I2C SDA pin on your Feather.
Now, let’s connect your Notecard using a Serial connection.
Connect V+ from the Notecarrier-AL to the USB pin on your Feather.
Connect GND from the Notecarrier-AL to a GND pin on your Feather.
Connect TX from the Notecarrier-AL to the RX pin on your Feather.
Connect RX from the Notecarrier-AL to the TX pin on your Feather.
Now that your hardware is all connected, let’s create a new Notehub project to receive sensor readings from your Notecard.
Navigate to notehub.io and log-in, or create a new account.
Using the New Project card, give your project a name and ProductUID.
NOTE: The ProductUID must be globally unique, so we recommend a namespaced name like
Take note of your ProductUID. This identifier is used by Notehub to associate your Notecard to your project.
Now you’re ready to write some firmware. When communicating with the Notecard,
you can manually send requests using the Serial
write function and passing-in
JSON objects, or use the note-python library. The code snippets below show both,
so feel free to use the approach that works for you.
Now that you’ve configured your MCU to communicate with the Notecard, let’s grab sensor readings from the BME680. First, you’ll want to grab a few libraries to use to interact with the device.
Navigate to the CircuitPython site and download the library bundle for the version of CircuitPython you’re using.
Unzip the archive.
adafruit_bus_devicefolders and copy both to the
libdirectory of your
CIRCUITPYmount. If the
libdirectory doesn’t exist, you can create it.
Now you’re reading to take readings from the BME680. Start by adding an
importfor the library to the top of your
- Configure the I2C connection to your device and create a new instance of the sensor.
i2c = busio.I2C(board.SCL, board.SDA) bmeSensor = adafruit_bme680.Adafruit_BME680_I2C(i2c)
- Now lets take a reading. Add a
while Trueblock to your
code.pyif there’s not one already. Then take a temperature and humidity reading and print each to the console before sleeping for 15 seconds and repeating the process.
while True: temp = bmeSensor.temperature humidity = bmeSensor.humidity print("\nTemperature: %0.1f C" % temp) print("Humidity: %0.1f %%" % humidity) time.sleep(15)
Now that we’re getting sensor readings, let’s send these to our Notecard.
Once you start capturing readings, your Notecard will initiate a connection to Notehub and will start transferring Notes. Depending on signal strength and coverage in your area, it may take a few minutes for your Notecard to connect to Notehub and transfer data.
Return to notehub.io and open your project. You should see your notecard in the Devices view.
Now, click on the Events left menu item. Once your sensor Notes start syncing, they’ll show up here.
You’ve successfully connected your Feather and external sensor to your Notecard!
During this tutorial, you set your Notecard into
continuous mode, which
maintains an active cellular connection and enables faster syncs with Notehub.
It doesn't have much impact on data usage, but it will draw more power. If
you're connected to battery power, or want to transition your project to battery
power, then you can put your Notecard into
periodic mode with the following
request using the in-browser terminal or directly in your firmware.