Skip to content

Instantly share code, notes, and snippets.

View jenschr's full-sized avatar

Jens Chr Brynildsen jenschr

View GitHub Profile
@jenschr
jenschr / i2cDetect_example_for_esp32.ino
Created August 10, 2019 14:01
i2cDetect script for the Banggood version of TTGO LoRa32
#include <Wire.h>
#include <i2cdetect.h>
void setup() {
// The Oled screen won't be visible unless we set the RESET line on the screen high
pinMode (16, OUTPUT);
digitalWrite (16, HIGH); // while OLED is running, GPIO16 must go high
// Rather than
Wire.begin(4, 15);
@jenschr
jenschr / SimpleLoraReciever
Created September 10, 2019 11:41
Very simple LoRa server for TTGO 1.0 boards
#include <SPI.h>
#include <LoRa.h>
#define SCK 5 // GPIO5 -- SX1278's SCK
#define MISO 19 // GPIO19 -- SX1278's MISO
#define MOSI 27 // GPIO27 -- SX1278's MOSI
#define SS 18 // GPIO18 -- SX1278's CS
#define RST 14 // GPIO14 -- SX1278's RESET
#define DI0 26 // GPIO26 -- SX1278's IRQ(Interrupt Request)
@jenschr
jenschr / SimpleLoraSender.ino
Created September 10, 2019 11:42
Very simple LoRa client for TTGO 1.0 boards
#include <SPI.h>
#include <LoRa.h>
int counter = 0;
#define SCK 5 // GPIO5 -- SX1278's SCK
#define MISO 19 // GPIO19 -- SX1278's MISO
#define MOSI 27 // GPIO27 -- SX1278's MOSI
#define SS 18 // GPIO18 -- SX1278's CS
@jenschr
jenschr / SimpleLoraReciever.ino
Last active September 10, 2019 11:43
Very simple LoRa 'server' for TTGO 1.0 boards
#include <SPI.h>
#include <LoRa.h>
#define SCK 5 // GPIO5 -- SX1278's SCK
#define MISO 19 // GPIO19 -- SX1278's MISO
#define MOSI 27 // GPIO27 -- SX1278's MOSI
#define SS 18 // GPIO18 -- SX1278's CS
#define RST 14 // GPIO14 -- SX1278's RESET
#define DI0 26 // GPIO26 -- SX1278's IRQ(Interrupt Request)
/*
LoRa Duplex communication
Sends a message every half second, and polls continually
for new incoming messages. Implements a one-byte addressing scheme,
with 0xFF as the broadcast address.
Uses readString() from Stream class to read payload. The Stream class'
timeout may affect other functuons, like the radio's callback. For an
@jenschr
jenschr / parseNumberToString.cpp
Last active October 30, 2019 10:21
Basic example of how a way parse a number to a char array using Modulo. Works for Arduino, stm32, Teensy and other Microcontrollers.
signed long int myNum = -1701543;
void setup() {
Serial.begin(9600);
delay(2000);
Serial.print(myNum);
char buff[14];
int bufferLength = parseNumberToString( buff, myNum );
Serial.print(":");
Serial.println(buff);
var mqtt = require('mqtt'); //https://www.npmjs.com/package/mqtt
var Topic = '#'; //subscribe to all topics
var Broker_URL = 'mqtt://localhost';
var Database_URL = 'localhost';
var options = {
clientId: 'MyMQTT'+Math.random()*64545353,
port: 1883,
username: 'MyUsername',
password: 'MyPassword',
@jenschr
jenschr / HiGrow_basics.ino
Last active February 17, 2020 17:54
Very basic Arduino example for testing the HiGrow board based on ESP32, DHT11 and a capacitive moisture sensor
/*
* Very basic Arduino example for testing the HiGrow board based on ESP32, DHT11 and a capacitive moisture sensor
*
* Details on the hardware and how to use it can be found on:
* http://flashgamer.com/blog/comments/higrow-esp32-moisture-and-temperature-sensor#capacitive
*/
#include "DHT.h"
#define DHTTYPE DHT11
@jenschr
jenschr / SerialPassthrough.ino
Last active July 24, 2020 21:24
Simple code snippet for talking to Serial devices - in this case a SIM7600E-H
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9);
void setup()
{
delay(500);
Serial.begin(115200);
mySerial.begin(115200); // use this line on a new module using 115200 baud by default
//mySerial.begin(19200); // after setting the baud rate to 19200, we use this speed for mySerial
pinMode(13, OUTPUT);
@jenschr
jenschr / base.h
Last active September 14, 2020 11:34
To get Flatbuffers to work with Teensy, we need to remove the Arduino specific code for STL (Teensy supports STL directly) in base.h (look for EDIT below, in two places)
#ifndef FLATBUFFERS_BASE_H_
#define FLATBUFFERS_BASE_H_
// clang-format off
// If activate should be declared and included first.
#if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && \
defined(_MSC_VER) && defined(_DEBUG)
// The _CRTDBG_MAP_ALLOC inside <crtdbg.h> will replace
// calloc/free (etc) to its debug version using #define directives.