Last active
April 15, 2017 08:55
-
-
Save TaijaQ/bb32b0c34c93d53acac568a071336c99 to your computer and use it in GitHub Desktop.
Raspberry Pi and Arduino development snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RASPBERRY PI | |
Mine | |
- Piface Digital | |
- WiFi Dongle | |
- | |
Others | |
- Adafruit DHT11 | |
- STM32 F103 C8T6 | |
- STM32 F030 | |
- WS2812 Breakout | |
- MH-Real-Time Clock Modules -2 | |
- Mitsumi Stepping Motor (7.5 Step) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# How to Set Up A 5V Relay On The Arduino | |
# http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/ | |
## | |
#include <math.h> | |
int pinOut = 10; | |
double Thermistor(int RawADC) { | |
double Temp; | |
Temp = log(10000.0*((1024.0/RawADC-1))); | |
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp ); | |
Temp = Temp - 273.15; | |
Temp = (Temp * 9.0)/ 5.0 + 32.0; | |
return Temp; | |
} | |
void setup() { | |
Serial.begin(9600); | |
pinMode(10, OUTPUT); | |
} | |
void loop() { | |
int val; | |
double temp; | |
val=analogRead(0); | |
temp=Thermistor(val); | |
Serial.print("Temperature = "); | |
Serial.print(temp); | |
Serial.println(" F"); | |
if (temp >= 150){ | |
digitalWrite(pinOut, LOW); | |
} | |
else { | |
digitalWrite(pinOut, HIGH); | |
} | |
delay(500); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import Adafruit_DHT | |
while True: | |
humidity, temperature = Adafruit_DHT.read_retry(11, 4) | |
print 'Temp: {0:0.1f} C Humidity: {1:0.1f} %'.format(temperature, humidity) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Turn Any Appliance into a Smart Device with an Arduino Controlled Power Outlet | |
# http://www.circuitbasics.com/build-an-arduino-controlled-power-outlet/ | |
## | |
#include <dht.h> | |
dht DHT; | |
#define DHT11_PIN 7 | |
int pinOut = 8; | |
void setup(){ | |
Serial.begin(9600); | |
pinMode(8, OUTPUT); | |
} | |
void loop() | |
{ | |
int chk = DHT.read11(DHT11_PIN); | |
Serial.print("Temperature = "); | |
Serial.println(DHT.temperature); | |
Serial.print("Humidity = "); | |
Serial.println(DHT.humidity); | |
if (DHT.humidity <= 40){ | |
digitalWrite(pinOut, HIGH); | |
} | |
else { | |
digitalWrite(pinOut, LOW); | |
} | |
delay(500); | |
} | |
NO | |
LOW = off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment