Skip to content

Instantly share code, notes, and snippets.

View futureshocked's full-sized avatar

Peter Dalmaris futureshocked

View GitHub Profile
@futureshocked
futureshocked / LJ - 10.40 - LJ - 10.40 - DAC0_write.py
Created April 26, 2021 02:21
This script shows how to write voltage to DAC0.
'''
LJ - 10.40 - LJ - 10.40 - DAC0_write.py
This script shows how to write voltage to DAC0.
Components
----------
- LabJack T4
- Voltmeter/Multimeter
@futureshocked
futureshocked / LJ - 10.50 - FIO4_blink.py
Created April 26, 2021 02:20
This script shows how to control an LED with FIO4.
@futureshocked
futureshocked / LJ - 10.60 - lua_script_host_control.py
Created April 26, 2021 02:19
This script shows how to control an LED with FIO4 by deploying a Lua scripts to the LabJack. This script also demonstrates communication between this Python script and the on-board Lua scrip via user RAM.
'''
LJ - 10.60 - lua_script_host_control.py
This script shows how to control an LED with FIO4 by deploying a Lua scripts
to the LabJack. This script also demonstrates communication between this Python
script and the on-board Lua scrip via user RAM.
Components
----------
@futureshocked
futureshocked / LJ - 10.70 - simple_logging.py
Created April 26, 2021 02:16
This script shows how to control an LED with FIO4 by deploying a Lua scripts to the LabJack. This script also demonstrates communication between this Python script and the on-board Lua scrip via user RAM.
'''
LJ - 10.70 - simple_logging.py
This script shows how to control an LED with FIO4 by deploying a Lua scripts
to the LabJack. This script also demonstrates communication between this Python
script and the on-board Lua scrip via user RAM.
Components
----------
@futureshocked
futureshocked / BME280.py
Created February 25, 2021 22:27
MicroPython driver for the BME280 sensor on the Raspberry Pi Pico
from machine import I2C
import time
# BME280 default address.
BME280_I2CADDR = 0x76
# Operating Modes
BME280_OSAMPLE_1 = 1
BME280_OSAMPLE_2 = 2
BME280_OSAMPLE_4 = 3
import paho.mqtt.client as mqtt
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe("techexplorations/test")
byte encodebool(boolean* arr)
{
byte val = 0;
for (int i = 0; i<4; i++)
{
val <<= 1;
if (arr[i]) val |= 1;
}
return val;
}
@futureshocked
futureshocked / led-pm-expreriment.ino
Created June 29, 2020 05:26
This sketch will blink the LED at GPIO5 once per second and then go to sleep.
// Written by Peter Dalmaris from Tech Explorations.
// Used to find out how long an ESP32 can last on a LiPo battery.
// This sketch will blink the LED at GPIO5 once per second and
// store the number of blinks in an EEPROM location.
// In between blinks, the ESP32 goes to sleep.
#include "EEPROM.h"
#include <DeepSleepScheduler.h>
#ifdef ESP32
@futureshocked
futureshocked / led-no-sleep-experiment.ino
Created June 29, 2020 05:25
This sketch will simply blink an LED at a 1Hz frequency and increment the counter in EEPROM address 0.
// Written by Peter Dalmaris from Tech Explorations.
// Used to find out how long an ESP32 can last on a LiPo battery.
// This sketch will simply blink an LED at a 1Hz frequency.
// It will increment the counter in EEPROM address 0 every time it blinks.
// https://techexplorations.com
#include "EEPROM.h"
int addr = 0;
#define EEPROM_SIZE 32
@futureshocked
futureshocked / EEPROM-Reader.ino
Created June 29, 2020 05:22
This sketch will initialise the long counter in address 0.
// This sketch will initialise the long
// counter in address 0.
// Written by Peter Dalmaris from Tech Explorations.
// Used to find out how long an ESP32 can last on a LiPo battery.
// https://techexplorations.com
#include "EEPROM.h"
int addr = 0;
#define EEPROM_SIZE 32