Skip to content

Instantly share code, notes, and snippets.

View lithiumhead's full-sized avatar

Anurag Chugh lithiumhead

View GitHub Profile
@lithiumhead
lithiumhead / Thingspeak_SHT11_Particle
Created November 11, 2015 15:35
Code for Particle Core/Photon to upload readings from SHT11 to Thingspeak.com
#define PARTICLE_PHOTON
#include "ThingSpeak/ThingSpeak.h"
#include "SHT1x/SHT1x.h"
//ThingSpeak.com configurations:
TCPClient client;
unsigned long myChannelNumber = REPLACE_WITH_YOUR_CHANNEL_NUMBER;
const char * myWriteAPIKey = "REPLACE_WITH_YOUR_API_KEY";
// Channel 1 is Temperature (deg C)
//Simple TCP Chat Client
//Taken from: http://www.tenouk.com/Module41a.html
//Using select() for I/O multiplexing
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
//Simple TCP Chat Server
//Taken from: http://www.tenouk.com/Module41.html
//Using select() for I/O multiplexing
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include "DHT.h"
// Uncomment one of the lines below for whatever DHT sensor type you're using!
//#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
@lithiumhead
lithiumhead / InitialStateDHT11.ino
Created February 23, 2017 03:19
Arduino code for ESP8266 to take readings from DHT11 and upload them to InitialState.com
#include <ESP8266WiFi.h>
#include "DHT.h"
////////////////////DHT11
//Uncomment one of the lines below for whatever DHT sensor type you're using!
#define DHTTYPE DHT11 //DHT11
//#define DHTTYPE DHT21 //DHT21 (AM2301)
//#define DHTTYPE DHT22 //DHT22 (AM2302), AM2321
@lithiumhead
lithiumhead / ClassroomTimerV1.ino
Created April 25, 2017 19:33
Classroom Timer made using Arduino UNO and MAX7219 based 4x4 Matrix displays
#include "PinChangeInt.h"
#include "TimerOne.h"
//We always have to include the library
#include "LedControlAC.h"
#define NBR_MTX 4
//LedControl(DataIn_Pin, Clock_Pin, Load_Pin, Number_of_Cascaded_Matrix_Displays);
LedControl lc = LedControl(2, 4, 3, NBR_MTX);
@lithiumhead
lithiumhead / elon_tweet.sh
Created May 1, 2017 12:28
Script to generate a screenshot of Elon Musk's latest tweet and set it as your background wallpaper
#!/bin/bash
#sudo apt-get install jq imagemagick pngcrush nkf
#https://askubuntu.com/questions/403918/setting-cron-to-run-a-shell-script-random-wallpaper-from-a-webpage
# export DBUS_SESSION_BUS_ADDRESS environment variable
PID=$(pgrep gnome-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
mkdir -p $HOME/Pictures/Elon_Tweets
@lithiumhead
lithiumhead / libhello.c
Created August 26, 2017 08:37
Hello World - C Shared Library
#include <stdio.h>
void hello(void)
{
puts("Hello, I'm a shared library");
}
@lithiumhead
lithiumhead / libhello.h
Created August 26, 2017 08:38
Hello World - C Shared Library
#ifndef libhello_h__
#define libhello_h__
extern void hello(void);
#endif // libhello_h__
@lithiumhead
lithiumhead / main.c
Created August 26, 2017 08:39
Hello World - C Shared Library
#include <stdio.h>
#include "libhello.h"
int main(void)
{
puts("This is a shared library test...");
hello();
return 0;
}