Skip to content

Instantly share code, notes, and snippets.

Avatar

Jens Chr Brynildsen jenschr

View GitHub Profile
View RS485_simple.ino
#include <SoftwareSerial.h>
const byte receivePin = 8; // green cable (RO)
const byte transmitPin = 9; // orange cable (DI)
const byte receiveEnablePin = 2; // blue cable (RE)
const byte RECEIVER_ENABLED = 0;
const byte RECEIVER_DISABLED = 1;
const byte LED_PIN = 13;
View Knock.ino
int lastVal = 0;
long lastKnock = 0;
void setup() {
Serial.begin( 9600 );
}
void loop() {
int readVal = analogRead( A2 );
if( readVal > lastVal+5 ){
View StepperDirect.ino
// This Arduino example demonstrates bidirectional operation of a
// 28BYJ-48, using a ULN2003 interface board to drive the stepper.
// The 28BYJ-48 motor is a 4-phase, 8-beat motor, geared down by
// a factor of 68. One bipolar winding is on motor pins 1 & 3 and
// the other on motor pins 2 & 4. The step angle is 5.625/64 and the
// operating Frequency is 100pps. Current draw is 92mA.
////////////////////////////////////////////////
//declare variables for the motor pins
int motorPin1 = 8; // Arduino pin 8 -> IN1
View IRReceive
/*
* IRremote: IRreceiveDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
@jenschr
jenschr / combined.html
Last active Jun 10, 2021
Paho MQTT websocket example. I had a hard time finding working examples of using the 1.1.0 version of this lib. Here' a basic setup keeping track of connection and unsent messages.
View combined.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Konkurranse Nespresso</title>
<script src="http://code.jquery.com/jquery-1.11.3.min.js" integrity="sha256-7LkWEzqTdpEfELxcZZlS6wAx5Ff13zZ83lYO2/ujj7g=" crossorigin="anonymous"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
@jenschr
jenschr / TTGO_LORA32_BATT_OLED.ino
Created Aug 10, 2019
Battery monitor example for the Banggood version of TTGO LoRa32
View TTGO_LORA32_BATT_OLED.ino
const uint8_t blue = 2;
const uint8_t vbatPin = 35;
#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`
float VBAT; // battery voltage from ESP32 ADC read
SSD1306 display(0x3c, 4, 15);
void setup()
{
Serial.begin(115200);
pinMode(blue, OUTPUT);
@jenschr
jenschr / MY1680U.ino
Created Mar 22, 2021
Arduino code snippet for controlling a MY1680U-12P using the MY1680U-16S chip for MP3 playback
View MY1680U.ino
/*
* Arduino snippet for controlling a MY1680U-12P
* using the MY1680U-16S chip for MP3 playback
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9);
#define START_CODE 0x7E
#define END_CODE 0xEF
@jenschr
jenschr / HiGrow_Thingspeak.ino
Last active Feb 6, 2021
Simple example showcasing how to publish data from the HiGrow board to Thingspeak
View HiGrow_Thingspeak.ino
/*
* Simple example showcasing how to publish data from the HiGrow board to Thingspeak
* For this to work, you'll need to create a file called "secrets.h" that holds the
* credentials you find on Thingspeak. These 4 lines are what is required in secrets.h
*
* #define SECRET_CH_ID 1234
* #define SECRET_WRITE_APIKEY "KLLJNKLJHGI"
* #define SECRET_SSID "yourssid"
* #define SECRET_PASS "yourpasswd"
*
@jenschr
jenschr / DweetSIM7600_for_TTGO_ESP32.ino
Created Nov 4, 2020
Basic sketch for an TTGO LoRa ESP-32 to send a message to Dweet.io using GET. Written specifically for the SIM7600E-H, but may work well on other similar modules.
View DweetSIM7600_for_TTGO_ESP32.ino
/*
* Basic sketch to send a message to Dweet.io using GET
* This sketch is written specifically for the SIM7600E-H
* This specific version is for TTGO LoRa with Oled. Note
* that you cannot use the OLED with Serial since the OLED
* Reset pin conflicts with RX2.
*
* Connect the R pin on the module to pin 16 on the ESP32
* Connect the T pin on the module to pin 17 on the ESP32
*
@jenschr
jenschr / DweetSIM7600_for_Photon.ino
Last active Nov 4, 2020
Basic Particle Photon sketch to send a message to Dweet.io using GET. Written specifically for the SIM7600E-H, but may work well on other similar modules.
View DweetSIM7600_for_Photon.ino
/*
* Basic sketch to send a message to Dweet.io using GET
* This sketch is written specifically for the SIM7600E-H
* This specific version is for Particle Photon.
*
* Connect the R pin on the module to pin 19 on the Photon
* Connect the T pin on the module to pin 18 on the Photon
*
* Also enter your own deviceName below (replace "8675840")
* and you can then go and see the result at