arduino:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
arduino:start [2022/03/01 15:40] – illu | arduino:start [2022/03/03 11:36] (current) – removed illu | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <code c> | ||
- | //PINS | ||
- | #define REEDSWITCH 13 | ||
- | #define WHEELSIZE 0.91 | ||
- | volatile unsigned long rotations = 0; | ||
- | float meter = 0.0; | ||
- | volatile unsigned long lastactive = 0; | ||
- | |||
- | // Debounce Vars | ||
- | volatile unsigned long last_micros; | ||
- | unsigned long debouncing_time = 500; // | ||
- | |||
- | void setup() | ||
- | { | ||
- | // Reed Sensor (Interrupt) | ||
- | attachInterrupt(digitalPinToInterrupt(REEDSWITCH), | ||
- | //PINS | ||
- | pinMode(REEDSWITCH, | ||
- | lastactive = millis(); | ||
- | } | ||
- | |||
- | void loop() | ||
- | { | ||
- | if ( rotations >= 1 && ((millis() - lastactive) >= 1500) ) { | ||
- | meter = rotations * WHEELSIZE; | ||
- | // rotations = 0; | ||
- | // meter = 0; | ||
- | } | ||
- | } | ||
- | |||
- | // ----- Helper Functions | ||
- | void debounceInterrupt() { | ||
- | if ( micros() < last_micros ) { | ||
- | last_micros = micros(); | ||
- | } | ||
- | if ((unsigned long)(micros() - last_micros) >= debouncing_time * 1000) { | ||
- | rotations++; | ||
- | last_micros = micros(); | ||
- | lastactive = millis(); | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | </ | ||
- | |||
- | |||
- | #include " | ||
- | |||
- | DHTesp dht; | ||
- | |||
- | void setup() | ||
- | { | ||
- | Serial.begin(115200); | ||
- | Serial.println(); | ||
- | Serial.println(" | ||
- | |||
- | dht.setup(12); | ||
- | } | ||
- | |||
- | void loop() | ||
- | { | ||
- | delay(dht.getMinimumSamplingPeriod()); | ||
- | |||
- | float humidity = dht.getHumidity(); | ||
- | float temperature = dht.getTemperature(); | ||
- | |||
- | Serial.print(dht.getStatusString()); | ||
- | Serial.print(" | ||
- | Serial.print(humidity, | ||
- | Serial.print(" | ||
- | Serial.print(temperature, | ||
- | Serial.print(" | ||
- | Serial.print(dht.toFahrenheit(temperature), | ||
- | Serial.print(" | ||
- | Serial.print(dht.computeHeatIndex(temperature, | ||
- | Serial.print(" | ||
- | Serial.println(dht.computeHeatIndex(dht.toFahrenheit(temperature), | ||
- | } | ||
- | |||
- | |||
- | #include < ESP8266WiFi.h> | ||
- | #include < WiFiClient.h> | ||
- | #include < ESP8266WebServer.h> | ||
- | |||
- | // Replace with your network credentials | ||
- | const char* ssid = "Your WiFI SSID"; | ||
- | const char* password = "Your WiFI Password"; | ||
- | |||
- | ESP8266WebServer server(80); | ||
- | |||
- | String page = ""; | ||
- | |||
- | void setup(void){ | ||
- | |||
- | delay(1000); | ||
- | Serial.begin(115200); | ||
- | WiFi.begin(ssid, | ||
- | Serial.println("" | ||
- | | ||
- | // Wait for connection | ||
- | while (WiFi.status() != WL_CONNECTED) { | ||
- | delay(500); | ||
- | Serial.print(" | ||
- | } | ||
- | Serial.println("" | ||
- | Serial.print(" | ||
- | Serial.println(ssid); | ||
- | Serial.print(" | ||
- | Serial.println(WiFi.localIP()); | ||
- | server.on("/", | ||
- | page = " | ||
- | server.send(200, | ||
- | }); | ||
- | | ||
- | server.begin(); | ||
- | Serial.println(" | ||
- | } | ||
- | |||
- | void loop(void){ | ||
- | server.handleClient(); | ||
- | } | ||
- | </ |
arduino/start.1646145659.txt.gz · Last modified: 2022/03/01 15:40 by illu