STEMMA QT devices with production arduboy

So I’ve been trying to use some I²c sensors from adafruit with one of my arduboys after adding a stemma qt connector. I can get the examples to work, but I can’t seem to use them with the arduboy lib unfortunately. However, I’m wondering if I could still draw graphics to the screen using a separate library for the display. I’ve tried adafruit’s SSD1306 library, changing the default SPI pins to the ones the screen is connected to on the production arduboy, but to no avail. It does seem to attempt to interface with it, as the screen is blanked, which is not the case when uploading a sketch that doesn’t update the display. But no graphics are displayed.

Anybody have ideas for where to go from where? would love to use an arduboy as a little modular sensor meter, even if I couldn’t interface it with games or the arduboy lib itself.

What makes the production arduboy’s SSD1306 different than a genuine SSD1306 module? I assume there must be something slightly different, otherwise the adafruit lib should “just work”.

1 Like

That’s probably because I2C hardware is powered down in BootPowerSaving()

Try this:

1 Like

No such luck. Here’s what I uploaded:


#include "Adafruit_APDS9960.h"
#include <Arduboy2.h>
Arduboy2 arduboy;

//create the APDS9960 object
Adafruit_APDS9960 apds;

void setup() {
  arduboy.begin();
  PRR0 &= ~_BV(PRTWI); 
  //enable proximity mode
  apds.enableProximity(true);

}

void loop() {
  if (!arduboy.nextFrame()) return;
  arduboy.clear();
  arduboy.println(apds.readProximity());
  arduboy.display();
}

And the result, a bootloop:

Actually, that one seems specific to the APDS9960, your tip did allow me to interface the bh1750 ambient light sensor!

Okay I tried arduino’s official lib (cuz apparently that’s a thing now) for the APDS9960 and it’s working wonderfully! Here’s the basic code I used for the proximity sensor:

/*
  APDS9960 - Proximity Sensor

  This example reads proximity data from the on-board APDS9960 sensor of the
  Nano 33 BLE Sense and prints the proximity value to the Serial Monitor
  every 100ms.

  The circuit:
  - Arduino Nano 33 BLE Sense

  This example code is in the public domain.
*/

#include <Arduino_APDS9960.h>
#include <Arduboy2.h>
Arduboy2 arduboy;
int proximity = 0;
void setup() {
  arduboy.begin();
  arduboy.clear();
  PRR0 &= ~_BV(PRTWI);
  if (!APDS.begin()) {
    arduboy.println("Error initializing APDS9960 sensor!");
  }
  arduboy.display();
}

void loop() {
  // check if a proximity reading is available
  if(!arduboy.nextFrame()) return;
  arduboy.clear();
  if (APDS.proximityAvailable()) {
    // read the proximity
    // - 0   => close
    // - 255 => far
    // - -1  => error
    proximity = APDS.readProximity();

    // print value to the Serial Monitor
  }
  arduboy.print(proximity);
  arduboy.display();
  // wait a bit before reading again
  delay(100);
}

If you’ve installed the homemade package try selecting standard Arduino core and see if that helps


Didn’t notice your last post. Good to see the Arduino lib works :+1:

1 Like

Got it to work with Ardubreakout! Honestly a pretty fun interface. I could probably do better with the code, it’s jumpy towards the left side of the screen because the way I’m controlling it is just xPaddle = proximity/2; and proximity goes from 0(closest) to 255 (furthest). It’s crude but it works!

1 Like

Now you should use it to make an Arduboy theremin :musical_score::notes:

1 Like

Oooo great idea! I’ve done something similar using the A4 pin’s EM interference after seeing someone else do it and not being able to find the sketch later. It should be pretty easy to adapt, I’ll post it here when I get it set up :grin:

This produced some interesting results from the way the piezo works at different frequencies, the lower ends sounding like dial-up tones and old ringtones!

Here’s the simple code I used, I’ll probably do some more tweaking for a better graphic visualizer:


#include <Arduino_APDS9960.h>
#include <Arduboy2.h>
Arduboy2 arduboy;
BeepPin2 beep;
float frequency = 523.251;
int proximity = 0;
int preprox;
int rectY = 0;
int rectX = WIDTH/2;
int rectSize = 1;
void setup() {
  arduboy.begin();
  beep.begin();
  arduboy.clear();
  PRR0 &= ~_BV(PRTWI);
  APDS.begin();
}

void loop() {
  // check if a proximity reading is available
  if(!arduboy.nextFrame()) return;
  arduboy.clear();
  
  if (APDS.proximityAvailable()) {
    // read the proximity
    // - 0   => close
    // - 255 => far
    // - -1  => error
    proximity = APDS.readProximity();
    
    // print value to the Serial Monitor
  }
  rectSize = proximity / 5;
  frequency = proximity;
  beep.tone(beep.freq(frequency));
  if (rectX + rectSize <WIDTH) rectX = proximity/2;
  //rectY = proximity/4;
  //arduboy.print("Proximity: ");
  arduboy.fillRect(rectX, rectY, rectSize, rectSize);
  //arduboy.println(proximity);
  arduboy.display();
  //delay(100);
}
3 Likes

I saw this on twitter! I really like the idea of having add on boards and expansions but I never could figure out an elegant way to do it with the size of the product.

1 Like

STEMMA QT is the way to go! It’s a teeny-tiny 4 pin i2c connector, perfect for the edge of PCBs. Adafruit makes tons of stemma qt breakout boards (mostly sensors) that can be daisy-chained together using the qt connectors, it’s really neat

This is great. @bateske can we have a production version of this please :slight_smile:

1 Like


SHTC3 Accurate Temp and humidity sensor! A little portable weather station

2 Likes

The interchangeable module approach is very interesting. I started using it for ESPboy about a year ago and so far I have about 30 different extensions and code for it. Simple things like a digital tape measure or weather station, but also more complex things like GSM phone, GPS navigator, LORA messenger, radiation meter, Web radio, FM radio, CW radio beacon, smart ice fishing rod and many more. There are some demonstrations on youtube and code on github. I think almost everything can be replicated on the Arduboy.

1 Like

Do all the modules use the same sort of pin interface (SPI or I2c etc) or is each on ea little different? Are they chainable like adafruit’s sensor modules? if not, do you think they could be modded as such?

Different modules can use different SPI, I2c, i2s, UART interfaces. Sometimes even additional pins are used. Theoretically, it is possible to chain the modules, providing, of course, the limitations of each particular interface for such operation and carefully considering it in the code. However, in my opinion, this complicates the idea. For example, the LORA messenger module has a redundant expansion slot and an additional keyboard module can be connected there.

1 Like

That’s pretty cool!! Having different interfaces is definitely interesting design that allows you to do more kinds of modules. The STEMMA QT breakouts are all I2c which is great for sensors and chaining them together, but can’t really do more complex modules like some of the ones you’ve made for espboy

1 Like

I really like the idea of adding an externally accessible communication port to the arduboy so it can interface with other devices or add functionality. I can imagine people connecting an arduboy as a general hardware user interface to control or monitor other hardware (like having an arduboy show 3d print progress wirelessly for octoprint, act like a little serial terminal for sbc’s, maybe an ir tv controller add on).

2 Likes