<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-414369779316658096</id><updated>2025-02-15T03:52:11.913-08:00</updated><title type='text'>arduino</title><subtitle type='html'>belajar arduino</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>36</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-6880488958947640517</id><published>2024-06-19T23:37:00.000-07:00</published><updated>2024-06-19T23:37:32.323-07:00</updated><title type='text'>nodemcu12-f esp8266 flow sensor result ISR not in IRAM!</title><content type='html'>&lt;p&gt;if we use esp8266 and have error ISR not in IRAm when we use interrupt&lt;/p&gt;&lt;p&gt;then we must code like this :&lt;/p&gt;&lt;p&gt;int sensorPin = 2;&lt;br /&gt;volatile long pulse = 0;&lt;br /&gt;&lt;br /&gt;// Declare the increase function prototype&lt;br /&gt;&lt;br /&gt;void IRAM_ATTR increase() { // use this IRAM_ATTR&lt;br /&gt;&amp;nbsp; pulse++;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void setup() {&lt;br /&gt;&amp;nbsp; pinMode(sensorPin, INPUT_PULLUP);&lt;br /&gt;&amp;nbsp; Serial.begin(115200);&lt;br /&gt;&amp;nbsp; attachInterrupt(digitalPinToInterrupt(sensorPin), increase, FALLING);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void loop() {&lt;br /&gt;&amp;nbsp; Serial.println(pulse);&lt;br /&gt;&amp;nbsp; delay(500);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/6880488958947640517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2024/06/nodemcu12-f-esp8266-flow-sensor-result.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/6880488958947640517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/6880488958947640517'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2024/06/nodemcu12-f-esp8266-flow-sensor-result.html' title='nodemcu12-f esp8266 flow sensor result ISR not in IRAM!'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-586321383251836799</id><published>2022-05-05T07:13:00.001-07:00</published><updated>2022-05-05T07:13:15.731-07:00</updated><title type='text'>arduino lightning thunder emi filter - low frequency filter </title><content type='html'>&lt;p&gt;&amp;nbsp;Emi from thunder/ lightning generate low frequency that can make electromagnet interference (EMI) effect in long cable &lt;br /&gt;&lt;/p&gt;&lt;p&gt;so we should shield the input output arduino from low frequency emi&amp;nbsp;&lt;/p&gt;&lt;p&gt;this how i do that&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrL1wOKj2Vvg3O7VH6yXimsQIDUD7J1e0FcshsnGIa8oW3IjkErjoeLMzkELCSYfBvD7Y70J_DdCDFZiYV6xL46ziomupWhm9-fXmJ91_Q7o6m-4Kgc_C1MYqGz5UW1OA8oLUMIsrBsRzkIRKYbuPA1JClvC5yQ94-pLpuvT8jfAUgpwRVfa4mBoXpOg/s640/emi%20arduino%20thunder%20lightning.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;506&quot; data-original-width=&quot;640&quot; height=&quot;253&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrL1wOKj2Vvg3O7VH6yXimsQIDUD7J1e0FcshsnGIa8oW3IjkErjoeLMzkELCSYfBvD7Y70J_DdCDFZiYV6xL46ziomupWhm9-fXmJ91_Q7o6m-4Kgc_C1MYqGz5UW1OA8oLUMIsrBsRzkIRKYbuPA1JClvC5yQ94-pLpuvT8jfAUgpwRVfa4mBoXpOg/s320/emi%20arduino%20thunder%20lightning.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/586321383251836799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2022/05/arduino-lightning-thunder-emi-filter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/586321383251836799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/586321383251836799'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2022/05/arduino-lightning-thunder-emi-filter.html' title='arduino lightning thunder emi filter - low frequency filter '/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrL1wOKj2Vvg3O7VH6yXimsQIDUD7J1e0FcshsnGIa8oW3IjkErjoeLMzkELCSYfBvD7Y70J_DdCDFZiYV6xL46ziomupWhm9-fXmJ91_Q7o6m-4Kgc_C1MYqGz5UW1OA8oLUMIsrBsRzkIRKYbuPA1JClvC5yQ94-pLpuvT8jfAUgpwRVfa4mBoXpOg/s72-c/emi%20arduino%20thunder%20lightning.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-4868370008865462587</id><published>2019-08-23T05:06:00.000-07:00</published><updated>2019-08-23T05:07:22.860-07:00</updated><title type='text'>BLYNK NODEMCU ULTRASONIC JSN-SR04T WATER LEVEL </title><content type='html'>nodemcu waterproof ultrasonic jsn-sr04t for water level using blynk&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
//****Virtual Pin Assignments****&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
// V0 - Blynk Version - labeled value&lt;/div&gt;
&lt;div&gt;
// V1 - ESP Version&amp;nbsp; &amp;nbsp; - labeled value&lt;/div&gt;
&lt;div&gt;
// V2 - Millis Uptime&amp;nbsp; - labeled value&lt;/div&gt;
&lt;div&gt;
// V3 - Wifi RSSI&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - labeled value&lt;/div&gt;
&lt;div&gt;
// V4 - Volume&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - labeled value&lt;/div&gt;
&lt;div&gt;
// V8 - Terminal&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - terminal&lt;/div&gt;
&lt;div&gt;
// V9 - Percent&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - level V widget -- value 1 -10&lt;/div&gt;
&lt;div&gt;
//V10 - Numeric Widget - Level Alert&lt;/div&gt;
&lt;div&gt;
//V11 - Button Widget to cancel alert or turn alert (on or off) --button&lt;/div&gt;
&lt;div&gt;
//V12 - Distance - height from sensor to water level&amp;nbsp; -- labeled value&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
//#define BLYNK_PRINT Serial&amp;nbsp; &amp;nbsp; // Comment this out to disable prints and save space&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
#include &amp;lt;ESP8266WiFi.h&amp;gt;&lt;/div&gt;
&lt;div&gt;
#include &amp;lt;BlynkSimpleEsp8266.h&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
#include &amp;lt;ESP8266mDNS.h&amp;gt;&amp;nbsp; // For OTA w/ ESP8266&lt;/div&gt;
&lt;div&gt;
#include &amp;lt;WiFiUdp.h&amp;gt;&amp;nbsp; // For OTA&lt;/div&gt;
&lt;div&gt;
#include &amp;lt;ArduinoOTA.h&amp;gt;&amp;nbsp; // For OTA&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
char auth[] = &quot;yourAuthCode&quot;;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
char ssid[] = &quot;changeto your ssid&quot;;&lt;/div&gt;
&lt;div&gt;
char pass[] = &quot;yourpassword&quot;;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
BlynkTimer timer;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
WidgetTerminal terminal(V8);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
#define echoPin 14// Echo Pin&lt;/div&gt;
&lt;div&gt;
#define trigPin 12&amp;nbsp; // Trigger Pin&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
#define filterSamples&amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // filterSamples should&amp;nbsp; be an odd number, no smaller than 3&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
int maximumRange = 450;&lt;/div&gt;
&lt;div&gt;
int minimumRange = 20;&lt;/div&gt;
&lt;div&gt;
int alertLevelCounter = 0; //Counter starts at zero&lt;/div&gt;
&lt;div&gt;
int volume;&lt;/div&gt;
&lt;div&gt;
int volume1; // for smoothing algorithum&lt;/div&gt;
&lt;div&gt;
int percent;&lt;/div&gt;
&lt;div&gt;
int percent1; // for smoothing algorithum&lt;/div&gt;
&lt;div&gt;
int levelAlert;&lt;/div&gt;
&lt;div&gt;
int wateralert = 0;&lt;/div&gt;
&lt;div&gt;
int sensSmoothArray1 [filterSamples];&amp;nbsp; &amp;nbsp;// array for holding raw sensor values for sensor1&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
int smoothDistance;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// variables for sensor1 data&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
double alertInMin = 0.5;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Alert time following alert water level being reached (0.5 = 30secs)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
const int alertDuration = 2;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Alert sent every 2 minutes&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
const int waterTankDia = 80;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Water Tank Diameter (cm)&lt;/div&gt;
&lt;div&gt;
const int waterTankHt = 100;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //ie. Sensor Height (cm)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
long jarak,jarak1;&lt;/div&gt;
&lt;div&gt;
long duration, distance, distance1;&amp;nbsp; &amp;nbsp; &amp;nbsp;// Duration used to calculate distance&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
BLYNK_CONNECTED() { // runs once at device startup, once connected to server.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; Blynk.syncVirtual(V10);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; Blynk.syncVirtual(V11);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
void MeasureCm() {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;//&amp;nbsp; The following trigPin/echoPin cycle is used to determine the&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;// distance of the nearest object by bouncing soundwaves off of it.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;digitalWrite(trigPin, LOW);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;delayMicroseconds(2);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;digitalWrite(trigPin, HIGH);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;delayMicroseconds(10);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;digitalWrite(trigPin, LOW);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;duration = pulseIn(echoPin, HIGH);&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;//Calculate the distance (in cm) based on the speed of sound.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;distance = duration/58.2;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;if(distance &amp;gt;= 20 ){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;volume = ((waterTankHt*(PI*(sq(waterTankDia/2))))-(distance*(PI*(sq(waterTankDia/2)))))/1000;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;//percent = ((float)volume/9000)*100;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; //jarak = 1-(distance/100);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; //volume = ((0.4 * 0.4 * (1-(distance/100))) *(22/7))*1000;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; percent = (100 - distance);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; //percent = 100 - (distance/3);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;}&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;else{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(distance &amp;lt; 20 ){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;volume = 450;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;percent = 100;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; Blynk.virtualWrite(V9, percent); // virtual pin&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; Blynk.virtualWrite(V12, distance); // virtual pin&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; Blynk.virtualWrite(V4, volume); // virtual pin&lt;/div&gt;
&lt;div&gt;
}&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
void UpTime() {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; Blynk.virtualWrite(2, (millis() / 1000));&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; Blynk.virtualWrite(3, WiFi.RSSI());&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; //terminal.println(levelAlert);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
BLYNK_WRITE(V10) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; levelAlert = param.asInt();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; terminal.print(&quot;Water Level Alert: &quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; terminal.println(levelAlert);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; terminal.println();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; terminal.flush();&lt;/div&gt;
&lt;div&gt;
}&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
BLYNK_WRITE(V11) {&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; int alertOff = param.asInt();&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; if(alertOff == 0) {&lt;/div&gt;
&lt;div&gt;
resetWaterLevelAlert();&lt;/div&gt;
&lt;div&gt;
wateralert = 1;&lt;/div&gt;
&lt;div&gt;
terminal.print(&quot;Level Alert is OFF&quot;);&lt;/div&gt;
&lt;div&gt;
terminal.println();&lt;/div&gt;
&lt;div&gt;
terminal.flush();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; else {&lt;/div&gt;
&lt;div&gt;
resetWaterLevelAlert();&lt;/div&gt;
&lt;div&gt;
wateralert = 0;&lt;/div&gt;
&lt;div&gt;
terminal.print(&quot;Level Alert is ON&quot;);&lt;/div&gt;
&lt;div&gt;
terminal.println();&lt;/div&gt;
&lt;div&gt;
terminal.flush();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
void checkWaterLevel() {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; if(volume1 &amp;lt; levelAlert &amp;amp;&amp;amp; wateralert == 0){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;alertLevelCounter += 1;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; if(alertLevelCounter &amp;gt; alertInMin * 60 &amp;amp;&amp;amp; wateralert == 0){&lt;/div&gt;
&lt;div&gt;
Blynk.notify(&quot;Water Tank Level Alert&quot;); // send push notification to blynk app&lt;/div&gt;
&lt;div&gt;
wateralert = 1;&lt;/div&gt;
&lt;div&gt;
resetWaterLevelAlert();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
void resetWaterLevelAlert() {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; alertLevelCounter = 0;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; wateralert = 0;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
void MeasureCmForSmoothing() {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; /* The following trigPin/echoPin cycle is used to determine the&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;distance of the nearest object by bouncing soundwaves off of it. */&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;digitalWrite(trigPin, LOW);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;delayMicroseconds(2);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;digitalWrite(trigPin, HIGH);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;delayMicroseconds(10);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;digitalWrite(trigPin, LOW);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;duration = pulseIn(echoPin, HIGH);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;//Calculate the distance (in cm) based on the speed of sound.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;distance1 = duration/58.2; //for smoothing algorithim&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;smoothDistance = digitalSmooth(distance1, sensSmoothArray1);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;{&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;if(distance1 &amp;gt;= 20 ) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;volume1 = ((waterTankHt*(PI*(sq(waterTankDia/2))))-(smoothDistance*(PI*(sq(waterTankDia/2)))))/1000;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;//volume1 = ((((0.4 * 0.4) * (1-(smoothDistance/100))) *(22/7))*1000);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; percent1 = (100 - smoothDistance);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;terminal.print(&quot;Uptime (secs): &quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;terminal.println((millis() / 1000));&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;terminal.print(&quot;Distance: &quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;terminal.println(distance1);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;terminal.print(&quot;Smoothed Distance: &quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;terminal.println(smoothDistance);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;terminal.println();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; terminal.print(&quot;percent1: &quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;terminal.println(percent1);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;terminal.flush();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;//terminal.print(&quot;Percent: &quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;// terminal.println(percent1);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;}&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;else{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if(distance1 &amp;lt; 20 ){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; volume1 = 450;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; percent1 = 100;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;}&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;div&gt;
}&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
void UploadMeasureCmForSmoothing() {&lt;/div&gt;
&lt;div&gt;
Blynk.virtualWrite(V12, smoothDistance); // virtual pin&lt;/div&gt;
&lt;div&gt;
Blynk.virtualWrite(V4, volume1); // virtual pin&lt;/div&gt;
&lt;div&gt;
Blynk.virtualWrite(V9, percent1); // virtual pin&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
terminal.print(&quot;Uploaded Volume: &quot;);&lt;/div&gt;
&lt;div&gt;
terminal.println(volume1);&lt;/div&gt;
&lt;div&gt;
terminal.print(&quot;Uploaded Smoothed Distance: &quot;);&lt;/div&gt;
&lt;div&gt;
terminal.println(smoothDistance);&lt;/div&gt;
&lt;div&gt;
terminal.println();&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
terminal.flush();&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
void setup() {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;Serial.begin(115200);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;Blynk.begin(auth, ssid, pass, &quot;blynk-cloud.com&quot;, 8080);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;ArduinoOTA.setHostname(&quot;Water_Tank&quot;);&amp;nbsp; // For OTA - Use your own device identifying name&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;ArduinoOTA.begin();&amp;nbsp; // For OTA&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;pinMode(trigPin, OUTPUT);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;pinMode(echoPin, INPUT);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;terminal.clear();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; timer.setTimeout(100, [](){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;timer.setInterval(5000L, UpTime);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;});&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;timer.setTimeout(400, [](){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;timer.setInterval(300000L, UploadMeasureCmForSmoothing);&amp;nbsp; //get a measurement straight up if the device was reset for some reason&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;});&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;timer.setTimeout(600, [](){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;timer.setTimer(1000L, MeasureCm, 1);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;});&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;timer.setTimeout(500, [](){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;timer.setInterval(1000L, checkWaterLevel);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;});&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;timer.setTimeout(700, [](){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;timer.setInterval(15000L, MeasureCmForSmoothing);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;});&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
void loop() {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; Blynk.run(); // Initiates Blynk&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; ArduinoOTA.handle();&amp;nbsp; // For OTA&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; timer.run(); // Initiates SimpleTimer&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
int digitalSmooth(int rawIn, int *sensSmoothArray){&amp;nbsp; &amp;nbsp; &amp;nbsp;// &quot;int *sensSmoothArray&quot; passes an array to the function - the asterisk indicates the array name is a pointer&lt;/div&gt;
&lt;div&gt;
int j, k, temp, top, bottom;&lt;/div&gt;
&lt;div&gt;
long total;&lt;/div&gt;
&lt;div&gt;
static int i;&lt;/div&gt;
&lt;div&gt;
// static int raw[filterSamples];&lt;/div&gt;
&lt;div&gt;
static int sorted[filterSamples];&lt;/div&gt;
&lt;div&gt;
boolean done;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
i = (i + 1) % filterSamples;&amp;nbsp; &amp;nbsp; // increment counter and roll over if necc. -&amp;nbsp; % (modulo operator) rolls over variable&lt;/div&gt;
&lt;div&gt;
sensSmoothArray[i] = rawIn;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// input new data into the oldest slot&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
// Serial.print(&quot;raw = &quot;);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;for (j=0; j&amp;lt;filterSamples; j++){&amp;nbsp; &amp;nbsp; &amp;nbsp;// transfer data array into anther array for sorting and averaging&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;sorted[j] = sensSmoothArray[j];&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;done = 0;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // flag to know when we&#39;re done sorting&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;while(done != 1){&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // simple swap sort, sorts numbers from lowest to highest&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; done = 1;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j = 0; j &amp;lt; (filterSamples - 1); j++){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(sorted[j] &amp;gt; sorted[j + 1]){&amp;nbsp; &amp;nbsp; &amp;nbsp;// numbers are out of order - swap&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;temp = sorted[j + 1];&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sorted [j+1] =&amp;nbsp; sorted[j] ;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sorted [j] = temp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;done = 0;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
/*&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; for (j = 0; j &amp;lt; (filterSamples); j++){&amp;nbsp; &amp;nbsp; // print the array to debug&lt;/div&gt;
&lt;div&gt;
Serial.print(sorted[j]);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Serial.print(&quot;&amp;nbsp; &amp;nbsp;&quot;);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; Serial.println();&lt;/div&gt;
&lt;div&gt;
*/&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;// throw out top and bottom 15% of samples - limit to throw out at least one from top and bottom&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;//&amp;nbsp; bottom = max(((filterSamples * 15)&amp;nbsp; / 100), 1);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;//&amp;nbsp; top = min((((filterSamples * 85) / 100) + 1&amp;nbsp; ), (filterSamples - 1));&amp;nbsp; &amp;nbsp;// the + 1 is to make up for asymmetry caused by integer rounding&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;bottom = max(((filterSamples * 20)&amp;nbsp; / 100), 1);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;top = min((((filterSamples * 80) / 100) + 1&amp;nbsp; ), (filterSamples - 1));&amp;nbsp; &amp;nbsp;// the + 1 is to make up for asymmetry caused by integer rounding&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;k = 0;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;total = 0;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; for( j = bottom; j&amp;lt; top; j++){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;total += sorted[j];&amp;nbsp; // total remaining indices&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;k++;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;//Serial.print(sorted[j]);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;//Serial.print(&quot;&amp;nbsp; &amp;nbsp;&quot;);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;//terminal.print(sorted[j]);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;//terminal.println(&quot;&amp;nbsp; &amp;nbsp;&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;//terminal.print(&quot;average: &quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;//terminal.println(total/k);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;//terminal.flush();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;//Serial.println();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;//Serial.print(&quot;average = &quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;//Serial.println(total/k);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; return total / k;&amp;nbsp; &amp;nbsp; // divide by number of samples&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/4868370008865462587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2019/08/blynk-nodemcu-ultrasonic-jsn-sr04t.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/4868370008865462587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/4868370008865462587'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2019/08/blynk-nodemcu-ultrasonic-jsn-sr04t.html' title='BLYNK NODEMCU ULTRASONIC JSN-SR04T WATER LEVEL '/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-1433639592591878588</id><published>2019-02-13T08:50:00.000-08:00</published><updated>2019-02-13T08:50:36.230-08:00</updated><title type='text'>arduino 4 channel relay jd-vcc</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibXWaRFgLmacQ9-0caXCFv716DQFujJm_tUh6B9MujpKY3c-ZSPWoTMJIoq1YuzfnJd_O-t_cX6sGEglQZdUqX7i5L1AZj8Wz3lJwwumAzRHkNo-n_RxHkbE2eTygd8YdAq-nIYfwUuEck/s1600/arduino+relay+4+channel.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;877&quot; data-original-width=&quot;1600&quot; height=&quot;350&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibXWaRFgLmacQ9-0caXCFv716DQFujJm_tUh6B9MujpKY3c-ZSPWoTMJIoq1YuzfnJd_O-t_cX6sGEglQZdUqX7i5L1AZj8Wz3lJwwumAzRHkNo-n_RxHkbE2eTygd8YdAq-nIYfwUuEck/s640/arduino+relay+4+channel.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
for my own documentation .&lt;br /&gt;
this picture was taken from outseal.com&lt;br /&gt;
&lt;br /&gt;
no need ground from arduino,&lt;br /&gt;
this relay is LOW ACTIVE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/1433639592591878588/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2019/02/arduino-4-channel-relay-jd-vcc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/1433639592591878588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/1433639592591878588'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2019/02/arduino-4-channel-relay-jd-vcc.html' title='arduino 4 channel relay jd-vcc'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibXWaRFgLmacQ9-0caXCFv716DQFujJm_tUh6B9MujpKY3c-ZSPWoTMJIoq1YuzfnJd_O-t_cX6sGEglQZdUqX7i5L1AZj8Wz3lJwwumAzRHkNo-n_RxHkbE2eTygd8YdAq-nIYfwUuEck/s72-c/arduino+relay+4+channel.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-7920115396618722398</id><published>2019-02-13T08:48:00.001-08:00</published><updated>2019-02-13T08:48:41.169-08:00</updated><title type='text'>Arduino HC12 with DFplayer</title><content type='html'>i want to make bell using HC-12 long range 433mhz with dfplayer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
here is the code&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
///// RECEIVER //////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// HC-12 TRANSCEIVER&lt;br /&gt;
// RECEIVER (RX) part&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SoftwareSerial.h&amp;gt; // import the necessary library&lt;br /&gt;
#include &amp;lt;DFPlayer_Mini_Mp3.h&amp;gt;&lt;br /&gt;
SoftwareSerial hc12(10, 9); // TX - RX-- HC-12&lt;br /&gt;
SoftwareSerial myMP3(12, 11); // bener 12/11&lt;br /&gt;
&lt;br /&gt;
char incomingByte;&lt;br /&gt;
String readBuffer = &quot;&quot;;&lt;br /&gt;
const int led&amp;nbsp; &amp;nbsp; &amp;nbsp;= 5;&lt;br /&gt;
const int setPin = 7; // pin used to set up the HC-12 wireless module&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
&amp;nbsp; pinMode(setPin, OUTPUT); //&amp;nbsp; setPin on hc12&lt;br /&gt;
&amp;nbsp; digitalWrite(led, LOW);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Serial.begin(9600);&lt;br /&gt;
&amp;nbsp; hc12.begin(9600); // Start the software serial port&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;start&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; digitalWrite(setPin, LOW);&lt;br /&gt;
&amp;nbsp; //hc12.print(&quot;AT+DEFAULT&quot;);&lt;br /&gt;
&amp;nbsp; hc12.print(&quot;AT+B19200&quot;);&lt;br /&gt;
&amp;nbsp; hc12.print(&quot;AT+C001&quot;);&lt;br /&gt;
&amp;nbsp; digitalWrite(setPin, HIGH);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; myMP3.begin(9600);&lt;br /&gt;
&amp;nbsp; mp3_set_serial (myMP3);&lt;br /&gt;
&amp;nbsp; delay(400);&lt;br /&gt;
&amp;nbsp; mp3_reset();&lt;br /&gt;
&amp;nbsp; delay(400);&lt;br /&gt;
&amp;nbsp; mp3_set_volume(15);&lt;br /&gt;
&amp;nbsp; delay(1000);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
&amp;nbsp; hc12.listen();&lt;br /&gt;
&amp;nbsp; while (hc12.available()) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.println(&quot;GET data&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; incomingByte = hc12.read();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; readBuffer += char(incomingByte);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.println(readBuffer);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (readBuffer == &quot;bel&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; hc12.print(&quot;bel1&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //Serial.println(&quot;GET DATA 2&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; mp3_play (1); //PLAY SONG 0001.mp3&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; delay(14000L);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; readBuffer = &quot;&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; } // bel&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; // PLAYING ANOTHER SOUND&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (readBuffer == &quot;ob&quot; ) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; hc12.print(&quot;ob1&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; mp3_play (2);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; delay(14000L);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; readBuffer = &quot;&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; } //calling my office boy&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
//TRANSMITTER&lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// HC-12 TRANSCEIVER&lt;br /&gt;
// TRANSMITTER (TX) part&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SoftwareSerial.h&amp;gt;&lt;br /&gt;
SoftwareSerial hc12(11, 9); //&amp;nbsp; TX-RX pins on Arduino&lt;br /&gt;
&lt;br /&gt;
const int pcnPin = 3; // pin connected to the output of the client alarm system&lt;br /&gt;
const int setPin = 7; // pin used to set up the HC-12 wireless module&lt;br /&gt;
const int led&amp;nbsp; &amp;nbsp; &amp;nbsp;= 5; //confirmation led blink&lt;br /&gt;
int var = 0;&lt;br /&gt;
int flag = 0;&lt;br /&gt;
unsigned long start, skrg;&lt;br /&gt;
unsigned long interval = 1000UL * 60 * 0.5;&lt;br /&gt;
char incomingByte;&lt;br /&gt;
String readBuffer = &quot;&quot;;&lt;br /&gt;
void setup() {&lt;br /&gt;
&amp;nbsp; pinMode(setPin, OUTPUT);&lt;br /&gt;
&amp;nbsp; pinMode(led, OUTPUT);&lt;br /&gt;
&amp;nbsp; digitalWrite(led, LOW);&lt;br /&gt;
&amp;nbsp; pinMode(pcnPin, INPUT_PULLUP); // my alarm system will ground the dry contact upon alarm&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; hc12.begin(9600); // start the software serial port&lt;br /&gt;
&amp;nbsp; Serial.begin(9600);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; digitalWrite(setPin, LOW);&lt;br /&gt;
&amp;nbsp; //hc12.print(&quot;AT+DEFAULT&quot;);&lt;br /&gt;
&amp;nbsp; hc12.print(&quot;AT+B19200&quot;);&lt;br /&gt;
&amp;nbsp; hc12.print(&quot;AT+C001&quot;);&lt;br /&gt;
&amp;nbsp; digitalWrite(setPin, HIGH);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
void loop() {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; if (digitalRead(pcnPin) == LOW &amp;amp;&amp;amp; flag == 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; start = millis();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(led, HIGH);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(200);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(led, LOW);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(200);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; flag = 1;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; skrg = millis();&lt;br /&gt;
&amp;nbsp; if ( skrg - start &amp;gt; interval ) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; flag = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //Serial.println(&quot;reset push&quot;);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; if (digitalRead(pcnPin) == LOW &amp;amp;&amp;amp; flag == 1) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; hc12.print(&quot;bel&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(led, HIGH);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(200);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(led, LOW);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(200);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(led, HIGH);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(200);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(led, LOW);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(200);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while (hc12.available()) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; incomingByte = hc12.read();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; readBuffer += char(incomingByte);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; if (readBuffer == &quot;&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; flag = 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; hc12.print(&quot;bel&quot;);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; if (readBuffer == &quot;bel1&quot;) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; flag = 0;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; delay(100);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/7920115396618722398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2019/02/arduino-hc12-with-dfplayer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7920115396618722398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7920115396618722398'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2019/02/arduino-hc12-with-dfplayer.html' title='Arduino HC12 with DFplayer'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-7293925345204483543</id><published>2018-05-25T08:47:00.002-07:00</published><updated>2018-05-25T08:47:47.711-07:00</updated><title type='text'>ARDUINO - DFPLAYER WITH DS3231</title><content type='html'>#include &amp;lt;SPI.h&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
#include &amp;lt;Wire.h&amp;gt;&lt;br /&gt;
#include &amp;lt;DS3231.h&amp;gt;&lt;br /&gt;
#include &amp;lt;SoftwareSerial.h&amp;gt;&lt;br /&gt;
#include &amp;lt;DFPlayer_Mini_Mp3.h&amp;gt;&lt;br /&gt;
#include &amp;lt;Button.h&amp;gt;&lt;br /&gt;
DS3231&amp;nbsp; rtc(SDA, SCL);&lt;br /&gt;
Time&amp;nbsp; t;&lt;br /&gt;
uint8_t hh = 0, mm = 0, ss = 0;&lt;br /&gt;
SoftwareSerial mySerial(11, 10); // Declare pin RX &amp;amp; TX&lt;br /&gt;
&lt;br /&gt;
#define BUTTON8 8 // tombol ON&lt;br /&gt;
#define PULLUP true&lt;br /&gt;
#define INVERT true&lt;br /&gt;
#define DEBOUNCE_MS 20&lt;br /&gt;
Button btn1(BUTTON8, PULLUP, INVERT, DEBOUNCE_MS);&lt;br /&gt;
&lt;br /&gt;
int b1 = 3; //tombol on/off&lt;br /&gt;
const int busyPin = 5; //Dfplayer -busypin will be HIGH if mp3 stop play&lt;br /&gt;
int busyStatus =0;&lt;br /&gt;
int led = 13;&lt;br /&gt;
void setup() {&lt;br /&gt;
&amp;nbsp; Serial.begin(57600);&lt;br /&gt;
&amp;nbsp; pinMode (busyPin, INPUT);&lt;br /&gt;
&amp;nbsp; pinMode(b1, INPUT_PULLUP);&lt;br /&gt;
&amp;nbsp; rtc.begin();&lt;br /&gt;
&amp;nbsp; mySerial.begin (9600);&lt;br /&gt;
&amp;nbsp; mp3_set_serial (mySerial); //set softwareSerial for DFPlayer&lt;br /&gt;
&amp;nbsp; delay(10);&lt;br /&gt;
&amp;nbsp; mp3_reset();&lt;br /&gt;
&amp;nbsp; delay(10);&amp;nbsp; &amp;nbsp;//wait 1ms for respon command&lt;br /&gt;
&amp;nbsp; mp3_set_volume (30); //Set volume value. From 0 to 30&lt;br /&gt;
&amp;nbsp; delay(500);&lt;br /&gt;
&amp;nbsp; pinMode(led, OUTPUT);&lt;br /&gt;
&amp;nbsp; digitalWrite(led, LOW);&lt;br /&gt;
&amp;nbsp; //rtc.setTime(8, 38, 0);&amp;nbsp; &amp;nbsp; &amp;nbsp;// Set the time to 12:00:00 (24hr format)&lt;br /&gt;
&amp;nbsp; //rtc.setDate(25, 5, 2018);&amp;nbsp; &amp;nbsp;// Set the date to January 1st, 2014&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; t = rtc.getTime();&amp;nbsp; // gate all data time &amp;amp; date from RTC&lt;br /&gt;
&amp;nbsp; hh = t.hour, DEC; //pengambilan data jam&lt;br /&gt;
&amp;nbsp; mm = t.min, DEC; //pengambilan data menit&lt;br /&gt;
&amp;nbsp; ss = t.sec, DEC; //pengambilan data detik&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.print(hh);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.print(&quot;:&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.print(mm);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.print(&quot;:&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.println(ss);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(1000);&lt;br /&gt;
&amp;nbsp; Serial.println(digitalRead(busyPin));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; if (btn1.read() == 1 ) { // nyalain mp3&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(led, HIGH);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; mp3_play(1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(1000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(led, LOW);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //delay(56000);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; if (hh &amp;gt;= 6 &amp;amp;&amp;amp; hh &amp;lt;= 22 ) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; busyStatus = digitalRead(busyPin);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if ( busyStatus == HIGH ) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; mp3_play(1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(led, HIGH);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; mp3_stop();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(led, LOW);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/7293925345204483543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2018/05/arduino-dfplayer-with-ds3231.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7293925345204483543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7293925345204483543'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2018/05/arduino-dfplayer-with-ds3231.html' title='ARDUINO - DFPLAYER WITH DS3231'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-7627227684700531670</id><published>2017-04-05T22:26:00.001-07:00</published><updated>2017-04-05T22:33:22.574-07:00</updated><title type='text'>READING AC 220 V arduino ZMPT101B</title><content type='html'>https://github.com/openenergymonitor/EmonLib&lt;br /&gt;
&lt;br /&gt;
// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3&lt;br /&gt;
&lt;br /&gt;
#include &quot;EmonLib.h&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Include Emon Library&lt;br /&gt;
EnergyMonitor emon1; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Create an instance&lt;br /&gt;
&lt;br /&gt;
int i = 0;&lt;br /&gt;
float tenvals = 0.0;&lt;br /&gt;
float minval = 1000;&lt;br /&gt;
float maxval = 0.0;&lt;br /&gt;
&lt;br /&gt;
void setup()&lt;br /&gt;
{ &lt;br /&gt;
&amp;nbsp; Serial.begin(115200);&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; emon1.voltage(2, 109, 1.7); &amp;nbsp;// Voltage: input pin, calibration, phase_shift&lt;br /&gt;
// &amp;nbsp;emon1.current(1, 111.1); &amp;nbsp; &amp;nbsp; &amp;nbsp; // Current: input pin, calibration.&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; emon1.calcVI(20,2000); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Calculate all. No.of half wavelengths (crossings), time-out&lt;br /&gt;
// &amp;nbsp;emon1.serialprint(); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
// &amp;nbsp;float realPower &amp;nbsp; &amp;nbsp; &amp;nbsp; = emon1.realPower; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//extract Real Power into variable&lt;br /&gt;
// &amp;nbsp;float apparentPower &amp;nbsp; = emon1.apparentPower; &amp;nbsp; &amp;nbsp;//extract Apparent Power into variable&lt;br /&gt;
// &amp;nbsp;float powerFActor &amp;nbsp; &amp;nbsp; = emon1.powerFactor; &amp;nbsp; &amp;nbsp; &amp;nbsp;//extract Power Factor into Variable&lt;br /&gt;
// &amp;nbsp;float supplyVoltage &amp;nbsp; = emon1.Vrms; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //extract Vrms into Variable&lt;br /&gt;
// &amp;nbsp;float Irms &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= emon1.Irms; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //extract Irms into Variable&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;float Vrms = (emon1.Vrms - 3);&lt;br /&gt;
&amp;nbsp;if (Vrms &amp;lt; 0) { Vrms = 0.0; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;tenvals += Vrms;&lt;br /&gt;
&amp;nbsp;if (minval &amp;gt; Vrms) { minval = Vrms; }&lt;br /&gt;
&amp;nbsp;if (maxval &amp;lt; Vrms) { maxval = Vrms; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;i++;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;if (i == 10)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; Serial.print(&quot;Avg: &quot;);&lt;br /&gt;
&amp;nbsp; Serial.print(tenvals/10);&lt;br /&gt;
&amp;nbsp; Serial.print(&quot; (&quot;);&lt;br /&gt;
&amp;nbsp; Serial.print(Vrms);&lt;br /&gt;
&amp;nbsp; Serial.print(&quot;) Min: &quot;);&lt;br /&gt;
&amp;nbsp; Serial.print(minval);&lt;br /&gt;
&amp;nbsp; Serial.print(&quot; Max: &quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(maxval);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; i = 0;&lt;br /&gt;
&amp;nbsp; tenvals = 0.0;&lt;br /&gt;
&amp;nbsp; minval = 1000.0;&lt;br /&gt;
&amp;nbsp; maxval = 0.0;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp; delay(100);&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/7627227684700531670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2017/04/reading-ac-220-v-arduino-zmpt101b.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7627227684700531670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7627227684700531670'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2017/04/reading-ac-220-v-arduino-zmpt101b.html' title='READING AC 220 V arduino ZMPT101B'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-7951152689070820162</id><published>2017-03-17T13:27:00.002-07:00</published><updated>2017-03-17T13:27:53.319-07:00</updated><title type='text'>ARDUINO COUNTER USING IR SENSOR FC-51</title><content type='html'>arduino counter using IR sensor FC-51 is for use at bathroom or toilet&lt;br /&gt;
for counting people in and out, if the counter is zero, then it will turn off the light&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#define in 5&lt;br /&gt;
#define out 7&lt;br /&gt;
#define relay 2&lt;br /&gt;
#define power 9&lt;br /&gt;
int pinIn;&lt;br /&gt;
int pinOut;&lt;br /&gt;
int statusIn= 0;&lt;br /&gt;
int statusOut;&lt;br /&gt;
int count=0;&lt;br /&gt;
void IN()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; count++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //Serial.println(count);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(1000);&lt;br /&gt;
}&lt;br /&gt;
void OUT()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; count--;&lt;br /&gt;
&amp;nbsp; //Serial.println(count);&lt;br /&gt;
&amp;nbsp; delay(1000);&lt;br /&gt;
}&lt;br /&gt;
void setup()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; Serial.begin(9600);&lt;br /&gt;
&amp;nbsp; delay(2000);&lt;br /&gt;
&amp;nbsp; pinMode(in, INPUT);&lt;br /&gt;
&amp;nbsp; pinMode(out, INPUT);&lt;br /&gt;
&amp;nbsp; pinMode(relay, OUTPUT);&lt;br /&gt;
&amp;nbsp; pinMode(power, OUTPUT);&lt;br /&gt;
&amp;nbsp; digitalWrite(power, HIGH);&lt;br /&gt;
}&lt;br /&gt;
void loop()&lt;br /&gt;
{ &lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.println(count);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //ada halangan 0&lt;br /&gt;
&amp;nbsp; &amp;nbsp; pinIn = digitalRead(in);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(statusIn == 0 &amp;amp;&amp;amp; pinIn == 0 &amp;amp;&amp;amp; pinOut == 0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; IN();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; statusIn = 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(statusIn == 1 &amp;amp;&amp;amp; pinIn == 1){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; statusIn =0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; pinOut = digitalRead(out);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(statusOut == 0 &amp;amp;&amp;amp; pinOut == 0 &amp;amp;&amp;amp; pinIn == 0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; OUT();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; statusOut = 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(statusOut == 1 &amp;amp;&amp;amp; pinOut == 1){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; statusOut =0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
================================&lt;br /&gt;
arduino bathroom ligh saving&lt;br /&gt;
arduino on off bathroom light&lt;br /&gt;
arduino automatic switch off bathroom if no people inside&lt;br /&gt;
lampu toilet otomatis&lt;br /&gt;
contact : veluska@gmail.com (at indonesia-jakarta)</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/7951152689070820162/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2017/03/arduino-counter-using-ir-sensor-fc-51.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7951152689070820162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7951152689070820162'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2017/03/arduino-counter-using-ir-sensor-fc-51.html' title='ARDUINO COUNTER USING IR SENSOR FC-51'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-4860471951123771609</id><published>2017-03-17T06:14:00.001-07:00</published><updated>2017-03-17T06:15:57.863-07:00</updated><title type='text'>arduino genset detect volt</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivL7bJMzCaoMqS-1e7WbLl0kQl7BMBiy03Zpp33RKAc0PVyINDWja3Chase8bLp41MCX2IBRaWSGNXX1TGwbXagiaFtUuI3tglc_HG0dYttrxvuKlD_UxiZeP8_3X25NScJ-sbphIG6A4N/s1600/arduino_generator_detector.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivL7bJMzCaoMqS-1e7WbLl0kQl7BMBiy03Zpp33RKAc0PVyINDWja3Chase8bLp41MCX2IBRaWSGNXX1TGwbXagiaFtUuI3tglc_HG0dYttrxvuKlD_UxiZeP8_3X25NScJ-sbphIG6A4N/s320/arduino_generator_detector.png&quot; width=&quot;187&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_PZwZMgXpvO8dMduo5rhZ7_mTzduxaCeGfiE0vzPYvC8sLx4vlkRbSsxVpgh8C7qo63XEV9xZ0zAw3Z84IzPHK5YM1Rc5PmnImj8vKsl3xEtiBi-7riulSpico3Ce6z0kc2hYVOff_l0a/s1600/genset_detect2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_PZwZMgXpvO8dMduo5rhZ7_mTzduxaCeGfiE0vzPYvC8sLx4vlkRbSsxVpgh8C7qo63XEV9xZ0zAw3Z84IzPHK5YM1Rc5PmnImj8vKsl3xEtiBi-7riulSpico3Ce6z0kc2hYVOff_l0a/s320/genset_detect2.png&quot; width=&quot;184&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJb53qzKEViFWpehln0AWe3AwWVHZ-KZPHpakuYaZe1yMkbzxFvZ5XIT1rLkymhxQBYAlTds3CUb3-QdRLNfWkLG8eNh4FG4WWMOwpcfT-1TNyZ3njty4JBGgJxrhS66G8PoD-9wxehAGU/s1600/genset_detect.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;156&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJb53qzKEViFWpehln0AWe3AwWVHZ-KZPHpakuYaZe1yMkbzxFvZ5XIT1rLkymhxQBYAlTds3CUb3-QdRLNfWkLG8eNh4FG4WWMOwpcfT-1TNyZ3njty4JBGgJxrhS66G8PoD-9wxehAGU/s320/genset_detect.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/4860471951123771609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2017/03/arduino-genset-detect-volt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/4860471951123771609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/4860471951123771609'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2017/03/arduino-genset-detect-volt.html' title='arduino genset detect volt'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivL7bJMzCaoMqS-1e7WbLl0kQl7BMBiy03Zpp33RKAc0PVyINDWja3Chase8bLp41MCX2IBRaWSGNXX1TGwbXagiaFtUuI3tglc_HG0dYttrxvuKlD_UxiZeP8_3X25NScJ-sbphIG6A4N/s72-c/arduino_generator_detector.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-1658859811139211729</id><published>2017-01-26T10:44:00.000-08:00</published><updated>2017-01-26T10:44:12.733-08:00</updated><title type='text'>ARDUINO LOAD CELL 50 KG</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3tpRTdkBJ1gldWcykj8PZ43GCfLbHTvT7_eFMU2TsjoG4nO_bh4VzPCf_euSLhLzkkooocvaziATSNvz3TY0gUKQWlA5zaO0NkON6cz5xwFqjU_V5d-oeOgzJSk5SpckhpG0GdRwFIVH3/s1600/load_cell_50kg.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;244&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3tpRTdkBJ1gldWcykj8PZ43GCfLbHTvT7_eFMU2TsjoG4nO_bh4VzPCf_euSLhLzkkooocvaziATSNvz3TY0gUKQWlA5zaO0NkON6cz5xwFqjU_V5d-oeOgzJSk5SpckhpG0GdRwFIVH3/s320/load_cell_50kg.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
First, you must using 4 load cell 50 kg for balance&lt;br /&gt;
please watch this tutorial&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe width=&quot;320&quot; height=&quot;266&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/0Lwdzpr_TxM/0.jpg&quot; src=&quot;https://www.youtube.com/embed/0Lwdzpr_TxM?feature=player_embedded&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
first do the calibration&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
=================================================================&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
#include &quot;HX711.h&quot; &amp;nbsp;//You must have this library in your arduino library folder ,search in github&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
#define DOUT &amp;nbsp;3&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
#define CLK &amp;nbsp;2&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
HX711 scale(DOUT, CLK);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//float calibration_factor = -96650; //-106600 worked for my 40Kg max scale setup&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp;float calibration_factor = 190;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//=============================================================================================&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SETUP&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//=============================================================================================&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
void setup() {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.begin(9600);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println(&quot;HX711 Calibration&quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println(&quot;Remove all weight from scale&quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println(&quot;After readings begin, place known weight on scale&quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println(&quot;Press a,s,d,f to increase calibration factor by 10,100,1000,10000 respectively&quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println(&quot;Press z,x,c,v to decrease calibration factor by 10,100,1000,10000 respectively&quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println(&quot;Press t for tare&quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; scale.set_scale();&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; scale.tare(); //Reset the scale to 0&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; long zero_factor = scale.read_average(); //Get a baseline reading&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.print(&quot;Zero factor: &quot;); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println(zero_factor);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//=============================================================================================&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LOOP&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//=============================================================================================&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
void loop() {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; scale.set_scale(calibration_factor); //Adjust to this calibration factor&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.print(&quot;Reading: &quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.print(0.453592 * scale.get_units(), 3);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.print(&quot; kg&quot;); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.print(&quot; calibration_factor: &quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.print(calibration_factor);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println();&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; if(Serial.available())&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; char temp = Serial.read();&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; if(temp == &#39;+&#39; || temp == &#39;a&#39;)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; calibration_factor += 10;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; else if(temp == &#39;-&#39; || temp == &#39;z&#39;)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; calibration_factor -= 10;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; else if(temp == &#39;s&#39;)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; calibration_factor += 100; &amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; else if(temp == &#39;x&#39;)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; calibration_factor -= 100; &amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; else if(temp == &#39;d&#39;)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; calibration_factor += 1000; &amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; else if(temp == &#39;c&#39;)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; calibration_factor -= 1000;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; else if(temp == &#39;f&#39;)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; calibration_factor += 10000; &amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; else if(temp == &#39;v&#39;)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; calibration_factor -= 10000; &amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; else if(temp == &#39;t&#39;)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; scale.tare(); &amp;nbsp;//Reset the scale to zero&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
=============================================================&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
load cell in action :&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
#include &quot;HX711.h&quot; &amp;nbsp;//You must have this library in your arduino library folder&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
#define DOUT &amp;nbsp;3&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
#define CLK &amp;nbsp;2&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
HX711 scale(DOUT, CLK);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
float calibration_factor = 230; //-106600 worked for my 40Kg max scale setup&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
double a;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//=============================================================================================&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SETUP&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//=============================================================================================&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
void setup() {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.begin(9600); &amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println(&quot;Press T to tare&quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; scale.set_scale(calibration_factor); &amp;nbsp;//Calibration Factor obtained from first sketch&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp;// scale.tare(); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Reset the scale to 0 &amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//=============================================================================================&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LOOP&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
//=============================================================================================&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
void loop() {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.print(&quot;Weight: &quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.print((0.453592 * scale.get_units(3))/10, 1); &amp;nbsp;//Up to 3 decimal points&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println(&quot; kg&quot;); //Change this to kg and re-adjust the calibration factor if you follow lbs&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; float a = ((0.453592 * scale.get_units(3))/10);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; Serial.println(a,1);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; if(a,1 &amp;gt;= 0.8){&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; Serial.println(&quot;stop&quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; if(Serial.available())&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; char temp = Serial.read();&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; if(temp == &#39;t&#39; || temp == &#39;T&#39;){&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; scale.tare(); &amp;nbsp;//Reset the scale to zero }&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; if(temp == &#39;a&#39;){&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; scale.set_scale(calibration_factor);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; scale.tare();&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; }&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/1658859811139211729/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2017/01/arduino-load-cell-50-kg.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/1658859811139211729'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/1658859811139211729'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2017/01/arduino-load-cell-50-kg.html' title='ARDUINO LOAD CELL 50 KG'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3tpRTdkBJ1gldWcykj8PZ43GCfLbHTvT7_eFMU2TsjoG4nO_bh4VzPCf_euSLhLzkkooocvaziATSNvz3TY0gUKQWlA5zaO0NkON6cz5xwFqjU_V5d-oeOgzJSk5SpckhpG0GdRwFIVH3/s72-c/load_cell_50kg.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-8713050455977164231</id><published>2017-01-17T02:13:00.001-08:00</published><updated>2017-02-27T01:13:10.925-08:00</updated><title type='text'>arduino TDS meter - cheap tds </title><content type='html'>just for my documentation&lt;br /&gt;
please refer to real web :&lt;br /&gt;
https://hackaday.io/project/7008-fly-wars-a-hackers-solution-to-world-hunger/log/24646-three-dollar-ec-ppm-meter-arduino&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Parts:&lt;br /&gt;
&lt;br /&gt;
-MCU of your choice with ADC&lt;br /&gt;
&lt;br /&gt;
-DS18B20 waterproof temperature sensor&lt;br /&gt;
&lt;br /&gt;
-500 ohm [or 1kohm resistor]&lt;br /&gt;
&lt;br /&gt;
-Type A Two Prong american plug to Figure 8&lt;br /&gt;
&lt;br /&gt;
-Female Socket for Figure 8 connector&lt;br /&gt;
&lt;br /&gt;
So why are we using a plug:&lt;br /&gt;
&lt;br /&gt;
-Cheap&lt;br /&gt;
&lt;br /&gt;
-Available worldwide&lt;br /&gt;
&lt;br /&gt;
-Standard size [makes calibration easy]&lt;br /&gt;
&lt;br /&gt;
Use the solid prong one like below and not the one with holes:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-UJ_K3GoTn6lql_nJ4qVoWzoaQhp9jir1avnBdIkrYqZ4YaV8UXPG5Pr_82fCdAjyAm3KzoS9yv0xHdXCsZqYFMjFrtMGm4ohW038a2YWAWdANw59D4gRb4NU9orDkzK-gIduofE94AuY/s1600/images.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;372&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-UJ_K3GoTn6lql_nJ4qVoWzoaQhp9jir1avnBdIkrYqZ4YaV8UXPG5Pr_82fCdAjyAm3KzoS9yv0xHdXCsZqYFMjFrtMGm4ohW038a2YWAWdANw59D4gRb4NU9orDkzK-gIduofE94AuY/s400/images.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;Wiring it up:&lt;br /&gt;
&lt;br /&gt;
Note: You want the Solid Prong type plug&lt;br /&gt;
&lt;br /&gt;
Do not Plug the pronged plug into the mains&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFfSS4R11j2v3VJrvZNQ7HYOKAe40jTPXQkD_cKGBgUVmEi2KbGE7fOWYiVyof4fTa5_e5r7y1RM66eGbChwzNoAom32E1McVibfDypH9h3UpzWmYkKe1zvUIc4LH63fUP6qfWbsEGGnb1/s1600/Pinout.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;474&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFfSS4R11j2v3VJrvZNQ7HYOKAe40jTPXQkD_cKGBgUVmEi2KbGE7fOWYiVyof4fTa5_e5r7y1RM66eGbChwzNoAom32E1McVibfDypH9h3UpzWmYkKe1zvUIc4LH63fUP6qfWbsEGGnb1/s640/Pinout.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Operating Principal&lt;br /&gt;
&lt;br /&gt;
PPM is calculated from the EC of a fluid, EC is the inverse of the electrical resistance of the fluid. We are estimating the EC or PPM of a fluid by measuring the resistance between two probes [The plug pins] when the plug is submerged in the liquid of interest.&lt;br /&gt;
&lt;br /&gt;
Ec measurement needs to be done using AC or the liquid of interest is polarised and will give bad readings. This has got to be a great example of asking why instead of just accepting a statement as fact, it turns out we can take a very fast DC reading without suffering polarisation. meaning we can make a really cheap EC sensor.&lt;br /&gt;
&lt;br /&gt;
Want to use it and dont care how it works? Skip to the main EC code and using the wiring diagram it will work.&lt;br /&gt;
&lt;br /&gt;
Temperature Compensation&lt;br /&gt;
&lt;br /&gt;
Temperature has an effect on the conductivity of fluids so it is essential that we compensate for this.&lt;br /&gt;
&lt;br /&gt;
It is common to use a liner approximation for small temperature changes[1] to convert them to their equivelant EC at 25*C:&lt;br /&gt;
&lt;br /&gt;
EC25 = EC /( 1 + a (T - 25) )&lt;br /&gt;
&lt;br /&gt;
EC25- Equivelant EC at 25&#39;C&lt;br /&gt;
&lt;br /&gt;
EC - Measured EC&lt;br /&gt;
&lt;br /&gt;
T- Temperature [Decgrees C] of Measurment&lt;br /&gt;
&lt;br /&gt;
a = 0.019 °C [Commonly used for nutrient solutions]&lt;br /&gt;
&lt;br /&gt;
Deciding on Value of R1&lt;br /&gt;
&lt;br /&gt;
//##################################################################################&lt;br /&gt;
//----------- Do not Replace R1 with a resistor lower than 300 ohms ------------&lt;br /&gt;
//##################################################################################&lt;br /&gt;
We can change the Value of R1 in the voltage divider to change the range of EC we want to measure. Below is the Equivalent Voltage divider circuit.&lt;br /&gt;
&lt;br /&gt;
//************************** Libraries Needed To Compile The Script [See Read me In Download] ***************//&lt;br /&gt;
// Both below Library are custom ones [ SEE READ ME In Downloaded Zip If You Dont Know how To install] Use them or add a pull up resistor to the temp probe&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;OneWire.h&amp;gt;&lt;br /&gt;
#include &amp;lt;DallasTemperature.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//************************* User Defined Variables ********************************************************//&lt;br /&gt;
//##################################################################################&lt;br /&gt;
//----------- &amp;nbsp;Do not Replace R1 with a resistor lower than 300 ohms &amp;nbsp; &amp;nbsp;------------&lt;br /&gt;
//##################################################################################&lt;br /&gt;
int R1= 1000;&lt;br /&gt;
int Ra=25; //Resistance of powering Pins&lt;br /&gt;
int ECPin= A0;&lt;br /&gt;
int ECGround=A1;&lt;br /&gt;
int ECPower =A4;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*********** Converting to ppm [Learn to use EC it is much better**************//&lt;br /&gt;
// Hana &amp;nbsp; &amp;nbsp; &amp;nbsp;[USA] &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PPMconverion: &amp;nbsp;0.5&lt;br /&gt;
// Eutech &amp;nbsp; &amp;nbsp;[EU] &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PPMconversion: &amp;nbsp;0.64&lt;br /&gt;
//Tranchen &amp;nbsp;[Australia] &amp;nbsp;PPMconversion: &amp;nbsp;0.7&lt;br /&gt;
// Why didnt anyone standardise this?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
float PPMconversion=0.5;&lt;br /&gt;
&lt;br /&gt;
//*************Compensating for temperature ************************************//&lt;br /&gt;
//The value below will change depending on what chemical solution we are measuring&lt;br /&gt;
//0.019 is generaly considered the standard for plant nutrients [google &quot;Temperature compensation EC&quot; for more info&lt;br /&gt;
float TemperatureCoef = 0.019; //this changes depending on what chemical we are measuring&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//********************** Cell Constant For Ec Measurements *********************//&lt;br /&gt;
//Mine was around 2.9 with plugs being a standard size they should all be around the same&lt;br /&gt;
//But If you get bad readings you can use the calibration script and fluid to get a better estimate for K&lt;br /&gt;
//float K=2.88;&lt;br /&gt;
&amp;nbsp;float K=4.25;&lt;br /&gt;
&lt;br /&gt;
//************ Temp Probe Related *********************************************//&lt;br /&gt;
#define ONE_WIRE_BUS 10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Data wire For Temp Probe is plugged into pin 10 on the Arduino&lt;br /&gt;
const int TempProbePossitive =8; &amp;nbsp;//Temp Probe power connected to pin 9&lt;br /&gt;
const int TempProbeNegative=9; &amp;nbsp; &amp;nbsp;//Temp Probe Negative connected to pin 8&lt;br /&gt;
&lt;br /&gt;
//***************************** END Of Recomended User Inputs *****************************************************************//&lt;br /&gt;
&lt;br /&gt;
OneWire oneWire(ONE_WIRE_BUS);// Setup a oneWire instance to communicate with any OneWire devices&lt;br /&gt;
DallasTemperature sensors(&amp;amp;oneWire);// Pass our oneWire reference to Dallas Temperature.&lt;br /&gt;
&lt;br /&gt;
float Temperature=10;&lt;br /&gt;
float EC=0;&lt;br /&gt;
float EC25 =0;&lt;br /&gt;
int ppm =0;&lt;br /&gt;
&lt;br /&gt;
float raw= 0;&lt;br /&gt;
float Vin= 5;&lt;br /&gt;
float Vdrop= 0;&lt;br /&gt;
float Rc= 0;&lt;br /&gt;
float buffer=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*********************************Setup - runs Once and sets pins etc ******************************************************//&lt;br /&gt;
void setup()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; Serial.begin(9600);&lt;br /&gt;
&amp;nbsp; pinMode(TempProbeNegative , OUTPUT ); //seting ground pin as output for tmp probe&lt;br /&gt;
&amp;nbsp; digitalWrite(TempProbeNegative , LOW );//Seting it to ground so it can sink current&lt;br /&gt;
&amp;nbsp; pinMode(TempProbePossitive , OUTPUT );//ditto but for positive&lt;br /&gt;
&amp;nbsp; digitalWrite(TempProbePossitive , HIGH );&lt;br /&gt;
&amp;nbsp; pinMode(ECPin,INPUT);&lt;br /&gt;
&amp;nbsp; pinMode(ECPower,OUTPUT);//Setting pin for sourcing current&lt;br /&gt;
&amp;nbsp; pinMode(ECGround,OUTPUT);//setting pin for sinking current&lt;br /&gt;
&amp;nbsp; digitalWrite(ECGround,LOW);//We can leave the ground connected permanantly&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; delay(100);// gives sensor time to settle&lt;br /&gt;
&amp;nbsp; sensors.begin();&lt;br /&gt;
&amp;nbsp; delay(100);&lt;br /&gt;
&amp;nbsp; //** Adding Digital Pin Resistance to [25 ohm] to the static Resistor *********//&lt;br /&gt;
&amp;nbsp; // Consule Read-Me for Why, or just accept it as true&lt;br /&gt;
&amp;nbsp; R1=(R1+Ra);// Taking into acount Powering Pin Resitance&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;ElCheapo Arduino EC-PPM measurments&quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;By: Michael Ratcliffe &amp;nbsp;Mike@MichaelRatcliffe.com&quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;Free software: you can redistribute it and/or modify it under GNU &quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;&quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;Make sure Probe and Temp Sensor are in Solution and solution is well mixed&quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;&quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;Measurments at 5&#39;s Second intervals [Dont read Ec morre than once every 5 seconds]:&quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
};&lt;br /&gt;
//******************************************* End of Setup **********************************************************************//&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//************************************* Main Loop - Runs Forever ***************************************************************//&lt;br /&gt;
//Moved Heavy Work To subroutines so you can call them from main loop without cluttering the main loop&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
GetEC(); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Calls Code to Go into GetEC() Loop [Below Main Loop] dont call this more that 1/5 hhz [once every five seconds] or you will polarise the water&lt;br /&gt;
PrintReadings(); &amp;nbsp;// Cals Print routine [below main loop]&lt;br /&gt;
delay(5000);&lt;br /&gt;
}&lt;br /&gt;
//************************************** End Of Main Loop **********************************************************************//&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//************ This Loop Is called From Main Loop************************//&lt;br /&gt;
void GetEC(){&lt;br /&gt;
&lt;br /&gt;
//*********Reading Temperature Of Solution *******************//&lt;br /&gt;
sensors.requestTemperatures();// Send the command to get temperatures&lt;br /&gt;
Temperature=sensors.getTempCByIndex(0); //Stores Value in Variable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//************Estimates Resistance of Liquid ****************//&lt;br /&gt;
digitalWrite(ECPower,HIGH);&lt;br /&gt;
raw= analogRead(ECPin);&lt;br /&gt;
raw= analogRead(ECPin);// This is not a mistake, First reading will be low beause if charged a capacitor&lt;br /&gt;
digitalWrite(ECPower,LOW);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//***************** Converts to EC **************************//&lt;br /&gt;
Vdrop= (Vin*raw)/1024.0;&lt;br /&gt;
Rc=(Vdrop*R1)/(Vin-Vdrop);&lt;br /&gt;
Rc=Rc-Ra; //acounting for Digital Pin Resitance&lt;br /&gt;
EC = 1000/(Rc*K);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//*************Compensating For Temperaure********************//&lt;br /&gt;
EC25 &amp;nbsp;= &amp;nbsp;EC/ (1+ TemperatureCoef*(Temperature-25.0));&lt;br /&gt;
ppm=(EC25)*(PPMconversion*1000);&lt;br /&gt;
;}&lt;br /&gt;
//************************** End OF EC Function ***************************//&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//***This Loop Is called From Main Loop- Prints to serial usefull info ***//&lt;br /&gt;
void PrintReadings(){&lt;br /&gt;
Serial.print(&quot;Rc: &quot;);&lt;br /&gt;
Serial.print(Rc);&lt;br /&gt;
Serial.print(&quot; EC: &quot;);&lt;br /&gt;
Serial.print(EC25);&lt;br /&gt;
Serial.print(&quot; Simens &amp;nbsp;&quot;);&lt;br /&gt;
Serial.print(ppm);&lt;br /&gt;
Serial.print(&quot; ppm &amp;nbsp;&quot;);&lt;br /&gt;
Serial.print(Temperature);&lt;br /&gt;
Serial.println(&quot; *C &quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
//********** Usued for Debugging ************&lt;br /&gt;
Serial.print(&quot;Vdrop: &quot;);&lt;br /&gt;
Serial.println(Vdrop);&lt;br /&gt;
Serial.print(&quot;Rc: &quot;);&lt;br /&gt;
Serial.println(Rc);&lt;br /&gt;
Serial.print(EC);&lt;br /&gt;
Serial.println(&quot;Siemens&quot;);&lt;br /&gt;
//********** end of Debugging Prints *********&lt;br /&gt;
*/&lt;br /&gt;
};</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/8713050455977164231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2017/01/arduino-tds-meter-cheap-tds.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/8713050455977164231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/8713050455977164231'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2017/01/arduino-tds-meter-cheap-tds.html' title='arduino TDS meter - cheap tds '/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-UJ_K3GoTn6lql_nJ4qVoWzoaQhp9jir1avnBdIkrYqZ4YaV8UXPG5Pr_82fCdAjyAm3KzoS9yv0xHdXCsZqYFMjFrtMGm4ohW038a2YWAWdANw59D4gRb4NU9orDkzK-gIduofE94AuY/s72-c/images.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-5543199232029944387</id><published>2017-01-11T09:41:00.001-08:00</published><updated>2017-01-11T09:41:24.195-08:00</updated><title type='text'>arduino water flow</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSDFRBtRUFNOz8JWWQmDuHbKQ8_9aU5ruOq3AFXgamvm5ECmN6g58oV6s3ssjFX7_8vt7Jwg7fFbfI54MxMOiYQPy3y3JKkjMtGOP4h6zIF3YuDT_lkl8hi1EhedrbaAgqPkF04ME3BEyC/s1600/water_flow_arduino.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;384&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSDFRBtRUFNOz8JWWQmDuHbKQ8_9aU5ruOq3AFXgamvm5ECmN6g58oV6s3ssjFX7_8vt7Jwg7fFbfI54MxMOiYQPy3y3JKkjMtGOP4h6zIF3YuDT_lkl8hi1EhedrbaAgqPkF04ME3BEyC/s640/water_flow_arduino.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Features:&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Model: YF-S201&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Working Voltage: 5 to 18V DC (min tested working voltage 4.5V)&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Max current draw: 15mA @ 5V&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Output Type: 5V TTL&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Working Flow Rate: 1 to 30 Liters/Minute&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Working Temperature range: -25 to +80?&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Working Humidity Range: 35%-80% RH&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Accuracy: ±10%&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Maximum water pressure: 2.0 MPa&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Output duty cycle: 50% +-10%&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Output rise time: 0.04us&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Output fall time: 0.18us&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Flow rate pulse characteristics: Frequency (Hz) = 7.5 * Flow rate (L/min)&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;b style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Pulses per Liter: 450&lt;/b&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Durability: minimum 300,000 cycles&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Cable length: 15cm&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;1/2&quot; nominal pipe connections, 0.78&quot; outer diameter, 1/2&quot; of thread&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;Size: 2.5&quot; x 1.4&quot; x 1.4&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
using interupt pin&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;const int PinSensorWaterFlowTaman=2;// intr 0 // pin 2&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;float flow_countertaman,litertaman,adcph,teg,ph;&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;const int PinKranTaman =9;//// kran untuk taman&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;void setup()&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp;pinMode(PinSensorWaterFlowTaman, INPUT);&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; digitalWrite(PinSensorWaterFlowTaman, HIGH);&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attachInterrupt(0, flowtaman, RISING); // Setup Interrupt 0 pada pin 2&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp;Serial.begin(9600);&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp; pinMode(PinKranTaman,OUTPUT);&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; digitalWrite(PinKranTaman,LOW);&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;void loop()&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;{&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp;Serial.println(flow_countertaman);&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp;Serial.println(litertaman);&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;delay(1000);&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;}&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;void flowtaman () // Interrupt function taman&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flow_countertaman++;&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; litertaman=flow_countertaman/450;&lt;/span&gt;&lt;br style=&quot;background-color: white; box-sizing: border-box; color: #222222; font-family: Roboto; font-size: 14px; margin: 0px; padding: 0px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #222222; font-family: Roboto; font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/5543199232029944387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2017/01/arduino-water-flow.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/5543199232029944387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/5543199232029944387'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2017/01/arduino-water-flow.html' title='arduino water flow'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSDFRBtRUFNOz8JWWQmDuHbKQ8_9aU5ruOq3AFXgamvm5ECmN6g58oV6s3ssjFX7_8vt7Jwg7fFbfI54MxMOiYQPy3y3JKkjMtGOP4h6zIF3YuDT_lkl8hi1EhedrbaAgqPkF04ME3BEyC/s72-c/water_flow_arduino.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-7601831605099766955</id><published>2017-01-10T10:19:00.003-08:00</published><updated>2017-02-23T20:21:21.643-08:00</updated><title type='text'>ACS712 with AC POWER</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc-mVUj7ve4gA7QZZ7g5MfCdYZOZE5g1BC-QFX21HUcDRlvacJOi_TbylbXxfLeQy50j_kU2WEZ8ZFTVbiVfx6Fytk7N4QlYM9hTquEz6XE75BEU-w9MOni4aU4nrWhLPBtDVjjSlWAu1D/s1600/acs712.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc-mVUj7ve4gA7QZZ7g5MfCdYZOZE5g1BC-QFX21HUcDRlvacJOi_TbylbXxfLeQy50j_kU2WEZ8ZFTVbiVfx6Fytk7N4QlYM9hTquEz6XE75BEU-w9MOni4aU4nrWhLPBtDVjjSlWAu1D/s320/acs712.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
GREEN = ARDE/GROUND&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
WHITE = PHASE&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
BLACK = 0V&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
copas dari&amp;nbsp;&lt;b&gt;https://www.facebook.com/dani.ardianto.rajacell&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;&quot;&gt;
//Mengukur arus pada tegangan AC 220V dengan Sensor ACS712&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;&quot;&gt;
//Analog Output ACS712 pada PIN A0&lt;br /&gt;
const int sensorIn = A0;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;&quot;&gt;
int mVperAmp = 185;&lt;br /&gt;
//Konversi A ke mV&lt;br /&gt;
// use 185 for ACS712 5A&lt;br /&gt;
// use 100 for ACS712 20A&lt;br /&gt;
// use 66 for ACS712 30A&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;&quot;&gt;
double Voltage = 0;&lt;br /&gt;
double VRMS = 0;&lt;br /&gt;
double AmpsRMS = 0;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;&quot;&gt;
void setup(){&lt;br /&gt;
Serial.begin(9600);&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;&quot;&gt;
void loop(){&lt;br /&gt;
Voltage = getVPP();&lt;br /&gt;
VRMS = (Voltage/2.0) *0.707;&lt;br /&gt;
AmpsRMS = (VRMS * 1000)/mVperAmp;&lt;br /&gt;
Serial.print(AmpsRMS);&lt;br /&gt;
Serial.println(&quot; Amps RMS&quot;);&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;&quot;&gt;
}&lt;br /&gt;
float getVPP()&lt;br /&gt;
{&lt;br /&gt;
float result;&lt;br /&gt;
int readValue; //value read from the sensor&lt;br /&gt;
int maxValue = 0; // store max value here&lt;br /&gt;
int minValue = 1024; // store min value here&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; margin-top: 6px;&quot;&gt;
uint32_t start_time = millis();&lt;br /&gt;
while((millis()-start_time) &amp;lt; 1000) //sample for 1 Sec&lt;br /&gt;
{&lt;br /&gt;
readValue = analogRead(sensorIn);&lt;br /&gt;
// see if you have a new maxValue&lt;br /&gt;
if (readValue &amp;gt; maxValue)&lt;br /&gt;
{&lt;br /&gt;
/*record the maximum sensor value*/&lt;br /&gt;
maxValue = readValue;&lt;br /&gt;
}&lt;br /&gt;
if (readValue &amp;lt; minValue)&lt;br /&gt;
{&lt;br /&gt;
/*record the maximum sensor value*/&lt;br /&gt;
minValue = readValue;&lt;br /&gt;
}&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #1d2129; display: inline; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin-top: 6px;&quot;&gt;
// Subtract min from max&lt;br /&gt;
result = ((maxValue - minValue) * 5.0)/1024.0;&lt;br /&gt;
return result;&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/7601831605099766955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2017/01/acs712-with-ac-power.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7601831605099766955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7601831605099766955'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2017/01/acs712-with-ac-power.html' title='ACS712 with AC POWER'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc-mVUj7ve4gA7QZZ7g5MfCdYZOZE5g1BC-QFX21HUcDRlvacJOi_TbylbXxfLeQy50j_kU2WEZ8ZFTVbiVfx6Fytk7N4QlYM9hTquEz6XE75BEU-w9MOni4aU4nrWhLPBtDVjjSlWAu1D/s72-c/acs712.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-5211753903993305189</id><published>2016-12-12T09:54:00.003-08:00</published><updated>2016-12-12T09:54:28.543-08:00</updated><title type='text'>arduino HC-SR04 anti bounching </title><content type='html'>&lt;span style=&quot;background-color: white; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;HC-SR04&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #f6f7f9; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 12px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;unsigned long delay1,delay2;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;if (jarak&amp;lt;=30){&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: #f6f7f9; color: #1d2129; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 12px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;if (millis()-delay1&amp;gt;=2000){&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;digitalWrite(relay,LOW);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;else { delay1=millis();}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;if (jaraK&amp;gt;=200){&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;if (millis()-delay2&amp;gt;=2000){&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;digitalWrite(relay,HIGH);&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;else { delay2=millis();}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/5211753903993305189/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/12/arduino-hc-sr04-anti-bounching.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/5211753903993305189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/5211753903993305189'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/12/arduino-hc-sr04-anti-bounching.html' title='arduino HC-SR04 anti bounching '/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-3176017494164440035</id><published>2016-11-28T07:11:00.001-08:00</published><updated>2016-12-28T12:08:58.232-08:00</updated><title type='text'>NRF24L01 for remote relay</title><content type='html'>NRF24L01 for remote relay&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//receiver&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SPI.h&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // SPI Arayüzünü dahil ettik.&lt;br /&gt;
//#include &quot;nRF24L01.h&quot;&lt;br /&gt;
#include &quot;RF24.h&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// RF24 kütüpanelerini dahil ettik.&lt;br /&gt;
#include &amp;lt;Wire.h&amp;gt;&lt;br /&gt;
#include &amp;lt;DS3231.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
DS3231 &amp;nbsp;rtc(SDA, SCL);&lt;br /&gt;
// Init a Time-data structure&lt;br /&gt;
Time &amp;nbsp;t;&lt;br /&gt;
uint32_t targetTime = 0;&lt;br /&gt;
uint8_t hh = 0, mm = 0, ss = 0, dd = 0, bb = 0; //variable Unsignet int 0-255&lt;br /&gt;
int yy = 0; //variable integer&lt;br /&gt;
byte data[1]; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Göndereceğimiz data değişkenini oluşturduk.&lt;br /&gt;
boolean var; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Bit şeklinde var değişkeninini oluşturduk.&lt;br /&gt;
const uint64_t pipe = 0xF0F0F0F0E1LL; &lt;br /&gt;
RF24 radio(9, 10); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Modülün CE pinini 9.pin CS pinini de 10.pine bağlayacağımızı belirttik.&lt;br /&gt;
&lt;br /&gt;
int r1 = 0, r2 = 0, r3 = 0;&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
&amp;nbsp; Serial.begin(57600);&lt;br /&gt;
&amp;nbsp; pinMode(3, OUTPUT); digitalWrite(3, HIGH);//kolam renang&lt;br /&gt;
&amp;nbsp; pinMode(5, OUTPUT); digitalWrite(5, HIGH);//kolam naga&lt;br /&gt;
&amp;nbsp; pinMode(7, OUTPUT); digitalWrite(7, HIGH); //lampu naga&lt;br /&gt;
&amp;nbsp; radio.begin(); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; radio.openReadingPipe(1, pipe); &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; radio.startListening();&lt;br /&gt;
&amp;nbsp; rtc.begin();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; // NRF remote&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; if (radio.available()) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; bool var = false;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while (!var) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; var = radio.read(&amp;amp;data, 1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }//while&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (data[0] == 1 &amp;amp;&amp;amp; r1 == 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(3, LOW);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;// Serial.println(&quot;RELAY 3 LOW&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; r1 = 1; data[0] = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (data[0] == 1 &amp;amp;&amp;amp; r1 == 1 ) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(3, HIGH);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //Serial.println(&quot;RELAY 3 HIGH &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; r1 = 0; data[0] = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (data[0] == 2 &amp;amp;&amp;amp; r2 == 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(5, LOW);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //Serial.println(&quot;RELAY 5 LOW&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; r2 = 1; data[0] = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (data[0] == 2 &amp;amp;&amp;amp; r2 == 1 ) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(5, HIGH);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //Serial.println(&quot;RELAY 5 HIGH &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; r2 = 0; data[0] = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (data[0] == 3 &amp;amp;&amp;amp; r3 == 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(7, LOW);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //Serial.println(&quot;RELAY 7 LOW&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; r3 = 1; data[0] = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (data[0] == 3 &amp;amp;&amp;amp; r3 == 1 ) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(7, HIGH);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //Serial.println(&quot;RELAY 7 HIGH &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; r3 = 0 ; data[0] = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; }//if&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; t = rtc.getTime(); &amp;nbsp;// gate all data time &amp;amp; date from RTC&lt;br /&gt;
&amp;nbsp; hh = t.hour, DEC; //pengambilan data jam&lt;br /&gt;
&amp;nbsp; mm = t.min, DEC; //pengambilan data menit&lt;br /&gt;
&amp;nbsp; ss = t.sec, DEC; //pengambilan data detik&lt;br /&gt;
&amp;nbsp; //Serial.print (hh); Serial.print (F(&quot; : &quot;));&lt;br /&gt;
&amp;nbsp; //Serial.print (mm); Serial.print (F(&quot; : &quot;));&lt;br /&gt;
&amp;nbsp; //Serial.println (ss);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; //jam 9 pagi&lt;br /&gt;
&amp;nbsp; if (hh == 10 &amp;amp;&amp;amp; mm == 0 &amp;amp;&amp;amp; ss == 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(3, LOW);//kolam renang&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(5, LOW);//kolam naga&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(7, HIGH);//lampu naga //relay 3&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; if (hh == 15 &amp;amp;&amp;amp; &amp;nbsp;mm == 0 &amp;amp;&amp;amp; ss == 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(3, HIGH);//kolam renang&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(5, HIGH);//kolam naga&lt;br /&gt;
&amp;nbsp; &amp;nbsp; digitalWrite(7, HIGH);//lampu naga&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
delay(1000);&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
// transmitter&lt;br /&gt;
#include &amp;nbsp;&amp;lt;SPI.h&amp;gt;&lt;br /&gt;
//#include &quot;nRF24L01.h&quot;&lt;br /&gt;
#include &amp;nbsp;&quot;RF24.h&quot;&lt;br /&gt;
#include &amp;lt;PinChangeInterrupt.h&amp;gt;&lt;br /&gt;
#include &amp;lt;avr/sleep.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
volatile byte flag = 0;&lt;br /&gt;
void handler() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; flag = 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //Serial.println(&quot;wake up&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //delay(100);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; detachPinChangeInterrupt(3);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; detachPinChangeInterrupt(5);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; detachPinChangeInterrupt(7);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
byte data[1];&lt;br /&gt;
const uint64_t pipe = 0xF0F0F0F0E1LL;&lt;br /&gt;
RF24 radio(9, 10); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Modülün CE pinini 9.pin CS pinini de 10.pine bağlayacağımızı belirttik.&lt;br /&gt;
unsigned long nowTime;&lt;br /&gt;
unsigned long start1;&lt;br /&gt;
&lt;br /&gt;
unsigned long previousMillis = 0;&lt;br /&gt;
unsigned long startSleep;&lt;br /&gt;
&lt;br /&gt;
int kirim = 0,btn3,btn5,btn7;&lt;br /&gt;
int sleepStatus = 0; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // variable to store a request for sleep&lt;br /&gt;
int count = 0; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // counter&lt;br /&gt;
void wakeUpNow() &amp;nbsp; {}&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
&amp;nbsp; Serial.begin(57600);&lt;br /&gt;
&amp;nbsp; pinMode(3, INPUT_PULLUP);&lt;br /&gt;
&amp;nbsp; pinMode(5, INPUT_PULLUP);&lt;br /&gt;
&amp;nbsp; pinMode(7, INPUT_PULLUP);&lt;br /&gt;
&amp;nbsp; pinMode(13, INPUT);&lt;br /&gt;
&amp;nbsp; digitalWrite(13, LOW);&lt;br /&gt;
&amp;nbsp; attachPCINT(digitalPinToPCINT(3), handler, CHANGE);&lt;br /&gt;
&amp;nbsp; attachPCINT(digitalPinToPCINT(5), handler, CHANGE);&lt;br /&gt;
&amp;nbsp; attachPCINT(digitalPinToPCINT(7), handler, CHANGE);&lt;br /&gt;
&amp;nbsp; radio.begin();&lt;br /&gt;
&amp;nbsp; radio.setRetries(15,15);&lt;br /&gt;
&amp;nbsp; radio.openWritingPipe(pipe);&lt;br /&gt;
&amp;nbsp; radio.startListening();&lt;br /&gt;
}&lt;br /&gt;
void sleepNow(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; set_sleep_mode(SLEEP_MODE_PWR_DOWN);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; sleep_enable(); &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; attachPCINT(digitalPinToPCINT(3), handler, CHANGE);&lt;br /&gt;
&amp;nbsp; attachPCINT(digitalPinToPCINT(5), handler, CHANGE);&lt;br /&gt;
&amp;nbsp; attachPCINT(digitalPinToPCINT(7), handler, CHANGE);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; sleep_mode(); &lt;br /&gt;
&amp;nbsp; &amp;nbsp; sleep_disable();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; detachPinChangeInterrupt(3);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; detachPinChangeInterrupt(5);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; detachPinChangeInterrupt(7);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
//Serial.println(&quot;bgn&quot;);&lt;br /&gt;
&amp;nbsp; btn3 = digitalRead(3);&lt;br /&gt;
&amp;nbsp; btn5 = digitalRead(5);&lt;br /&gt;
&amp;nbsp; btn7 = digitalRead(7);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; if(flag == 1){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if (btn3==0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data[0] = 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Serial.println(&quot;RELAY 3 &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; else if (btn5==0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data[0] = 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Serial.println(&quot;RELAY 5 &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; else if (btn7==0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data[0] = 3;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Serial.println(&quot;RELAY 7 &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; radio.stopListening();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; radio.write( &amp;amp;data, sizeof(unsigned long) );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; radio.startListening();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(1000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; data[0]=9;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; flag = 0;&lt;br /&gt;
&amp;nbsp; }//flag&lt;br /&gt;
&amp;nbsp; startSleep = millis();&lt;br /&gt;
&amp;nbsp; if(startSleep - previousMillis &amp;gt;= 3000) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; previousMillis = startSleep;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.println(&quot;sleep&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; sleepNow();&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}//end loop&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/3176017494164440035/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/11/nrf24l01-for-remote-relay.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/3176017494164440035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/3176017494164440035'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/11/nrf24l01-for-remote-relay.html' title='NRF24L01 for remote relay'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-2178203329734219740</id><published>2016-11-07T11:40:00.005-08:00</published><updated>2016-12-28T12:07:08.554-08:00</updated><title type='text'>nodemcu cloudmqtt servo</title><content type='html'>#include &amp;lt;ESP8266WiFi.h&amp;gt;&lt;br /&gt;
#include &amp;lt;PubSubClient.h&amp;gt;&lt;br /&gt;
#include &amp;lt;Servo.h&amp;gt; &lt;br /&gt;
#include&amp;lt;EEPROM.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
long lastReconnectAttempt = 0;&lt;br /&gt;
int servoPin = D4;&lt;br /&gt;
bool statusBall;&lt;br /&gt;
const char *statusBall2;&lt;br /&gt;
bool statusBall3;&lt;br /&gt;
int addressEpp = 0;&lt;br /&gt;
Servo servo; &lt;br /&gt;
const char *statusServo;&lt;br /&gt;
const char *ssid = &amp;nbsp;&quot;ssid&quot;; &amp;nbsp; // cannot be longer than 32 characters!&lt;br /&gt;
const char *pass = &amp;nbsp;&quot;pass&quot;; &amp;nbsp; //&lt;br /&gt;
&lt;br /&gt;
//Prepare Mqtt connection data&lt;br /&gt;
const char *MQTTBroker = &quot;cloudmqtt.com&quot;;&lt;br /&gt;
const char *MQTTuser = &quot;&quot;;&lt;br /&gt;
const char *MQTTpassword = &quot;&quot;;&lt;br /&gt;
//const char *Topic = &quot;/kranstatus&quot;;&lt;br /&gt;
//const char *Topicid = &quot;/kran&quot;;&lt;br /&gt;
uint16_t port = 12728;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void cekMem(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; statusBall=EEPROM.read(1);&lt;br /&gt;
&amp;nbsp;// Serial.println(&quot; memory &quot;);&lt;br /&gt;
&amp;nbsp;// Serial.println(statusBall);&lt;br /&gt;
&amp;nbsp; if(statusBall == 1){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; statusBall2 = &quot;on&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servoOn();&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; if(statusBall == 0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; statusBall2 =&quot;off&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servoOff();&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;// Serial.println(&quot;memory part&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;//Serial.println(statusBall2);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void servoOn(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.attach(servoPin);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.write(86);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(800);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.detach();&lt;br /&gt;
&amp;nbsp; &amp;nbsp;// Serial.println(&quot;servo on&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; statusBall2 = &quot;on&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; EEPROM.write(1, 1);&lt;br /&gt;
}&lt;br /&gt;
void servoOff(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.attach(servoPin);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.write(250);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(800);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.detach();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //Serial.println(&quot;servo off&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; statusBall2 = &quot;off&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; EEPROM.write(1, 0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//PubSubClient mqtt(MQTTBroker,port);&lt;br /&gt;
WiFiClient wclient;&lt;br /&gt;
PubSubClient client(wclient, MQTTBroker, port);&lt;br /&gt;
&lt;br /&gt;
void callback(const MQTT::Publish&amp;amp; pub){&lt;br /&gt;
&amp;nbsp; //Serial.println(pub.payload_string());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(pub.payload_string()==&quot;on&quot; &amp;amp;&amp;amp; statusBall2 == &quot;off&quot; ){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servoOn();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //Serial.println(&quot;call back on&quot;);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; if(pub.payload_string()==&quot;off&quot; &amp;amp;&amp;amp; statusBall2 == &quot;on&quot;){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servoOff();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //Serial.println(&quot;call back off&quot;);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
void WIFI_Connect()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; WiFi.disconnect(1);&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;Booting Sketch...&quot;);&lt;br /&gt;
&amp;nbsp; delay(2000);&lt;br /&gt;
&amp;nbsp; WiFi.mode(WIFI_STA);&lt;br /&gt;
&amp;nbsp; WiFi.begin(ssid, pass);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int Attempt = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while (WiFi.status() == 6) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(100);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Attempt++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if (Attempt == 300) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ESP.restart();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; client.set_callback(callback); &amp;nbsp;//Set Callback function&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; if (client.connect(MQTT::Connect(&quot;kran&quot;).set_auth(MQTTuser,MQTTpassword))){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; client.publish(&quot;kranstatus&quot;, statusBall2); &amp;nbsp;//publish&lt;br /&gt;
&amp;nbsp; &amp;nbsp; client.subscribe(&quot;kranstatus&quot;); &amp;nbsp; &amp;nbsp;//subscribe&lt;br /&gt;
&amp;nbsp; } &lt;br /&gt;
&amp;nbsp; &amp;nbsp;// Serial.print(&quot;Wifi connect&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //Serial.println(WiFi.status()); &lt;br /&gt;
}&lt;br /&gt;
void setup()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; statusBall=EEPROM.read(1);&lt;br /&gt;
&amp;nbsp; //Serial.print(&quot; memory --&quot;);&lt;br /&gt;
&amp;nbsp; //Serial.println(statusBall);&lt;br /&gt;
&amp;nbsp; if(statusBall == 1){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; statusBall2 = &quot;on&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servoOn();&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; if(statusBall == 0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; statusBall2 =&quot;off&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servoOff();&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; //Serial.print(&quot;memory status&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;//Serial.println(statusBall2);&lt;br /&gt;
&amp;nbsp; //Serial.begin(9600);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; WIFI_Connect();&lt;br /&gt;
&amp;nbsp; //client.set_callback(callback); &amp;nbsp;//Set Callback function&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; //if (client.connect(MQTT::Connect(&quot;kran&quot;).set_auth(MQTTuser,MQTTpassword))){&lt;br /&gt;
&amp;nbsp; // &amp;nbsp;client.publish(&quot;kranstatus&quot;, statusBall2); &amp;nbsp;//publish&lt;br /&gt;
&amp;nbsp; // &amp;nbsp;client.subscribe(&quot;kranstatus&quot;); &amp;nbsp; &amp;nbsp;//subscribe&lt;br /&gt;
&amp;nbsp; //}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //delay(1000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //client.subscribe(&quot;kranstatus&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //client.publish(&quot;kranstatus&quot;, statusBall2); &amp;nbsp;//publish&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //Serial.print(&quot;status loop &quot;); &lt;br /&gt;
&amp;nbsp; &amp;nbsp; //Serial.println(WiFi.status());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(2000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (WiFi.status() == 6)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //Serial.println(&quot;putus koneksi&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; WIFI_Connect();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if(!client.subscribe(&quot;kranstatus&quot;)){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WIFI_Connect();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if(!client.publish(&quot;kranstatus&quot;, statusBall2)){ &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WIFI_Connect();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //delay(1000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //client.subscribe(&quot;kranstatus&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //client.publish(&quot;kranstatus&quot;, statusBall2); &amp;nbsp;//publish&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
client.loop();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/2178203329734219740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/11/nodemcu-cloudmqtt-servo_7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/2178203329734219740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/2178203329734219740'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/11/nodemcu-cloudmqtt-servo_7.html' title='nodemcu cloudmqtt servo'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-4137156512441971236</id><published>2016-10-26T11:49:00.001-07:00</published><updated>2016-11-07T11:52:34.500-08:00</updated><title type='text'>Nodemcu 12E with servo mg995</title><content type='html'>#include &amp;lt;ESP8266WiFi.h&amp;gt;&lt;br /&gt;
#include &amp;lt;Servo.h&amp;gt; &lt;br /&gt;
const char* ssid = &quot;&quot;;&lt;br /&gt;
const char* password = &quot;&quot;;&lt;br /&gt;
&lt;br /&gt;
//int ledPin = 13; // GPIO13&lt;br /&gt;
int val = 0; &amp;nbsp; &amp;nbsp; // variable for reading the pin status&lt;br /&gt;
int servoPin = D4;&lt;br /&gt;
Servo servo; &lt;br /&gt;
int flag = 1;&lt;br /&gt;
int tranPin = 14; //Transister base pin&lt;br /&gt;
&lt;br /&gt;
WiFiServer server(80);&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
&amp;nbsp; Serial.begin(115200);&lt;br /&gt;
&amp;nbsp; delay(10);&lt;br /&gt;
&amp;nbsp; pinMode(tranPin, OUTPUT);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Serial.begin(9600);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; servo.attach(servoPin);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; // Connect to WiFi network&lt;br /&gt;
&amp;nbsp; Serial.println();&lt;br /&gt;
&amp;nbsp; Serial.println();&lt;br /&gt;
&amp;nbsp; Serial.print(&quot;Connecting to &quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(ssid);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; WiFi.begin(ssid, password);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; while (WiFi.status() != WL_CONNECTED) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(500);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.print(&quot;.&quot;);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;&quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;WiFi connected&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; // Start the server&lt;br /&gt;
&amp;nbsp; server.begin();&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;Server started&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; // Print the IP address&lt;br /&gt;
&amp;nbsp; Serial.print(&quot;Use this URL to connect: &quot;);&lt;br /&gt;
&amp;nbsp; Serial.print(&quot;http://&quot;);&lt;br /&gt;
&amp;nbsp; Serial.print(WiFi.localIP());&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;/&quot;);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() {&lt;br /&gt;
&amp;nbsp; // Check if a client has connected&lt;br /&gt;
&amp;nbsp; WiFiClient client = server.available();&lt;br /&gt;
&amp;nbsp; if (!client) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; // Wait until the client sends some data&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;new client&quot;);&lt;br /&gt;
&amp;nbsp; while(!client.available()){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(1);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; // Read the first line of the request&lt;br /&gt;
&amp;nbsp; String request = client.readStringUntil(&#39;\r&#39;);&lt;br /&gt;
&amp;nbsp; Serial.println(request);&lt;br /&gt;
&amp;nbsp; client.flush();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; // Match the request&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; int value = LOW;&lt;br /&gt;
&amp;nbsp; if (request.indexOf(&quot;/LED=ON&quot;) != -1) &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; /*&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(flag ==0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(tranPin, HIGH); //turn on servo power&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; servo.write(60);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; delay(800);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(tranPin, LOW); //turn on servo power&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; flag = 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; */&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.attach(servoPin);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.write(60);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(800);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.detach();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; value = HIGH;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; if (request.indexOf(&quot;/LED=OFF&quot;) != -1) &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; /*&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(flag == 1){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(tranPin, HIGH); //turn on servo power&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; servo.write(150);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; delay(800);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(tranPin, LOW); //turn on servo power&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; flag = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; */&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.attach(servoPin);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.write(150);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(800);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; servo.detach();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; value = LOW;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
// Set ledPin according to the request&lt;br /&gt;
//digitalWrite(ledPin, value);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; // Return the response&lt;br /&gt;
&amp;nbsp; client.println(&quot;HTTP/1.1 200 OK&quot;);&lt;br /&gt;
&amp;nbsp; client.println(&quot;Content-Type: text/html&quot;);&lt;br /&gt;
&amp;nbsp; client.println(&quot;&quot;); // &amp;nbsp;do not forget this one&lt;br /&gt;
&amp;nbsp; client.println(&quot;&amp;lt;!DOCTYPE HTML&amp;gt;&quot;);&lt;br /&gt;
&amp;nbsp; client.println(&quot;&amp;lt;html&amp;gt;&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; client.print(&quot;Valve is now: &quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; if(value == HIGH) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; client.print(&quot;ON&quot;);&lt;br /&gt;
&amp;nbsp; } else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; client.print(&quot;OFF&quot;);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; client.println(&quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;);&lt;br /&gt;
&amp;nbsp; client.println(&quot;&amp;lt;a href=\&quot;/LED=ON\&quot;\&quot;&amp;gt;&amp;lt;button&amp;gt;Turn On &amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;&quot;);&lt;br /&gt;
&amp;nbsp; client.println(&quot;&amp;lt;a href=\&quot;/LED=OFF\&quot;\&quot;&amp;gt;&amp;lt;button&amp;gt;Turn Off &amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&quot;); &lt;br /&gt;
&amp;nbsp; client.println(&quot;&amp;lt;/html&amp;gt;&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; delay(1);&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;Client disonnected&quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(&quot;&quot;);&lt;br /&gt;
&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/4137156512441971236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/10/nodemcu-12e-with-servo-mg995.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/4137156512441971236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/4137156512441971236'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/10/nodemcu-12e-with-servo-mg995.html' title='Nodemcu 12E with servo mg995'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-5839507379995525682</id><published>2016-08-18T06:22:00.002-07:00</published><updated>2016-08-18T06:22:40.724-07:00</updated><title type='text'>NRF24L01</title><content type='html'>&lt;pre&gt;// http://www.bajdi.com
// Sending a struct with the nRF24L01 module
// Data to be sent is the reading of 2 analog pins
// Data received is the analog reading of 2 pins on the other Arduino 

#include &amp;lt;SPI.h&amp;gt;
#include &quot;nRF24L01.h&quot;
#include &quot;RF24.h&quot;

RF24 radio(1,2);  // make sure this corresponds to the pins you are using
const uint64_t pipes[2] = { 
  0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

const int led = 0;

typedef struct{
  int A;
  int B;
  float C;
  float D;
}
A_t;

typedef struct{
  int W;
  int X;
  float Y;
  float Z;
}
B_t;

A_t duino1;  
B_t duino2; 

void setup()
{
  Serial.begin(57600);
  pinMode(led, OUTPUT);
  radio.begin();
  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1,pipes[1]);
}

void loop(void)
{
  // we need data to sent...
  duino2.W = analogRead(A0);
  duino2.X = analogRead(A1);
  duino2.Y = analogRead(A0)/102.3;
  duino2.Z = analogRead(A1)/102.3;
  // end of analog reading

  // radio stuff
  radio.stopListening();
  bool ok = radio.write( &amp;amp;duino2, sizeof(duino2) );
  radio.startListening();

  unsigned long started_waiting_at = millis();
  bool timeout = false;
  while ( ! radio.available() &amp;amp;&amp;amp; ! timeout )
    if (millis() - started_waiting_at &amp;gt; 250 )
      timeout = true;

  if ( timeout )
  {
    Serial.println(&quot;Failed, response timed out.&quot;);
    digitalWrite(led, HIGH);
  }
  else
  {
    radio.read( &amp;amp;duino1, sizeof(duino1) );
    digitalWrite(led, LOW);
  }
  // end of radio stuff

  // serial print received data
  Serial.print(&quot;duino1.A = &quot;);
  Serial.println(duino1.A);
  Serial.print(&quot;duino1.B = &quot;);
  Serial.println(duino1.B);
  Serial.print(&quot;duino1.C = &quot;);
  Serial.println(duino1.C);
  Serial.print(&quot;duino1.D = &quot;);
  Serial.println(duino1.D);
  // end of serial printing
}&lt;/pre&gt;
&lt;pre&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;/pre&gt;
&lt;pre&gt;============================================================&lt;/pre&gt;
&lt;pre&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;/pre&gt;
&lt;pre&gt;// http://www.bajdi.com
// Sending a struct with the nRF24L01 module
// Data to be sent is the reading of 2 analog pins
// Data received is the analog reading of 2 pins on the other Arduino 

#include &amp;lt;SPI.h&amp;gt;
#include &quot;nRF24L01.h&quot;
#include &quot;RF24.h&quot;

typedef struct{
  int A;
  int B;
  float C;
  float D;
}
A_t;

typedef struct{
  int W;
  int X;
  float Y;
  float Z;
}
B_t;

A_t duino1;  
B_t duino2;

RF24 radio(8,9);   // make sure this corresponds to the pins you are using
const uint64_t pipes[2] = { 
  0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

void setup()
{
  Serial.begin(57600);
  radio.begin();
  radio.openWritingPipe(pipes[1]);
  radio.openReadingPipe(1,pipes[0]);
  radio.startListening();
}

void loop(void)
{ 
  // we need data to sent...
  duino1.A = analogRead(A0);
  duino1.B = analogRead(A1);
  duino1.C = analogRead(A0)/102.3;
  duino1.D = analogRead(A1)/102.3;
  // end of analog reading

  // radio stuff
  if ( radio.available() )
  {
    bool done = false;
    while (!done)
    {
      done = radio.read( &amp;amp;duino2, sizeof(duino2) );
    }
    radio.stopListening();
    radio.write( &amp;amp;duino1, sizeof(duino1) );
    radio.startListening();
  }
  // end of radio stuff

  // serial print received data 
  Serial.print(&quot;duino2.W = &quot;);
  Serial.println(duino2.W);
  Serial.print(&quot;duino2.X = &quot;);
  Serial.println(duino2.X);
  Serial.print(&quot;duino2.Y = &quot;);
  Serial.println(duino2.Y);
  Serial.print(&quot;duino2.Z = &quot;);
  Serial.println(duino2.Z);
  // end of serial printing
}&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/5839507379995525682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/08/nrf24l01.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/5839507379995525682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/5839507379995525682'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/08/nrf24l01.html' title='NRF24L01'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-341950086288034682</id><published>2016-08-14T12:16:00.002-07:00</published><updated>2016-08-14T12:16:31.501-07:00</updated><title type='text'>Simple NRF24L01 wireless remote</title><content type='html'>&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 17px; line-height: 24px;&quot;&gt;Code for Receiver&lt;/span&gt;&lt;br /&gt;
#include &amp;lt;&quot;spi .h&quot;&amp;gt;&lt;br /&gt;
#include &quot;nRF24L01.h&quot;&lt;br /&gt;
#include &quot;RF24.h&quot;&lt;br /&gt;
int msg[1];&lt;br /&gt;
RF24 radio(9,10);&lt;br /&gt;
const uint64_t pipe = 0xE8E8F0F0E1LL;&lt;br /&gt;
int LED1 = 3;&lt;br /&gt;
void setup(void){&lt;br /&gt;
&amp;nbsp;Serial.begin(9600);&lt;br /&gt;
&amp;nbsp;radio.begin();&lt;br /&gt;
&amp;nbsp;radio.openReadingPipe(1,pipe);&lt;br /&gt;
&amp;nbsp;radio.startListening();&lt;br /&gt;
&amp;nbsp;pinMode(LED1, OUTPUT);&lt;br /&gt;
}&lt;br /&gt;
void loop(void){&lt;br /&gt;
&amp;nbsp;if (radio.available()){&lt;br /&gt;
&amp;nbsp; &amp;nbsp;bool done = false; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;while (!done){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;done = radio.read(msg, 1); &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.println(msg[0]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if (msg[0] == 111){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; delay(10);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(LED1, HIGH);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;else {digitalWrite(LED1, LOW);}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;delay(10);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp;else{Serial.println(&quot;No radio available&quot;);}}&lt;br /&gt;
============================================&lt;br /&gt;
code for transmitter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;nbsp;&amp;lt;SPI.h&amp;gt;&lt;br /&gt;
#include &quot;nRF24L01.h&quot;&lt;br /&gt;
#include &quot;RF24.h&quot;&lt;br /&gt;
int msg[1];&lt;br /&gt;
RF24 radio(9,10);&lt;br /&gt;
const uint64_t pipe = 0xE8E8F0F0E1LL;&lt;br /&gt;
int SW1 = 7;&lt;br /&gt;
void setup(void){&lt;br /&gt;
&amp;nbsp;Serial.begin(9600);&lt;br /&gt;
&amp;nbsp;radio.begin();&lt;br /&gt;
&amp;nbsp;radio.openWritingPipe(pipe);&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp;void loop(void){&lt;br /&gt;
&amp;nbsp;if (digitalRead(SW1) == HIGH){&lt;br /&gt;
&amp;nbsp;msg[0] = 111;&lt;br /&gt;
&amp;nbsp;radio.write(msg, 1);}}&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/341950086288034682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/08/simple-nrf24l01-wireless-remote.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/341950086288034682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/341950086288034682'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/08/simple-nrf24l01-wireless-remote.html' title='Simple NRF24L01 wireless remote'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-7979318006918299915</id><published>2016-08-14T12:08:00.001-07:00</published><updated>2016-08-14T12:10:40.786-07:00</updated><title type='text'>NRF24L01 multi receiver</title><content type='html'>hardware:
0.1 uf capacitors recommended

The connections are laid out in detail in the first link on the prior page. Basically, the pins in the lower right corners of the diagrams above must be connected to the corresponding Arduino pins. VCC must be 3.3V and CE and CSN from the NRF24L01+ connect to pins 7 and 8, respectively, on the Arduino. The IRQ pin is unnecessary in this application. Soldering a 0.1 uf capacitor between the VCC and ground pins of the NRF24L01+ is a good idea.&lt;br /&gt;
&amp;nbsp;

&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYBk7kBsql41MoxmyHVpcKL_nLq4M1G3llT32e4Yx9xcszsI1at57oU6MwYCADRzmQ3jqk34HiIz3dzR5EdvJ6kB0fcygbJ1I7rqRCUK-Y8nCW_8S_fgn3aRMsR8oAoBKxV7giWNJcsaRP/s1600/nrf_freq.jpg&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;614&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYBk7kBsql41MoxmyHVpcKL_nLq4M1G3llT32e4Yx9xcszsI1at57oU6MwYCADRzmQ3jqk34HiIz3dzR5EdvJ6kB0fcygbJ1I7rqRCUK-Y8nCW_8S_fgn3aRMsR8oAoBKxV7giWNJcsaRP/s640/nrf_freq.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 17px; line-height: 24px; margin-bottom: 10px; margin-top: 3px;&quot;&gt;
This example is a frivolous game in which the PRX generates a random number and the nodes try to guess the number. Its real purpose is to demonstrate the network in action.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 17px; line-height: 24px; margin-bottom: 10px; margin-top: 3px;&quot;&gt;
While I think Codebender is fantastic, Please copy the code out of Codebender because the RF24.h library in Codebender appears to be an older version.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 17px; line-height: 24px; margin-bottom: 10px; margin-top: 3px;&quot;&gt;
First, the code for the PRX primary receiver (hub)&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 17px; line-height: 24px; margin-bottom: 10px; margin-top: 3px;&quot;&gt;
=======================================================&lt;/div&gt;
// An example demonstrating the multiceiver capability of the NRF24L01+&lt;br /&gt;
// in a star network with one PRX hub and up to six PTX nodes&lt;br /&gt;
&lt;br /&gt;
//This sketch is a modification from a video on the ForceTronics YouTube Channel,&lt;br /&gt;
//which code was leveraged from http://maniacbug.github.io/RF24/starping_8pde-example.html&lt;br /&gt;
//This sketch is free to the public to use and modify at your own risk&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SPI.h&amp;gt; //Call SPI library so you can communicate with the nRF24L01+&lt;br /&gt;
#include &amp;lt;nRF24L01.h&amp;gt; //nRF2401 libarary found at https://github.com/tmrh20/RF24/&lt;br /&gt;
#include &amp;lt;RF24.h&amp;gt; //nRF2401 libarary found at https://github.com/tmrh20/RF24/&lt;br /&gt;
&lt;br /&gt;
const int pinCE = 7; //This pin is used to set the nRF24 to standby (0) or active mode (1)&lt;br /&gt;
const int pinCSN = 8; //This pin is used to tell the nRF24 whether the SPI communication is a command or message to send out&lt;br /&gt;
RF24 radio(pinCE, pinCSN); // Declare object from nRF24 library (Create your wireless SPI)&lt;br /&gt;
&lt;br /&gt;
//Create up to 6 pipe addresses P0 - P5; &amp;nbsp;the &quot;LL&quot; is for LongLong type&lt;br /&gt;
const uint64_t rAddress[] = {0x7878787878LL, 0xB3B4B5B6F1LL, 0xB3B4B5B6CDLL, 0xB3B4B5B6A3LL, 0xB3B4B5B60FLL, 0xB3B4B5B605LL };&lt;br /&gt;
&lt;br /&gt;
byte daNumber = 0; //The number that the transmitters are trying to guess&lt;br /&gt;
&lt;br /&gt;
void setup() &amp;nbsp;&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; randomSeed(analogRead(0)); //create unique seed value for random number generation&lt;br /&gt;
&amp;nbsp; daNumber = (byte)random(11); //Create random number that transmitters have to guess&lt;br /&gt;
&amp;nbsp; Serial.begin(115200); &amp;nbsp;//start serial to communication&lt;br /&gt;
&amp;nbsp; Serial.print(&quot;The number they are trying to guess is: &quot;);&lt;br /&gt;
&amp;nbsp; Serial.println(daNumber); //print the number that they have to guess&lt;br /&gt;
&amp;nbsp; Serial.println();&lt;br /&gt;
&amp;nbsp; radio.begin(); &amp;nbsp;//Start the nRF24 module&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; radio.setPALevel(RF24_PA_LOW); &amp;nbsp;// &quot;short range setting&quot; - increase if you want more range AND have a good power supply&lt;br /&gt;
&amp;nbsp; radio.setChannel(108); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// the higher channels tend to be more &quot;open&quot;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; // Open up to six pipes for PRX to receive data&lt;br /&gt;
&amp;nbsp; radio.openReadingPipe(0,rAddress[0]);&lt;br /&gt;
&amp;nbsp; radio.openReadingPipe(1,rAddress[1]);&lt;br /&gt;
&amp;nbsp; radio.openReadingPipe(2,rAddress[2]);&lt;br /&gt;
&amp;nbsp; radio.openReadingPipe(3,rAddress[3]);&lt;br /&gt;
&amp;nbsp; radio.openReadingPipe(4,rAddress[4]);&lt;br /&gt;
&amp;nbsp; radio.openReadingPipe(5,rAddress[5]);&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; radio.startListening(); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Start listening for messages&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() &lt;br /&gt;
{ &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; byte pipeNum = 0; //variable to hold which reading pipe sent data&lt;br /&gt;
&amp;nbsp; &amp;nbsp; byte gotByte = 0; //used to store payload from transmit module&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while(radio.available(&amp;amp;pipeNum)){ //Check if received data&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;radio.read( &amp;amp;gotByte, 1 ); //read one byte of data and store it in gotByte variable&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.print(&quot;Received guess from transmitter: &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.println(pipeNum + 1); //print which pipe or transmitter this is from&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.print(&quot;They guess number: &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.println(gotByte); //print payload or the number the transmitter guessed&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(gotByte != daNumber) { //if true they guessed wrong&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Serial.println(&quot;Fail!! Try again.&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;else { //if this is true they guessed right&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if(sendCorrectNumber(pipeNum)) Serial.println(&quot;Correct! You&#39;re done.&quot;); //if true we successfully responded&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; else Serial.println(&quot;Write failed&quot;); //if true we failed responding&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.println();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;delay(200); &amp;nbsp; &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;//This function turns the receiver into a transmitter briefly to tell one of the nRF24s&lt;br /&gt;
//in the network that it guessed the right number. Returns true if write to module was&lt;br /&gt;
//successful&lt;br /&gt;
bool sendCorrectNumber(byte xMitter) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; bool worked; //variable to track if write was successful&lt;br /&gt;
&amp;nbsp; &amp;nbsp; radio.stopListening(); //Stop listening, start receiving data.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; radio.openWritingPipe(rAddress[xMitter]); //Open writing pipe to the nRF24 that guessed the right number&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; // note that this is the same pipe address that was just used for receiving&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(!radio.write(&amp;amp;daNumber, 1)) &amp;nbsp;worked = false; //write the correct number to the nRF24 module, and check that it was received&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else worked = true; //it was received&lt;br /&gt;
&amp;nbsp; &amp;nbsp; radio.startListening(); //Switch back to a receiver&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return worked; &amp;nbsp;//return whether write was successful&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
=========================================================&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 17px; line-height: 24px;&quot;&gt;And now the code for the PTX primary transmitters (nodes)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
// An example demonstrating the multiceiver capability of the NRF24L01+&lt;br /&gt;
// in a star network with one PRX hub and up to six PTX nodes&lt;br /&gt;
&lt;br /&gt;
//This sketch is a modification from a video on the ForceTronics YouTube Channel,&lt;br /&gt;
&lt;br /&gt;
//which code was leveraged from http://maniacbug.github.io/RF24/starping_8pde-example.html&lt;br /&gt;
&lt;br /&gt;
//This sketch is free to the public to use and modify at your own risk&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SPI.h&amp;gt; //Call SPI library so you can communicate with the nRF24L01+&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;nRF24L01.h&amp;gt; //nRF2401 libarary found at https://github.com/tmrh20/RF24/&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;RF24.h&amp;gt; //nRF2401 libarary found at https://github.com/tmrh20/RF24/&lt;br /&gt;
&lt;br /&gt;
const int pinCE = 7; //This pin is used to set the nRF24 to standby (0) or active mode (1)&lt;br /&gt;
&lt;br /&gt;
const int pinCSN = 8; //This pin is used to tell the nRF24 whether the SPI communication is a command or message to send out&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RF24 radio(pinCE, pinCSN); // Create your nRF24 object or wireless SPI connection&lt;br /&gt;
&lt;br /&gt;
#define WHICH_NODE 2 &amp;nbsp; &amp;nbsp; // must be a number from 1 - 6 identifying the PTX node&lt;br /&gt;
&lt;br /&gt;
const uint64_t wAddress[] = {0x7878787878LL, 0xB3B4B5B6F1LL, 0xB3B4B5B6CDLL, 0xB3B4B5B6A3LL, 0xB3B4B5B60FLL, 0xB3B4B5B605LL};&lt;br /&gt;
&lt;br /&gt;
const uint64_t PTXpipe = wAddress[ WHICH_NODE - 1 ]; &amp;nbsp; // Pulls the address from the above array for this node&#39;s pipe&lt;br /&gt;
&lt;br /&gt;
byte counter = 1; //used to count the packets sent&lt;br /&gt;
&lt;br /&gt;
bool done = false; //used to know when to stop sending packets&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void setup() &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Serial.begin(115200); &amp;nbsp; //start serial to communicate process&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; randomSeed(analogRead(0)); //create unique seed value for random number generation&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; radio.begin(); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Start the nRF24 module&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; radio.setPALevel(RF24_PA_LOW); &amp;nbsp;// &quot;short range setting&quot; - increase if you want more range AND have a good power supply&lt;br /&gt;
&amp;nbsp; radio.setChannel(108); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// the higher channels tend to be more &quot;open&quot;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; radio.openReadingPipe(0,PTXpipe); &amp;nbsp;//open reading or receive pipe&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; radio.stopListening(); //go into transmit mode&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop() &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(!done) { //true once you guess the right number&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;byte randNumber = (byte)random(11); //generate random guess between 0 and 10&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;radio.openWritingPipe(PTXpipe); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//open writing or transmit pipe&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if (!radio.write( &amp;amp;randNumber, 1 )){ &amp;nbsp;//if the write fails let the user know over serial monitor&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.println(&quot;Guess delivery failed&quot;); &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;else { //if the write was successful&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Serial.print(&quot;Success sending guess: &quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Serial.println(randNumber);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; radio.startListening(); //switch to receive mode to see if the guess was right&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; unsigned long startTimer = millis(); //start timer, we will wait 200ms&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bool timeout = false;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while ( !radio.available() &amp;amp;&amp;amp; !timeout ) { //run while no receive data and not timed out&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (millis() - startTimer &amp;gt; 200 ) timeout = true; //timed out&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (timeout) Serial.println(&quot;Last guess was wrong, try again&quot;); //no data to receive guess must have been wrong&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else &amp;nbsp;{ //we received something so guess must have been right&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; byte daNumber; //variable to store received value&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; radio.read( &amp;amp;daNumber,1); //read value&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(daNumber == randNumber) { //make sure it equals value we just sent, if so we are done&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Serial.println(&quot;You guessed right so you are done&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; done = true; //signal to loop that we are done guessing&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else Serial.println(&quot;Something went wrong, keep guessing&quot;); //this should never be true, but just in case&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; radio.stopListening(); //go back to transmit mode&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(1000);&lt;br /&gt;
}&lt;br /&gt;
=========================================&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 17px; line-height: 24px; margin-bottom: 10px; margin-top: 3px;&quot;&gt;
The #define WHICH_NODE statement needs to be altered for each node. Otherwise, the code is the same.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 17px; line-height: 24px; margin-bottom: 10px; margin-top: 3px;&quot;&gt;
When running, I suggest powering the PRX first and starting the serial monitor for it. Otherwise you might miss the action!&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 17px; line-height: 24px; margin-bottom: 10px; margin-top: 3px;&quot;&gt;
ENJOY! And please do comment on any way in which this Instructable might be improved.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/7979318006918299915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/08/nrf24l01-multi-receiver.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7979318006918299915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/7979318006918299915'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/08/nrf24l01-multi-receiver.html' title='NRF24L01 multi receiver'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYBk7kBsql41MoxmyHVpcKL_nLq4M1G3llT32e4Yx9xcszsI1at57oU6MwYCADRzmQ3jqk34HiIz3dzR5EdvJ6kB0fcygbJ1I7rqRCUK-Y8nCW_8S_fgn3aRMsR8oAoBKxV7giWNJcsaRP/s72-c/nrf_freq.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-3331259779303461526</id><published>2016-06-25T13:02:00.001-07:00</published><updated>2016-06-25T13:03:30.530-07:00</updated><title type='text'>How to disable internal Arduino ATMEGA pullups on SDA and SCL with I2C bus</title><content type='html'>&lt;span style=&quot;color: #222222; font-family: &amp;quot;typoninesans regular&amp;quot;;&quot;&gt;&lt;span style=&quot;background-color: whitesmoke; font-size: 14.6994px; line-height: 20.5792px;&quot;&gt;just edit libraries/wire/utility/twi.c and comment out the following:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;typoninesans regular&amp;quot;;&quot;&gt;&lt;span style=&quot;background-color: whitesmoke; font-size: 14.6994px; line-height: 20.5792px;&quot;&gt;// activate internal pullups for twi.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;typoninesans regular&amp;quot;;&quot;&gt;&lt;span style=&quot;background-color: whitesmoke; font-size: 14.6994px; line-height: 20.5792px;&quot;&gt;&amp;nbsp; digitalWrite(SDA, 1);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;typoninesans regular&amp;quot;;&quot;&gt;&lt;span style=&quot;background-color: whitesmoke; font-size: 14.6994px; line-height: 20.5792px;&quot;&gt;&amp;nbsp; digitalWrite(SCL, 1);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;typoninesans regular&amp;quot;;&quot;&gt;&lt;span style=&quot;background-color: whitesmoke; font-size: 14.6994px; line-height: 20.5792px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;typoninesans regular&amp;quot;;&quot;&gt;&lt;span style=&quot;background-color: whitesmoke; font-size: 14.6994px; line-height: 20.5792px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div style=&quot;color: #191919; font-family: Helvetica, Arial, sans-serif; font-size: 15.2112px; line-height: 26.6587px;&quot;&gt;
Doing this in the sketch seems to be equivalent:&lt;/div&gt;
&lt;div style=&quot;color: #191919; font-family: Helvetica, Arial, sans-serif; font-size: 15.2112px; line-height: 26.6587px;&quot;&gt;
pinMode(SDA, INPUT);&lt;br /&gt;pinMode(SCL, INPUT);&lt;/div&gt;
&lt;div style=&quot;color: #191919; font-family: Helvetica, Arial, sans-serif; font-size: 15.2112px; line-height: 26.6587px;&quot;&gt;
Even doing this immediately after Wire.begin() potentially still sends 5V glitches on SDA/SCL.&lt;/div&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;typoninesans regular&amp;quot;;&quot;&gt;&lt;span style=&quot;background-color: whitesmoke; font-size: 14.6994px; line-height: 20.5792px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #191919; font-family: Helvetica, Arial, sans-serif; font-size: 15.2112px; line-height: 26.6587px;&quot;&gt;
(tested with arduino-1.6.0 on a NANO)&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/3331259779303461526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/06/how-to-disable-internal-arduino-atmega.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/3331259779303461526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/3331259779303461526'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/06/how-to-disable-internal-arduino-atmega.html' title='How to disable internal Arduino ATMEGA pullups on SDA and SCL with I2C bus'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-270374397806530902</id><published>2016-05-05T10:20:00.001-07:00</published><updated>2016-05-31T06:07:43.462-07:00</updated><title type='text'>humidity sensor</title><content type='html'>#define DHTPIN 2 &amp;nbsp; &lt;br /&gt;
#define RELAYPIN 4&lt;br /&gt;
#define DHTTYPE DHT11 &amp;nbsp; // DHT 21 (AM2301)&lt;br /&gt;
#define next 9&lt;br /&gt;
#define INC 7&lt;br /&gt;
#define set_mode 5&lt;br /&gt;
&lt;br /&gt;
/* ----- C Program for Arduino based Alarm Clock ---- */&lt;br /&gt;
#include &amp;lt;Wire.h&amp;gt;&lt;br /&gt;
#include&amp;lt;EEPROM.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;&lt;br /&gt;
#include &quot;DHT.h&quot;&lt;br /&gt;
DHT dht(DHTPIN, DHTTYPE);&lt;br /&gt;
&lt;br /&gt;
LiquidCrystal_I2C lcd(0x27, 16, 2);&lt;br /&gt;
&lt;br /&gt;
unsigned long previousMillis = 0;&lt;br /&gt;
const long interval = 5000; &lt;br /&gt;
&lt;br /&gt;
int HMIN,HMAX,h,t;&lt;br /&gt;
int add = 11;&lt;br /&gt;
&amp;nbsp; int st=0; //var for void match&lt;br /&gt;
&amp;nbsp; int sb=0;//var for void match&lt;br /&gt;
void setup()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;cekMem();&lt;br /&gt;
&amp;nbsp;//Serial.begin(9600);&lt;br /&gt;
&amp;nbsp;Wire.begin();&lt;br /&gt;
&amp;nbsp;dht.begin();&lt;br /&gt;
&amp;nbsp;lcd.init();&lt;br /&gt;
&amp;nbsp;lcd.backlight();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;pinMode(INC, INPUT);&lt;br /&gt;
&amp;nbsp;pinMode(next, INPUT);&lt;br /&gt;
&amp;nbsp;pinMode(set_mode, INPUT);&lt;br /&gt;
&amp;nbsp;pinMode(RELAYPIN, OUTPUT);&lt;br /&gt;
&amp;nbsp;digitalWrite(next, HIGH);&lt;br /&gt;
&amp;nbsp;digitalWrite(set_mode, HIGH);&lt;br /&gt;
&amp;nbsp;digitalWrite(INC, HIGH);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;lcd.setCursor(0,0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;lcd.print(&quot;Sensor Starting..&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(2000);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; //unsigned long currentMillis = millis();&lt;br /&gt;
&amp;nbsp; h = dht.readHumidity();&lt;br /&gt;
&amp;nbsp; t = dht.readTemperature();&lt;br /&gt;
&amp;nbsp; if (isnan(t) || isnan(h)) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.setCursor(1,0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(&quot;Error&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.setCursor(0,1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(&quot;Check Sensor cable&quot;);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; else {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.clear();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(&quot;Now: T:&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(t);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(&quot; H: &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(h);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.setCursor(0, 1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(&quot;H Min/max: &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(HMIN);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(&quot;/&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(HMAX);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(1000);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; if(digitalRead(set_mode)==0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.clear();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.setCursor(1,0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; setHmin();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.clear();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.setCursor(1,0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(&quot;Setting Humidity&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.setCursor(0,1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lcd.print(&quot;tersimpan&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(2000); &amp;nbsp; &lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; match();&lt;br /&gt;
}//loop&lt;br /&gt;
void setHmin(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.setCursor(1,0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.clear();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.print(&quot;SET H MIN&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.setCursor(0,1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.print(HMIN);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;int temp=1,hmin1=0,hmax1=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;while(temp==1){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(digitalRead(INC)==0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HMIN++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.setCursor(0,1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.print(HMIN);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(HMIN==99){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;HMIN=65;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}//if(HMIN==99){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //while(digitalRead(INC)==0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }//if(digitalRead(INC)==0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;delay(1000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(digitalRead(next)==0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; hmin1=HMIN;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; EEPROM.write(add++,hmin1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lcd.clear();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lcd.setCursor(1,0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lcd.print(&quot;H MIN SAVED at: &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lcd.setCursor(0,1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lcd.print(HMIN);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; delay(3000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(digitalRead(next)==0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp=2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }//if(digitalRead(next)==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }//while temp==1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while(temp==2){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; //setting HMAX&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; lcd.clear();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; lcd.setCursor(1,0); &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; lcd.print(&quot;Set H MAX&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.setCursor(0,1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.print(HMAX); &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if(digitalRead(INC)==0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HMAX++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lcd.setCursor(0,1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lcd.print(HMAX); &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(HMAX==99){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HMAX=65;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }//if(HMAX==99){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //while(digitalRead(next)==0);//?&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; delay(1000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if(digitalRead(next)==0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hmax1=HMAX;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;EEPROM.write(add++, hmax1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.clear();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.setCursor(1,0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.print(&quot;H MAX Saved at: &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.setCursor(0,1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lcd.print(HMAX);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;temp=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while(digitalRead(next)==0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}//if(digitalRead(next)==0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}//if(digitalRead(INC)==0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;delay(1000);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//}//while temp=2&lt;br /&gt;
}//setHmin()&lt;br /&gt;
void cekMem(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int tem[17];&lt;br /&gt;
&amp;nbsp; for(int i=11;i&amp;lt;17;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; tem[i]=EEPROM.read(i);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; HMIN= tem[11];&lt;br /&gt;
&amp;nbsp; HMAX =tem[12];&lt;br /&gt;
&amp;nbsp; if(HMIN &amp;gt;= 100) { HMIN = 65;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else if(HMIN &amp;lt;= 65) {HMIN = 60; }&lt;br /&gt;
&amp;nbsp; if(HMAX &amp;gt;=100){ HMAX=65;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else if (HMAX &amp;lt;= 65) {HMAX = 60; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void match(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; /if (currentMillis - previousMillis &amp;gt;= interval) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if((HMIN &amp;gt;= h) &amp;amp;&amp;amp; (st==0) ){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(RELAYPIN, HIGH);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; st=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; sb=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if((HMAX &amp;lt;= h) &amp;amp;&amp;amp; (sb==0)){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; digitalWrite(RELAYPIN, LOW);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; sb=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; st=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}//void match&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/270374397806530902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/05/humidity-sensor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/270374397806530902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/270374397806530902'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/05/humidity-sensor.html' title='humidity sensor'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-2782488955837320205</id><published>2016-04-03T08:51:00.001-07:00</published><updated>2016-04-03T08:51:01.536-07:00</updated><title type='text'>ARDUINO TWO PIR WITH MILIS</title><content type='html'>int calibrationTime = 5; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
//the time when the sensor outputs a low impulse&lt;br /&gt;
long unsigned int lowIn; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
//the amount of milliseconds the sensor has to be low&lt;br /&gt;
//before we assume all motion has stopped&lt;br /&gt;
long unsigned int pause = 5000; &lt;br /&gt;
&lt;br /&gt;
boolean lockLow = true;&lt;br /&gt;
boolean takeLowTime; &lt;br /&gt;
&lt;br /&gt;
int pirPin = 3; &amp;nbsp; &amp;nbsp;//the digital pin connected to the PIR sensor&#39;s output&lt;br /&gt;
int pirPin2 = 4; &amp;nbsp; &amp;nbsp;//the digital pin connected to the PIR sensor&#39;s output&lt;br /&gt;
int ledPin = 13;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////&lt;br /&gt;
//SETUP&lt;br /&gt;
void setup(){&lt;br /&gt;
&amp;nbsp; Serial.begin(9600);&lt;br /&gt;
&amp;nbsp; pinMode(pirPin, INPUT);&lt;br /&gt;
&amp;nbsp; pinMode(pirPin2, INPUT);&lt;br /&gt;
&amp;nbsp; pinMode(ledPin, OUTPUT);&lt;br /&gt;
&amp;nbsp; digitalWrite(pirPin, LOW);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; //give the sensor some time to calibrate&lt;br /&gt;
&amp;nbsp; Serial.print(&quot;calibrating sensor &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(int i = 0; i &amp;lt; calibrationTime; i++){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Serial.print(&quot;.&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; delay(1000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.println(&quot; done&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Serial.println(&quot;SENSOR ACTIVE&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; delay(50);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
////////////////////////////&lt;br /&gt;
//LOOP&lt;br /&gt;
void loop(){&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if((digitalRead(pirPin) ||digitalRead(pirPin2)) &amp;nbsp;== HIGH){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;digitalWrite(ledPin, HIGH); &amp;nbsp; //the led visualizes the sensors output pin state&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(lockLow){ &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//makes sure we wait for a transition to LOW before any further output is made:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lockLow = false; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.println(&quot;---&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.print(&quot;motion detected at &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.print(millis()/1000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.println(&quot; sec&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;delay(50);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;takeLowTime = true;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if((digitalRead(pirPin) ||digitalRead(pirPin2)) &amp;nbsp;== LOW){ &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;digitalWrite(ledPin, LOW); &amp;nbsp;//the led visualizes the sensors output pin state&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(takeLowTime){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lowIn = millis(); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//save the time of the transition from high to LOW&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; takeLowTime = false; &amp;nbsp; &amp;nbsp; &amp;nbsp; //make sure this is only done at the start of a LOW phase&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//if the sensor is low for more than the given pause,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//we assume that no more motion is going to happen&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(!lockLow &amp;amp;&amp;amp; millis() - lowIn &amp;gt; pause){ &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//makes sure this block of code is only executed again after&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//a new motion sequence has been detected&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lockLow = true; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.print(&quot;motion ended at &quot;); &amp;nbsp; &amp;nbsp; &amp;nbsp;//output&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.print((millis() - pause)/1000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Serial.println(&quot; sec&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;delay(50);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; }</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/2782488955837320205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/04/arduino-two-pir-with-milis.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/2782488955837320205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/2782488955837320205'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/04/arduino-two-pir-with-milis.html' title='ARDUINO TWO PIR WITH MILIS'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-2216224331035331782</id><published>2016-03-20T08:35:00.002-07:00</published><updated>2016-03-20T08:38:59.233-07:00</updated><title type='text'>arduino RF-Receiver Code</title><content type='html'>/*
  Example for receiving
  
  http://code.google.com/p/rc-switch/
  
  If you want to visualize a telegram copy the raw data and 
  paste it into http://test.sui.li/oszi/
*/

#include &lt;RCSwitch.h&gt;

RCSwitch mySwitch = RCSwitch();
int a=0;
int relay = 5;
void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 =&gt; that is pin #2
}

void loop() {
  if (mySwitch.available()) {
    a = mySwitch.getReceivedValue();
    
    if(a == 17715){
      //Serial.println(&quot;Relay ON&quot;);
       digitalWrite(ledPin, HIGH);  
    }
    if(a == 17724){
      //Serial.println(&quot;Relay OFF&quot;);
      digitalWrite(ledPin, LOW);  
    }

    mySwitch.resetAvailable();
  }
}</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/2216224331035331782/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2016/03/arduino-rf-receiver-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/2216224331035331782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/2216224331035331782'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2016/03/arduino-rf-receiver-code.html' title='arduino RF-Receiver Code'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-414369779316658096.post-281212614502813480</id><published>2015-09-22T12:37:00.003-07:00</published><updated>2015-09-22T12:37:50.944-07:00</updated><title type='text'>ESP8266 Remote Controlled Sockets | ESP8266 control 433mhz remote control</title><content type='html'>&lt;h2 style=&quot;background-color: white; box-sizing: border-box; margin: 0px 0px 10px;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Lato, sans-serif; font-size: 17px; font-weight: 400; line-height: 27.625px;&quot;&gt;i get this tutorial on website&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-size: 17px; font-weight: normal; line-height: 27.625px;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Lato, sans-serif;&quot;&gt;&lt;a href=&quot;http://randomnerdtutorials.com/esp8266-remote-controlled-sockets/&quot;&gt;http://randomnerdtutorials.com/esp8266-remote-controlled-sockets/&lt;/a&gt; , i copy from this site for my own purpose documentation, please refer to that website for detail&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: transparent; font-size: 17px; font-weight: normal; line-height: 27.625px;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Lato, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 30px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px;&quot;&gt;
Parts List&lt;/h2&gt;
&lt;h3 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 24px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px;&quot;&gt;
&lt;div style=&quot;box-sizing: border-box; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px;&quot;&gt;
Here’s the hardware that you need to complete&amp;nbsp;this project:&lt;/div&gt;
&lt;ul style=&quot;box-sizing: border-box; font-size: 17px; line-height: 27.625px; margin: 0px 0px 28px 40px; padding: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box; list-style-type: disc;&quot;&gt;&lt;a href=&quot;http://ebay.to/1HkFXB1&quot; style=&quot;background: 0px 0px; box-sizing: border-box; color: #4b77f2; text-decoration: none; transition: all 0.1s ease-in-out;&quot; target=&quot;_blank&quot; title=&quot;eBay&quot;&gt;1x&amp;nbsp;ESP8266 (eBay)&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style-type: disc;&quot;&gt;&lt;a href=&quot;http://ebay.to/1EQQWjA&quot; style=&quot;background: 0px 0px; box-sizing: border-box; color: #4b77f2; text-decoration: none; transition: all 0.1s ease-in-out;&quot; target=&quot;_blank&quot;&gt;1x&amp;nbsp;FTDI programmer (eBay)&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style-type: disc;&quot;&gt;&lt;a href=&quot;http://ebay.to/1EJbhZE&quot; style=&quot;background: 0px 0px; box-sizing: border-box; color: #4b77f2; text-decoration: none; transition: all 0.1s ease-in-out;&quot; target=&quot;_blank&quot;&gt;1x Arduino (eBay)&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style-type: disc;&quot;&gt;&lt;a href=&quot;http://ebay.to/1LHyroq&quot; style=&quot;background: 0px 0px; box-sizing: border-box; color: #4b77f2; text-decoration: none; transition: all 0.1s ease-in-out;&quot; target=&quot;_blank&quot;&gt;1x 433MHz Receiver/Transmitter module (eBay)&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style-type: disc;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;a href=&quot;http://ebay.to/1KkYpvp&quot; style=&quot;background: 0px 0px; box-sizing: border-box; color: #4b77f2; text-decoration: none; transition: all 0.1s ease-in-out;&quot; target=&quot;_blank&quot;&gt;Remote and sockets that work&amp;nbsp;at 433MHz (eBay)&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 24px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px;&quot;&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 24px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px;&quot;&gt;
RC Switch Library Download&lt;/h3&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px;&quot;&gt;
Here’s the Arduino library&amp;nbsp;you need for this project:&lt;/div&gt;
&lt;ol style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin: 0px 0px 28px 40px; padding: 0px;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box; list-style-type: decimal;&quot;&gt;Download the&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;a href=&quot;https://github.com/sui77/rc-switch&quot; style=&quot;background: 0px 0px; box-sizing: border-box; color: #4b77f2; text-decoration: none; transition: all 0.1s ease-in-out;&quot; target=&quot;_blank&quot;&gt;RC Switch&amp;nbsp;library&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style-type: decimal;&quot;&gt;Unzip the RC Switch library&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style-type: decimal;&quot;&gt;Remove the “-” from the folder name, otherwise your Arduino IDE won’t recognize your library&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style-type: decimal;&quot;&gt;Install the RC Switch library in your Arduino IDE&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; list-style-type: decimal;&quot;&gt;Restart your Arduino IDE&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px;&quot;&gt;
The RC Switch library is great and it works with almost all remote controlled sockets in the market.&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 30px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px;&quot;&gt;
Receiver Circuit&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW7D4PwVZwvsrrPEydmf35lrpwqKEDFttS3NAZN_eputYu1Ess8qEVGu4GuLP5nC76bV5stHIBY8zV7nsFZjUFSlGf1v1O_40J4kEF9WR1vEocrk1MyfziNR8BWfhkHSQGgcyg0Y1J7bKn/s1600/433mhz-receiver-circuit-esp8266.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;370&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW7D4PwVZwvsrrPEydmf35lrpwqKEDFttS3NAZN_eputYu1Ess8qEVGu4GuLP5nC76bV5stHIBY8zV7nsFZjUFSlGf1v1O_40J4kEF9WR1vEocrk1MyfziNR8BWfhkHSQGgcyg0Y1J7bKn/s640/433mhz-receiver-circuit-esp8266.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px;&quot;&gt;Follow the circuit above for your receiver. Then upload the code below or you can go to File &amp;gt; Examples &amp;gt; RC Switch &amp;gt; ReceiveDemo_Advanced.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;&lt;div class=&quot;gist-it-gist&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; white-space: normal;&quot;&gt;
&lt;div class=&quot;gist-file&quot; style=&quot;border: 1px solid rgb(222, 222, 222); box-sizing: border-box; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; margin: 0px 0px 1em; padding: 0px;&quot;&gt;
&lt;div class=&quot;gist-data&quot; style=&quot;background-color: ghostwhite; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; box-sizing: border-box; margin: 0px; overflow: auto; padding: 0px; word-wrap: normal;&quot;&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background: none 0px 0px repeat scroll transparent !important; border: medium none !important; box-sizing: border-box; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 1em; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;/*********
  Rui Santos
  Complete project details at http://randomnerdtutorials.com  
*********/&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&amp;lt;RCSwitch.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;RCSwitch&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; mySwitch &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;RCSwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; setup&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;9600&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;enableReceive&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;// Receiver on inerrupt 0 =&amp;gt; that is pin #2&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; loop&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;available&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;())&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    output&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;getReceivedValue&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;getReceivedBitlength&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;getReceivedDelay&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;getReceivedRawdata&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;getReceivedProtocol&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;());&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;resetAvailable&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 30px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px;&quot;&gt;
&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;
Save the TriState Values&lt;/span&gt;&lt;/h2&gt;
&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; margin-bottom: 16px; padding: 0px;&quot;&gt;
Open your Arduino serial monitor at a baud rate of 9600 and start pressing the buttons of your remote. Save the TriState values (highlighted in red) of each key in a notepad.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggHKCgtPshCXW97hShCgpI8el0ozNU6SvhcFgFVuVKp-rdlKvbtcjLb6RJuGulKh22DQsl-Qdi_5I5IPhZfb3kRFntcQIyrcOfSrxITl9zOtKJUp4QwJ_6bKjgso6XY0C9oHZEb8qAVjT_/s1600/tristatevalues.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;262&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggHKCgtPshCXW97hShCgpI8el0ozNU6SvhcFgFVuVKp-rdlKvbtcjLb6RJuGulKh22DQsl-Qdi_5I5IPhZfb3kRFntcQIyrcOfSrxITl9zOtKJUp4QwJ_6bKjgso6XY0C9oHZEb8qAVjT_/s640/tristatevalues.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; margin-bottom: 16px; padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 30px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px; white-space: normal;&quot;&gt;
Schematics (3.3V FTDI&amp;nbsp;Programmer)&lt;/h2&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
The schematics to upload code to your ESP8266 are very straight forward. You only need to establish a serial communication between your FTDI programmer and your ESP8266 to upload some code.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXjD6VGwBiAS3GFa2uoH6XQKYcmux4MtAJJzqfoopFL4jOyBcwY5figlshYDPZNsga3s7rN9GEGYKZcVm-Ux9dv-Y0VQZi6LtlLmdBh87Zn5SOPLZEkXWis753UBTmigrKj6kgI4XfdVPx/s1600/Flashing-Firmware-FTDI-Programmer.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;172&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXjD6VGwBiAS3GFa2uoH6XQKYcmux4MtAJJzqfoopFL4jOyBcwY5figlshYDPZNsga3s7rN9GEGYKZcVm-Ux9dv-Y0VQZi6LtlLmdBh87Zn5SOPLZEkXWis753UBTmigrKj6kgI4XfdVPx/s640/Flashing-Firmware-FTDI-Programmer.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 30px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px; white-space: normal;&quot;&gt;
Uploading your ESP8266 code&lt;/h2&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
Having the ESP8266 add-on for the Arduino IDE installed (&lt;a href=&quot;http://randomnerdtutorials.com/how-to-install-esp8266-board-arduino-ide/&quot; style=&quot;background: 0px 0px; box-sizing: border-box; color: #4b77f2; text-decoration: none; transition: all 0.1s ease-in-out;&quot; target=&quot;_blank&quot;&gt;How to Install the ESP8266 Board in Arduino IDE&lt;/a&gt;). Go to Tools and select “Generic ESP8266 Module”.&lt;/div&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8QiKc93xZMUf9FhRcsqB8txrHd0BPtjo5R_UYwGtYJ4FqXB8D_ip8rUhO7h9_7FsfV0E78KhoVKqtpHUHEo1fmKO_C359t30zzp_jhOSC3P1d23GMurp9AoZ63TZbavDMd2HuQjQfwFrD/s1600/Arduino-IDE-select-esp8266.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8QiKc93xZMUf9FhRcsqB8txrHd0BPtjo5R_UYwGtYJ4FqXB8D_ip8rUhO7h9_7FsfV0E78KhoVKqtpHUHEo1fmKO_C359t30zzp_jhOSC3P1d23GMurp9AoZ63TZbavDMd2HuQjQfwFrD/s640/Arduino-IDE-select-esp8266.png&quot; width=&quot;542&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
Copy the sketch below to your Arduino IDE. Replace the SSID and password with your own credentials. You also need to change the TriState values. After modifying my sketch upload it to your ESP8266.&lt;/div&gt;
&lt;div class=&quot;gist-it-gist&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; white-space: normal;&quot;&gt;
&lt;div class=&quot;gist-file&quot; style=&quot;border: 1px solid rgb(222, 222, 222); box-sizing: border-box; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; margin: 0px 0px 1em; padding: 0px;&quot;&gt;
&lt;div class=&quot;gist-data&quot; style=&quot;background-color: ghostwhite; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; box-sizing: border-box; margin: 0px; overflow: auto; padding: 0px; word-wrap: normal;&quot;&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background: none 0px 0px repeat scroll transparent !important; border: medium none !important; box-sizing: border-box; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 1em; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;/*********
  Rui Santos
  Complete project details at http://randomnerdtutorials.com  
*********/&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&amp;lt;ESP8266WiFi.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&amp;lt;WiFiClient.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&amp;lt;ESP8266WebServer.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&amp;lt;ESP8266mDNS.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;#include&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&amp;lt;RCSwitch.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;RCSwitch&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; mySwitch &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;RCSwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;MDNSResponder&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; mdns&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;// Replace with your network credentials&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; ssid &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;YOUR_SSID&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; password &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;YOUR_PASSWORD&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

ESP8266WebServer server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;// Replace with your remote TriState values&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; socket1TriStateOn &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;0FFF0FFFFFFF&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; socket1TriStateOff &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;0FFF0FFFFFF0&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; socket2TriStateOn &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;0FFFFF0FFFFF&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; socket2TriStateOff &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;0FFFFF0FFFF0&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; webPage &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
 
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; setup&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  webPage &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;&amp;lt;h1&amp;gt;ESP8266 Web Server&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;Socket #1 &amp;lt;a href=\&quot;socket1On\&quot;&amp;gt;&amp;lt;button&amp;gt;ON&amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;&amp;amp;nbsp;&amp;lt;a href=\&quot;socket1Off\&quot;&amp;gt;&amp;lt;button&amp;gt;OFF&amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  webPage &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;&amp;lt;p&amp;gt;Socket #2 &amp;lt;a href=\&quot;socket2On\&quot;&amp;gt;&amp;lt;button&amp;gt;ON&amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;&amp;amp;nbsp;&amp;lt;a href=\&quot;socket2Off\&quot;&amp;gt;&amp;lt;button&amp;gt;OFF&amp;lt;/button&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;enableTransmit&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  delay&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;115200&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;WiFi&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;ssid&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; password&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;

  &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;box-sizing: border-box; color: #880000;&quot;&gt;// Wait for connection&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;WiFi&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; WL_CONNECTED&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    delay&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;Connected to &quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;ssid&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;IP address: &quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;WiFi&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;localIP&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;());&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  
  &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;mdns&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;esp8266&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;WiFi&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;localIP&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;()))&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;MDNS responder started&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  
  server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;[](){&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;text/html&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; webPage&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;/socket1On&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;[](){&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;text/html&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; webPage&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;sendTriState&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;socket1TriStateOn&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    delay&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;/socket1Off&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;[](){&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;text/html&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; webPage&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;sendTriState&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;socket1TriStateOff&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    delay&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; 
  &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;/socket2On&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;[](){&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;text/html&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; webPage&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;sendTriState&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;socket2TriStateOn&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    delay&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;/socket2Off&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;[](){&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;text/html&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; webPage&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    mySwitch&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;sendTriState&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;socket2TriStateOff&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
    delay&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;box-sizing: border-box; color: #006666;&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; 
  &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;begin&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;box-sizing: border-box; color: #660066;&quot;&gt;Serial&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;box-sizing: border-box; color: #008800;&quot;&gt;&quot;HTTP server started&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
 
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; loop&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;box-sizing: border-box; color: #000088;&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
  server&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;handleClient&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;box-sizing: border-box; color: black;&quot;&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 30px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px; white-space: normal;&quot;&gt;
ESP8266 IP Address&lt;/h2&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
Open the Arduino serial monitor at a baud rate of 115200. Connect GPIO 0 of your ESP8266 to VCC and reset your board.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
After a few seconds your IP address should appear. In my case it’s&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;192.168.1.70&lt;/span&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK56tDl-PPNmP3nfB5UY1EkpNUyNbLSY3OHdUtwLTXfgDJ5fd2sw39a0jLdTesJvHSCh8CVKFIuEkzeynVEjgCSKb_ud11r8k0530t4J09JhS9XHmBX93z3ewAy9fxo7hC5Tt2gl5svbR2/s1600/esp-ip-address.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK56tDl-PPNmP3nfB5UY1EkpNUyNbLSY3OHdUtwLTXfgDJ5fd2sw39a0jLdTesJvHSCh8CVKFIuEkzeynVEjgCSKb_ud11r8k0530t4J09JhS9XHmBX93z3ewAy9fxo7hC5Tt2gl5svbR2/s640/esp-ip-address.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 30px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px; white-space: normal;&quot;&gt;
Final Circuit&lt;/h2&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
This is the final circuit for your ESP8266&amp;nbsp;that hosts a web server and transmits RF signals to control your sockets.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhQNvwe5rSmUQrmpNwXN77XqD7xNA4BjlWX92yxw5QppwP09R6WfFbnym8AAbSnPM4Sp91csBt69t2UyhYNY3vM42RfVL6JiNOal9332z8PlXjTETHJTtlDg6o7bLn8noz6pFigzD6iJor/s1600/esp-with-433Mhz-Copy.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;290&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhQNvwe5rSmUQrmpNwXN77XqD7xNA4BjlWX92yxw5QppwP09R6WfFbnym8AAbSnPM4Sp91csBt69t2UyhYNY3vM42RfVL6JiNOal9332z8PlXjTETHJTtlDg6o7bLn8noz6pFigzD6iJor/s640/esp-with-433Mhz-Copy.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 30px; font-weight: 400; line-height: 1.2; margin: 0px 0px 10px; white-space: normal;&quot;&gt;
Demonstration&lt;/h2&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
For the final demonstration open any browser from a device that is connected to the same router that your ESP is. Then type&amp;nbsp;the IP address and click Enter!&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir8TSUY3uxPvCdSgQmh5reAsjMvYXxPbuZoft-22WV8yIKw_aNwV5Fh80rfo_p9J68iClwmjqOJrbmpgAGzFPIJZ93aVKS4VEqSv-WBkhyB9HEFAYmBEgB2Y36auy8KlgTBH_jUc4ekGsz/s1600/Screenshot_2015-09-15-18-31-331.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;460&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir8TSUY3uxPvCdSgQmh5reAsjMvYXxPbuZoft-22WV8yIKw_aNwV5Fh80rfo_p9J68iClwmjqOJrbmpgAGzFPIJZ93aVKS4VEqSv-WBkhyB9HEFAYmBEgB2Y36auy8KlgTBH_jUc4ekGsz/s640/Screenshot_2015-09-15-18-31-331.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; margin-bottom: 16px; padding: 0px; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; white-space: normal;&quot;&gt;Now when you press the buttons in your web server you can control both sockets (&lt;/span&gt;&lt;span style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Lato, sans-serif; font-size: 17px; font-weight: 700; line-height: 27.625px; white-space: normal;&quot;&gt;watch the video&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; white-space: normal;&quot;&gt;&amp;nbsp;at the beginning of this project&amp;nbsp;for a live demo).&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixSY6N5TFd0MtxxEUqXb8U0eltwof5fXvpkjxcKmIA2mOdmOYb9JkakvU6kVdPMdsFcI0wxfzS4VeoTd-7zoIxiyhkp_KwfjQ7zvZ7Ne_utS81o6ZB5n_l7VC4ioAoJUjFWvH5LuxjAhXm/s1600/on-and-off-sockets1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;206&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixSY6N5TFd0MtxxEUqXb8U0eltwof5fXvpkjxcKmIA2mOdmOYb9JkakvU6kVdPMdsFcI0wxfzS4VeoTd-7zoIxiyhkp_KwfjQ7zvZ7Ne_utS81o6ZB5n_l7VC4ioAoJUjFWvH5LuxjAhXm/s320/on-and-off-sockets1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre class=&quot;prettyprint prettyprinted&quot; style=&quot;background-attachment: scroll !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: repeat !important; background-size: initial !important; border: medium none !important; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; line-height: 27.625px; overflow: auto; padding: 0px !important;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;box-sizing: border-box; color: #666600;&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Lato, sans-serif; font-size: 17px; line-height: 27.625px; white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://arduino99.blogspot.com/feeds/281212614502813480/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://arduino99.blogspot.com/2015/09/esp8266-remote-controlled-sockets.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/281212614502813480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/414369779316658096/posts/default/281212614502813480'/><link rel='alternate' type='text/html' href='http://arduino99.blogspot.com/2015/09/esp8266-remote-controlled-sockets.html' title='ESP8266 Remote Controlled Sockets | ESP8266 control 433mhz remote control'/><author><name>Johan</name><uri>http://www.blogger.com/profile/05630213194754209115</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW7D4PwVZwvsrrPEydmf35lrpwqKEDFttS3NAZN_eputYu1Ess8qEVGu4GuLP5nC76bV5stHIBY8zV7nsFZjUFSlGf1v1O_40J4kEF9WR1vEocrk1MyfziNR8BWfhkHSQGgcyg0Y1J7bKn/s72-c/433mhz-receiver-circuit-esp8266.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>