Created
December 12, 2015 18:38
-
-
Save jherrlin/6760751101e3dd402822 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the working sketch | |
// THIS IS THE WORKING ONE!! | |
// With ESP8266 | |
#include <OneWire.h> | |
#include <DallasTemperature.h> | |
#include <SoftwareSerial.h> | |
#define ONE_WIRE_BUS 3 | |
#define SSID "network" | |
#define PASS "Smorbonden(#12)" | |
OneWire oneWire(ONE_WIRE_BUS); | |
DallasTemperature sensors(&oneWire); | |
SoftwareSerial esp(10, 11); // RX, TX | |
void setup(){ | |
Serial.begin(9600); | |
esp.begin(9600); | |
esp.println("AT+RST"); | |
delay(5000); | |
esp.println("AT+CWMODE=1"); | |
delay(5000); | |
String connectString = "AT+CWJAP="; | |
connectString += SSID; | |
connectString += "\",\""; | |
connectString += PASS; | |
connectString += "\""; | |
esp.println(connectString); | |
} | |
void loop(){ | |
sensors.requestTemperatures(); | |
delay(5000); | |
float tempC = sensors.getTempCByIndex(0); | |
delay(5000); | |
char buffer[10]; | |
String tempCstring = dtostrf(tempC, 4, 1, buffer); | |
delay(5000); | |
esp.println("AT+CIPSTART=\"UDP\",\"10.0.0.10\",16000"); | |
delay(5000); | |
esp.println("AT+CIPSEND=12"); | |
delay(5000); | |
esp.print(tempCstring); | |
esp.println(";sensor3"); | |
delay(25000); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment