This is an old revision of the document!
The Oak is packed with a lot of features, including built-in Wifi, in a small package, making it ideal for somewhat remote projects. Projects where you won't always have access to a 110V / USB power source. That's exactly where a powered breadboard comes in.
| Part | Quantity | Identification |
|---|---|---|
| Oak with soldered headers | 1 | |
| Breadboard Power Supply Module | 1 | |
| 9V to Barrel Jack Cable | 1 | |
| 9V Battery | 1 | |
| Jumper Wires | 2 |
This tutorial is a very simple one, simply powering your Oak for portability. Different breadboard power modules should “Spark” your ingenuity for powering the sensors as well. This particular power module offers many options. In addition to power by USB or by DC barrel connector, it has a wide range our outputs as well. This unit powers the rails on each side of the breadboard, but wait there's more: You can also choose between 3.3V, 5V and off. One side can be 3.3V to power your Oak and your 3.3v sensors, the other side you can run 5V power for those things that require it.
Deep Sleep
This is the simple code from the First Blink sketch. It's used simply to verify that your Oak is connected and working
void setup()
{
pinMode(1, OUTPUT); //LED on Oak
}
void loop()
{
digitalWrite(1, HIGH);
delay(1000);
digitalWrite(1, LOW);
delay(1000);
}
Let's add / power a sensor as well. For this we'll use the US-100 Ultrasonic, powered via the module, and running the same sketch as in the starter lesson. Refer to that lesson for the sketch details.
int trigPin = 2; // Trigger Pin
int echoPin = 4; // Echo Pin
int LEDPin = 1; // Onboard LED
unsigned long Time_Echo_us = 0;
unsigned long Len_mm = 0;
char post_Distance[16];
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LEDPin, OUTPUT); // Use LED indicator for visual feedback
}
void loop() {
digitalWrite(trigPin, LOW);
delay(100);
digitalWrite(trigPin, HIGH);
delay(10);
digitalWrite(trigPin, LOW);
Time_Echo_us = pulseIn(echoPin, HIGH);
Len_mm = (Time_Echo_us*34/100)/2;
sprintf(post_Distance, "%04d", Len_mm);
Particle.publish("distance in mm:", post_Distance);
if((Len_mm < 3000) && (Len_mm > 1)) { // Length effective range (1, 3000).
digitalWrite(LEDPin, HIGH);
}
else {
digitalWrite(LEDPin, LOW);
}
delay(1000);
}
}
When you initially power the oak via a breadboard power supply, you might think that you are “losing” a power pin on the Oak. As can see this isn't the case at all, as the power supply powers the rail, and your other connected devices, so there's no lose of pins.
Creating IoT is good, creating IoT that are portable, without the need to run pesky wires, for your internet connection, or power is even better. In cases like this, energy is at a premium, and needs to be conserved at all costs, and luckily the Oak allows us to do just that with is sleep modes.