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 / tilt_pan_tracker_0.1.ino
Last active January 16, 2019 07:29
Initial sketch for tracking light source - not optimized.
/*
* modified from code
* by Mathias Leroy
*
*/
#include <stdio.h>
#include <Servo.h>
Servo servoH;
Servo servoV;
@IOT-123
IOT-123 / uno_test_hardware_watchdog.ino
Last active December 30, 2017 07:00
A test harness, using an UNO/ESP8266, for the ATtiny85 hardware watchdog, targeting D1M Blocks (custom shields for Wermos D1 Mini)
#include <Wire.h>
byte _interval = 0;
void setup() {
Serial.begin(9600);
Wire.begin(); // join i2c bus (address optional for master)
delay(3000);
Serial.println("Sending started");
SendCmd('G', 1); // get the expected pat interval
@IOT-123
IOT-123 / attiny85_hardware_watchdog.ino
Created December 29, 2017 08:18
A stand-alone hardware watchdog with I2C comms, suitable as a shield (2.7 - 5.5V VCC) for Wemos D1 Mini, Arduino Uno...
#include "TinyWireS.h" //SDA/SCL PB0/PB2 5/7 //tws_delay(ms)
#include <EEPROM.h>
#define PIN_BITE 3
#define PIN_LED 1
#define BLINK_SHORT 250
#define BLINK_LONG 1000
#define EEPROM_VERSION 0
@IOT-123
IOT-123 / d1m_slog_test_deep_sleep.ino
Last active December 30, 2017 06:13
A simple sketch to test the D1M SLOG (SLeep + watchdOG) deep sleep function. Ensure both jumpers are set to the outer position (connecting D0 to RST).
// during wake prints 3 lines to console only
// then sleep 10 seconds, then repeat...
const int sleepSeconds = 10;
void setup() {
Serial.begin(115200);
Serial.println("\n\nWake up");
// Connect D0 to RST to wake up
pinMode(D0, WAKEUP_PULLUP);
@IOT-123
IOT-123 / d1m_slog_minimum_watchdog.ino
Last active December 30, 2017 07:02
The bare minimim needed to pat the dog to stop a reset. If the MCU does not do its job it is bitten (reset).
#include <Wire.h>
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
}
void loop() {
Wire.beginTransmission(8); // transmit to device #8
Wire.write('P'); // sends a char
Wire.write(0); // sends one byte
@IOT-123
IOT-123 / d1m_wifi_configure_i2c_slave.ino
Created December 30, 2017 09:44
Use serial input (console) to send I2C commands to an I2C slave. Must accept the format <char><byte> (2 bytes of data).
#include <Wire.h>
const byte _numChars = 32;
char _receivedChars[_numChars]; // an array to store the received data
boolean _newData = false;
void setup() {
Serial.begin(9600);
Wire.begin(); // join i2c bus (address optional for master)
@IOT-123
IOT-123 / i2c_ardpromi_extender.ino
Created January 1, 2018 05:45
Code from ESPEasy used for extending DIGITAL/ANALOG pins on D1M WIFI SOC using I2C
/****************************************************************************************************************************\
* Arduino project "ESP Easy" Copyright www.esp8266.nu
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You received a copy of the GNU General Public License along with this program in file 'License.txt'.
*
* IDE download : https://www.arduino.cc/en/Main/Software
@IOT-123
IOT-123 / d1m_test_ardupromi_extender_v0.1.ino
Created January 2, 2018 02:05
Use serial input from your D1M WIFI BLOCK to test the analog and digital pins via I2C to the D1M ARDUPOMI+ BLOCK.
#include <Wire.h>
#define I2C_MSG_IN_SIZE 4
#define I2C_MSG_OUT_SIZE 4
#define CMD_DIGITAL_WRITE 1
#define CMD_DIGITAL_READ 2
#define CMD_ANALOG_WRITE 3
#define CMD_ANALOG_READ 4
/*
* modified from code
* by Mathias Leroy
*
* V0.2 MODIFICATIONS
** I2C SET GET
** EEPROM SET GET
** REMOVE SERIAL OUTPUT - AFFECTED I2C
** ENABLE/DISABLE TRACKING
** MOVE SERVOS TO LIMITS VIA I2C
@IOT-123
IOT-123 / d1m_serial_input_i2c_char_byte_byte_v0.1.ino
Created January 7, 2018 23:36
Captures serial input (keyboard input in the console window) and forwards it to an I2C slave in the format char, byte, byte.
#include <Wire.h>
#define I2C_MSG_IN_SIZE 2
#define I2C_MSG_OUT_SIZE 3
#define I2C_SLAVE_ADDRESS 10
boolean _newData = false;
const byte _numChars = 32;
char _receivedChars[_numChars]; // an array to store the received data