Sensor Buddy
Reading sensor data at your desk on your IDE serial monitor is never accurate to in-situ projects, especially with isolated power supplies. Sensor Buddy ties in to your project via I2C (SDL/SCL), direct sensor connection, remote coms (RF) or wifi (internal ESP8266) and/or can also test sensors before embedding.


NodeMCU 1.0 ESP-12E
0.96" OLED I2C SSD1306 128X64
(2) 4 pin JST Female
Toggle Switch



Internal Code
/*
Sensor Buddy
vije miller
edit: libraries/Adafruit_SSD1306.h
unhash: #define SSD1306_128_64
hash: #define SSD1306_128_32
install: Adafruit_BusIO Library
0X3D to 0X3C
*/
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#define OLED_ADDR 0x3C
Adafruit_SSD1306 display(-1);

const int d_pin = D6;
int d_in;
int d_last;
const int a_pin = A0;
int a_in;
int a_last;

void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(29, 16);
display.print("SENSOR BUDDY");
display.display();
pinMode(d_pin, INPUT);
pinMode(a_pin, INPUT);
}

void loop() {
// hash out if wifi_data
// or alt input
sensor_range();
}

void sensor_range() {
d_in = digitalRead(d_pin);
a_in = analogRead(a_pin);
if (d_in != d_last || a_in != a_last) {
display.setTextSize(2);
display.setTextColor(WHITE, BLACK);
display.setCursor(42, 36);
if (d_in > 1 && a_in <= 1) {
display.print(d_in);
display.print(" ");
} else if (a_in > 1 && d_in <= 1) {
display.print(a_in);
display.print(" ");
} else {
display.print("0000");
}
display.display();
}
d_last = d_in;
a_last = a_in;
delay(100);
}



I2C (SDL/SDA)
/*
Sensor Buddy
vije miller
edit: libraries/Adafruit_SSD1306.h
unhash: #define SSD1306_128_64
hash: #define SSD1306_128_32
install: Adafruit_BusIO Library
0X3D to 0X3C
*/
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#define OLED_ADDR 0x3C
Adafruit_SSD1306 display(-1);
int sensor_call;

void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(29, 16);
display.print("SENSOR BUDDY");
display.display();
}

void loop() {
// sensor_call = read sensor
sensor_range(sensor_call);
}

void sensor_range(int sensor_print) {
display.setTextSize(2);
display.setTextColor(WHITE, BLACK);
display.setCursor(42, 36);
display.print(sensor_print);
display.print(" ");
display.display();
}

@pkvi
KE=½mv²
11,218 miters
3 miters today
198 tenons
Subscribe