Skip to content

Instantly share code, notes, and snippets.

View IOT-123's full-sized avatar

IOT123 IOT-123

View GitHub Profile
@IOT-123
IOT-123 / temt6000_attiny_i2c_v3.ino
Last active May 22, 2018 05:13
IOT123 ATTINY85 I2C SLAVE AUTO-JOIN LAYER FOR SENSOR: TEMT6000
/*
*
* IOT123 ATTINY85 I2C SLAVE AUTO-JOIN LAYER FOR SENSOR: TEMT6000
*
* Take readings on TEMT6000 and send across wire on request via I2C in 3 segment 16byte packets
* ID of PROPERTY (set in _properties)
* VALUE of PROPERTY (set in getProperties)
* MORE TO COME (0/1 0 = last property)
*
* Pins on ATTINY85
@IOT-123
IOT-123 / uno_i2c_generic_sensor_test_w_plotter.ino
Last active May 12, 2018 05:20
I2C Master logging from I2C slave with plotter support.
#include <Wire.h>
#define ADDRESS_SLAVE 10
bool _outputPlotterOnly = false;
bool _confirmedMetadata = false;
int _packetSegment = 0;
bool _i2cNodeProcessed = false;
char _property[2][24] = {"name", "value"};
@IOT-123
IOT-123 / attiny_max9812_i2c.ino
Last active May 22, 2018 02:28
Used for I2C BRICK.
/*
*
* IOT123 ATTINY85 I2C SLAVE AUTO-JOIN LAYER FOR SENSOR: MAX9812
*
* Take readings on MAX9812 and send across wire on request via I2C in 3 segment 16byte packets
* ID of PROPERTY (set in _properties)
* VALUE of PROPERTY (set in getProperties)
* MORE TO COME (0/1 0 = last property)
*
* Pins on ATTINY85
/****************************************
Example Sound Level Sketch for the
Adafruit Microphone Amplifier
****************************************/
#define USE_SOFTWARE_SERIAL 1
#if (USE_SOFTWARE_SERIAL)
#include <SoftwareSerial.h>
/****************************************
Example Sound Level Sketch for the
Adafruit Microphone Amplifier
****************************************/
const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;
void setup()
{
@IOT-123
IOT-123 / temt6000_attiny_i2c.ino
Created May 3, 2018 09:14
IOT123 ATTINY85 I2C SLAVE AUTO-JOIN LAYER FOR SENSOR: TEMT6000
/*
*
* IOT123 ATTINY85 I2C SLAVE AUTO-JOIN LAYER FOR SENSOR: TEMT6000
*
* Take readings on GY302 and send across wire on request via I2C in 3 segment 16byte packets
* ID of PROPERTY (set in _properties)
* VALUE of PROPERTY (set in getProperties)
* MORE TO COME (0/1 0 = last property)
*
* Pins on ATTINY85
@IOT-123
IOT-123 / attiny85_is3V3.ino
Created May 3, 2018 04:39
As multiple volages can be applied, check the current VCC.
// https://www.avrfreaks.net/forum/attiny85-vcc-measurement-skews-higher-vcc-voltages
//5v = 6393, 6504
//3.3V 3430
bool is3V3() {
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
ADMUX = _BV(MUX3) | _BV(MUX2);
@IOT-123
IOT-123 / mq2_attiny_i2c.ino
Last active May 3, 2018 08:55
IOT123 ATTINY85 I2C SLAVE AUTO-JOIN LAYER FOR SENSOR: MQ2
/*
*
* IOT123 ATTINY85 I2C SLAVE AUTO-JOIN LAYER FOR SENSOR: MQ2
*
* Take readings on MQ2 and send across wire on request via I2C in 3 segment 16byte packets
* ID of PROPERTY (set in _properties)
* VALUE of PROPERTY (set in getProperties)
* MORE TO COME (0/1 0 = last property)
*
* Pins on ATTINY85
@IOT-123
IOT-123 / dht11_attiny_i2c.ino
Last active May 3, 2018 08:54
IOT123 ATTINY85 I2C SLAVE AUTO-JOIN LAYER FOR SENSOR: DHT11. See: https://github.com/IOT-123/dht11_attiny_i2c
/*
*
* IOT123 ATTINY85 I2C SLAVE AUTO-JOIN LAYER FOR SENSOR: DHT11
*
* Take readings on DHT11 and send across wire on request via I2C in 3 segment 16byte packets
* ID of PROPERTY (set in _properties)
* VALUE of PROPERTY (set in getProperties)
* MORE TO COME (0/1 0 = last property)
*
* Pins on ATTINY85
@IOT-123
IOT-123 / uno_i2c_generic_sensor_test.ino
Last active May 3, 2018 08:42
IOT123 UNO MASTER AUTO-JOIN VERIFIER
#include <Wire.h>
#define ADDRESS_SLAVE 8
int _packetSegment = 0;
bool _i2cNodeProcessed = false;
char _property[2][16] = {"name", "value"};
void setup() {
Wire.begin(); // join i2c bus (address optional for master)