Skip to content

Instantly share code, notes, and snippets.

View jenschr's full-sized avatar

Jens Chr Brynildsen jenschr

View GitHub Profile
@jenschr
jenschr / settime_Serial.ino
Created May 2, 2024 18:52
Better init code for OWHL
/* improved settimeSerial.ino
https://github.com/millerlp/OWHL/blob/master/settime_Serial/settime_Serial.ino
Use this to get your real time clock date and time values
synchronized closely.
Copyright Luke Miller 2015
To use this program, upload it to your board, then open the
serial monitor at 57600 baud. Make sure the serial monitor
is set to send a 'newline' when you hit return (see the
menu in the lower right of the Arduino serial monitor window)
/*********************************************************
Minimal example for LTR329ALS sensor for LectureFeather
*********************************************************/
#include "Adafruit_LTR329_LTR303.h"
#include <Adafruit_DotStar.h>
Adafruit_LTR329 ltr = Adafruit_LTR329();
// There is only one pixel on the board
#define NUMPIXELS 1
@jenschr
jenschr / VS1053B_Adafruit_playback.ino
Created May 4, 2023 11:11
Simple sketch to make the baldram/ESP_VS1053_Library work with the Adafruit VS1053 breakout
#include <SPI.h>
#include <Wire.h>
#include <VS1053.h>
#include "SampleMp3.h"
// These are the pins used for the breakout example
#define BREAKOUT_RESET 9 // VS1053 reset pin (output)
#define BREAKOUT_CS 10 // VS1053 chip select pin (output)
#define BREAKOUT_DCS 6 // VS1053 Data/command select pin (output)
#define CARDCS 4 // Card chip select pin
@jenschr
jenschr / main.cpp
Last active July 15, 2024 09:32
ESP32's can use use either a TCP-client or a HTTP Client to do POST requests. This snippet will let you do a POST request directly to an IP address.
#include <WiFi.h>
#include <HTTPClient.h>
// WiFi network name and password:
const char * networkName = "your-ssid";
const char * networkPswd = "your-password";
// Internet address to send POST data to
const char * hostDomain = "10.13.37.158";
const int hostPort = 3001;
String getValue(String data, char separator, int index)
{
int found = 0;
int strIndex[] = { 0, -1 };
int maxIndex = data.length() - 1;
for (int i = 0; i <= maxIndex && found <= index; i++) {
if (data.charAt(i) == separator || i == maxIndex) {
found++;
strIndex[0] = strIndex[1] + 1;
@jenschr
jenschr / index.html
Created September 27, 2022 09:54
TEK303 Mqtt example HTML
<!doctype html>
<html lang="en" data-theme="dark"/>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.min.js" type="text/javascript"></script>
<script src="./secret.js" type="text/javascript"></script>
<script src="./mqtt.js" type="text/javascript"></script>
<title>MQTT Demo</title>
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css">
</head>
@jenschr
jenschr / mqtt.js
Created September 27, 2022 09:53
TEK303 Mqtt client example
const myTopic = "users/jensa/led";
const myServer = "mqtt.toytronics.com";
const client = new Paho.MQTT.Client(myServer,8883, "myClientId" + new Date().getTime());
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
console.log("Start connection!");
var connectOptions = {
int sensorPin = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
#include <Arduino.h>
#include <Wire.h>
#include <i2cdetect.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_DotStar.h>
#include "Adafruit_SHT31.h"
#include "Adafruit_LTR329_LTR303.h"
// There is only one pixel on the board
@jenschr
jenschr / dweetio.ino
Last active March 1, 2024 08:04
Basic code for setting a Dweet with a GET request on an ESP32
#include <WiFi.h>
/*
* Basic code for setting a Dweet with a GET request on an ESP32
*
* Original by Liz Miller (www.learnrobotics.org)
* Updated for ESP32 by https://gist.github.com/jenschr
*/
// WiFi parameters
const char* ssid = "your-ssid"; // Replace with your ssid