diff --git a/.gitignore b/.gitignore index bb6b37978..80e746465 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,2 @@ -build-leonardo -build-uno - -esp8266-arduino/.DS_Store - -.DS_Store - -compile_mac.sh -airrohr-firmware/.vscode \ No newline at end of file +.vscode +.pio diff --git a/BeginnersGuide/Guide.md b/BeginnersGuide/Guide.md deleted file mode 100644 index c9deca23a..000000000 --- a/BeginnersGuide/Guide.md +++ /dev/null @@ -1 +0,0 @@ - :information_source: Siehe [Wiki Seite des Projekts](https://github.com/opendata-stuttgart/meta/wiki/Firmware-einspielen) zum Thema 'Firmware einspielen'. diff --git a/BeginnersGuide/airrohr_set_howto_short.de.md b/BeginnersGuide/airrohr_set_howto_short.de.md deleted file mode 100644 index bce3bc577..000000000 --- a/BeginnersGuide/airrohr_set_howto_short.de.md +++ /dev/null @@ -1,152 +0,0 @@ -% Bauanleitung Feinstaubsensor -% luftdaten.info – Feinstaub selber messen - -* [Bauanleitung online](https://luftdaten.info/feinstaubsensor-bauen/) - -## Feinstaubsensor – Bauanleitung - -### Bausatzliste - -* NodeMCU ESP8266, CPU/WLAN -* SDS011 Feinstaubsensor -* Temperatursensor - * DHT22, Temperatur & Luftfeuchtigkeit - * alternativ BME280 mit zusätzlichem Luftdrucksensor und i²c-Schnittstelle - -* Bilderstrecke NodeMCU, SDS011, DHT22, BME280 - - ![](https://luftdaten.info/wp-content/uploads/2018/02/Foto_NodeMCU-300x235.jpg){width=20%} - ![](https://luftdaten.info/wp-content/uploads/2018/02/Foto_SDS011-300x261.jpg){width=20%} - ![](https://luftdaten.info/wp-content/uploads/2018/02/Foto_DHT22-245x300.jpg){width=10%} - ![](img/sensor_bme280.jpg){width=10%} -* Steckverbinder (Dupont-Kabel) 2x4 Stück -* USB Kabel z.B: flach 2m Micro-USB -* Steckernetzteil USB -* 2x Kabelbinder (sehr klein/schmal) -* Schlauch, möglichst nicht transparent, Innen-Durchmesser 6 mm, Länge ca. 20cm (Baumarkt) -* Wetterschutz: 2x Marley Silent HT Bogen (DN 75 87°) -* Die Firmware sollte schon eingespielt sein, bitte prüfen, sonst nach Anleitung auf luftdaten.info: [Firmware einspielen](https://luftdaten.info/feinstaubsensor-bauen/#firmware-einspielen), z.B. mit dem [airrohr-firmware-flasher](https://github.com/opendata-stuttgart/airrohr-firmware-flasher) - * ESP anschließen, dann sollte es nach 1-2 Minuten ein WLAN Feinstaubsensor-xxx WLAN geben - * oder: via USB an den Rechner anschließen und serielle Schnittstelle beobachten (evtl. Treiber notwendig und serielles Terminal-programm) - -## Zusammenbau der Elektronik - -Die elektronischen Teile werden zusammen geschaltet - -![NodeMCU v.3 + SDS011 + BME280](img/airrohr_connection_sds011_bme280.pdf){width=40%} -![NodeMCU v.3 + SDS011 + BME280](img/airrohr_connection_sds011_dht22.pdf){width=40%} - -**Hinweis:**Unsere Anleitung bezieht sich auf Version 3 der NodeMCU. Diese ist zu erkennen an den Anschlüssen VU und G (siehe Zeichnung). Bei anderen Versionen steht an diesen Anschlüssen RSV. Dort können die Anschlüsse VIN statt VU und GND statt G neben dem MicroUSB-Anschluß genutzt werden. Siehe auch [Pinouts NodeMCU v2, v3](https://github.com/opendata-stuttgart/meta/wiki/Pinouts-NodeMCU-v2,-v3). - -### Anschluß SDS011 - -Pins sind von RECHTS nach LINKS nummeriert, beim Verbinden darauf achten, das die Kabel wirklich auf den Pins stecken, da die meisten Dupont-Kabel auch „neben“ die Pins passen. Falls lange und kurze Kabel da sind, hier die kurzen nutzen. - -| SDS011 Pin| Text | NodeMCU (ESP8266) | -|----------:|-------:|:----------------------------------------| -| 1 | TXD | Pin D1 | -| 2 | RXD | Pin D2 | -| 3 | GND | GND/G | -| 4 | 2,5 um | | -| 5 | 5V | VU (NodeMCU v3) / VIN (NodeMCU v1,v2) | -| 6 | 1 um | | -| 7 | NC | | - - -### Anschluß eines DHT22 - -Pins sind von LINKS nach RECHTS nummeriert, Vorderseite ist das „Gitter“. - -| DHT22 Pin | NodeMCU (ESP8266) | -|----------:|:-------------------| -| 1 | 3V3 (3.3V)/VU (5V) | -| 2 | D7 | -| 3 | | -| 4 | GND/G | - - - - -### Anschluß eines BME280 (Alternative zum DHT22) - -Die Pins des BME280 sind beschriftet, es werden 4 Pins verbunden: - -| BME280 | NodeMCU (ESP8266) | -|--------:|:------------------| -| VIN | 3V3 (3.3V) | -| GND | GND/G | -| SDA | D3 | -| SCL | D4 | - -Andere i²c-Geräte (z.B. Display) werden ebenfalls dieselben Pins SDA-D3 und SCL-D4 angeschlossen (y-Kabelverbindung notwendig). Anschlüsse für einige weitere Bauteile sind online in der [FAQ](https://luftdaten.info/faq/) aufgeführt. - -### Zusammenbinden - -* Mit dem ersten Kabelbinder den NodeMCU (ESP8266) und den Sensor SDS011 so zusammenbinden, dass die WLAN Antenne vom Sensor weg zeigt -* Mit dem zweiten Kabelbinder den Temperatursensor DHT22 (alternativ BME280) am Schlauch befestigen -* USB-Kabel durch das Rohr fädeln. Einbau so, dass die Platine des SDS oben ist und der Lüfter unten -* auf der Röhrenseite ohne Gummidichtung einschieben -* Die Teile so in das Rohr schieben, dass der Sensor im Rohr festklemmt -* Schlauch mit USB Kabel aus dem Rohr Ende schauen lassen -* Schlauch mit USB Kabel aus dem Rohr Ende schauen lassen. -* Den zweiten Rohrbogen auf den ersten schieben. Dabei darauf achten, dass keine Kabel eingeklemmt werden. -* Den Temperatursensor am Schlauch so positionieren, dass er knapp im Rohrinneren ist -* Den Schlauch am Rohrende abschneiden. -* Die offenen Enden der Rohre mit einem Netz, Gitter oder ähnlichen verschließen, dass die Luft zirkulieren kann aber die Tiere wie Käfer, Spinnen oder ähnliches draußen bleiben. -* Bilderstrecke - - ![](https://luftdaten.info/wp-content/uploads/2015/02/IMG_6491-495x400.png){width=30%}--> - ![](https://luftdaten.info/wp-content/uploads/2015/02/IMG_6492-e1500917451756-495x400.png){width=30%} - ![](https://luftdaten.info/wp-content/uploads/2015/02/IMG_6494-e1500917517160-495x400.png){width=30%} - -## Konfiguration der Messstation - -* Station mit Stromkabel anschließen -* Die Station versucht, sich auf den konfigurierten WLAN-Accesspoint zu verbinden (default ist "Freifunk-disabled"). Klappt dies nicht, öffnet der Sensor einen Accesspoint mit dem Namen Feinstaubsensor-ID, wobei ID die ChipID (dezimal, im Beispiel unten die 13597771) ist. -**Diese ID bitte unbedingt notieren, diese wird für die Anmeldung des Sensors benötigt!** -* Mit diesem Accesspoint verbinden. Kurz warten, bis die Verbindung hergestellt ist. -**Android:** Falls die Verbindung sofort wieder getrennt wird muss evtl. unter _‚Verbindungen-WLAN-Erweitert‘_ die Option _‚Intelligenter Netzwechsel‘_ (englisch _‚Smart network switch‘_) deaktiviert werden. -* Dann im Browser die Seite http://192.168.4.1/ aufrufen, dort kann der Sensor konfiguriert werden: http://192.168.4.1/ –> Konfigurieren - - **Bitte beachten:** Es braucht eventuell ein paar Versuche, bis der NodeMCU sich mit dem Heim-WLAN verbindet. Bitte nicht ungeduldig werden und es solange versuchen, bis es klappt. Der Chip kann auch über ein Smartphone konfiguriert werden. Wenn die Konfiguration des Sensors funktioniert hat, ist die Konfigurationsseite unter dieser IP 192.168.4.1 nicht mehr erreichbar -* Unter ‚Konfigurieren‘ die SSID (Name des Heim-WLANs) und den Netzwerksicherheitsschlüssel (unter Windows) bzw. das WLAN-Passwort des Heim-WLANs eintragen, speichern -* Für Feinstaubsensoren nach dieser Anleitung muss nichts weiter geändert werden -* Nach dem Speichern wird der Sensor neu gestartet und ist auf diesem Weg nicht mehr erreichbar, wenn er sich mit dem WLAN verbindet - -Wenn keine weiteren Änderungen vorgenommen worden als das Eintragen der WLAN-Daten, kann der Sensor nach ca. 10 Minuten auf den folgenden Seiten ‚getestet‘ werden. Gesucht werden muss auf diesen Seiten nach der ChipID (im Bespiel oben die 13597771). -Sensordaten: [www.madavi.de/sensor/graph.php](http://www.madavi.de/sensor/graph.php) -WLAN-Signal: [www.madavi.de/sensor/signal.php](http://www.madavi.de/sensor/signal.php) - -### Screenshots - -* Airrohr Startseite, Airrohr Konfiguration: WiFi und Sensoren (hier: BME280), Weitere Einstellungen und APIs - - ![](luftdaten-screenshots/airrohr_config_initial_en.png){width=24%} - ![](luftdaten-screenshots/airrohr_config_startpage_en_en.png){width=24%} - ![](luftdaten-screenshots/airrohr_config_wifi_sensor_bme280_en.png){width=24%} - ![](luftdaten-screenshots/airrohr_config_more_api_en.png){width=24%} - -### Registrieren des Sensors via meine.luftdaten.info - -Unter [meine.luftdaten.info](https://meine.luftdaten.info/) können Sensoren durch die Benutzer selbst eingetragen werden. Damit der Sensor Teil des Netzwerkes wird, brauchen wir noch einige Angaben. -Registriere dich, falls noch nicht geschehen, und logge dich ein, dann füge einen Sensor hinzu und fülle das Formular aus. - -* deine ID des ESP8266 (NodeMCU) –> kommt als Nummer im WLAN (Feinstaubsensor-…) oder auf der Konfigurationsseite oben -* deine Emailadresse (wird nicht veröffentlicht) -* deine Adresse: Strasse mit Hausnummer, PLZ und Ort und die Standortkoordinaten (werden nur gerundet herausgegeben) -* die Umgebung der Station – z. B. Höhe über Grund, Strassenseite, hohes Verkehrsaufkommen, freies Feld oder ähnliches - -* Startseite -> (Login) - Sensoren -> Sensor registrieren - - ![](luftdaten-screenshots/meine_luftdaten_webpage_de.png){width=30%} - ![](luftdaten-screenshots/meine_luftdaten_mysensors_de.png){width=30%} - ![](luftdaten-screenshots/meine_luftdaten_register_sensor_de.png){width=30%} -* Grundeinstellungen, Weitere Angaben - - ![](luftdaten-screenshots/meine_luftdaten_node_settings_base_de.png){width=30%} - ![](luftdaten-screenshots/meine_luftdaten_node_settings_additional_de.png){width=30%} - ![](luftdaten-screenshots/meine_luftdaten_node_settings_location_de.png){width=30%} - -* (c) NodeMCU drawing by [roman-minyaylov](https://github.com/roman-minyaylov/nodemcu-v3-fritzing), MIT License diff --git a/BeginnersGuide/airrohrdebug/debug_sensor_issues.de.md b/BeginnersGuide/airrohrdebug/debug_sensor_issues.de.md deleted file mode 100644 index 95a60f424..000000000 --- a/BeginnersGuide/airrohrdebug/debug_sensor_issues.de.md +++ /dev/null @@ -1,40 +0,0 @@ -# Sensorprobleme beheben - -Dieses sind Dinge, die man prüfen sollte, falls ein Sensor mal nicht wie erwartet funktioniert. -Die [ID] ist durch die eigene Sensor-ID zu ersetzen (eine mehrstellige Zahl), [sensortyp] kann z.B. sein: `sds011`, `dht22`, `bme280`. - -Online: - -* wurden Daten online eingeliefert (madvi API)? - * https://www.madavi.de/sensor/graph.php?sensor=esp8266-[ID]-[sensortyp] - * Nach der [ID] kann auch im Text auf der Seite https://www.madavi.de/sensor/graph.php gesucht werden - * ist der Sensor via https://devices.sensor.community/ angemeldet und sendete Daten an die Haupt-API (Sichtbarkeit auf Karte)? -* schauen, ob der WLAN Signalpegel vielleicht etwas schwach in der Vergangenheit war: - * hier ist das Signal-Log serverseitig: https://www.madavi.de/sensor/signal.php?sensor=esp8266-[ID] - -Am USB-Kabel: - -* Stromversorgung checken: USB Kabel -* Reboot (Stromversorgung unterbrechen, z.B. USB Stecker ziehen) -* Ist die WLAN Konfig OK (der Sensor verbindet auf das konfigurierte WLAN)? Falls nicht: - * macht der Sensor einen AP auf (in den ersten 2-7 Minuten nach einem Reboot)? - * Nach airrohr-[ID] WLAN Netzwerk Ausschau halten. Geduld, es kann nach dem Boot 1-2 Minuten dauern. -* Auf dem eigenen Router nachsehen, ob der Sensor im Netzwerk angemeldet ist, dann die IP merken - * alternativ "Discovery" im flashtool nutzen: https://github.com/opendata-stuttgart/airrohr-firmware-flasher/ - * Falls ja: auf die IP mit einem Browser verbinden http://[IP]/ , dort sollte die Oberfläche erscheinen - * Falls nein: der ESP hat Probleme, z.B. Stromversorgung nicht ausreichend, reboot loop o.ä. -* USB an einen Rechner anschließen und dort das Log ansehen - * Text auf serieller Schnittstelle mit seriellem Terminal-Programm verfolgen (Settings: baud 9600, 8N1) - * Linux: screen, minicom, cutecom; Windows: Tera Term; MacOS: screen, minicom, ...? - * evtl. sind passende usb2serial Treiber noch nötig, siehe https://github.com/opendata-stuttgart/meta/wiki/Firmware-einspielen - * Dort sollte man erkennen können, was der Sensor gerade tut (Bootmeldungen, WLAN Verbindung oder AP, Messung - erst nach 3 Minuten) - -An der Elektronik: - -* Sensorelektronik aus dem Gehäuse nehmen und beobachten -* Stromversorgung noch einmal checken/tauschen - * blinkt der ESP kurz nach Reboot? - * SDS011: rote LED/Lüfter an nach Reboot? - * die Kabel zu den Sensoren noch einmal checken/tauschen - - diff --git a/BeginnersGuide/compile.sh b/BeginnersGuide/compile.sh deleted file mode 100755 index b37e32050..000000000 --- a/BeginnersGuide/compile.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -targetdpi=150 - -for i in airrohr_set_howto_short.*.md -do - - target="$i.pdf" - dpitarget="$i.${targetdpi}dpi.pdf" - - echo "$i -> $target" - pandoc --toc -V classoption:DIV21 -V colorlinks:true -V documentclass:scrartcl --pdf-engine=xelatex -fmarkdown+autolink_bare_uris+lists_without_preceding_blankline -o "$target" "$i" - - echo "$target -> $dpitarget" - gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dColorImageResolution="$targetdpi" -dColorImageDownsampleType=/Average -dGrayImageDownsampleType=/Average -dGrayImageResolution="$targetdpi" -dMonoImageResolution="$targetdpi" -dMonoImageDownsampleType=/Average -dOiptimize=true -dDownsampleColorImages=true -dDownsampleGrayImages=true -dDownsampleMonoImages=true -dColorConversionStrategy=/sRGB -dNOPAUSE -dQUIET -dBATCH -sOutputFile="${dpitarget}" "${target}" - -done - - diff --git a/BeginnersGuide/img/Boardmanager.png b/BeginnersGuide/img/Boardmanager.png deleted file mode 100644 index b35d216e1..000000000 Binary files a/BeginnersGuide/img/Boardmanager.png and /dev/null differ diff --git a/BeginnersGuide/img/Einstellungen.png b/BeginnersGuide/img/Einstellungen.png deleted file mode 100644 index b91476f2f..000000000 Binary files a/BeginnersGuide/img/Einstellungen.png and /dev/null differ diff --git a/BeginnersGuide/img/LICENSE b/BeginnersGuide/img/LICENSE deleted file mode 100644 index b89528ced..000000000 --- a/BeginnersGuide/img/LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -* airrohr_connection_sds011_bme280.svg is a derived work of NodeMCUBreadboard.svg by roman-minyaylov -* Source: https://github.com/roman-minyaylov/nodemcu-v3-fritzing -* MIT License diff --git a/BeginnersGuide/img/NodeMCU-v2.jpg b/BeginnersGuide/img/NodeMCU-v2.jpg deleted file mode 100644 index 62eaa0ea4..000000000 Binary files a/BeginnersGuide/img/NodeMCU-v2.jpg and /dev/null differ diff --git a/BeginnersGuide/img/NodeMCU.jpg b/BeginnersGuide/img/NodeMCU.jpg deleted file mode 100644 index 2e50b3301..000000000 Binary files a/BeginnersGuide/img/NodeMCU.jpg and /dev/null differ diff --git a/BeginnersGuide/img/NodeMCU.png b/BeginnersGuide/img/NodeMCU.png deleted file mode 100644 index cc3ba2b14..000000000 Binary files a/BeginnersGuide/img/NodeMCU.png and /dev/null differ diff --git a/BeginnersGuide/img/Uberspielen.jpg b/BeginnersGuide/img/Uberspielen.jpg deleted file mode 100644 index fd0885339..000000000 Binary files a/BeginnersGuide/img/Uberspielen.jpg and /dev/null differ diff --git a/BeginnersGuide/img/airrohr_connection_sds011_bme280.pdf b/BeginnersGuide/img/airrohr_connection_sds011_bme280.pdf deleted file mode 100644 index 62ab89a8e..000000000 Binary files a/BeginnersGuide/img/airrohr_connection_sds011_bme280.pdf and /dev/null differ diff --git a/BeginnersGuide/img/airrohr_connection_sds011_bme280.png b/BeginnersGuide/img/airrohr_connection_sds011_bme280.png deleted file mode 100644 index b9af4f749..000000000 Binary files a/BeginnersGuide/img/airrohr_connection_sds011_bme280.png and /dev/null differ diff --git a/BeginnersGuide/img/airrohr_connection_sds011_bme280.svg b/BeginnersGuide/img/airrohr_connection_sds011_bme280.svg deleted file mode 100644 index 14eb2fc96..000000000 --- a/BeginnersGuide/img/airrohr_connection_sds011_bme280.svg +++ /dev/null @@ -1,1542 +0,0 @@ - - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -D0 -D1 -D2 -D3 -D4 -3V3 -GND -D5 -D6 -D7 -D8 -RX -TX -GND -3V3 -Vin -GND -RST -EN -3V3 -GND -SK -S0 -SC -S1 -S2 -S3 -VU -GND -A0 -FLASH -RST -Lolin -NodeMcu v3 -SDA -SCL -GND -VIN -BME280 -5V -TXD -RXD -GND -2,5um -1um -NC -SDS011 - \ No newline at end of file diff --git a/BeginnersGuide/img/airrohr_connection_sds011_dht22.pdf b/BeginnersGuide/img/airrohr_connection_sds011_dht22.pdf deleted file mode 100644 index ffc893b7e..000000000 Binary files a/BeginnersGuide/img/airrohr_connection_sds011_dht22.pdf and /dev/null differ diff --git a/BeginnersGuide/img/airrohr_connection_sds011_dht22.svg b/BeginnersGuide/img/airrohr_connection_sds011_dht22.svg deleted file mode 100644 index 1739891df..000000000 --- a/BeginnersGuide/img/airrohr_connection_sds011_dht22.svg +++ /dev/null @@ -1,1768 +0,0 @@ - - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -D0 - -D1 - -D2 - -D3 - -D4 - -3V3 - -GND - -D5 - -D6 - -D7 - -D8 - -RX - -TX - -GND - -3V3 - -Vin - -GND - -RST - -EN - -3V3 - -GND - -SK - -S0 - -SC - -S1 - -S2 - -S3 - -VU - -GND - -A0 - -FLASH - -RST - -Lolin - -NodeMcu v3 - - - - - - - -5V - -TXD - -RXD - -GND - -2,5um - -1um - -NC - -SDS011 - -DHT22 -3V/5V -S -GND -Y-cable 5V - \ No newline at end of file diff --git a/BeginnersGuide/img/sensor_bme280.jpg b/BeginnersGuide/img/sensor_bme280.jpg deleted file mode 100644 index 7749a603a..000000000 Binary files a/BeginnersGuide/img/sensor_bme280.jpg and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/airrohr_config_initial_done_en.png b/BeginnersGuide/luftdaten-screenshots/airrohr_config_initial_done_en.png deleted file mode 100644 index 56145b312..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/airrohr_config_initial_done_en.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/airrohr_config_initial_en.png b/BeginnersGuide/luftdaten-screenshots/airrohr_config_initial_en.png deleted file mode 100644 index c84ec9533..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/airrohr_config_initial_en.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/airrohr_config_more_api_en.png b/BeginnersGuide/luftdaten-screenshots/airrohr_config_more_api_en.png deleted file mode 100644 index 6679baae5..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/airrohr_config_more_api_en.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/airrohr_config_startpage_en_en.png b/BeginnersGuide/luftdaten-screenshots/airrohr_config_startpage_en_en.png deleted file mode 100644 index d894b6f90..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/airrohr_config_startpage_en_en.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/airrohr_config_wifi_sensor_bme280_en.png b/BeginnersGuide/luftdaten-screenshots/airrohr_config_wifi_sensor_bme280_en.png deleted file mode 100644 index 6310838ba..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/airrohr_config_wifi_sensor_bme280_en.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/airrohr_config_wifi_sensor_dht22_en.png b/BeginnersGuide/luftdaten-screenshots/airrohr_config_wifi_sensor_dht22_en.png deleted file mode 100644 index e42977f67..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/airrohr_config_wifi_sensor_dht22_en.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_mysensors_de.png b/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_mysensors_de.png deleted file mode 100644 index a0d2885ce..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_mysensors_de.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_node_settings_additional_de.png b/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_node_settings_additional_de.png deleted file mode 100644 index 3576398aa..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_node_settings_additional_de.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_node_settings_base_de.png b/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_node_settings_base_de.png deleted file mode 100644 index 9623c73d0..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_node_settings_base_de.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_node_settings_location_de.png b/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_node_settings_location_de.png deleted file mode 100644 index e4b81d2f8..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_node_settings_location_de.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_register_sensor_de.png b/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_register_sensor_de.png deleted file mode 100644 index 36b9f98ed..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_register_sensor_de.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_webpage_de.png b/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_webpage_de.png deleted file mode 100644 index ccc7acc25..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/meine_luftdaten_webpage_de.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-50-32.png b/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-50-32.png deleted file mode 100644 index 8e989f9aa..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-50-32.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-52-02.png b/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-52-02.png deleted file mode 100644 index f8a89f3fd..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-52-02.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-52-58.png b/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-52-58.png deleted file mode 100644 index 9bed87b08..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-52-58.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-55-41.png b/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-55-41.png deleted file mode 100644 index beea6b8f1..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-55-41.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-56-56.png b/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-56-56.png deleted file mode 100644 index 51109dfec..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-56-56.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-57-19.png b/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-57-19.png deleted file mode 100644 index 9eb12bd74..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-24_20-57-19.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-25_11-43-31.png b/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-25_11-43-31.png deleted file mode 100644 index b9d9ef0e1..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-25_11-43-31.png and /dev/null differ diff --git a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-25_11-44-35.png b/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-25_11-44-35.png deleted file mode 100644 index 1395f13fe..000000000 Binary files a/BeginnersGuide/luftdaten-screenshots/screenshot_2019-08-25_11-44-35.png and /dev/null differ diff --git a/airrohr-firmware/Contributing.md b/Contributing.md similarity index 100% rename from airrohr-firmware/Contributing.md rename to Contributing.md diff --git a/airrohr-firmware/DHT.cpp b/DHT.cpp similarity index 100% rename from airrohr-firmware/DHT.cpp rename to DHT.cpp diff --git a/airrohr-firmware/DHT.h b/DHT.h similarity index 100% rename from airrohr-firmware/DHT.h rename to DHT.h diff --git a/airrohr-firmware/LICENSE.md b/LICENSE.md similarity index 100% rename from airrohr-firmware/LICENSE.md rename to LICENSE.md diff --git a/MobileFeinstaub/.gitignore b/MobileFeinstaub/.gitignore deleted file mode 100644 index a4f405d19..000000000 --- a/MobileFeinstaub/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -* -!.gitignore -!config.xml -!www/* -!res/* -!*.md diff --git a/MobileFeinstaub/config.xml b/MobileFeinstaub/config.xml deleted file mode 100644 index 0b4a3350a..000000000 --- a/MobileFeinstaub/config.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - MobileFeinstaub - - Mobile Feinstaubmessung - - - Rajko Zschiegner (Open Knowledge Lab Stuttgart) - - - - - - - - - - - - - - - - - - - - - - diff --git a/MobileFeinstaub/readme.md b/MobileFeinstaub/readme.md deleted file mode 100644 index 87f0e33b2..000000000 --- a/MobileFeinstaub/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# Mobile Feinstaub Messung - -Source code für cordova (https://cordova.apache.org/) - -benötigte Plugins - -CordovArduino (cordova plugin add cordovarduino) diff --git a/MobileFeinstaub/res/mipmap-hdpi/codeforstuttgart_hdpi.png b/MobileFeinstaub/res/mipmap-hdpi/codeforstuttgart_hdpi.png deleted file mode 100644 index f999bc617..000000000 Binary files a/MobileFeinstaub/res/mipmap-hdpi/codeforstuttgart_hdpi.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-hdpi/icon.png b/MobileFeinstaub/res/mipmap-hdpi/icon.png deleted file mode 100644 index f999bc617..000000000 Binary files a/MobileFeinstaub/res/mipmap-hdpi/icon.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-ldpi/codeforstuttgart_ldpi.png b/MobileFeinstaub/res/mipmap-ldpi/codeforstuttgart_ldpi.png deleted file mode 100644 index 07cceb6e7..000000000 Binary files a/MobileFeinstaub/res/mipmap-ldpi/codeforstuttgart_ldpi.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-ldpi/icon.png b/MobileFeinstaub/res/mipmap-ldpi/icon.png deleted file mode 100644 index 07cceb6e7..000000000 Binary files a/MobileFeinstaub/res/mipmap-ldpi/icon.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-mdpi/codeforstuttgart_mdpi.png b/MobileFeinstaub/res/mipmap-mdpi/codeforstuttgart_mdpi.png deleted file mode 100644 index 4a8c5d785..000000000 Binary files a/MobileFeinstaub/res/mipmap-mdpi/codeforstuttgart_mdpi.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-mdpi/icon.png b/MobileFeinstaub/res/mipmap-mdpi/icon.png deleted file mode 100644 index 4a8c5d785..000000000 Binary files a/MobileFeinstaub/res/mipmap-mdpi/icon.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-xhdpi/codeforstuttgart_xhdpi.png b/MobileFeinstaub/res/mipmap-xhdpi/codeforstuttgart_xhdpi.png deleted file mode 100644 index 5e2c0e585..000000000 Binary files a/MobileFeinstaub/res/mipmap-xhdpi/codeforstuttgart_xhdpi.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-xhdpi/icon.png b/MobileFeinstaub/res/mipmap-xhdpi/icon.png deleted file mode 100644 index 5e2c0e585..000000000 Binary files a/MobileFeinstaub/res/mipmap-xhdpi/icon.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-xxhdpi/codeforstuttgart_xxhdpi.png b/MobileFeinstaub/res/mipmap-xxhdpi/codeforstuttgart_xxhdpi.png deleted file mode 100644 index 87b58482b..000000000 Binary files a/MobileFeinstaub/res/mipmap-xxhdpi/codeforstuttgart_xxhdpi.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-xxhdpi/icon.png b/MobileFeinstaub/res/mipmap-xxhdpi/icon.png deleted file mode 100644 index 87b58482b..000000000 Binary files a/MobileFeinstaub/res/mipmap-xxhdpi/icon.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-xxxhdpi/codeforstuttgart_xxxhdpi.png b/MobileFeinstaub/res/mipmap-xxxhdpi/codeforstuttgart_xxxhdpi.png deleted file mode 100644 index cc53b4cef..000000000 Binary files a/MobileFeinstaub/res/mipmap-xxxhdpi/codeforstuttgart_xxxhdpi.png and /dev/null differ diff --git a/MobileFeinstaub/res/mipmap-xxxhdpi/icon.png b/MobileFeinstaub/res/mipmap-xxxhdpi/icon.png deleted file mode 100644 index cc53b4cef..000000000 Binary files a/MobileFeinstaub/res/mipmap-xxxhdpi/icon.png and /dev/null differ diff --git a/MobileFeinstaub/www/css/index.css b/MobileFeinstaub/www/css/index.css deleted file mode 100644 index 67f20614a..000000000 --- a/MobileFeinstaub/www/css/index.css +++ /dev/null @@ -1,116 +0,0 @@ -* { - -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */ -} - -div[ng-view]{ - height: 100%; -} - -body { - -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */ - -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */ - -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */ - background-color:#E4E4E4; - background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); - background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); - background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); - background-image:-webkit-gradient( - linear, - left top, - left bottom, - color-stop(0, #A7A7A7), - color-stop(0.51, #E4E4E4) - ); - background-attachment:fixed; - font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif; - font-size:12px; - height:100vh; - margin:0px; - padding:0px; - text-transform:uppercase; - width:100%; -} - -/* Portrait layout (default) */ -.app { - height: 100%; - margin: 10%; -} - -#logo { - width: 50%; -} - -.value_out { - width: 100%; - text-align: left; -} - -#P1,#P2 { - font-family: Courier; -} - -#debug_out { -// display: none; -} - -#graph { - max-width: 500px; - text-align: center; -} - -/* Landscape layout (with min-width) */ -@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) { - .app { - } - - #logo { - width:28%; - } - -} - -h1 { - font-size:24px; - font-weight:normal; - margin:0px; - overflow:visible; - padding:0px; - text-align:center; -} - -.event { - border-radius:4px; - -webkit-border-radius:4px; - color:#FFFFFF; - font-size:12px; - margin:0px 30px; - padding:2px 0px; -} - -.event.listening { - background-color:#333333; - display:block; -} - -.event.received { - background-color:#4B946A; - display:none; -} - -@keyframes fade { - from { opacity: 1.0; } - 50% { opacity: 0.4; } - to { opacity: 1.0; } -} - -@-webkit-keyframes fade { - from { opacity: 1.0; } - 50% { opacity: 0.4; } - to { opacity: 1.0; } -} - -.blink { - animation:fade 3000ms infinite; - -webkit-animation:fade 3000ms infinite; -} diff --git a/MobileFeinstaub/www/img/CFG_logo.svg b/MobileFeinstaub/www/img/CFG_logo.svg deleted file mode 100644 index 1741813be..000000000 --- a/MobileFeinstaub/www/img/CFG_logo.svg +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/MobileFeinstaub/www/index.html b/MobileFeinstaub/www/index.html deleted file mode 100644 index c4367b121..000000000 --- a/MobileFeinstaub/www/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - Mobile Feinstaubmessung - - -
-

- -

Mobile Feinstaubmessung

-
-

PM10:

-

PM2.5:

-

...

- -
-
- - - - diff --git a/MobileFeinstaub/www/js/index.js b/MobileFeinstaub/www/js/index.js deleted file mode 100644 index 3d86e0373..000000000 --- a/MobileFeinstaub/www/js/index.js +++ /dev/null @@ -1,157 +0,0 @@ -var app = { - - initialize: function() { - document.addEventListener('deviceready', this.onDeviceReady, false); - }, - onDeviceReady: function() { - var P1Text = document.getElementById('P1'); - var P2Text = document.getElementById('P2'); - var debug_out = document.getElementById('debug_out'); -// var on = document.getElementById('on'); -// var off = document.getElementById('off'); - var str = ''; - var buffer = []; - var graph_buffer_p1 = []; - var graph_buffer_p2 = []; - var value = 0; - var pm25_serial = 0; - var pm10_serial = 0; - var checksum_is = 0; - var serial_pos = 0; - var checksum_ok = 0; - - var errorCallback = function(message) { - alert('Error: ' + message); - }; - // request permission first - serial.requestPermission( - // if user grants permission - function(successMessage) { - // open serial port - serial.open( - {baudRate: 9600}, - // if port is succesfully opened - function(successMessage) { - // register the read callback - - serial.registerReadCallback( - function success(data){ - // decode the received message - var view = new Uint8Array(data); - setTimeout(function(){ - if(view.length >= 1) { - for(var i=0; i < view.length; i++) { - buffer.push(view[i]); - } - } - while (buffer.length > 0) { - value = buffer.shift(); -// console.log(value); - switch (serial_pos) { - case 0: if (value != 170) { serial_pos = -1; }; break; - case 1: if (value != 192) { serial_pos = -1; }; break; - case 2: pm25_serial = value; checksum_is = value; break; - case 3: pm25_serial += (value << 8); checksum_is += value; break; - case 4: pm10_serial = value; checksum_is += value; break; - case 5: pm10_serial += (value << 8); checksum_is += value; break; - case 6: checksum_is += value; break; - case 7: checksum_is += value; break; - case 8: - if (value == (checksum_is % 256)) { checksum_ok = 1; } else { serial_pos = -1; }; break; - case 9: if (value != 171) { serial_pos = -1; }; break; - } - serial_pos++; - if (serial_pos == 10 && checksum_ok == 1) { - if ((! isNaN(pm10_serial)) && (! isNaN(pm25_serial))) { - P1Text.innerText = (pm10_serial/10).toFixed(1); - P2Text.innerText = (pm25_serial/10).toFixed(1); - while (graph_buffer_p1.length >= 500) graph_buffer_p1.shift(); - while (graph_buffer_p2.length >= 500) graph_buffer_p2.shift(); - graph_buffer_p1.push(pm10_serial/10); - graph_buffer_p2.push(pm25_serial/10); - } - serial_pos = 0; checksum_ok = 0; pm10_serial = 0.0; pm25_serial = 0.0; checksum_is = 0; - } - } -// debug_out.innerText = graph_buffer_p1.length; - var canvas = document.getElementById("graph"); - var canvas_width = Math.min(document.getElementById("value_out").offsetWidth,500); - canvas.style.width = canvas_width+"px"; - - var graph_offset = Math.max(0,(graph_buffer_p1.length-canvas.width)) - console.log("Buffer length: "+graph_buffer_p1.length+", Canvas width (calc): "+canvas_width+", Canvas width: "+canvas.width+", Canvas height: "+canvas.height+", Offset: "+graph_offset); - - if (canvas.getContext) { - - var ctx = canvas.getContext("2d"); - - ctx.clearRect(0,0,canvas.width, canvas.height); - - ctx.strokeStyle = "gray"; - ctx.beginPath(); - ctx.moveTo(0,0); - ctx.lineTo(canvas.width-1,0); - ctx.lineTo(canvas.width-1,149); - ctx.lineTo(0,149); - ctx.lineTo(0,0); - ctx.stroke(); - - ctx.beginPath(); - ctx.moveTo(0,100); - ctx.lineTo(canvas.width-1,100); - ctx.stroke(); - - ctx.beginPath(); - ctx.moveTo(0,50); - ctx.lineTo(canvas.width-1,50); - ctx.stroke(); - - var max_p1 = 150; - for (var i=graph_offset; i < graph_buffer_p1.length; i++) { - if (graph_buffer_p1[i] > max_p1) { max_p1 = graph_buffer_p1[i]; } - } - - scaling = (Math.floor(max_p1/100)+1)*100/150; - console.log(max_p1+", "+scaling); - - ctx.strokeStyle = "rgb(200,0,0)"; - ctx.beginPath(); - ctx.moveTo(0,150-(graph_buffer_p1[graph_offset]/scaling)) - for (var i=graph_offset; i < graph_buffer_p1.length; i++) { - ctx.lineTo(i-graph_offset, 150-Math.round(graph_buffer_p1[i]/scaling)); - ctx.stroke(); - } - - ctx.strokeStyle = "rgb(0, 0, 200)"; - ctx.beginPath(); - ctx.moveTo(0,150-(graph_buffer_p2[graph_offset]/scaling)) - for (var i=graph_offset; i < graph_buffer_p2.length; i++) { - ctx.lineTo(i-graph_offset, 150-Math.round(graph_buffer_p2[i]/scaling)); - ctx.stroke(); - } - } - },200); - }, - // error attaching the callback - errorCallback - ); - }, - // error opening the port - errorCallback - ); - }, - // user does not grant permission - errorCallback - ); - -/* on.onclick = function() { - console.log('click'); - if (open) serial.write('1'); - }; - off.onclick = function() { - if (open) serial.write('0'); - } */ - } -}; - -app.initialize(); diff --git a/airrohr-firmware/Readme.md b/Readme.md similarity index 71% rename from airrohr-firmware/Readme.md rename to Readme.md index bed94eacf..94695061b 100644 --- a/airrohr-firmware/Readme.md +++ b/Readme.md @@ -1,4 +1,8 @@ -# airRohr Sensor Firmware for SPS30, SDS011, DHT22, BMP180, BMP/E 280 and many more +# Robonomics Sensor Firmware for SDS011, DHT22, BMP180, BMP/E 280 and many more sensors + +This repository is a fork of the [airRohr Sensor Firmware](https://github.com/opendata-stuttgart/sensors-software). We have added several new features, including a Noise Meter, a Geiger Counter, and a VOC sensor. Additionally, support for [Robonomics Decentralized Sensors Network](https://sensors.social/#/) has been integrated to enhance functionality. + +More information you can find in [Robonomics Academy](https://robonomics.academy/en/learn/sensors-connectivity-course/overview/). ## Features: * many environmental and air quality sensors can be used concurrently @@ -6,12 +10,59 @@ * Configuration via HTTP in local WiFi or with a Sensor-as Access-Point * Support for OLED- and LCD-Displays (SSD1306, SH1106 and LCD1602, LCD2004) * Wide selection of API integrations for measurement reporting -* Ability to print measurements as CSV via USB-serial * Used with ESP8266 (NodeMCU v2/v3 and compatible) and ESP32 (experimental) -## Contributing +## Sensor Setup + +* You can find more information about how to get the sensor in [Sensor Hardware](https://robonomics.academy/en/learn/sensors-connectivity-course/sensor-hardware/) guide in Robonomics Academy. + +* And the detailed information about sensor setup you can find in [Setting up and connecting sensors](https://robonomics.academy/en/learn/sensors-connectivity-course/setting-up-and-connecting-sensors/) article. + +## Additional Information + +### WiFi configuration +If a (previously) configured WiFi is not reachable within 20 seconds after power-on, +the firmware flips itself into AP mode and creates a WiFi network in the form `RobonomicsSensor-\[Sensor-ID\]`. -To add your Connectivity Robonomics Server to sensors firmware fork this repository and edit [robonomics_servers.h](./robonomics_servers.h) file. Add your server in a list in the following format: +This WiFi network is by default unencrypted. When a client connects to this, it will get +redirected to the sensors web server `http://192.168.4.1/` which allows initial configuration. + +Configurable is +* WiFi Access Point to use +* Options for measurements (Sensors to poll, intervals..) +* APIs to send the measurements + +The unencrypted Access Point for initial configuration will turn itself off after about +10 minutes. In order to reactivate please power cycle the board. + +--- + +### Build and Flash Firmware from Source + +To build the firmware you need [Platformio](https://platformio.org/) tool. In this article, we'll provide instructions on how to build the firmware with [Platformio core](https://docs.platformio.org/en/latest/core/installation/index.html). + +Clone the repo: +```bash +git clone https://github.com/airalab/sensors-software.git +cd sensors-software +``` + +Build the firmware: +```bash +pio run -e nodemcuv2_en +``` +Firmware binary file will be in `builds` folder. + +To flash the device, connect it to the computer with a USB cable and run +```bash +pio run -t upload -e nodemcuv2_en +``` + +--- + +### Contributing + +To add your Connectivity Robonomics Server to sensors firmware, fork this repository and edit [robonomics_servers.h](./robonomics_servers.h) file. Add your server in a list in the following format: ```bash {"", } ``` @@ -32,24 +83,9 @@ For example: Then make a pull request. -## WiFi configuration -For German Version see: [Konfiguration der Sensoren](https://github.com/opendata-stuttgart/meta/wiki/Konfiguration-der-Sensoren) - -If a (previously) configured WiFi is not reachable within 20 seconds after power-on, -the firmware flips itself into AP mode and creates a WiFi network in the form `airRohr-\[Sensor-ID\]`. - -This WiFi network is by default unencrypted. When a client connects to this, it will get -redirected to the sensors web server `http://192.168.4.1/` which allows initial configuration. - -Configurable is -* WiFi Access Point to use -* Options for measurements (Sensors to poll, intervals..) -* APIs to send the measurements - -The unencrypted Access Point for initial configuration will turn itself off after about -10 minutes. In order to reactivate please power cycle the board. +--- -## DHT22 Humidity Reporting +### DHT22 Humidity Reporting The DHT22 sensor is originally an Indoor sensor. For outdoor use it appears to be rather sensitive to water condensation after 100% rel.Humidity that keep it for very long time @@ -58,21 +94,26 @@ which tends to cause the sensor to crash until hard power-loss restarted. Better experiences have been made with a BME280 or SHT3x sensor, so consider those instead. +--- + -## Debug via USB-Serial +### Debug via USB-Serial -Connecting/Powering via a computer USB will provide USB serial with the settings 9600 baud 8N1. +Connecting/Powering via a computer USB will provide USB serial with the settings 115200 baud. By default the sensor will provide human readable debug information of configurable granularity there. -## Save as CSV +--- + +### Save as CSV All measurements can also be read as CSV via USB-Serial when using the USB port in the settings 9600 Baud 8N1. In order to avoid interfering of debug options (see earlier section) set debug to None in the configuration. +--- -## Wiring +### Wiring ![https://raw.githubusercontent.com/opendata-stuttgart/meta/master/files/nodemcu-v3-schaltplan-sds011.jpg](https://raw.githubusercontent.com/opendata-stuttgart/meta/master/files/nodemcu-v3-schaltplan-sds011.jpg) @@ -174,17 +215,3 @@ VCC and GND can be provided by board (use 3.3v!) * TX von Neo -> Pin D5 (RX) * RX von Neo -> Pin D6 (TX) -## Sensor.Community API "Pins" - -For use of multiple sensors with Sensor.Community (formerly Luftdaten.info), you need to specify a -*virtual* API Pin in the sensor registration form at devices.sensor.community. The firmware uses -the following API pins hardcoded. These match what the Sensor.Community API expect and will be used -by default when selecting the correct sensor model. - -* HPM/PMS/SDS011/SPS30 => Pin 1 -* BME280 => Pin 11 -* BMP180/BMP280 => Pin 3 -* DHT22/HTU21D/SHT3x => Pin 7 -* GPS(Neo-6M) => Pin 9 -* DS18B20 => Pin 13 -* DNMS +> Pin 15 diff --git a/airrohr-firmware/Versions.md b/Versions.md similarity index 100% rename from airrohr-firmware/Versions.md rename to Versions.md diff --git a/airrohr-firmware/airrohr-cfg.h b/airrohr-cfg.h similarity index 100% rename from airrohr-firmware/airrohr-cfg.h rename to airrohr-cfg.h diff --git a/airrohr-firmware/airrohr-cfg.h.py b/airrohr-cfg.h.py similarity index 100% rename from airrohr-firmware/airrohr-cfg.h.py rename to airrohr-cfg.h.py diff --git a/airrohr-firmware/airrohr-firmware.ino b/airrohr-firmware.ino similarity index 100% rename from airrohr-firmware/airrohr-firmware.ino rename to airrohr-firmware.ino diff --git a/airrohr-firmware/.gitignore b/airrohr-firmware/.gitignore deleted file mode 100644 index 51ce723cc..000000000 --- a/airrohr-firmware/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -examples -keywords.txt -library.json -*.ino.orig -builds/ -!builds/readme.md -.clang_complete -.gcc-flags.json -.vscode/.browse.c_cpp.db* -.vscode/c_cpp_properties.json -.vscode/launch.json -.travis.yml -.pio/ diff --git a/airrohr-firmware/.vscode/settings.json b/airrohr-firmware/.vscode/settings.json deleted file mode 100644 index 4632cb171..000000000 --- a/airrohr-firmware/.vscode/settings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "files.associations": { - "array": "c", - "string": "c", - "string_view": "c", - "*.ipp": "c", - "functional": "c", - "bitset": "c", - "initializer_list": "c", - "utility": "c", - "cstdlib": "cpp", - "radsens1v2.h": "c" - } -} \ No newline at end of file diff --git a/airrohr-firmware/airrohr-logo-common.h b/airrohr-logo-common.h similarity index 100% rename from airrohr-firmware/airrohr-logo-common.h rename to airrohr-logo-common.h diff --git a/airrohr-update-loader/.gitignore b/airrohr-update-loader/.gitignore deleted file mode 100644 index ba1c555b1..000000000 --- a/airrohr-update-loader/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.pio -.clang_complete -.gcc-flags.json -builds/ diff --git a/airrohr-update-loader/airrohr-update-loader.ino b/airrohr-update-loader/airrohr-update-loader.ino deleted file mode 100644 index 4af6f2579..000000000 --- a/airrohr-update-loader/airrohr-update-loader.ino +++ /dev/null @@ -1,203 +0,0 @@ -/************************************************************************ - * * - * This source code needs to be compiled for the board * - * NodeMCU 1.0 (ESP-12E Module) * - * * - ************************************************************************ - * * - * airRohr firmware * - * Copyright (C) 2016-2018 Code for Stuttgart a.o. * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - * * - ************************************************************************ - * OK LAB Particulate Matter Sensor * - * * - * Loader for two step update * - * * - * * - ************************************************************************ - - * 8.10.2019 (Arduino Core 2.4.2): - * DATA: [=== ] 34.0% (used 27876 bytes from 81920 bytes) - * PROGRAM: [=== ] 25.6% (used 267072 bytes from 1044464 bytes) - - * 28.10.2019 (Arduino Core 2.5.2): - * DATA: [=== ] 32.9% (used 26964 bytes from 81920 bytes) - * PROGRAM: [=== ] 26.9% (used 280588 bytes from 1044464 bytes) - - ************************************************************************/ -// increment on change -#define SOFTWARE_VERSION "LOADER-002" - -/***************************************************************** - * Includes * - *****************************************************************/ -#include -#include // must be first -#include - -// define debug levels -#define DEBUG_ERROR 1 -#define DEBUG_WARNING 2 -#define DEBUG_MIN_INFO 3 -#define DEBUG_MED_INFO 4 -#define DEBUG_MAX_INFO 5 - -/****************************************************************** - * The variables inside the cfg namespace are persistent * - * configuration values. They have defaults which can be * - * configured at compile-time via the ext_def.h file * - * They can be changed by the user via the web interface, the * - * changes are persisted to the flash and read back after reboot. * - * Note that the names of these variables can't be easily changed * - * as they are part of the json format used to persist the data. * - ******************************************************************/ -namespace cfg { - int debug = DEBUG_MIN_INFO; -} - -/***************************************************************** - * Debug output * - *****************************************************************/ - -#define debug_level_check(level) if (level > cfg::debug) return; - -static void debug_outln_info(const __FlashStringHelper* text) { - debug_level_check(DEBUG_MIN_INFO); Serial.println(text); -} - -static void debug_outln_info(const __FlashStringHelper* text, const String& option) { - debug_level_check(DEBUG_MIN_INFO); - Serial.print(text); - Serial.println(option); -} - -static void debug_outln_error(const __FlashStringHelper* text) { - debug_level_check(DEBUG_ERROR); Serial.println(text); -} - -#undef debug_level_check - -bool use_old_firmware = false; - -static bool SPIFFSAutoUpdate() { - const char firmware_filename[] = "/firmware.bin"; - const char firmware_md5_filename[] = "/firmware.bin.md5"; - const char prev_firmware_filename[] = "/firmware.old"; - - String firmware = use_old_firmware ? prev_firmware_filename : firmware_filename; - - if (!SPIFFS.exists(firmware)) { - debug_outln_info(F("No Firmware file found, looking for: "), firmware); - return false; - } - File updateFile = SPIFFS.open(firmware, "r"); - if (!updateFile) { - debug_outln_info(F("Failed to open : "), firmware); - return false; - } - if (updateFile.size() >= ESP.getFreeSketchSpace()) { - debug_outln_error(F("Cannot update, Firmware too large")); - return false; - } - if (!Update.begin(updateFile.size(), U_FLASH)) { - StreamString error; - Update.printError(error); - - debug_outln_info(F("Update.begin returned: "), error); - return false; - } - if (!use_old_firmware) { - File md5File = SPIFFS.open(firmware_md5_filename, "r"); - if (md5File) { - String md5sum_firmware = md5File.readString(); - debug_outln_info(F("Found firmware MD5: "), md5sum_firmware); - Update.setMD5(md5sum_firmware.c_str()); - md5File.close(); - } - } - if (Update.writeStream(updateFile) != updateFile.size()) { - StreamString error; - Update.printError(error); - - debug_outln_info(F("Update.writeStream returned: "), error); - return false; - } - updateFile.close(); - - if (!Update.end()) { - StreamString error; - Update.printError(error); - - debug_outln_info(F("Update.end() returned: "), error); - return false; - } - - debug_outln_info(F("Moving Firmware image to old.")); - - SPIFFS.remove(prev_firmware_filename); - SPIFFS.remove(firmware_md5_filename); - SPIFFS.rename(firmware_filename, prev_firmware_filename); - SPIFFS.end(); - - debug_outln_info(F("Erasing SDK config.")); - ESP.eraseConfig(); - - debug_outln_info(F("Finished successfully.. Rebooting!")); - delay(500); - ESP.restart(); - return true; -} - -/***************************************************************** - * The Setup * - *****************************************************************/ -void setup() { - Serial.begin(9600); // Output to Serial at 9600 baud - pinMode(LED_BUILTIN, OUTPUT); - - if (!SPIFFS.begin()) { - debug_outln_error(F("Failed to mount SPIFFS!")); - return; - } -} - -/***************************************************************** - * And action * - *****************************************************************/ -void loop() { - - if (!SPIFFSAutoUpdate()) { - bool slow = false; - - debug_outln_error(F("Update Failed.")); - debug_outln_error(F("Please upload the latest firmware as '/firmware.bin' on SPIFSS to recover.")); - - for (int j = 0; j < 3; ++j) { - for (int i = 0; i < 3; ++i) { - digitalWrite(LED_BUILTIN, HIGH); - delay(60); - digitalWrite(LED_BUILTIN, LOW); - delay(slow ? 1000 : 400); - yield(); - } - digitalWrite(LED_BUILTIN, HIGH); - delay(800); - slow = !slow; - } - } - - use_old_firmware = !use_old_firmware; -} diff --git a/airrohr-update-loader/astyle.rc b/airrohr-update-loader/astyle.rc deleted file mode 120000 index 0edff163f..000000000 --- a/airrohr-update-loader/astyle.rc +++ /dev/null @@ -1 +0,0 @@ -../airrohr-firmware/astyle.rc \ No newline at end of file diff --git a/airrohr-update-loader/platformio.ini b/airrohr-update-loader/platformio.ini deleted file mode 100644 index cec96d074..000000000 --- a/airrohr-update-loader/platformio.ini +++ /dev/null @@ -1,44 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; http://docs.platformio.org/page/projectconf.html - -[platformio] -src_dir = . - -[common] -build_flags = - -DVTABLES_IN_FLASH -D BEARSSL_SSL_BASIC - -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY - -DNDEBUG - -Wl,-Teagle.flash.4m3m.ld -board_build.f_cpu = 160000000L -; Always depend on specific library versions (wherever possible) -; Keep Library names in alphabetical order -lib_deps_external = -extra_scripts = platformio_script.py -# This release is reflecting the Arduino Core 2.7.4 release -# When the requirement for Arduino Core is raised, this -# needs to be adjusted to the matching version from -# https://github.com/platformio/platform-espressif8266/releases -platform_version = espressif8266@2.6.2 - -[env] -;lib_ldf_mode = chain+ ; automatically detect libraries by the used includes -lib_ldf_mode = off ; all used libs must be explicitly referenced -monitor_speed = 9600 - -[env:nodemcuv2] -lang = loader -platform = ${common.platform_version} -framework = arduino -board = nodemcuv2 -board_build.f_cpu = ${common.board_build.f_cpu} -build_flags = ${common.build_flags} -lib_deps = ${common.lib_deps_external} -extra_scripts = ${common.extra_scripts} diff --git a/airrohr-update-loader/platformio_script.py b/airrohr-update-loader/platformio_script.py deleted file mode 120000 index e79ffa066..000000000 --- a/airrohr-update-loader/platformio_script.py +++ /dev/null @@ -1 +0,0 @@ -../airrohr-firmware/platformio_script.py \ No newline at end of file diff --git a/apiclients/LICENSE b/apiclients/LICENSE deleted file mode 100644 index d8e5781c6..000000000 --- a/apiclients/LICENSE +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (C) 2014 - 2015 Openknowledge Lab Stuttgart - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License version 2 as published -by the Free Software Foundation. - -If the program is linked with libraries which are licensed under one of -the following licenses, the combination of the program with the linked -library is not considered a "derivative work" of the program: - - • Apache License, version 2.0 - • Apache Software License, version 1.0 - • GNU Lesser General Public License, version 3 - • Mozilla Public License, versions 1.0, 1.1 and 2.0 - • Common Development and Distribution License (CDDL), version 1.0 - -Therefore the distribution of the program linked with libraries licensed -under the aforementioned licenses, is permitted by the copyright holders -if the distribution is compliant with both the GNU General Public -License version 2 and the aforementioned licenses. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -Public License for more details. - diff --git a/apiclients/archive.luftdaten.info/00disclamer.md b/apiclients/archive.luftdaten.info/00disclamer.md deleted file mode 100644 index fb1295adc..000000000 --- a/apiclients/archive.luftdaten.info/00disclamer.md +++ /dev/null @@ -1,14 +0,0 @@ -# Archive of luftdaten.info / api.dusti.xyz - -## about - -This archive consists of CSV dumps of all outdoor PPD42NS sensor that seem to have valid data. - -## Problems - -Please report problems in our opendata-stuttgart issuetracker: https://github.com/opendata-stuttgart/meta/issues - -## Future improvements - -- description of position of sensor on location -- image of sensor at location diff --git a/apiclients/config.py.template b/apiclients/config.py.template deleted file mode 100644 index edddf5cc7..000000000 --- a/apiclients/config.py.template +++ /dev/null @@ -1,5 +0,0 @@ -API_TOKEN = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' -PUSHOVER_CLIENT_TOKEN = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -PUSHOVER_API_TOKEN = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -LAST_N_HOURS = 1 -LAST_N_MINUTES = 5 diff --git a/apiclients/config.sh.template b/apiclients/config.sh.template deleted file mode 100644 index aa950e9b9..000000000 --- a/apiclients/config.sh.template +++ /dev/null @@ -1,5 +0,0 @@ -# cp this to config.sh and adapt values -# your token here -API_TOKEN='YOURTOKENHERE' -# your sensorids here (note: not nodeid) -SENSOR_IDS='01 02' diff --git a/apiclients/getarchive.sh b/apiclients/getarchive.sh deleted file mode 100755 index 27f3efb43..000000000 --- a/apiclients/getarchive.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -urlbase="archive.luftdaten.info" - -# remove index.html before fetching -rm archive.luftdaten.info/index.html -f - -# mirror the archive via wget (brute force) -# wget -r -c -np -nc -N -k http://archive.luftdaten.info/ -# sort dates reversed -# wget -r -c -np -nc -N -k "http://archive.luftdaten.info/?C=N;O=D" - -# echo "stopping here." -# exit 0 - -#urlfile=$(mktemp tmp.currurl) - -# do it by dates backwards from yesterday to one year ago -for dd in {1..365} -do - fetchdate=$(date -I --date="$dd days ago") - if [ -d "$urlbase/$fetchdate" ] ; then continue ; fi -# echo "$fetchdate" >> "$urlfile" - wget --force-directories -r -c -np -N -k "$urlbase/$fetchdate" -# -nc -#--base="http://$urlbase/" -# -i "$urlfile" -done - - -# cleanup -#rm "$urlfile" diff --git a/apiclients/getcsvdata.py b/apiclients/getcsvdata.py deleted file mode 100755 index a9c608183..000000000 --- a/apiclients/getcsvdata.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python - -#import json -import argparse -import os -import sys -import csv -#import urllib2 -import pandas as pd -#import string -#from urllib2 import urlopen -import datetime -import dateutil -import requests - -parser = argparse.ArgumentParser(description='Get CSV data from archive') -parser.add_argument('-s', '--sensorid', type=int, default=None, dest='sensorid', required=True, - help='sensorid of sensor to fetch data via api') -parser.add_argument('-c', '--cachedir', default='csvcache', - help='cached csv filedir') -parser.add_argument('-b', '--baseurl', default='http://archive.madflex.de', - help='base URL (without trailing /)') -parser.add_argument('-n', '--ndays', type=int, default=30, dest='ndays', - help='maximum number of days to fetch values for') -parser.add_argument('-l', '--lastday', type=str, default=str(datetime.date.today()-datetime.timedelta(1)), dest='lastday', - help='last day to fetch values for, defaults to yesterday') - -# files are given on commandline -#parser.add_argument(metavar='J', type=str, nargs='*', dest='jsonfilenames', - #help='json files to be processed') - -args = parser.parse_args() - - -try: - ldate=dateutil.parser.parse(args.lastday).date() -except ValueError as e: - print "error parsing lastday:"+e.message - sys.exit(1) - -# TODO: create cachedir, if not existent -if not os.path.isdir(args.cachedir): - os.makedirs(args.cachedir) - -df=pd.DataFrame() - -for daydiff in range(args.ndays): - datetoget=ldate-datetime.timedelta(daydiff) - basefilename=str(datetoget)+"_ppd42ns_sensor_"+str(args.sensorid)+".csv" - fetchurl=args.baseurl+"/"+str(datetoget)+"/"+basefilename - cachefile=os.path.join(args.cachedir,basefilename) - if not os.path.exists(cachefile): - print "file"+cachefile+" not cached, getting from server" - try: - print fetchurl - r=requests.get(fetchurl) - if len(r.text) == 0: - print "fetched no data" - continue - with open(cachefile,"w") as f: - f.write(r.text) - - except IOError as (errno, strerror): - sys.stdout.write("I/O error({0}): {1}".format(errno, strerror)) - continue - # add to dataframe - with open(cachefile,"r") as f: - df=df.append(pd.read_csv(f)) - - - - - - diff --git a/apiclients/getdata.sh b/apiclients/getdata.sh deleted file mode 100755 index d741475e3..000000000 --- a/apiclients/getdata.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -# source vars -source config.sh - -#tmpdir="$(mktemp -d --tmpdir dusti.sensordata.XXXX)" -tmpdir="$(mktemp -d dusti.sensordata.$(date -I).XXXX)" -echo $tmpdir - -pushd "$tmpdir" -for sensorid in $SENSOR_IDS -do - - echo "sensorid $sensorid" - mkdir -p "$sensorid" - pushd "$sensorid" - - # get first one, parse no of pages - wget --header "Authorization: Token $API_TOKEN" "http://api.dusti.xyz/v1/data/?format=json&sensor=$sensorid&page=1" -O "tmp.json" - if [ $? -ne 0 ] ;then - echo "error getting first data page for sensorid $sensorid" - popd - continue - fi - count=$(grep -o '"count":[0-9]*,' "tmp.json" | grep -o '[0-9]*') - # pages are count/10+1 - npages=$(($count/10+1)) - rm "tmp.json" - - for page in $(seq -w 1 $npages) - do - # http://api.dusti.xyz/v1/data/?format=json&sensor=40&page=$page - - outfile="page_$page.json" - wget --header "Authorization: Token $API_TOKEN" "http://api.dusti.xyz/v1/data/?format=json&sensor=$sensorid&page=$page" -O "$outfile" - - done - popd -done - -echo results in $tmpdir diff --git a/apiclients/getsensordata.py b/apiclients/getsensordata.py deleted file mode 100755 index 73dc8e0f9..000000000 --- a/apiclients/getsensordata.py +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env python - -# TODO: fails for multiple sensor types/messages (multisens) -# handle this better (check dict keys/combine) -# TODO: requests via https (we have a token to secure) -import json -import argparse -import sys -import csv -import urllib2 -import pandas as pd -#import string -from urllib2 import urlopen -try: - from config import API_TOKEN -except: - print ("could not load from config.py, please create and add API_TOKEN = 'YOURTOKEN'") - sys.exit(2) -# files are given on commandline or downloaded from api via sensor number - - -class DustiApi(object): - """class to handle the dusti API""" - nextpageurl=None - sensorid=None - apiendpoint='http://api.dusti.xyz/v1/data/' - page=1 - sensordata=pd.DataFrame() # TODO: which data type, pandas series/df? - # DataFrame is fine, missing/new columns are added as needed - maxmeas=None - def __init__(self,sensorid,apiendpoint,maxmeas=None): - self.setSensorID(sensorid) - self.setApiEndpoint(apiendpoint) - self.maxmeas=maxmeas - def setSensorID(self,newsensorid): - if newsensorid is None: - raise ValueError('DustiApi: sensorid is None') - self.sensorid=newsensorid - def setApiEndpoint(self,newapiendpoint): - if newapiendpoint is not None: - self.apiendpoint=newapiendpoint - def fetchpage(self,page=1): - self.page=page - apigeturl=self.apiendpoint+'?format=json&sensor='+str(self.sensorid)+'&page='+str(page) - try: - req = urllib2.Request(apigeturl) - req.add_header('Authorization', 'Token '+API_TOKEN) - r = urllib2.urlopen(req) - jsondata = r.read() - return jsondata - except IOError as (errno, strerror): - sys.stdout.write("I/O error({0}): {1}".format(errno, strerror)) - return None - def fetchnextpage(self): - self.page+=1 - return self.fetchpage() - def result2dict(self,r): - rd={} - for e in r: - rd[u'timestamp']=pd.to_datetime(e[u'timestamp'],utc=True) - for m in e['sensordatavalues']: - rd[m['value_type']]=float(m['value']) - #[1]['sensordatavalues'][1]['value_type'] - return rd - def result2df(self,r): - return pd.DataFrame(self.result2dict(r)) - def parseaddsensordata(self,jsonstr): - j=json.loads(jsonstr) - for r in j: - rd=self.result2df(r) - self.sensordata.append(rd) - def getdata(self): - # what values do we have? - # iterate over any - return self.sensordata - -class json2csv_unused(object): - csvrowdicts=[] # list of dicts for each row - csvwriter=None - def json2csvdict(jsonstr): - pass - def json2csvfile(jsonstr,csvfilehandle,printheader=False): - printcsvheader=True - for r in jsonstr['results']: - csvdict={} - csvdict['timestamp']=r['timestamp'] - for v in r['sensordatavalues']: - csvdict[v['value_type']]=v['value'] - return csvdict - if printheader: - fieldnames=csvdict.keys() - csvwriter = csv.DictWriter(csvout, fieldnames=csvdict.keys()) - csvwriter.writeheader() - printcsvheader=False - csvwriter.writerow(csvdict) - -parser = argparse.ArgumentParser(description='Process json from dusti API to CSV') -parser.add_argument('-s', '--sensorid', type=int, default=None, dest='sensorid', required=False, - help='sensorid of sensor to fetch data via api') -parser.add_argument('-o', '--outfile', default=None, type=str, dest='outfile', - help='output filename (.csv), if not given print to stdout') -parser.add_argument('-a', '--apiendpoint', default='http://api.dusti.xyz/v1/data/', - help='endpoint of API') -parser.add_argument('-m', '--maxvalues', type=int, default=None, dest='maxvalues', - help='maximum number of values to fetch') -# files are given on commandline -parser.add_argument(metavar='J', type=str, nargs='*', dest='jsonfilenames', - help='json files to be processed') - -args = parser.parse_args() - -print(args) - -da=DustiApi(sensorid=args.sensorid,apiendpoint=args.apiendpoint) -# measurements dict for the result -md={} -printcsvheader=True -getnextpage=True -#jsonfilename= -# get the json directly via api -#res=da.apifetch(sensorid=args.sensorid,apiendpoint=args.apiendpoint,page=1) -#if res is None: - #sys.stdout.write('error fetching first page from api') - #getnextpage=False -#while getnextpage: - #res=apifetch - #j=json.loads(res) - - -for jsonfilename in args.jsonfilenames: - with open(jsonfilename) as f: - j=json.load(f) - nextfile=j['next'] - for r in j['results']: - rd=result2dict(r) - if md["_".join(sorted(rd.keys()))] is None: - md["_".join(sorted(rd.keys()))]=[rd] - else: - md["_".join(sorted(rd.keys()))].append(rd) - # merge into one frame or multiple frames/csvs? - - - #csvdict={} - #csvdict[u'timestamp']=r['timestamp'] - #for v in r['sensordatavalues']: - #csvdict[v['value_type']]=v['value'] - #if printcsvheader: - #fieldnames=csvdict.keys() - #csvwriter = csv.DictWriter(csvout, fieldnames=csvdict.keys()) - #csvwriter.writeheader() - #printcsvheader=False - #csvwriter.writerow(csvdict) - -# close csvout file handler - -csvfilename=args.outfile -if csvfilename is None: - csvout=sys.stdout -else: - csvout=open(csvfilename,'w') - # TODO do stuff here - csvout.close() - -#sys.exit() - -# use pd series -#d=pd.read_json(jsonfilename) -#s=pd.Series(csvdict) -#pd.DatetimeIndex(pd.to_datetime(s.keys()),utc=True)) -#s= -#pd.to_datetime(s.timestamp) diff --git a/arduino/blank/Makefile b/arduino/blank/Makefile deleted file mode 100644 index e14496e44..000000000 --- a/arduino/blank/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -BOARD_TAG = leonardo -ISP_PROG = gpio -ISP_PORT = /dev/ttyACM0 -MONITOR_PORT = /dev/ttyACM0 -AVRDUDE = /usr/bin/avrdude -AVRDUDE_CONF = /etc/avrdude.conf - -include /usr/share/arduino/Arduino.mk diff --git a/arduino/blank/blank.ino b/arduino/blank/blank.ino deleted file mode 100644 index 6133ba2ce..000000000 --- a/arduino/blank/blank.ino +++ /dev/null @@ -1,5 +0,0 @@ -void setup() { -} - -void loop() { -} diff --git a/arduino/bmp180/Makefile b/arduino/bmp180/Makefile deleted file mode 100644 index 9a52f2125..000000000 --- a/arduino/bmp180/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -BOARD_TAG = uno -ISP_PROG = gpio -ISP_PORT = /dev/ttyACM0 -MONITOR_PORT = /dev/ttyACM0 -AVRDUDE = /usr/bin/avrdude -AVRDUDE_CONF = /etc/avrdude.conf - -ARDUINO_LIBS = Wire BMP180 -USER_LIB_PATH = ../libs - -include /usr/share/arduino/Arduino.mk diff --git a/arduino/bmp180/bmp180-serial.ino b/arduino/bmp180/bmp180-serial.ino deleted file mode 100644 index e624cab5b..000000000 --- a/arduino/bmp180/bmp180-serial.ino +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************** - This is an example for the BMP085 Barometric Pressure & Temp Sensor - - Designed specifically to work with the Adafruit BMP085 Breakout - ----> https://www.adafruit.com/products/391 - - These displays use I2C to communicate, 2 pins are required to - interface - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - BSD license, all text above must be included in any redistribution - ****************************************************/ - -// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!) -// Connect GND to Ground -// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5 -// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4 -// EOC is not used, it signifies an end of conversion -// XCLR is a reset pin, also not used here - -#include -#include - -Adafruit_BMP085 bmp; - -void setup() { - Serial.begin(9600); - if (!bmp.begin()) { - Serial.println("Could not find a valid BMP085 sensor, check wiring!"); - while (1) {} - } -} - -void loop() { - Serial.print("Temperature = "); - Serial.print(bmp.readTemperature()); - Serial.println(" *C"); - - Serial.print("Pressure = "); - Serial.print(bmp.readPressure()); - Serial.println(" Pa"); - - // Calculate altitude assuming 'standard' barometric - // pressure of 1013.25 millibar = 101325 Pascal - Serial.print("Altitude = "); - Serial.print(bmp.readAltitude()); - Serial.println(" meters"); - - Serial.print("Pressure at sealevel (calculated) = "); - Serial.print(bmp.readSealevelPressure()); - Serial.println(" Pa"); - - // you can get a more precise measurement of altitude - // if you know the current sea level pressure which will - // vary with weather and such. If it is 1015 millibars - // that is equal to 101500 Pascals. - Serial.print("Real altitude = "); - Serial.print(bmp.readAltitude(101500)); - Serial.println(" meters"); - - Serial.println(); - delay(500); -} diff --git a/arduino/bmp180/readme.txt b/arduino/bmp180/readme.txt deleted file mode 100644 index 92c362dae..000000000 --- a/arduino/bmp180/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -Library code from https://github.com/adafruit/Adafruit-BMP085-Library - diff --git a/arduino/dsm501a-bmp180-serial/Makefile b/arduino/dsm501a-bmp180-serial/Makefile deleted file mode 100644 index 9a52f2125..000000000 --- a/arduino/dsm501a-bmp180-serial/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -BOARD_TAG = uno -ISP_PROG = gpio -ISP_PORT = /dev/ttyACM0 -MONITOR_PORT = /dev/ttyACM0 -AVRDUDE = /usr/bin/avrdude -AVRDUDE_CONF = /etc/avrdude.conf - -ARDUINO_LIBS = Wire BMP180 -USER_LIB_PATH = ../libs - -include /usr/share/arduino/Arduino.mk diff --git a/arduino/dsm501a-bmp180-serial/dsm501a-bmp180-serial.ino b/arduino/dsm501a-bmp180-serial/dsm501a-bmp180-serial.ino deleted file mode 100644 index 3245d157b..000000000 --- a/arduino/dsm501a-bmp180-serial/dsm501a-bmp180-serial.ino +++ /dev/null @@ -1,120 +0,0 @@ -/* - dsm501a - - publish via serial and raspberry pi/python - - specification: http://i.publiclab.org/system/images/photos/000/003/726/original/tmp_DSM501A_Dust_Sensor630081629.pdf - -dsm501a - pin 1 () -> unused! - pin 2 (PM10) -> Arduino Pin 8 - pin 3 () -> Arduino 5V - pin 4 (PM25) -> Arduino Pin 9 - pin 5 () -> Arduino GND - -bmp180 - + -> 3.3V - - -> GND - data -> anaolog 4 - Clock -> anaolog 5 - -*/ - -#include -#include - -Adafruit_BMP085 bmp; - -// - -boolean valP1 = HIGH; -boolean valP2 = HIGH; - -unsigned long starttime; -unsigned long durationP1; -unsigned long durationP2; - -boolean trigP1 = false; -boolean trigP2 = false; -unsigned long trigOnP1; -unsigned long trigOnP2; - -unsigned long sampletime_ms = 15000; -unsigned long lowpulseoccupancyP1 = 0; -unsigned long lowpulseoccupancyP2 = 0; - -void setup() { - Serial.begin(9600); - if (!bmp.begin()) { - Serial.println("# Could not find a valid BMP085 sensor!"); - } - pinMode(8,INPUT); - pinMode(9,INPUT); - starttime = millis(); -} - -void loop() { - float ratio = 0; - float concentration = 0; - - valP1 = digitalRead(8); - valP2 = digitalRead(9); - - if(valP1 == LOW && trigP1 == false){ - trigP1 = true; - trigOnP1 = micros(); - } - - if (valP1 == HIGH && trigP1 == true){ - durationP1 = micros() - trigOnP1; - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1; - trigP1 = false; - } - - if(valP2 == LOW && trigP2 == false){ - trigP2 = true; - trigOnP2 = micros(); - } - - if (valP2 == HIGH && trigP2 == true){ - durationP2 = micros() - trigOnP2; - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2; - trigP2 = false; - } - - if ((millis()-starttime) > sampletime_ms) - { - ratio = lowpulseoccupancyP1/(sampletime_ms*10.0); // int percentage 0 to 100 - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // spec sheet curve - Serial.print("dsm501a_durP10:"); - Serial.print(lowpulseoccupancyP1); - Serial.print(";dsm501a_ratioP10:"); - Serial.print(ratio); - Serial.print(";dsm501a_P10:"); - Serial.print(concentration); - - ratio = lowpulseoccupancyP2/(sampletime_ms*10.0); - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; - - Serial.print(";dsm501a_durP25:"); - Serial.print(lowpulseoccupancyP2); - Serial.print(";dsm501a_ratioP25:"); - Serial.print(ratio); - Serial.print(";dsm501a_P25:"); - Serial.print(concentration); - - // bmp180 - Serial.print(";bmp180_temperature:"); - Serial.print(bmp.readTemperature()); - Serial.print(";bmp180_pressure:"); - Serial.print(bmp.readPressure()); - Serial.print(";bmp180_altitude:"); - Serial.print(bmp.readAltitude()); - Serial.print(";bmp180_pressure_sealevel:"); - Serial.println(bmp.readSealevelPressure()); - - lowpulseoccupancyP1 = 0; - lowpulseoccupancyP2 = 0; - starttime = millis(); - } -} diff --git a/arduino/dsm501a-serial/Makefile b/arduino/dsm501a-serial/Makefile deleted file mode 100644 index 536364611..000000000 --- a/arduino/dsm501a-serial/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -BOARD_TAG = uno -ISP_PROG = gpio -ISP_PORT = /dev/ttyACM0 -MONITOR_PORT = /dev/ttyACM0 -AVRDUDE = /usr/bin/avrdude -AVRDUDE_CONF = /etc/avrdude.conf - -include /usr/share/arduino/Arduino.mk diff --git a/arduino/dsm501a-serial/dsm501a-serial.ino b/arduino/dsm501a-serial/dsm501a-serial.ino deleted file mode 100644 index a86f208fe..000000000 --- a/arduino/dsm501a-serial/dsm501a-serial.ino +++ /dev/null @@ -1,94 +0,0 @@ -/* - dsm501a - - publish via serial and raspberry pi/python - - specification: http://i.publiclab.org/system/images/photos/000/003/726/original/tmp_DSM501A_Dust_Sensor630081629.pdf - -dsm501a - pin 1 () -> unused! - pin 2 (PM10) -> Arduino Pin 8 - pin 3 () -> Arduino 5V - pin 4 (PM25) -> Arduino Pin 9 - pin 5 () -> Arduino GND - -*/ - -boolean valP1 = HIGH; -boolean valP2 = HIGH; - -unsigned long starttime; -unsigned long durationP1; -unsigned long durationP2; - -boolean trigP1 = false; -boolean trigP2 = false; -unsigned long trigOnP1; -unsigned long trigOnP2; - -unsigned long sampletime_ms = 15000; -unsigned long lowpulseoccupancyP1 = 0; -unsigned long lowpulseoccupancyP2 = 0; - -void setup() { - Serial.begin(9600); - pinMode(8,INPUT); - pinMode(9,INPUT); - starttime = millis(); -} - -void loop() { - float ratio = 0; - float concentration = 0; - - valP1 = digitalRead(8); - valP2 = digitalRead(9); - - if(valP1 == LOW && trigP1 == false){ - trigP1 = true; - trigOnP1 = micros(); - } - - if (valP1 == HIGH && trigP1 == true){ - durationP1 = micros() - trigOnP1; - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1; - trigP1 = false; - } - - if(valP2 == LOW && trigP2 == false){ - trigP2 = true; - trigOnP2 = micros(); - } - - if (valP2 == HIGH && trigP2 == true){ - durationP2 = micros() - trigOnP2; - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2; - trigP2 = false; - } - - if ((millis()-starttime) > sampletime_ms) - { - ratio = lowpulseoccupancyP1/(sampletime_ms*10.0); // int percentage 0 to 100 - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // spec sheet curve - Serial.print("durP10:"); - Serial.print(lowpulseoccupancyP1); - Serial.print(";ratioP10:"); - Serial.print(ratio); - Serial.print(";P10:"); - Serial.print(concentration); - - ratio = lowpulseoccupancyP2/(sampletime_ms*10.0); - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; - - Serial.print(";durP25:"); - Serial.print(lowpulseoccupancyP2); - Serial.print(";ratioP25:"); - Serial.print(ratio); - Serial.print(";P25:"); - Serial.println(concentration); - - lowpulseoccupancyP1 = 0; - lowpulseoccupancyP2 = 0; - starttime = millis(); - } -} diff --git a/arduino/gp2y10-serial/Makefile b/arduino/gp2y10-serial/Makefile deleted file mode 100644 index f6364e80b..000000000 --- a/arduino/gp2y10-serial/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -BOARD_TAG = leonardo -ISP_PROG=gpio -ISP_PORT=/dev/ttyACM0 -MONITOR_PORT = /dev/ttyACM0 -AVRDUDE = /usr/bin/avrdude -AVRDUDE_CONF = /etc/avrdude.conf - -include /usr/share/arduino/Arduino.mk diff --git a/arduino/gp2y10-serial/gp2y10-serial.ino b/arduino/gp2y10-serial/gp2y10-serial.ino deleted file mode 100644 index 9b60b7104..000000000 --- a/arduino/gp2y10-serial/gp2y10-serial.ino +++ /dev/null @@ -1,50 +0,0 @@ -/* - Standalone Sketch to use with a Arduino UNO and a - Sharp Optical Dust Sensor GP2Y1010AU0F -*/ - -int measurePin = 0; // V0 (Pin 5) to Arduino A0 -int ledPower = 2; // PIN 3 (LED) to Arduino D2 - -int samplingTime = 280; -int deltaTime = 40; -int sleepTime = 9680; - -float voMeasured = 0; -float calcVoltage = 0; -float dustDensity = 0; - -void setup(){ - Serial.begin(9600); - pinMode(ledPower,OUTPUT); -} - -void loop(){ - digitalWrite(ledPower,LOW); // power on the LED - delayMicroseconds(samplingTime); - - voMeasured = analogRead(measurePin); // read the dust value - - delayMicroseconds(deltaTime); - digitalWrite(ledPower,HIGH); // turn the LED off - delayMicroseconds(sleepTime); - - // 0 - 5V mapped to 0 - 1023 integer values - // recover voltage - calcVoltage = voMeasured * (5.0 / 1024.0); - - // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/ - // Chris Nafis (c) 2012 - dustDensity = 0.17 * calcVoltage - 0.1; - - Serial.print("GP2Y1010AU0F_vo_raw:"); - Serial.print(voMeasured); - - Serial.print(";GP2Y1010AU0F_voltage:"); - Serial.print(calcVoltage); - - Serial.print(";GP2Y1010AU0F_dust_density:"); - Serial.println(dustDensity); // unit: mg/m3 - - delay(1000); -} diff --git a/arduino/libs/BMP180/Adafruit_BMP085.cpp b/arduino/libs/BMP180/Adafruit_BMP085.cpp deleted file mode 100644 index 14e7e96ff..000000000 --- a/arduino/libs/BMP180/Adafruit_BMP085.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/*************************************************** - This is a library for the Adafruit BMP085/BMP180 Barometric Pressure + Temp sensor - - Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout - ----> http://www.adafruit.com/products/391 - ----> http://www.adafruit.com/products/1603 - - These displays use I2C to communicate, 2 pins are required to - interface - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - BSD license, all text above must be included in any redistribution - ****************************************************/ - -#include "Adafruit_BMP085.h" - -Adafruit_BMP085::Adafruit_BMP085() { -} - - -boolean Adafruit_BMP085::begin(uint8_t mode) { - if (mode > BMP085_ULTRAHIGHRES) - mode = BMP085_ULTRAHIGHRES; - oversampling = mode; - - Wire.begin(); - - if (read8(0xD0) != 0x55) return false; - - /* read calibration data */ - ac1 = read16(BMP085_CAL_AC1); - ac2 = read16(BMP085_CAL_AC2); - ac3 = read16(BMP085_CAL_AC3); - ac4 = read16(BMP085_CAL_AC4); - ac5 = read16(BMP085_CAL_AC5); - ac6 = read16(BMP085_CAL_AC6); - - b1 = read16(BMP085_CAL_B1); - b2 = read16(BMP085_CAL_B2); - - mb = read16(BMP085_CAL_MB); - mc = read16(BMP085_CAL_MC); - md = read16(BMP085_CAL_MD); -#if (BMP085_DEBUG == 1) - Serial.print("ac1 = "); Serial.println(ac1, DEC); - Serial.print("ac2 = "); Serial.println(ac2, DEC); - Serial.print("ac3 = "); Serial.println(ac3, DEC); - Serial.print("ac4 = "); Serial.println(ac4, DEC); - Serial.print("ac5 = "); Serial.println(ac5, DEC); - Serial.print("ac6 = "); Serial.println(ac6, DEC); - - Serial.print("b1 = "); Serial.println(b1, DEC); - Serial.print("b2 = "); Serial.println(b2, DEC); - - Serial.print("mb = "); Serial.println(mb, DEC); - Serial.print("mc = "); Serial.println(mc, DEC); - Serial.print("md = "); Serial.println(md, DEC); -#endif - - return true; -} - -int32_t Adafruit_BMP085::computeB5(int32_t UT) { - int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15; - int32_t X2 = ((int32_t)mc << 11) / (X1+(int32_t)md); - return X1 + X2; -} - -uint16_t Adafruit_BMP085::readRawTemperature(void) { - write8(BMP085_CONTROL, BMP085_READTEMPCMD); - delay(5); -#if BMP085_DEBUG == 1 - Serial.print("Raw temp: "); Serial.println(read16(BMP085_TEMPDATA)); -#endif - return read16(BMP085_TEMPDATA); -} - -uint32_t Adafruit_BMP085::readRawPressure(void) { - uint32_t raw; - - write8(BMP085_CONTROL, BMP085_READPRESSURECMD + (oversampling << 6)); - - if (oversampling == BMP085_ULTRALOWPOWER) - delay(5); - else if (oversampling == BMP085_STANDARD) - delay(8); - else if (oversampling == BMP085_HIGHRES) - delay(14); - else - delay(26); - - raw = read16(BMP085_PRESSUREDATA); - - raw <<= 8; - raw |= read8(BMP085_PRESSUREDATA+2); - raw >>= (8 - oversampling); - - /* this pull broke stuff, look at it later? - if (oversampling==0) { - raw <<= 8; - raw |= read8(BMP085_PRESSUREDATA+2); - raw >>= (8 - oversampling); - } - */ - -#if BMP085_DEBUG == 1 - Serial.print("Raw pressure: "); Serial.println(raw); -#endif - return raw; -} - - -int32_t Adafruit_BMP085::readPressure(void) { - int32_t UT, UP, B3, B5, B6, X1, X2, X3, p; - uint32_t B4, B7; - - UT = readRawTemperature(); - UP = readRawPressure(); - -#if BMP085_DEBUG == 1 - // use datasheet numbers! - UT = 27898; - UP = 23843; - ac6 = 23153; - ac5 = 32757; - mc = -8711; - md = 2868; - b1 = 6190; - b2 = 4; - ac3 = -14383; - ac2 = -72; - ac1 = 408; - ac4 = 32741; - oversampling = 0; -#endif - - B5 = computeB5(UT); - -#if BMP085_DEBUG == 1 - Serial.print("X1 = "); Serial.println(X1); - Serial.print("X2 = "); Serial.println(X2); - Serial.print("B5 = "); Serial.println(B5); -#endif - - // do pressure calcs - B6 = B5 - 4000; - X1 = ((int32_t)b2 * ( (B6 * B6)>>12 )) >> 11; - X2 = ((int32_t)ac2 * B6) >> 11; - X3 = X1 + X2; - B3 = ((((int32_t)ac1*4 + X3) << oversampling) + 2) / 4; - -#if BMP085_DEBUG == 1 - Serial.print("B6 = "); Serial.println(B6); - Serial.print("X1 = "); Serial.println(X1); - Serial.print("X2 = "); Serial.println(X2); - Serial.print("B3 = "); Serial.println(B3); -#endif - - X1 = ((int32_t)ac3 * B6) >> 13; - X2 = ((int32_t)b1 * ((B6 * B6) >> 12)) >> 16; - X3 = ((X1 + X2) + 2) >> 2; - B4 = ((uint32_t)ac4 * (uint32_t)(X3 + 32768)) >> 15; - B7 = ((uint32_t)UP - B3) * (uint32_t)( 50000UL >> oversampling ); - -#if BMP085_DEBUG == 1 - Serial.print("X1 = "); Serial.println(X1); - Serial.print("X2 = "); Serial.println(X2); - Serial.print("B4 = "); Serial.println(B4); - Serial.print("B7 = "); Serial.println(B7); -#endif - - if (B7 < 0x80000000) { - p = (B7 * 2) / B4; - } else { - p = (B7 / B4) * 2; - } - X1 = (p >> 8) * (p >> 8); - X1 = (X1 * 3038) >> 16; - X2 = (-7357 * p) >> 16; - -#if BMP085_DEBUG == 1 - Serial.print("p = "); Serial.println(p); - Serial.print("X1 = "); Serial.println(X1); - Serial.print("X2 = "); Serial.println(X2); -#endif - - p = p + ((X1 + X2 + (int32_t)3791)>>4); -#if BMP085_DEBUG == 1 - Serial.print("p = "); Serial.println(p); -#endif - return p; -} - -int32_t Adafruit_BMP085::readSealevelPressure(float altitude_meters) { - float pressure = readPressure(); - return (int32_t)(pressure / pow(1.0-altitude_meters/44330, 5.255)); -} - -float Adafruit_BMP085::readTemperature(void) { - int32_t UT, B5; // following ds convention - float temp; - - UT = readRawTemperature(); - -#if BMP085_DEBUG == 1 - // use datasheet numbers! - UT = 27898; - ac6 = 23153; - ac5 = 32757; - mc = -8711; - md = 2868; -#endif - - B5 = computeB5(UT); - temp = (B5+8) >> 4; - temp /= 10; - - return temp; -} - -float Adafruit_BMP085::readAltitude(float sealevelPressure) { - float altitude; - - float pressure = readPressure(); - - altitude = 44330 * (1.0 - pow(pressure /sealevelPressure,0.1903)); - - return altitude; -} - - -/*********************************************************************/ - -uint8_t Adafruit_BMP085::read8(uint8_t a) { - uint8_t ret; - - Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device -#if (ARDUINO >= 100) - Wire.write(a); // sends register address to read from -#else - Wire.send(a); // sends register address to read from -#endif - Wire.endTransmission(); // end transmission - - Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device - Wire.requestFrom(BMP085_I2CADDR, 1);// send data n-bytes read -#if (ARDUINO >= 100) - ret = Wire.read(); // receive DATA -#else - ret = Wire.receive(); // receive DATA -#endif - Wire.endTransmission(); // end transmission - - return ret; -} - -uint16_t Adafruit_BMP085::read16(uint8_t a) { - uint16_t ret; - - Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device -#if (ARDUINO >= 100) - Wire.write(a); // sends register address to read from -#else - Wire.send(a); // sends register address to read from -#endif - Wire.endTransmission(); // end transmission - - Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device - Wire.requestFrom(BMP085_I2CADDR, 2);// send data n-bytes read -#if (ARDUINO >= 100) - ret = Wire.read(); // receive DATA - ret <<= 8; - ret |= Wire.read(); // receive DATA -#else - ret = Wire.receive(); // receive DATA - ret <<= 8; - ret |= Wire.receive(); // receive DATA -#endif - Wire.endTransmission(); // end transmission - - return ret; -} - -void Adafruit_BMP085::write8(uint8_t a, uint8_t d) { - Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device -#if (ARDUINO >= 100) - Wire.write(a); // sends register address to read from - Wire.write(d); // write data -#else - Wire.send(a); // sends register address to read from - Wire.send(d); // write data -#endif - Wire.endTransmission(); // end transmission -} diff --git a/arduino/libs/BMP180/Adafruit_BMP085.h b/arduino/libs/BMP180/Adafruit_BMP085.h deleted file mode 100644 index d91b7b16a..000000000 --- a/arduino/libs/BMP180/Adafruit_BMP085.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************** - This is a library for the Adafruit BMP085/BMP180 Barometric Pressure + Temp sensor - - Designed specifically to work with the Adafruit BMP085 or BMP180 Breakout - ----> http://www.adafruit.com/products/391 - ----> http://www.adafruit.com/products/1603 - - These displays use I2C to communicate, 2 pins are required to - interface - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - BSD license, all text above must be included in any redistribution - ****************************************************/ - -#ifndef ADAFRUIT_BMP085_H -#define ADAFRUIT_BMP085_H - -#if (ARDUINO >= 100) - #include "Arduino.h" -#else - #include "WProgram.h" -#endif -#include "Wire.h" - -#define BMP085_DEBUG 0 - -#define BMP085_I2CADDR 0x77 - -#define BMP085_ULTRALOWPOWER 0 -#define BMP085_STANDARD 1 -#define BMP085_HIGHRES 2 -#define BMP085_ULTRAHIGHRES 3 -#define BMP085_CAL_AC1 0xAA // R Calibration data (16 bits) -#define BMP085_CAL_AC2 0xAC // R Calibration data (16 bits) -#define BMP085_CAL_AC3 0xAE // R Calibration data (16 bits) -#define BMP085_CAL_AC4 0xB0 // R Calibration data (16 bits) -#define BMP085_CAL_AC5 0xB2 // R Calibration data (16 bits) -#define BMP085_CAL_AC6 0xB4 // R Calibration data (16 bits) -#define BMP085_CAL_B1 0xB6 // R Calibration data (16 bits) -#define BMP085_CAL_B2 0xB8 // R Calibration data (16 bits) -#define BMP085_CAL_MB 0xBA // R Calibration data (16 bits) -#define BMP085_CAL_MC 0xBC // R Calibration data (16 bits) -#define BMP085_CAL_MD 0xBE // R Calibration data (16 bits) - -#define BMP085_CONTROL 0xF4 -#define BMP085_TEMPDATA 0xF6 -#define BMP085_PRESSUREDATA 0xF6 -#define BMP085_READTEMPCMD 0x2E -#define BMP085_READPRESSURECMD 0x34 - - -class Adafruit_BMP085 { - public: - Adafruit_BMP085(); - boolean begin(uint8_t mode = BMP085_ULTRAHIGHRES); // by default go highres - float readTemperature(void); - int32_t readPressure(void); - int32_t readSealevelPressure(float altitude_meters = 0); - float readAltitude(float sealevelPressure = 101325); // std atmosphere - uint16_t readRawTemperature(void); - uint32_t readRawPressure(void); - - private: - int32_t computeB5(int32_t UT); - uint8_t read8(uint8_t addr); - uint16_t read16(uint8_t addr); - void write8(uint8_t addr, uint8_t data); - - uint8_t oversampling; - - int16_t ac1, ac2, ac3, b1, b2, mb, mc, md; - uint16_t ac4, ac5, ac6; -}; - - -#endif // ADAFRUIT_BMP085_H diff --git a/arduino/libs/DHT-sensor-library/DHT.cpp b/arduino/libs/DHT-sensor-library/DHT.cpp deleted file mode 100644 index efa1d3924..000000000 --- a/arduino/libs/DHT-sensor-library/DHT.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* DHT library - -MIT license -written by Adafruit Industries -*/ - -#include "DHT.h" - -DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { - _pin = pin; - _type = type; - _count = count; - firstreading = true; -} - -void DHT::begin(void) { - // set up the pins! - pinMode(_pin, INPUT); - digitalWrite(_pin, HIGH); - _lastreadtime = 0; -} - -//boolean S == Scale. True == Farenheit; False == Celcius -float DHT::readTemperature(bool S) { - float f; - - if (read()) { - switch (_type) { - case DHT11: - f = data[2]; - if(S) - f = convertCtoF(f); - - return f; - case DHT22: - case DHT21: - f = data[2] & 0x7F; - f *= 256; - f += data[3]; - f /= 10; - if (data[2] & 0x80) - f *= -1; - if(S) - f = convertCtoF(f); - - return f; - } - } - Serial.print("Read fail"); - return NAN; -} - -float DHT::convertCtoF(float c) { - return c * 9 / 5 + 32; -} - -float DHT::readHumidity(void) { - float f; - if (read()) { - switch (_type) { - case DHT11: - f = data[0]; - return f; - case DHT22: - case DHT21: - f = data[0]; - f *= 256; - f += data[1]; - f /= 10; - return f; - } - } - Serial.print("Read fail"); - return NAN; -} - - -boolean DHT::read(void) { - uint8_t laststate = HIGH; - uint8_t counter = 0; - uint8_t j = 0, i; - unsigned long currenttime; - - // pull the pin high and wait 250 milliseconds - digitalWrite(_pin, HIGH); - delay(250); - - currenttime = millis(); - if (currenttime < _lastreadtime) { - // ie there was a rollover - _lastreadtime = 0; - } - if (!firstreading && ((currenttime - _lastreadtime) < 2000)) { - return true; // return last correct measurement - //delay(2000 - (currenttime - _lastreadtime)); - } - firstreading = false; - /* - Serial.print("Currtime: "); Serial.print(currenttime); - Serial.print(" Lasttime: "); Serial.print(_lastreadtime); - */ - _lastreadtime = millis(); - - data[0] = data[1] = data[2] = data[3] = data[4] = 0; - - // now pull it low for ~20 milliseconds - pinMode(_pin, OUTPUT); - digitalWrite(_pin, LOW); - delay(20); - cli(); - digitalWrite(_pin, HIGH); - delayMicroseconds(40); - pinMode(_pin, INPUT); - - // read in timings - for ( i=0; i< MAXTIMINGS; i++) { - counter = 0; - while (digitalRead(_pin) == laststate) { - counter++; - delayMicroseconds(1); - if (counter == 255) { - break; - } - } - laststate = digitalRead(_pin); - - if (counter == 255) break; - - // ignore first 3 transitions - if ((i >= 4) && (i%2 == 0)) { - // shove each bit into the storage bytes - data[j/8] <<= 1; - if (counter > _count) - data[j/8] |= 1; - j++; - } - - } - - sei(); - - /* - Serial.println(j, DEC); - Serial.print(data[0], HEX); Serial.print(", "); - Serial.print(data[1], HEX); Serial.print(", "); - Serial.print(data[2], HEX); Serial.print(", "); - Serial.print(data[3], HEX); Serial.print(", "); - Serial.print(data[4], HEX); Serial.print(" =? "); - Serial.println(data[0] + data[1] + data[2] + data[3], HEX); - */ - - // check we read 40 bits and that the checksum matches - if ((j >= 40) && - (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) ) { - return true; - } - - - return false; - -} diff --git a/arduino/libs/DHT-sensor-library/DHT.h b/arduino/libs/DHT-sensor-library/DHT.h deleted file mode 100644 index 1c78c870a..000000000 --- a/arduino/libs/DHT-sensor-library/DHT.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef DHT_H -#define DHT_H -#if ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - -/* DHT library - -MIT license -written by Adafruit Industries -*/ - -// how many timing transitions we need to keep track of. 2 * number bits + extra -#define MAXTIMINGS 85 - -#define DHT11 11 -#define DHT22 22 -#define DHT21 21 -#define AM2301 21 - -class DHT { - private: - uint8_t data[6]; - uint8_t _pin, _type, _count; - boolean read(void); - unsigned long _lastreadtime; - boolean firstreading; - - public: - DHT(uint8_t pin, uint8_t type, uint8_t count=6); - void begin(void); - float readTemperature(bool S=false); - float convertCtoF(float); - float readHumidity(void); - -}; -#endif diff --git a/arduino/libs/DHT-sensor-library/README.txt b/arduino/libs/DHT-sensor-library/README.txt deleted file mode 100644 index 4dfcbab3c..000000000 --- a/arduino/libs/DHT-sensor-library/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -This is an Arduino library for the DHT series of low cost temperature/humidity sensors. - -To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder DHT. Check that the DHT folder contains DHT.cpp and DHT.h. Place the DHT library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. \ No newline at end of file diff --git a/arduino/libs/DHT-sensor-library/examples/DHTtester/DHTtester.pde b/arduino/libs/DHT-sensor-library/examples/DHTtester/DHTtester.pde deleted file mode 100644 index 8f40790b7..000000000 --- a/arduino/libs/DHT-sensor-library/examples/DHTtester/DHTtester.pde +++ /dev/null @@ -1,44 +0,0 @@ -// Example testing sketch for various DHT humidity/temperature sensors -// Written by ladyada, public domain - -#include "DHT.h" - -#define DHTPIN 2 // what pin we're connected to - -// Uncomment whatever type you're using! -//#define DHTTYPE DHT11 // DHT 11 -#define DHTTYPE DHT22 // DHT 22 (AM2302) -//#define DHTTYPE DHT21 // DHT 21 (AM2301) - -// Connect pin 1 (on the left) of the sensor to +5V -// Connect pin 2 of the sensor to whatever your DHTPIN is -// Connect pin 4 (on the right) of the sensor to GROUND -// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor - -DHT dht(DHTPIN, DHTTYPE); - -void setup() { - Serial.begin(9600); - Serial.println("DHTxx test!"); - - dht.begin(); -} - -void loop() { - // Reading temperature or humidity takes about 250 milliseconds! - // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) - float h = dht.readHumidity(); - float t = dht.readTemperature(); - - // check if returns are valid, if they are NaN (not a number) then something went wrong! - if (isnan(t) || isnan(h)) { - Serial.println("Failed to read from DHT"); - } else { - Serial.print("Humidity: "); - Serial.print(h); - Serial.print(" %\t"); - Serial.print("Temperature: "); - Serial.print(t); - Serial.println(" *C"); - } -} diff --git a/arduino/libs/RedFly/README b/arduino/libs/RedFly/README deleted file mode 100644 index 1187a4c3f..000000000 --- a/arduino/libs/RedFly/README +++ /dev/null @@ -1 +0,0 @@ -source: https://github.com/watterott/Arduino-Libs/tree/master/RedFly diff --git a/arduino/libs/RedFly/RedFly.cpp b/arduino/libs/RedFly/RedFly.cpp deleted file mode 100644 index fa1800dcd..000000000 --- a/arduino/libs/RedFly/RedFly.cpp +++ /dev/null @@ -1,1491 +0,0 @@ -/* - RedFly Lib for Arduino - by Watterott electronic (www.watterott.com) - */ - -#include -#if defined(__AVR__) -# include -# include -# include -#else -# include -# include -#endif -#if ARDUINO >= 100 -# include "Arduino.h" -#else -# include "WProgram.h" -#endif -#include "RedFlyCommands.h" -#include "RedFly.h" -#include "RedFlyClient.h" -#include "RedFlyServer.h" -#include "RedFlyNBNS.h" - - -#define RX_PIN (0) -#define TX_PIN (1) -#define RST_PIN (2) -#define CS_PIN (3) - -#define RST_DISABLE() digitalWrite(RST_PIN, HIGH) -#define RST_ENABLE() digitalWrite(RST_PIN, LOW) - -#define CS_DISABLE() digitalWrite(CS_PIN, HIGH) -#define CS_ENABLE() digitalWrite(CS_PIN, LOW) - -#if defined(__AVR__) && defined(UBRRH) && defined(UBRRL) -# define _UCSRA_ UCSRA -# define _RXC_ RXC -# define _UCSRC_ UCSRC -# define _USBS_ USBS -# define _SERIAL_ Serial -#elif defined(__AVR__) && !defined(UBRR0H) && !defined(UBRR0L) -# define _UCSRA_ UCSR1A -# define _RXC_ RXC1 -# define _UCSRC_ UCSR1C -# define _USBS_ USBS1 -# define _SERIAL_ Serial1 -#elif defined(__AVR__) -# define _UCSRA_ UCSR0A -# define _RXC_ RXC0 -# define _UCSRC_ UCSR0C -# define _USBS_ USBS0 -# define _SERIAL_ Serial -#else -# define _SERIAL_ Serial -# define _USART_ USART0 -#endif - - -REDFLY RedFly; - - -//-------------------- Constructor/Destructor -------------------- - - -REDFLY::REDFLY(void) -{ - return; -} - - -REDFLY::~REDFLY(void) -{ - return; -} - - -//-------------------- Public -------------------- - - -uint8_t REDFLY::init(uint32_t br, uint8_t pwr) -{ - uint8_t ret=0xFF, i; - uint32_t ms; - - //init pins -#ifdef CS_PIN - pinMode(CS_PIN, OUTPUT); - CS_DISABLE(); //deselect -#endif -#ifdef RST_PIN - pinMode(RST_PIN, OUTPUT); - RST_ENABLE(); //reset on -#endif -#ifdef TX_PIN - pinMode(TX_PIN, OUTPUT); - digitalWrite(TX_PIN, HIGH); -#endif -#ifdef RX_PIN - pinMode(RX_PIN, INPUT); - digitalWrite(RX_PIN, HIGH); //pull-up on -#endif - - //reset vars - memset(ipaddr, 0, sizeof(ipaddr)); - memset(buffer, 0, sizeof(buffer)); - - //set serial port config - baudrate = br; - setbaudrate(br); - - //enable module communication - enable(); - - //reset module - RST_ENABLE(); - delay_10ms(5); //wait 50ms - RST_DISABLE(); - - //auto baud rate detection - delay_10ms(11); //wait 110ms for module boot-up - for(i=4; i!=0; i--) //try 4 times - { - write(0x1C); //transmit 0x1C - for(ms=millis(); (millis()-ms) < 200;) //wait 200ms for response - { - if(available()) - { - if(read() == 0x55) //wait for 0x55 - { - write(0x55); //transmit 0x55 - delay_10ms(10); //wait 100ms - //skip firmware upgrade question at power on - write('n'); - write('\n'); - ret = 0xFE; - i = 1; //break 1st for loop - break; //break 2nd for loop - } - } - } - } - delay_10ms(20); //wait 200ms for booting - - //get firmware version and set config - // if(ret == 0xFE) - // { - for(i=3; i!=0; i--) //try 3 times - { - flush(); - if(cmd(PSTR(CMD_FWVERSION)) == 0) - { - //cmd(PSTR(CMD_RESET)); //soft reset - cmd(PSTR(CMD_BAND BAND24)); - cmd(PSTR(CMD_INIT)); - tx_power = pwr; - ret = 0; - break; - } - delay_10ms(10); - } - // } - - if(ret) - { - disable(); - } - - return ret; -} - - -uint8_t REDFLY::init(uint8_t pwr) { return init(REDFLY_BAUDRATE, pwr); } -uint8_t REDFLY::init(void) { return init(REDFLY_BAUDRATE, HIGH_POWER); } - - -void REDFLY::enable(void) //select module -{ - flush(); //clear buffers - setbaudrate(baudrate); - read_state = 0; - CS_ENABLE(); - - return; -} - - -void REDFLY::disable(void) //deselect module -{ - flush(); //clear buffers - read_state = 0; - CS_DISABLE(); - - return; -} - - -uint8_t REDFLY::getversion(char *ver) //return module firmware version -{ - uint8_t ret; - - for(uint8_t i=3; i!=0; i--) //try 3 times - { - memset(buffer, 0, sizeof(buffer)); - ret = cmd(buffer, sizeof(buffer), PSTR(CMD_FWVERSION)); //OKa.b.c - if(ret == 0) - { - //buffer[0] = 'O', buffer[1] = 'K' - memcpy(&ver[0], &buffer[2], 5); - ver[5] = 0; - return 0; - } - } - - return ret; -} - - -uint8_t REDFLY::getmac(uint8_t *mac) //return module MAC address -{ - uint8_t ret; - - for(uint8_t i=3; i!=0; i--) //try 3 times - { - memset(buffer, 0, sizeof(buffer)); - ret = cmd(buffer, sizeof(buffer), PSTR(CMD_MAC)); //OKabcdef - if(ret == 0) - { - memcpy(&mac[0], &buffer[2], 6); //buffer[0] = 'O', buffer[1] = 'K' - return 0; - } - } - - return ret; -} - - -uint8_t REDFLY::getlocalip(uint8_t *ip) //return module IP address -{ - if(ipaddr[0]) - { - memcpy(ip, ipaddr, 4); - return 0; - } - - return 1; -} - - -uint8_t REDFLY::getip(char *host, uint8_t *ip) //return IP addr from host/domain -{ - uint8_t ret; - - for(uint8_t i=3; i!=0; i--) //try 3 times - { - memset(buffer, 0, sizeof(buffer)); - ret = cmd(buffer, sizeof(buffer), PSTR(CMD_DNSGET), (uint8_t*)host, strlen(host)); //OKx... - if(ret == 0) - { - if(buffer[2]) //IP received? - { - memcpy(&ip[0], &buffer[3], 4); - return 0; - } - } - } - - return ret; -} - - -#define NTP_PORT (123) -#define NTP_PACKETLEN (48) -#define NTP_FLAGOFFSET (0) -#define NTP_TIMEOFFSET (40) -uint32_t REDFLY::gettime(uint8_t *server, uint16_t port) -{ - uint8_t buf[64]; //min. NTP_PACKETLEN - uint32_t time=0UL, ms; - uint8_t hNTP, sock, buf_len, *ptr; - uint16_t rd, len; - - if(port == 0) - { - port = NTP_PORT; - } - - //open connection to server - hNTP = socketConnect(PROTO_UDP, server, port, port); - if(hNTP != INVALID_SOCKET) - { - //send NTP request - memset(buf, 0, NTP_PACKETLEN); - buf[NTP_FLAGOFFSET] = (0<<6)|(1<<3)|(3<<0); //NTP flags: LI=0 | VN=1 | Mode=3 -> Client - if(socketSend(hNTP, buf, NTP_PACKETLEN) == 0) - { - //get data - ptr = buf; - buf_len = 0; - for(ms=millis(); (millis()-ms) < 3000;) //wait max. 3s - { - sock = hNTP; - rd = socketRead(&sock, &len, ptr, sizeof(buf)-buf_len); - if((rd != 0) && (rd != 0xFFFF)) //0xFFFF = connection closed - { - ptr += rd; - buf_len += rd; - } - if(buf_len && (len == 0)) //all data received? - { - break; - } - } - //check data - if((buf_len >= NTP_PACKETLEN) && ((buf[NTP_FLAGOFFSET]&0x07) == 4)) //NTP flags: Mode=4 -> Server - { - //time = (uint32_t)*((uint32_t*)&buf[NTP_TIMEOFFSET]); - time = (((uint32_t)buf[NTP_TIMEOFFSET+0])<<24)| - (((uint32_t)buf[NTP_TIMEOFFSET+1])<<16)| - (((uint32_t)buf[NTP_TIMEOFFSET+2])<< 8)| - (((uint32_t)buf[NTP_TIMEOFFSET+3])<< 0); //swap32 - time -= 2208988800UL; //sub seconds 1900-1970 - } - } - socketClose(hNTP); - } - - return time; -} - - -uint32_t REDFLY::gettime(uint8_t *server){ return gettime(server, 0); }; - - -uint8_t REDFLY::getrssi(void) //return signal strength for current connection -{ - for(uint8_t i=3; i!=0; i--) //try 3 times - { - memset(buffer, 0, sizeof(buffer)); - if(cmd(buffer, sizeof(buffer), PSTR(CMD_RSSI)) == 0) //OKx - { - return buffer[2]; - } - } - - return 0; -} - - -uint8_t REDFLY::getbssid(char *ssid, uint8_t *mac) //return SSID and MAC, call after scan() -{ - uint8_t ret; - - memset(buffer, 0, sizeof(buffer)); - - ret = cmd(buffer, sizeof(buffer), PSTR(CMD_BSSID)); - - if(ret == 0) //successful - { - //buffer[0] = 'O', buffer[1] = 'K' - memcpy(ssid, &buffer[2], 32); //SSID - ssid[32] = 0; //32+1 - memcpy(&mac[0], &buffer[34], 6); //MAC - } - else - { - ssid[0] = 0; - } - - return ret; -} - - -uint8_t REDFLY::gettype(char *ssid, uint8_t *type) //return SSID and network type (0=Ad-hoc, 1=Infrastructure), call after scan() -{ - uint8_t ret; - - memset(buffer, 0, sizeof(buffer)); - - ret = cmd(buffer, sizeof(buffer), PSTR(CMD_NWTYPE)); - - if(ret == 0) //successful - { - //buffer[0] = 'O', buffer[1] = 'K' - memcpy(ssid, &buffer[2], 32); //SSID - ssid[32] = 0; //32+1 - *type = buffer[34]; //type - } - else - { - ssid[0] = 0; - } - - return ret; -} - - -uint8_t REDFLY::scan(void) -{ - cmd(PSTR(CMD_NUMSCAN "0")); //return all results on scan command - - return cmd(PSTR(CMD_SCAN "0")); -} - - -uint8_t REDFLY::scan(uint8_t chn, char *ssid, uint8_t *mode, uint8_t *rssi) //chn 0 = all -{ - uint8_t ret, len; - - memset(buffer, 0, sizeof(buffer)); - - cmd(PSTR(CMD_NUMSCAN "1")); //return only one result on scan command - - if(ssid[0] != 0) //scan for ssid - { - uitoa(chn, (char*)&buffer[0]); //chn - len = strlen((char*)buffer); - strcat_P((char*)&buffer[len], PSTR(",")); //, - len = strlen((char*)buffer); - strcat((char*)&buffer[len], ssid); //ssid - ret = cmd(buffer, sizeof(buffer), PSTR(CMD_SCAN), (char*)buffer); - } - else - { - ret = cmd(buffer, sizeof(buffer), PSTR(CMD_SCAN), chn); - } - - if(ret == 0) //scan successful - { - memcpy(ssid, &buffer[2], 32); //SSID - ssid[32] = 0; //32+1 - if(mode) - { - *mode = buffer[34]; - } - if(rssi) - { - *rssi = buffer[35]; - } - } - else - { - if(rssi) - { - *rssi = 0; - } - } - - return ret; -} - - -uint8_t REDFLY::scan(char *ssid, uint8_t *mode, uint8_t *rssi) { return scan(0, ssid, mode, rssi); } -uint8_t REDFLY::scan(char *ssid) { return scan(0, ssid, 0, 0); } - - -uint8_t REDFLY::nextscan(char *ssid, uint8_t *mode, uint8_t *rssi) -{ - uint8_t ret; - - memset(buffer, 0, sizeof(buffer)); - - ret = cmd(buffer, sizeof(buffer), PSTR(CMD_NEXTSCAN)); - - if(ret == 0) //scan successful - { - memcpy(ssid, &buffer[2], 32); //SSID - ssid[32] = 0; //32+1 - if(mode) - { - *mode = buffer[34]; - } - if(rssi) - { - *rssi = buffer[35]; - } - } - else - { - if(rssi) - { - *rssi = 0; - } - } - - return ret; -} - - -uint8_t REDFLY::nextscan(char *ssid) { nextscan(ssid, 0, 0); } - - -uint8_t REDFLY::join(char *ssid, char *key, uint8_t net, uint8_t chn, uint8_t authmode) -{ - uint8_t ret=0; - - //network - switch(net) - { - case INFRASTRUCTURE: - cmd(PSTR(CMD_NETWORK "INFRASTRUCTURE")); - break; - case IBSS_JOINER: - if(key) - { - cmd(PSTR(CMD_NETWORK "IBSS_SEC,0,0")); - } - else - { - cmd(PSTR(CMD_NETWORK "IBSS,0,0")); - } - break; - case IBSS_CREATOR: - if(key) - { - cmd(PSTR(CMD_NETWORK "IBSS_SEC,1,"), chn); - } - else - { - cmd(PSTR(CMD_NETWORK "IBSS,1,"), chn); - } - break; - } - - //authentication mode - if(authmode <= 4) - { - cmd(PSTR(CMD_AUTHMODE), authmode); - } - - //key - if(key) - { - cmd(PSTR(CMD_PSK), key); - } - - //join - switch(tx_power) - { - //auto data rate - case LOW_POWER: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_LOWPW)); break; - case MED_POWER: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_MEDPW)); break; - case HIGH_POWER: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_HIGHPW)); break; - //1Mbps - case LOW_POWER_1M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_LOWPW1M)); break; - case MED_POWER_1M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_MEDPW1M)); break; - case HIGH_POWER_1M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_HIGHPW1M)); break; - //2Mbps - case LOW_POWER_2M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_LOWPW2M)); break; - case MED_POWER_2M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_MEDPW2M)); break; - case HIGH_POWER_2M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_HIGHPW2M)); break; - //11Mbps - case LOW_POWER_11M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_LOWPW11M)); break; - case MED_POWER_11M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_MEDPW11M)); break; - case HIGH_POWER_11M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_HIGHPW11M)); break; - //12Mbps - case LOW_POWER_12M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_LOWPW12M)); break; - case MED_POWER_12M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_MEDPW12M)); break; - case HIGH_POWER_12M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_HIGHPW12M)); break; - //24Mbps - case LOW_POWER_24M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_LOWPW24M)); break; - case MED_POWER_24M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_MEDPW24M)); break; - case HIGH_POWER_24M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_HIGHPW24M)); break; - //54Mbps - case LOW_POWER_54M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_LOWPW54M)); break; - case MED_POWER_54M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_MEDPW54M)); break; - case HIGH_POWER_54M: ret = cmd(PSTR(CMD_JOIN), ssid, PSTR(JOIN_HIGHPW54M)); break; - } - - return ret; -} - - -uint8_t REDFLY::join(char *ssid, char *key, uint8_t net, uint8_t chn) { return join(ssid, key, net, chn, 0xFF); } //IBSS_CREATOR -uint8_t REDFLY::join(char *ssid, uint8_t net, uint8_t chn) { return join(ssid, 0, net, chn, 0xFF); } //IBSS_CREATOR -uint8_t REDFLY::join(char *ssid, char *key, uint8_t net) { return join(ssid, key, net, 0, 0xFF); } //INFRASTRUCTURE or IBSS_JOINER -uint8_t REDFLY::join(char *ssid, uint8_t net) { return join(ssid, 0, net, 0, 0xFF); } //INFRASTRUCTURE or IBSS_JOINER -uint8_t REDFLY::join(char *ssid, char *key) { return join(ssid, key, INFRASTRUCTURE, 0, 0xFF); } //INFRASTRUCTURE -uint8_t REDFLY::join(char *ssid) { return join(ssid, 0, INFRASTRUCTURE, 0, 0xFF); } //INFRASTRUCTURE - - -uint8_t REDFLY::disconnect(void) -{ - socketReset(); - memset(ipaddr, 0, sizeof(ipaddr)); - - return cmd(PSTR(CMD_DISCONN)); -} - - -uint8_t REDFLY::begin(uint8_t dhcp, uint8_t *ip, uint8_t *dns, uint8_t *gateway, uint8_t *netmask) -{ - uint8_t len; - - //reset sockets and IP addr - socketReset(); - memset(ipaddr, 0, sizeof(ipaddr)); - memset(buffer, 0, sizeof(buffer)); - - //dhcp or auto ip - if(dhcp == 2) //Auto-IP - { - if(cmd(buffer, sizeof(buffer), PSTR(CMD_IPCONF IPCONF_AUTOIP)) == 0) //OKMACaddrIPaddrSUBNETGateway - { - memcpy(&ipaddr[0], &buffer[8], 4); - return 0; - } - return 2; - } - else if(dhcp) //DHCP - { - if(cmd(buffer, sizeof(buffer), PSTR(CMD_IPCONF IPCONF_DHCP)) == 0) //OKMACaddrIPaddrSUBNETGateway - { - memcpy(&ipaddr[0], &buffer[8], 4); - return 0; - } - return 1; - } - - //static ip settings - if(dns) - { - iptoa(dns, (char*)&buffer[0]); - cmd(PSTR(CMD_DNSSERVER), (char*)buffer); //set DNS server (FW >= 4.3.0 required) - } - if(ip) - { - iptoa(ip, (char*)buffer); - memcpy(ipaddr, ip, 4); - } - else - { - strcat_P((char*)buffer, PSTR("192.168.0.1")); - ipaddr[0] = 192; - ipaddr[1] = 168; - ipaddr[2] = 0; - ipaddr[3] = 1; - } - if(netmask) - { - strcat_P((char*)buffer, PSTR(",")); - len = strlen((char*)buffer); - iptoa(netmask, (char*)&buffer[len]); - } - else - { - strcat_P((char*)buffer, PSTR(",255.255.255.0")); - } - if(gateway) - { - strcat_P((char*)buffer, PSTR(",")); - len = strlen((char*)buffer); - iptoa(gateway, (char*)&buffer[len]); - } - - return cmd(PSTR(CMD_IPCONF "0,"), (char*)buffer); //xxx.xxx.xxx.xxx,yyy.yyy.yyy.yyy,zzz.zzz.zzz.zzz -} - -uint8_t REDFLY::begin(uint8_t *ip, uint8_t *dns, uint8_t *gateway, uint8_t *netmask) { return begin( 0, ip, dns, gateway, netmask); } -uint8_t REDFLY::begin(uint8_t *ip, uint8_t *dns, uint8_t *gateway) { return begin( 0, ip, dns, gateway, 0); } -uint8_t REDFLY::begin(uint8_t *ip, uint8_t *dns) { return begin( 0, ip, dns, 0, 0); } -uint8_t REDFLY::begin(uint8_t *ip) { return begin( 0, ip, 0, 0, 0); } -uint8_t REDFLY::begin(uint8_t dhcp) { return begin(dhcp, 0, 0, 0, 0); } -uint8_t REDFLY::begin(void) { return begin( 1, 0, 0, 0, 0); } - - -uint8_t REDFLY::socketConnect(uint8_t proto, uint8_t *ip, uint16_t port, uint16_t lport) -{ - uint8_t ret=INVALID_SOCKET, len; - - //ip - iptoa(ip, (char*)buffer); - //port - strcat_P((char*)buffer, PSTR(",")); - len = strlen((char*)buffer); - uitoa(port, (char*)&buffer[len]); - //local port - strcat_P((char*)buffer, PSTR(",")); - len = strlen((char*)buffer); - uitoa(lport, (char*)&buffer[len]); - - if(proto == PROTO_MCAST) //Multicast - { - proto = SOCKET_MCAST; - if(cmd(buffer, 8, PSTR(CMD_MCAST), (char*)buffer) == 0) //xxx.xxx.xxx.xxx,aaaaa,bbbbb - { - ret = buffer[2]; //OKx - } - } - else if(proto == PROTO_TCP) //TCP - { - proto = SOCKET_TCP; - if(cmd(buffer, 8, PSTR(CMD_TCP), (char*)buffer) == 0) //xxx.xxx.xxx.xxx,aaaaa,bbbbb - { - ret = buffer[2]; //OKx - } - } - else //UDP - { - proto = SOCKET_UDP; - if(cmd(buffer, 8, PSTR(CMD_UDP), (char*)buffer) == 0) //xxx.xxx.xxx.xxx,aaaaa,bbbbb - { - ret = buffer[2]; //OKx - } - } - - if(ret != INVALID_SOCKET) //handle okay -> save socket handle and type - { - for(uint8_t i=0; i 2048) - { - lport = 1024; - } - - return socketConnect(proto, ip, port, lport); -} - - -uint8_t REDFLY::socketListen(uint8_t proto, uint16_t lport) -{ - uint8_t ret=INVALID_SOCKET; - - //local port - uitoa(lport, (char*)&buffer[0]); - - if(proto == PROTO_TCP) //TCP - { - proto = SOCKET_TCP; - if(cmd(buffer, sizeof(buffer), PSTR(CMD_LTCP), (char*)buffer) == 0) - { - ret = buffer[2]; //OKx - } - } - else //UDP - { - proto = SOCKET_UDP; - if(cmd(buffer, sizeof(buffer), PSTR(CMD_LUDP), (char*)buffer) == 0) - { - ret = buffer[2]; //OKx - } - } - - if(ret != INVALID_SOCKET) //handle okay -> save socket handle and type - { - for(uint8_t i=0; i= 8) - { - if((buf[0] == 'R') && \ - (buf[1] == 'S') && \ - (buf[2] == 'I') && \ - (buf[3] == '_') && \ - (buf[4] == 'R') && \ - (buf[5] == 'E') && \ - (buf[6] == 'A') && \ - (buf[7] == 'D')) //RSI_READ - { - last_socket = readwait(); - last_len = readwait(); - last_len |= readwait()<<8; - - if((last_socket == INVALID_SOCKET) || (last_len == 0)) - { - read_state = 0; - last_socket = INVALID_SOCKET; - last_len = 0; - break; - } - read_state = 2; - - //get IP and port on UDP connection - if(socketState(last_socket) == SOCKET_UDP) - { - udp_ip[0] = readwait(); - udp_ip[1] = readwait(); - udp_ip[2] = readwait(); - udp_ip[3] = readwait(); - udp_port = readwait(); - udp_port |= readwait()<<8; - } - - if((*socket != INVALID_SOCKET) && (*socket != last_socket)) //abort if not searched socket - { - return 0; - } - if(dst_size == 0) - { - stop = 1; //break loop - } - } - else if((buf[0] == 'S') && \ - (buf[1] == 'I') && \ - (buf[2] == '_') && \ - (buf[3] == 'C') && \ - (buf[4] == 'L') && \ - (buf[5] == 'O') && \ - (buf[6] == 'S') && \ - (buf[7] == 'E')) //SI_CLOSE - { - last_socket = readwait(); - readwait(); readwait(); //trailing \r\n - last_len = 0; - rd = 0xFFFF; - read_state = 0; - stop = 1; //break loop - for(uint8_t i=0; i 0xDB 0xDD - { - write(0xDB); - write(0xDD); - c = pgm_read_byte(p2++); - } - else if((c == 0x0D) && (pgm_read_byte(p2) == 0x0A)) //\r\n -> 0xDB 0xDC - { - write(0xDB); - write(0xDC); - p2++; - c = pgm_read_byte(p2++); - } - else - { - write(c); - c = pgm_read_byte(p2++); - } - } - } - - //send v2 parameter 3 - if(v2_size) - { - while(v2_size) - { - if(v2[0] == 0xDB) //0xDB -> 0xDB 0xDD - { - write(0xDB); - write(0xDD); - v2++; v2_size--; - } - else if((v2[0] == 0x0D) && (v2[1] == 0x0A) && (v2_size >= 2)) //\r\n -> 0xDB 0xDC - { - write(0xDB); - write(0xDC); - v2+=2; v2_size-=2; - } - else - { - write(*v2++); - v2_size--; - } - } - } - - //flush rx and tx buffer - flush_nowait(); - - //send end characters of command - write('\r'); - write('\n'); - - //read response - timeout = 10000; //default timeout: 10s - if(dst_size == 0) //dont save response - { - buf[0] = 0; - buf[5] = 0; - for(i=0, ms=millis(); (millis()-ms) < timeout;) - { - if(available()) - { - c = read(); - if(i < 8) - { - buf[i++] = c; - if((buf[0] != 'O') && (buf[0] != 'E')) //OK or ERROR - { - i = 0; - } - } - ms = millis(); - timeout = 3; //3 ms timeout - } - } - } - else //save response to dst - { - dst[0] = 0; - dst[5] = 0; - for(i=0, ms=millis(); (millis()-ms) < timeout;) - { - if(available()) - { - c = read(); - if(i < dst_size) - { - dst[i++] = c; - if((dst[0] != 'O') && (dst[0] != 'E')) //OK or ERROR - { - i = 0; - } - } - ms = millis(); - timeout = 3; //3 ms timeout - } - } - buf[0] = dst[0]; - buf[1] = dst[1]; - buf[5] = dst[5]; - } - - //check response - if((buf[0] == 'O') && (buf[1] == 'K')) - { - return 0; //OK - } - else if((buf[0] == 'E') && (buf[1] == 'R') && (buf[5] != 0) && (buf[5] != '\r')) - { - return buf[5]; //ERROR code - } - - return 0xFF; -} - - -uint8_t REDFLY::cmd(uint8_t *dst, uint8_t dst_size, PGM_P p1, int16_t val) -{ - char buf[8]; - - itoa(val, buf, 10); - - return cmd(dst, dst_size, p1, buf, 0, 0, 0); -} - -uint8_t REDFLY::cmd(uint8_t *dst, uint8_t dst_size, PGM_P p1, uint8_t *v2, uint16_t v2_size) { return cmd(dst, dst_size, p1, 0, 0, v2, v2_size); } -uint8_t REDFLY::cmd(uint8_t *dst, uint8_t dst_size, PGM_P p1, char *v1) { return cmd(dst, dst_size, p1, v1, 0, 0, 0); } -uint8_t REDFLY::cmd(uint8_t *dst, uint8_t dst_size, PGM_P p1) { return cmd(dst, dst_size, p1, 0, 0, 0, 0); } -uint8_t REDFLY::cmd( PGM_P p1, char *v1, PGM_P p2) { return cmd( 0, 0, p1, v1, p2, 0, 0); } -uint8_t REDFLY::cmd( PGM_P p1, char *v1, uint8_t *v2, uint16_t v2_size) { return cmd( 0, 0, p1, v1, 0, v2, v2_size); } -uint8_t REDFLY::cmd( PGM_P p1, char *v1) { return cmd( 0, 0, p1, v1, 0, 0, 0); } -uint8_t REDFLY::cmd( PGM_P p1, int16_t v1) { return cmd( 0, 0, p1, v1 ); } -uint8_t REDFLY::cmd( PGM_P p1) { return cmd( 0, 0, p1, 0, 0, 0, 0); } - - -void REDFLY::flush(void) -{ - uint32_t ms; - - //clear tx buffer - _SERIAL_.flush(); - - //clear rx buffer -#if defined(__AVR__) - for(ms=millis(); ((_UCSRA_&(1<<_RXC_)) || available()) && ((millis()-ms) < 50);) //50ms -#else - for(ms=millis(); available() && ((millis()-ms) < 50);) //50ms -#endif - { - read(); - } - delay_10ms(1); - - return; -} - - -void REDFLY::flush_nowait(void) -{ - //clear tx buffer - _SERIAL_.flush(); - - //clear rx buffer - for(int len=available(); len!=0; len--) - { - read(); - } - - return; -} - - -int REDFLY::available(void) -{ - return _SERIAL_.available(); -} - - -uint8_t REDFLY::readwait(void) //serial read -{ - while(!available()); - - return (uint8_t)_SERIAL_.read(); -} - - -uint8_t REDFLY::read(void) //serial read -{ - return _SERIAL_.read(); -} - - -void REDFLY::write(uint8_t c) //serial write -{ - _SERIAL_.write(c); - - return; -} - - -void REDFLY::setbaudrate(uint32_t br) //set serial baudrate and config (8n2) -{ - if(br < 9600) - { - br = 9600; - } - else if(br > 3686400) - { - br = 3686400; - } - - _SERIAL_.begin(br); - - //8 N 2 -#if defined(__AVR__) - _UCSRC_ |= (1<<_USBS_); -#else - _USART_->US_MR |= US_MR_NBSTOP_2_BIT; - //_USART_->US_MR = US_MR_USART_MODE_NORMAL | US_MR_USCLKS_MCK | US_MR_CHRL_8_BIT | US_MR_PAR_NO | US_MR_NBSTOP_2_BIT | US_MR_CHMODE_NORMAL; -#endif - - return; -} - - -char* REDFLY::iptoa(uint8_t *ip, char *s) //convert ip to string -{ - sprintf_P(s, PSTR("%i.%i.%i.%i"), ip[0], ip[1], ip[2], ip[3]); - - return s; -} - - -char* REDFLY::uitoa(uint16_t val, char *s) //convert unsigned int to string -{ - sprintf_P(s, PSTR("%u"), val); - - return s; -} - - -void REDFLY::delay_10ms(uint8_t ms) //delay of 10ms * x -{ - for(; ms!=0; ms--) - { -#if defined(__AVR__) - _delay_ms(10); -#else - delay(10); -#endif - } - - return; -} diff --git a/arduino/libs/RedFly/RedFly.h b/arduino/libs/RedFly/RedFly.h deleted file mode 100644 index 935821e47..000000000 --- a/arduino/libs/RedFly/RedFly.h +++ /dev/null @@ -1,194 +0,0 @@ -#ifndef REDFLY_h -#define REDFLY_h - - -#include -#if defined(__AVR__) -# include -#else -# define pgm_read_byte(addr) (*(const uint8_t *)(addr)) -# define pgm_read_word(addr) (*(const uint16_t *)(addr)) -# define pgm_read_dword(addr) (*(const uint32_t *)(addr)) -# define PSTR(x) (x) -# define PGM_P const char* -# define strlen_P strlen -# define strcpy_P strcpy -# define strcat_P strcat -# define strcmp_P strcmp -# define strncmp_P strncmp -# define strncasecmp_P strncasecmp -# define sprintf_P sprintf -#endif - - -//default baud rate -#define REDFLY_BAUDRATE (9600) - -//Tx power (init cmd) -#define LOW_POWER (0) -#define MED_POWER (1) -#define HIGH_POWER (2) -#define LOW_POWER_1M (3) -#define MED_POWER_1M (4) -#define HIGH_POWER_1M (5) -#define LOW_POWER_2M (6) -#define MED_POWER_2M (7) -#define HIGH_POWER_2M (8) -#define LOW_POWER_11M (9) -#define MED_POWER_11M (10) -#define HIGH_POWER_11M (11) -#define LOW_POWER_12M (12) -#define MED_POWER_12M (13) -#define HIGH_POWER_12M (14) -#define LOW_POWER_24M (15) -#define MED_POWER_24M (16) -#define HIGH_POWER_24M (17) -#define LOW_POWER_54M (18) -#define MED_POWER_54M (19) -#define HIGH_POWER_54M (20) - -//net type (join cmd) -#define INFRASTRUCTURE (0) -#define IBSS_JOINER (1) -#define IBSS_CREATOR (2) - -//protocol (socket cmds) -#define PROTO_TCP (0) -#define PROTO_UDP (1) -#define PROTO_MCAST (2) - -//max. sockets (WiFi module supports up to 8 sockets and FW 4.7.1 only 7 sockets) -#define MAX_SOCKETS (7) -#define INVALID_SOCKET (0xFF) - -//socket states -#define SOCKET_TCP PROTO_TCP -#define SOCKET_UDP PROTO_UDP -#define SOCKET_MCAST PROTO_MCAST -#define SOCKET_CLOSED (0xFF) - -#ifndef SWAP16 -#define SWAP16(x) ((((x)&0x00FF)<<8)| \ - (((x)&0xFF00)>>8)) -#endif - -#ifndef SWAP32 -#define SWAP32(x) ((((x)&0xFF000000UL)>>24)| \ - (((x)&0x00FF0000UL)>> 8)| \ - (((x)&0x0000FF00UL)<< 8)| \ - (((x)&0x000000FFUL)<<24)) -#endif - - -typedef struct -{ - uint8_t handle; - uint8_t state; -} SOCKET_STATE; - - -extern class REDFLY RedFly; - -class REDFLY -{ - public: - REDFLY(void); - ~REDFLY(void); - - uint8_t init(uint32_t br, uint8_t pwr); //br=baudrate, pwr=tx_power - uint8_t init(uint8_t pwr); //pwr=tx_power - uint8_t init(void); - - void enable(void); - void disable(void); - - uint8_t getversion(char *ver); - uint8_t getmac(uint8_t *mac); - uint8_t getlocalip(uint8_t *ip); - uint8_t getip(char *host, uint8_t *ip); - uint32_t gettime(uint8_t *server, uint16_t port); - uint32_t gettime(uint8_t *server); - uint8_t getrssi(void); - uint8_t getbssid(char *ssid, uint8_t *mac); - uint8_t gettype(char *ssid, uint8_t *type); - - uint8_t scan(void); - uint8_t scan(uint8_t chn, char *ssid, uint8_t *mode, uint8_t *rssi); //returns: ssid, mode, rssi - uint8_t scan(char *ssid, uint8_t *mode, uint8_t *rssi); //returns: ssid, mode, rssi - uint8_t scan(char *ssid); //returns: ssid - uint8_t nextscan(char *ssid, uint8_t *mode, uint8_t *rssi); //returns: ssid, mode, rssi - uint8_t nextscan(char *ssid); //returns: ssid - - uint8_t join(char *ssid, char *key, uint8_t net, uint8_t chn, uint8_t authmode); //INFRASTRUCTURE or IBSS_JOINER or IBSS_CREATOR - uint8_t join(char *ssid, char *key, uint8_t net, uint8_t chn); //IBSS_CREATOR - uint8_t join(char *ssid, uint8_t net, uint8_t chn); //IBSS_CREATOR - uint8_t join(char *ssid, char *key, uint8_t net); //INFRASTRUCTURE or IBSS_JOINER - uint8_t join(char *ssid, uint8_t net); //INFRASTRUCTURE or IBSS_JOINER - uint8_t join(char *ssid, char *key); //INFRASTRUCTURE - uint8_t join(char *ssid); //INFRASTRUCTURE - - uint8_t disconnect(void); //disassociate - - uint8_t begin(uint8_t dhcp, uint8_t *ip, uint8_t *dns, uint8_t *gateway, uint8_t *netmask); - uint8_t begin(uint8_t *ip, uint8_t *dns, uint8_t *gateway, uint8_t *netmask); //dhcp off - uint8_t begin(uint8_t *ip, uint8_t *dns, uint8_t *gateway); //dhcp off - uint8_t begin(uint8_t *ip, uint8_t *dns); //dhcp off - uint8_t begin(uint8_t *ip); //dhcp off - uint8_t begin(uint8_t dhcp); //dhcp or autoip - uint8_t begin(void); //dhcp on - - uint8_t socketConnect(uint8_t proto, uint8_t *ip, uint16_t port, uint16_t lport); //ret 0xFF=error - uint8_t socketConnect(uint8_t proto, uint8_t *ip, uint16_t port); //ret 0xFF=error (lport=1024...2048) - - uint8_t socketListen(uint8_t proto, uint16_t lport); //ret 0xFF=error - - uint8_t socketClose(uint8_t socket); - uint8_t socketClosed(uint8_t socket); //0!=closed - uint8_t socketStatus(uint8_t socket); //ret 0xFF=error - uint8_t socketState(uint8_t socket); //ret 0xFF=closed - - uint8_t socketSend(uint8_t socket, uint8_t *stream, uint16_t size, uint8_t *ip, uint16_t port); //ip+port only for UDP - uint8_t socketSend(uint8_t socket, char *stream, uint8_t *ip, uint16_t port); //ip+port only for UDP - uint8_t socketSendPGM(uint8_t socket, PGM_P stream, uint8_t *ip, uint16_t port); //ip+port only for UDP - uint8_t socketSend(uint8_t socket, uint8_t *stream, uint16_t size); //TCP - uint8_t socketSend(uint8_t socket, char *stream); //TCP - uint8_t socketSendPGM(uint8_t socket, PGM_P stream); //TCP - uint8_t socketSend(uint8_t socket, int value); //TCP - - uint16_t socketRead(uint8_t *socket, uint16_t *len, uint8_t *ip, uint16_t *port, uint8_t *dst, uint16_t dst_size); //ret 0xFFFF=closed - uint16_t socketRead(uint8_t *socket, uint16_t *len, uint8_t *dst, uint16_t dst_size); - - void socketReset(void); - - private: - uint8_t tx_power, read_state; - uint8_t buffer[48]; //min. 48 (receive and data buffer) - uint32_t baudrate; - uint8_t ipaddr[4]; - SOCKET_STATE socket_state[MAX_SOCKETS]; - - uint8_t cmd(uint8_t *dst, uint8_t dst_size, PGM_P p1, char *v1, PGM_P p2, uint8_t *v2, uint16_t v2_size); - uint8_t cmd(uint8_t *dst, uint8_t dst_size, PGM_P p1, int16_t v1); - uint8_t cmd(uint8_t *dst, uint8_t dst_size, PGM_P p1, uint8_t *v2, uint16_t v2_size); - uint8_t cmd(uint8_t *dst, uint8_t dst_size, PGM_P p1, char *v1); - uint8_t cmd(uint8_t *dst, uint8_t dst_size, PGM_P p1); - uint8_t cmd(PGM_P p1, char *v1, PGM_P p2); - uint8_t cmd(PGM_P p1, char *v1, uint8_t *v2, uint16_t v2_size); - uint8_t cmd(PGM_P p1, char *v1); - uint8_t cmd(PGM_P p1, int16_t v1); - uint8_t cmd(PGM_P p1); - - void flush(void); - void flush_nowait(void); - int available(void); - uint8_t readwait(void); - uint8_t read(void); - void write(uint8_t c); - void setbaudrate(uint32_t br); - char* iptoa(uint8_t *ip, char *s); - char* uitoa(uint16_t val, char *s); - void delay_10ms(uint8_t ms); -}; - - -#endif //REDFLY_h diff --git a/arduino/libs/RedFly/RedFlyClient.cpp b/arduino/libs/RedFly/RedFlyClient.cpp deleted file mode 100644 index 5747a8c51..000000000 --- a/arduino/libs/RedFly/RedFlyClient.cpp +++ /dev/null @@ -1,456 +0,0 @@ -#include -#if defined(__AVR__) -# include -#endif -#if ARDUINO >= 100 -# include "Arduino.h" -#else -# include "WProgram.h" -#endif -#include "RedFly.h" -#include "RedFlyClient.h" - - -#define MAX_ERRORS (10) - - -//-------------------- Constructor/Destructor -------------------- - - -RedFlyClient::RedFlyClient(void) -{ - c_port = 0; - c_socket = INVALID_SOCKET; - - return; -} - - -RedFlyClient::RedFlyClient(uint8_t socket) -{ - c_port = 0; - c_socket = socket; - - return; -} - - -RedFlyClient::RedFlyClient(uint8_t *ip, uint16_t port) -{ - c_ip[0] = ip[0]; - c_ip[1] = ip[1]; - c_ip[2] = ip[2]; - c_ip[3] = ip[3]; - c_port = port; - c_socket = INVALID_SOCKET; - - return; -} - - -RedFlyClient::RedFlyClient(uint8_t *ip, uint16_t port, uint16_t lport) -{ - c_ip[0] = ip[0]; - c_ip[1] = ip[1]; - c_ip[2] = ip[2]; - c_ip[3] = ip[3]; - c_port = port; - c_lport = lport; - c_socket = INVALID_SOCKET; - - return; -} - - -RedFlyClient::~RedFlyClient(void) -{ - stop(); - - return; -} - - -//-------------------- Public -------------------- - - -void RedFlyClient::begin(void) -{ - connectSocket(PROTO_TCP); - - return; -} - - -void RedFlyClient::beginUDP(void) -{ - connectSocket(PROTO_UDP); - - return; -} - - -int RedFlyClient::connect(void) -{ - return connectSocket(PROTO_TCP); -} - - -int RedFlyClient::connectUDP(void) -{ - return connectSocket(PROTO_UDP); -} - - -int RedFlyClient::connect(uint8_t *ip, uint16_t port) -{ - c_ip[0] = ip[0]; - c_ip[1] = ip[1]; - c_ip[2] = ip[2]; - c_ip[3] = ip[3]; - c_port = port; - - return connectSocket(PROTO_TCP); -} - - -int RedFlyClient::connectUDP(uint8_t *ip, uint16_t port) -{ - c_ip[0] = ip[0]; - c_ip[1] = ip[1]; - c_ip[2] = ip[2]; - c_ip[3] = ip[3]; - c_port = port; - - return connectSocket(PROTO_UDP); -} - - -int RedFlyClient::connect(uint8_t *ip, uint16_t port, uint16_t lport) -{ - c_ip[0] = ip[0]; - c_ip[1] = ip[1]; - c_ip[2] = ip[2]; - c_ip[3] = ip[3]; - c_port = port; - c_lport = lport; - - return connectSocket(PROTO_TCP); -} - - -int RedFlyClient::connectUDP(uint8_t *ip, uint16_t port, uint16_t lport) -{ - c_ip[0] = ip[0]; - c_ip[1] = ip[1]; - c_ip[2] = ip[2]; - c_ip[3] = ip[3]; - c_port = port; - c_lport = lport; - - return connectSocket(PROTO_UDP); -} - - -int RedFlyClient::connect(char *host, uint16_t port) -{ - if(RedFly.getip(host, c_ip) == 0) - { - c_port = port; - return connectSocket(PROTO_TCP); - } - - return 0; -} - - -int RedFlyClient::connectUDP(char *host, uint16_t port) -{ - if(RedFly.getip(host, c_ip) == 0) - { - c_port = port; - return connectSocket(PROTO_UDP); - } - - return 0; -} - - -int RedFlyClient::connectSocket(uint8_t p) -{ - if(c_socket != INVALID_SOCKET) - { - return 0; - } - - if(c_lport) - { - c_socket = RedFly.socketConnect(p, c_ip, c_port, c_lport); - } - else - { - c_socket = RedFly.socketConnect(p, c_ip, c_port); - } - - if(c_socket == INVALID_SOCKET) - { - return 0; - } - - proto = p; - error = 0; - - return 1; -} - - -uint8_t RedFlyClient::connected(void) -{ - if(c_socket == INVALID_SOCKET) - { - return 0; - } - - if(RedFly.socketClosed(c_socket)) //socket closed? - { - c_socket = INVALID_SOCKET; - return 0; - } - - if(error >= MAX_ERRORS) - { - RedFly.socketClose(c_socket); - c_socket = INVALID_SOCKET; - return 0; - } - - return 1; -} - - -void RedFlyClient::stop(void) -{ - if(c_socket == INVALID_SOCKET) - { - return; - } - - flush(); //clear buffer - - RedFly.socketClose(c_socket); - c_socket = INVALID_SOCKET; - error = 0; - - return; -} - - -uint8_t RedFlyClient::status(void) -{ - if(c_socket == INVALID_SOCKET) - { - return 1; - } - - if(RedFly.socketStatus(c_socket)) //socket closed? - { - c_socket = INVALID_SOCKET; - return 1; - } - - return 0; -} - - -uint8_t RedFlyClient::getsocket(void) -{ - return c_socket; -} - - -int RedFlyClient::available(void) -{ - uint8_t socket=c_socket; - uint16_t len=0; - - if(socket != INVALID_SOCKET) - { - RedFly.socketRead(&socket, &len, 0, 0); - } - - return (int)len; -} - - -int RedFlyClient::read(void) -{ - uint8_t b; - uint8_t socket=c_socket; - uint16_t len, rd; - - if(socket == INVALID_SOCKET) - { - return -1; - } - - rd = RedFly.socketRead(&socket, &len, &b, 1); - - if(rd == 0) - { - return -1; - } - if(rd == 0xFFFF) //socket closed? - { - c_socket = INVALID_SOCKET; - return -1; - } - - return b; -} - - -int RedFlyClient::read(uint8_t *s, size_t sz) -{ - int c, rd; - - for(rd=0; sz;) - { - c = read(); - if(c != -1) - { - *s++ = (uint8_t)c; - sz--; - rd++; - } - else - { - break; - } - } - - return rd; -} - - -void RedFlyClient::flush(void) -{ - for(int len=available(); len!=0; len--) - { - read(); - } - - return; -} - - -size_t RedFlyClient::write(uint8_t b) -{ - if(c_socket != INVALID_SOCKET) - { - if(RedFly.socketSend(c_socket, (uint8_t*)&b, 1, c_ip, c_port)) - { - if(++error >= MAX_ERRORS) - { - RedFly.socketClose(c_socket); - c_socket = INVALID_SOCKET; - } - } - else - { - error = 0; - return 1; - } - } - - return 0; -} - - -size_t RedFlyClient::write(const char *s) -{ - if(c_socket != INVALID_SOCKET) - { - if(RedFly.socketSend(c_socket, (char*)s, c_ip, c_port)) - { - if(++error >= MAX_ERRORS) - { - RedFly.socketClose(c_socket); - c_socket = INVALID_SOCKET; - } - } - else - { - error = 0; - return strlen(s); - } - } - - return 0; -} - - -size_t RedFlyClient::write(const uint8_t *s, size_t size) -{ - if(c_socket != INVALID_SOCKET) - { - if(RedFly.socketSend(c_socket, (uint8_t*)s, size, c_ip, c_port)) - { - if(++error >= MAX_ERRORS) - { - RedFly.socketClose(c_socket); - c_socket = INVALID_SOCKET; - } - } - else - { - error = 0; - return size; - } - } - - return 0; -} - - -size_t RedFlyClient::print_P(PGM_P s) -{ - if(c_socket != INVALID_SOCKET) - { - if(RedFly.socketSendPGM(c_socket, s, c_ip, c_port)) - { - if(++error >= MAX_ERRORS) - { - RedFly.socketClose(c_socket); - c_socket = INVALID_SOCKET; - } - } - else - { - error = 0; - return strlen_P(s); - } - } - - return 0; -} - - -size_t RedFlyClient::println_P(PGM_P s) -{ - size_t len; - - len = print_P(s); - if(len) - { - len += print_P(PSTR("\r\n")); - } - - return len; -} - - -//the next function allows us to use the client returned by -//RedFlyServer::available() as the condition in an if-statement. -RedFlyClient::operator bool() -{ - return c_socket != INVALID_SOCKET; -} diff --git a/arduino/libs/RedFly/RedFlyClient.h b/arduino/libs/RedFly/RedFlyClient.h deleted file mode 100644 index c854d20c1..000000000 --- a/arduino/libs/RedFly/RedFlyClient.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef REDFLYCLIENT_h -#define REDFLYCLIENT_h - - -#include -#if defined(__AVR__) -# include -#endif -#include "Print.h" -#include "RedFly.h" -#include "Server.h" - - -class RedFlyClient : public Server -{ - public: - RedFlyClient(void); - RedFlyClient(uint8_t socket); - RedFlyClient(uint8_t *ip, uint16_t port); - RedFlyClient(uint8_t *ip, uint16_t port, uint16_t lport); - ~RedFlyClient(void); - - virtual void begin(void); //same as connect() - virtual void beginUDP(void); //same as connect() - virtual int connect(void); - virtual int connectUDP(void); - virtual int connect(uint8_t *ip, uint16_t port); - virtual int connectUDP(uint8_t *ip, uint16_t port); - virtual int connect(uint8_t *ip, uint16_t port, uint16_t lport); - virtual int connectUDP(uint8_t *ip, uint16_t port, uint16_t lport); - virtual int connect(char *host, uint16_t port); - virtual int connectUDP(char *host, uint16_t port); - int connectSocket(uint8_t p); - virtual uint8_t connected(void); - virtual void stop(void); - uint8_t status(void); - uint8_t getsocket(void); - - virtual int available(void); - virtual int read(void); - virtual int read(uint8_t *s, size_t sz); - //virtual int peek(void); //not available - virtual void flush(void); - virtual size_t write(uint8_t b); - virtual size_t write(const char *s); - virtual size_t write(const uint8_t *s, size_t sz); - virtual size_t print_P(PGM_P s); - virtual size_t println_P(PGM_P s); - - virtual operator bool(); - - using Print::write; - - private: - uint8_t c_socket; - uint8_t c_ip[4]; - uint16_t c_port; - uint16_t c_lport; - uint8_t proto, error; -}; - - -#endif //REDFLYCLIENT_h diff --git a/arduino/libs/RedFly/RedFlyCommands.h b/arduino/libs/RedFly/RedFlyCommands.h deleted file mode 100644 index 46f933c0d..000000000 --- a/arduino/libs/RedFly/RedFlyCommands.h +++ /dev/null @@ -1,168 +0,0 @@ -#ifndef REDFLYCOMMANDS_h -#define REDFLYCOMMANDS_h - - -#define CMD_OK "OK" -#define CMD_ERROR "ERROR" - - -//Command -#define CMD_FWVERSION "AT+RSI_FWVERSION?" //firmware version - //ret: OKMajor.Minor1.Minor2 - -#define CMD_RESET "AT+RSI_RESET" //soft reset - //ret: OK - -#define CMD_BAUDRATE "AT+RSI_BAUDRATE=" //baud_rate - //ret: OK - -#define CMD_MAC "AT+RSI_MAC?" //get MAC address of the module - //ret: OKabcdef - -#define CMD_RSSI "AT+RSI_RSSI?" //get signal strength for current connection - //ret: OKa - -#define CMD_NWPARAMS "AT+RSI_NWPARAMS?" //get module paramters - // 32 1 32 1 6 1 4 4 4 1 - //ret: OK - // [][] (...up to ) - // - -#define CMD_BAND "AT+RSI_BAND=" //set band -#define BAND24 "0" //set 2.4GHz -#define BAND5 "1" //set 5GHz - -#define CMD_INIT "AT+RSI_INIT" //execut after BAND - -#define CMD_SCAN "AT+RSI_SCAN=" //chn,SSID (SSID for hidden Access Points, chn=0 -> all channels) - //ret: OK... -#define CMD_NEXTSCAN "AT+RSI_NEXTSCAN" - //ret: OK... -#define CMD_NUMSCAN "AT+RSI_NUMSCAN=" //set number -#define CMD_GETNUMSCAN "AT+RSI_NUMSCAN?" //get number -#define CMD_NWTYPE "AT+RSI_NWTYPE?" //get network type (0=Ad-hoc, 1=Infrastructure) - //ret: OK... -#define CMD_BSSID "AT+RSI_BSSID?" //get network MAC - //ret: OK... -#define MODE_OPEN "0" -#define MODE_WPA "1" -#define MODE_WPA2 "2" -#define MODE_WEP "3" - //chn: 0=all, - // 2.4GHz 1...14, - // 5GHz 36,40,44,48,52,56,60,64,100,104,108,112,116,136,140,149,153,157,161,165 - //ret: OK... - -#define CMD_NETWORK "AT+RSI_NETWORK=" //INFRASTRUCTURE or IBSS,type,chn - //IBSS type: 0 indicates IBSS Joiner and 1 indicates IBSS Creator - //for Joiner mode, chn has to be 0 - -#define CMD_PSK "AT+RSI_PSK=" //Pre Shared Key, max length is 63 characters -#define CMD_PSK_WEP "AT+RSI_WEP_KEYS=" //3 WEP keys: key_index,key2,key3,key4 - -#define CMD_AUTHMODE "AT+RSI_AUTHMODE=" //auth mode -#define AUTHMODE_WEPOK "0" //WEP Open Key -#define AUTHMODE_WEPSK "1" //WEP Shared Key -#define AUTHMODE_WPA "2" //WPA -#define AUTHMODE_WPA2 "3" //WPA2 -#define AUTHMODE_OPEN "4" //No securtiy (open) - -#define CMD_JOIN "AT+RSI_JOIN=" //SSID,TxRate(1 byte),TxPower(1 byte) -#define JOIN_LOWPW ",0,0" //auto data rate, 7dBm -#define JOIN_MEDPW ",0,1" //auto data rate, 10dBm -#define JOIN_HIGHPW ",0,2" //auto data rate, 16...17dBm -#define JOIN_LOWPW1M ",1,0" //1 Mbps, 7dBm -#define JOIN_MEDPW1M ",1,1" //1 Mbps, 10dBm -#define JOIN_HIGHPW1M ",1,2" //1 Mbps, 16...17dBm -#define JOIN_LOWPW2M ",2,0" //2 Mbps, 7dBm -#define JOIN_MEDPW2M ",2,1" //2 Mbps, 10dBm -#define JOIN_HIGHPW2M ",2,2" //2 Mbps, 16...17dBm -#define JOIN_LOWPW11M ",4,0" //11 Mbps, 7dBm -#define JOIN_MEDPW11M ",4,1" //11 Mbps, 10dBm -#define JOIN_HIGHPW11M ",4,2" //11 Mbps, 16...17dBm -#define JOIN_LOWPW12M ",7,0" //12 Mbps, 7dBm -#define JOIN_MEDPW12M ",7,1" //12 Mbps, 10dBm -#define JOIN_HIGHPW12M ",7,2" //12 Mbps, 16...17dBm -#define JOIN_LOWPW24M ",9,0" //24 Mbps, 7dBm -#define JOIN_MEDPW24M ",9,1" //24 Mbps, 10dBm -#define JOIN_HIGHPW24M ",9,2" //24 Mbps, 16...17dBm -#define JOIN_LOWPW54M ",12,0" //54 Mbps, 7dBm -#define JOIN_MEDPW54M ",12,1" //54 Mbps, 10dBm -#define JOIN_HIGHPW54M ",12,2" //54 Mbps, 16...17dBm - //DataRate (Mbps)=TxRate - // auto=0, 1=1, 2=2, 5.5=3, 11=4, 6=5, 9=6, 12=7, 18=8, 24=9, 36=10, 48=11, 54=12 - // MCS0=13, MCS1=14, MCS2=15, MCS3=16, MCS4=17, MCS5=18, MCS6=19, MCS7=20 - //802.11n: 6.5, 13, 19.5, 26, 39, 52, 58.5, 65 Mbps - //802.11a/g: 6, 9, 12, 18, 24, 36, 48, 54 Mbps - //802.11b: 1, 2, 5.5, 11 Mbps - -#define CMD_DISCONN "AT+RSI_DISASSOC" //disassociate / disconnect - -#define CMD_PWMODE "AT+RSI_PWMODE=" //power mode 0, 1 or 2 - -#define CMD_SLEEPTIMER "AT+RSI_SLEEPTIMER=" //milliseconds, max 10000 - - -//TCP/IP Commands -/* -#define ERROR_1 (-1) //255 Waiting for the connection from peer. -#define ERROR_2 (-2) //254 Socket not available. -#define ERROR_3 (-3) //253 Deauthentication from the Access Point. -#define ERROR_4 (-4) //252 Illegal IP/Port parameters. -#define ERROR_5 (-5) //251 TCP/IP configuration failure. -#define ERROR_6 (-6) //250 Invalid socket. -#define ERROR_7 (-7) //249 Association not done. -#define ERROR_8 (-8) //248 Error in cmd. -#define ERROR_9 (-9) //247 Error with byte stuffing for escape characters. -#define ERROR_10 (-10) //246 IP Lease expired. -#define ERROR_11 (-11) //245 TCP Connection closed. -#define ERROR_12 (-12) //244 Pre-Shared Key not set for connection to a secure Access Point. -#define ERROR_13 (-13) //243 No Access Points scanned -#define ERROR_14 (-14) //242 INIT cmd already issued. This error is sent when the INIT cmd is sent more than once. -#define ERROR_15 (-15) //241 JOIN cmd already issued. This error is sent when the JOIN cmd is sent more than once. -#define ERROR_16 (-16) //240 DHCP Failure. -#define ERROR_17 (-17) //239 Baud Rate Not Supported. -*/ - -#define CMD_IPCONF "AT+RSI_IPCONF=" //DHCP_MODE(0=manual, 1=DHCP),IP,SUBNET,GATEWAY - //ret: OKMACaddrIPaddrSUBNETGateway -#define IPCONF_DHCP "1,0,0" -#define IPCONF_AUTOIP "2,0,0" - -#define CMD_DNSSERVER "AT+RSI_DNSSERVER=" //DNS server - //ret: OK - -#define CMD_DNSGET "AT+RSI_DNSGET=" // DNS Resolution - //ret: OKx... - // x = number of IP addresses - -#define CMD_TCP "AT+RSI_TCP=" //host,port,lport //Open and Connect to a TCP Socket - //ret: OKsock_handle - -#define CMD_LTCP "AT+RSI_LTCP=" //lport //Open a Listening TCP Socket - //ret: OKsock_handle - -#define CMD_UDP "AT+RSI_UDP=" //host,port,lport //Open a UDP Socket - //ret: OKsock_handle - -#define CMD_LUDP "AT+RSI_LUDP=" //lport //Open a Listening UDP Socket - //ret: OKsock_handle - -#define CMD_MCAST "AT+RSI_ MULTICAST=" //host,port,lport //Open a Multicast Socket - //ret: OKsock_handle - -#define CMD_CTCP "AT+RSI_CTCP=" //hn //Get a Listening socket's active conn. status - //ret: OKChnIP_AddressPort - // Chn >=0: A handle to an active connected socket - // Chn =-1: No connection has been established - -#define CMD_CLS "AT+RSI_CLS=" //hn //Close a Socket - //ret: OK - -#define CMD_SEND "AT+RSI_SND=" //hn,sz,Dip,Dport,Data //Send a byte stream to a Socket - //ret: OKsz (sz in 2bytes) - -#define CMD_READ "AT+RSI_READ" //hn,sz,Sip,Sport,Data //Receive a byte stream on a Socket - - -#endif //REDFLYCOMMANDS_h diff --git a/arduino/libs/RedFly/RedFlyNBNS.cpp b/arduino/libs/RedFly/RedFlyNBNS.cpp deleted file mode 100644 index cfa75c756..000000000 --- a/arduino/libs/RedFly/RedFlyNBNS.cpp +++ /dev/null @@ -1,229 +0,0 @@ -#include -#if defined(__AVR__) -# include -#endif -#if ARDUINO >= 100 -# include "Arduino.h" -#else -# include "WProgram.h" -#endif -#include "RedFly.h" -#include "RedFlyNBNS.h" - - -//NBNS Question -#define NBNSQ_PACKETLEN (38) -#define NBNSQ_TYPE_NB (0x0020) -#define NBNSQ_CLASS_IN (0x0001) -typedef struct __attribute__((packed)) -{ - uint8_t len : 8; // 8bit Len: 32 - char name[33]; //33byte Name + null - uint16_t type : 16; //16bit Type - uint16_t clas : 16; //16bit Class -} NBNS_Question; - -//NBNS Answer -#define NBNSA_PACKETLEN (50) -#define NBNSA_TYPE_NB (0x0020) -#define NBNSA_CLASS_IN (0x0001) -typedef struct __attribute__((packed)) -{ - uint8_t len : 8; // 8bit Len: 32 - char name[33]; //33byte Name + null - uint16_t type : 16; //16bit Type - uint16_t clas : 16; //16bit Class - uint32_t ttl : 32; //32bit Time to live - uint16_t rdlen : 16; //16bit Data len - uint16_t flags : 16; //16bit Flags - rdata - uint8_t addr[4]; //32bit IP Addr - rdata -} NBNS_Answer; - -//NBNS (NetBIOS Name Service) -#define NBNS_PORT (137) -#define NBNS_PACKETLEN (12) -#define NBNS_OPMASK (0x7800) -#define NBNS_REPLYMASK (0x000F) -#define NBNS_FLAG_RESPONSE (1<<15) -#define NBNS_FLAG_QUERY (0<<15) -#define NBNS_FLAG_AUTHORITY (1<<10) -#define NBNS_OP_QUERY (0<<11) -typedef struct __attribute__((packed)) -{ - uint16_t id : 16; //16bit Transaction ID - uint16_t flags_op : 16; //16bit Flags - uint16_t qdcount : 16; //16bit Question Entries - uint16_t ancount : 16; //16bit Answer RRs - uint16_t nscount : 16; //16bit Authority RRs - uint16_t arcount : 16; //16bit Additional RRs - union - { - NBNS_Question qd; - NBNS_Answer an; - } data; -} NBNS_Packet; - - -//-------------------- Constructor/Destructor -------------------- - - -RedFlyNBNS::RedFlyNBNS(void) : RedFlyServer(NBNS_PORT) -{ - strcpy(devname, "REDFLY"); - - return; -} - - -RedFlyNBNS::RedFlyNBNS(char *name) : RedFlyServer(NBNS_PORT) -{ - strcpy(devname, name); - - return; -} - - -RedFlyNBNS::~RedFlyNBNS(void) -{ - stop(); - - return; -} - - -//-------------------- Public -------------------- - - -void RedFlyNBNS::setName(char *name) -{ - strcpy(devname, name); - - return; -} - - -#if defined(__AVR__) -void RedFlyNBNS::setNamePGM(PGM_P name) -{ - strcpy_P(devname, name); - - return; -} -#endif - - -#define SWAP16(x) ((((x)&0x00FF)<<8)| \ - (((x)&0xFF00)>>8)) -#define SWAP32(x) ((((x)&0xFF000000UL)>>24)| \ - (((x)&0x00FF0000UL)>> 8)| \ - (((x)&0x0000FF00UL)<< 8)| \ - (((x)&0x000000FFUL)<<24)) -uint8_t RedFlyNBNS::service(void) -{ - uint16_t len; - uint8_t buf[NBNS_PACKETLEN+NBNSA_PACKETLEN]; - NBNS_Packet *nbns; - char name[16+1]; - uint8_t type; - - if(!connected()) //listening port still open? - { - stop(); //stop and reset server - beginUDP(); //start server - return 1; - } - - //data available? - len = available(); - if(len >= (NBNS_PACKETLEN+NBNSQ_PACKETLEN)) - { - //read data - read(buf, sizeof(buf)); - flush(); //flush input buffer - //check data for NBNS header and question - nbns = (NBNS_Packet*) buf; - if((nbns->qdcount == SWAP16(0x0001)) && - (nbns->data.qd.len == 32) && - (nbns->data.qd.type == SWAP16(NBNSQ_TYPE_NB)) && - (nbns->data.qd.clas == SWAP16(NBNSQ_CLASS_IN))) //NBNS question - { - type = decode(name, nbns->data.qd.name); - if((type == 0x00) && (strcasecmp(name, devname) == 0))//0x00 = Workstation - { - //create NBNS answer - nbns->id = nbns->id; - nbns->flags_op = SWAP16(NBNS_FLAG_RESPONSE|NBNS_FLAG_AUTHORITY); - nbns->qdcount = SWAP16(0x0000); - nbns->ancount = SWAP16(0x0001); - nbns->nscount = SWAP16(0x0000); - nbns->arcount = SWAP16(0x0000); - nbns->data.an.len = 32; - nbns->data.an.type = SWAP16(NBNSA_TYPE_NB); - nbns->data.an.clas = SWAP16(NBNSA_CLASS_IN); - nbns->data.an.ttl = SWAP32(3600); //time to live 3600 sec = 1 hour - nbns->data.an.rdlen = SWAP16(0x0006); - nbns->data.an.flags = SWAP16(0x0000); - RedFly.getlocalip(nbns->data.an.addr); - encode(nbns->data.an.name, devname, 0x00); //0x00 = Workstation - nbns->data.an.name[32] = 0; - //send answer - write(buf, NBNS_PACKETLEN+NBNSA_PACKETLEN); - return 0xFF; - } - } - } - - return 0; -} - - -//-------------------- Private -------------------- - - -uint8_t RedFlyNBNS::decode(char *dst, char *src) -{ - uint8_t i, j; - char c; - - for(i=0, j=0; i<15; i++) - { - c = (src[j++]-'A')<<4; - c |= (src[j++]-'A')<<0; - if(c == ' ') - { - break; - } - dst[i] = toupper(c); - } - dst[i] = 0; - - return (((src[30]-'A')<<4)|(src[31]-'A')); //0x00 = Workstation -} - - -void RedFlyNBNS::encode(char *dst, char *src, uint8_t type) -{ - uint8_t i, j; - char c; - - //encode name - for(i=0, j=0; (i<15) && src[i]; i++) - { - c = toupper(src[i]); - dst[j++] = 'A'+((c>>4)&0x0f); - dst[j++] = 'A'+((c>>0)&0x0f); - } - - //add spaces - for(; i<15; i++) - { - dst[j++] = 'A'+((' '>>4)&0x0f); - dst[j++] = 'A'+((' '>>0)&0x0f); - } - - //set type (0x00 = Workstation) - dst[j++] = 'A'+((type>>4)&0x0f); - dst[j++] = 'A'+((type>>0)&0x0f); - - return; -} diff --git a/arduino/libs/RedFly/RedFlyNBNS.h b/arduino/libs/RedFly/RedFlyNBNS.h deleted file mode 100644 index 285a0cc76..000000000 --- a/arduino/libs/RedFly/RedFlyNBNS.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef REDFLYNBNS_h -#define REDFLYNBNS_h - - -#include -#if defined(__AVR__) -# include -#endif -#include "RedFlyServer.h" - - -class RedFlyNBNS : RedFlyServer -{ - public: - RedFlyNBNS(void); - RedFlyNBNS(char *name); - ~RedFlyNBNS(void); - - void setName(char *name); -#if defined(__AVR__) - void setNamePGM(PGM_P name); -#endif - uint8_t service(void); - - private: - char devname[16+1]; - - uint8_t decode(char *dst, char *src); - void encode(char *dst, char *src, uint8_t type); -}; - - -#endif //REDFLYNBNS_h diff --git a/arduino/libs/RedFly/RedFlyServer.cpp b/arduino/libs/RedFly/RedFlyServer.cpp deleted file mode 100644 index 1181835fd..000000000 --- a/arduino/libs/RedFly/RedFlyServer.cpp +++ /dev/null @@ -1,392 +0,0 @@ -#include -#if defined(__AVR__) -# include -#endif -#if ARDUINO >= 100 -# include "Arduino.h" -#else -# include "WProgram.h" -#endif -#include "RedFly.h" -#include "RedFlyServer.h" - - -#define MAX_ERRORS (10) - - -//-------------------- Constructor/Destructor -------------------- - - -RedFlyServer::RedFlyServer(void) -{ - s_port = 80; - s_socket = INVALID_SOCKET; - - return; -} - - -RedFlyServer::RedFlyServer(uint16_t port) -{ - s_port = port; - s_socket = INVALID_SOCKET; - - return; -} - - -RedFlyServer::~RedFlyServer(void) -{ - stop(); - - return; -} - - -//-------------------- Public -------------------- - - -void RedFlyServer::begin(void) -{ - connectSocket(PROTO_TCP); - - return; -} - - -void RedFlyServer::beginUDP(void) -{ - connectSocket(PROTO_UDP); - - return; -} - - -int RedFlyServer::connect(void) -{ - return connectSocket(PROTO_TCP); -} - - -int RedFlyServer::connectUDP(void) -{ - return connectSocket(PROTO_UDP); -} - - -int RedFlyServer::connect(uint16_t port) -{ - s_port = port; - - return connectSocket(PROTO_TCP); -} - - -int RedFlyServer::connectUDP(uint16_t port) -{ - s_port = port; - - return connectSocket(PROTO_UDP); -} - - -int RedFlyServer::connectSocket(uint8_t p) -{ - if(s_socket != INVALID_SOCKET) - { - return 0; - } - - s_socket = RedFly.socketListen(p, s_port); - - if(s_socket == INVALID_SOCKET) - { - return 0; - } - - c_ip[0] = 0; - c_ip[1] = 0; - c_ip[2] = 0; - c_ip[3] = 0; - c_port = 0; - proto = p; - error = 0; - - return 1; -} - - -uint8_t RedFlyServer::connected(void) -{ - if(s_socket == INVALID_SOCKET) - { - return 0; - } - - if(RedFly.socketClosed(s_socket)) //socket closed? - { - s_socket = INVALID_SOCKET; - return 0; - } - - if(error >= MAX_ERRORS) - { - RedFly.socketClose(s_socket); - s_socket = INVALID_SOCKET; - return 0; - } - - return 1; -} - - -void RedFlyServer::stop(void) -{ - if(s_socket == INVALID_SOCKET) - { - return; - } - - flush(); //clear buffer - - RedFly.socketClose(s_socket); - s_socket = INVALID_SOCKET; - error = 0; - - return; -} - - -uint8_t RedFlyServer::status(void) -{ - if(s_socket == INVALID_SOCKET) - { - return 1; - } - - if(RedFly.socketStatus(s_socket)) //socket closed? - { - s_socket = INVALID_SOCKET; - return 1; - } - - return 0; -} - - -uint8_t RedFlyServer::getsocket(void) -{ - return s_socket; -} - - -void RedFlyServer::getip(uint8_t *ip) -{ - ip[0] = c_ip[0]; - ip[1] = c_ip[1]; - ip[2] = c_ip[2]; - ip[3] = c_ip[3]; - - return; -} - - -uint16_t RedFlyServer::getport(void) -{ - return c_port; -} - - -int RedFlyServer::available(void) -{ - uint8_t socket=s_socket; - uint16_t len=0; - - if(socket != INVALID_SOCKET) - { - RedFly.socketRead(&socket, &len, 0, 0); - } - - return (int)len; -} - - -int RedFlyServer::read(void) -{ - uint8_t b; - uint8_t socket=s_socket; - uint16_t len, rd; - - if(socket == INVALID_SOCKET) - { - return -1; - } - - if(RedFly.socketState(socket) == SOCKET_UDP) - { - rd = RedFly.socketRead(&socket, &len, c_ip, &c_port, &b, 1); - } - else - { - rd = RedFly.socketRead(&socket, &len, &b, 1); - } - if(rd == 0) - { - return -1; - } - if(rd == 0xFFFF) //socket closed? - { - s_socket = INVALID_SOCKET; - return -1; - } - - return b; -} - - -int RedFlyServer::read(uint8_t *s, size_t sz) -{ - int c, rd; - - for(rd=0; sz;) - { - c = read(); - if(c != -1) - { - *s++ = (uint8_t)c; - sz--; - rd++; - } - else - { - break; - } - } - - return rd; -} - - -void RedFlyServer::flush(void) -{ - for(int len=available(); len!=0; len--) - { - read(); - } - - return; -} - - -size_t RedFlyServer::write(uint8_t b) -{ - if(s_socket != INVALID_SOCKET) - { - if(RedFly.socketSend(s_socket, (uint8_t*)&b, 1, c_ip, c_port)) - { - if(++error >= MAX_ERRORS) - { - RedFly.socketClose(s_socket); - s_socket = INVALID_SOCKET; - } - } - else - { - error = 0; - return 1; - } - } - - return 0; -} - - -size_t RedFlyServer::write(const char *s) -{ - if(s_socket != INVALID_SOCKET) - { - if(RedFly.socketSend(s_socket, (char*)s, c_ip, c_port)) - { - if(++error >= MAX_ERRORS) - { - RedFly.socketClose(s_socket); - s_socket = INVALID_SOCKET; - } - } - else - { - error = 0; - return strlen(s); - } - } - - return 0; -} - - -size_t RedFlyServer::write(const uint8_t *s, size_t size) -{ - if(s_socket != INVALID_SOCKET) - { - if(RedFly.socketSend(s_socket, (uint8_t*)s, size, c_ip, c_port)) - { - if(++error >= MAX_ERRORS) - { - RedFly.socketClose(s_socket); - s_socket = INVALID_SOCKET; - } - } - else - { - error = 0; - return size; - } - } - - return 0; -} - - -size_t RedFlyServer::print_P(PGM_P s) -{ - if(s_socket != INVALID_SOCKET) - { - if(RedFly.socketSendPGM(s_socket, s, c_ip, c_port)) - { - if(++error >= MAX_ERRORS) - { - RedFly.socketClose(s_socket); - s_socket = INVALID_SOCKET; - } - } - else - { - error = 0; - return strlen_P(s); - } - } - - return 0; -} - - -size_t RedFlyServer::println_P(PGM_P s) -{ - size_t len; - - len = print_P(s); - if(len) - { - len += print_P(PSTR("\r\n")); - } - - return len; -} - - -//the next function allows us to use the client returned by -//RedFlyServer::available() as the condition in an if-statement. -RedFlyServer::operator bool() -{ - return s_socket != INVALID_SOCKET; -} diff --git a/arduino/libs/RedFly/RedFlyServer.h b/arduino/libs/RedFly/RedFlyServer.h deleted file mode 100644 index 478af0a06..000000000 --- a/arduino/libs/RedFly/RedFlyServer.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef REDFLYSERVER_h -#define REDFLYSERVER_h - - -#include -#if defined(__AVR__) -# include -#endif -#include "Print.h" -#include "RedFly.h" -#include "Server.h" - - -class RedFlyServer : public Server -{ - public: - RedFlyServer(void); - RedFlyServer(uint16_t port); - ~RedFlyServer(void); - - virtual void begin(void); //same as connect() - virtual void beginUDP(void); //same as connect() - virtual int connect(void); - virtual int connectUDP(void); - virtual int connect(uint16_t port); - virtual int connectUDP(uint16_t port); - int connectSocket(uint8_t p); - virtual uint8_t connected(void); - virtual void stop(void); - uint8_t status(void); - uint8_t getsocket(void); - void getip(uint8_t *ip); - uint16_t getport(void); - - virtual int available(void); - virtual int read(void); - virtual int read(uint8_t *s, size_t sz); - //virtual int peek(void); //not available - virtual void flush(void); - virtual size_t write(uint8_t b); - virtual size_t write(const char *s); - virtual size_t write(const uint8_t *s, size_t sz); - virtual size_t print_P(PGM_P s); - virtual size_t println_P(PGM_P s); - - virtual operator bool(); - - using Print::write; - - private: - uint16_t s_port; - uint8_t s_socket; - uint8_t c_ip[4]; - uint16_t c_port; - uint8_t proto, error; -}; - - -#endif //REDFLYSERVER_h diff --git a/arduino/libs/SHT1x b/arduino/libs/SHT1x deleted file mode 160000 index be7042c3e..000000000 --- a/arduino/libs/SHT1x +++ /dev/null @@ -1 +0,0 @@ -Subproject commit be7042c3e3cb32c778b9c9ca270b3df57f769ea5 diff --git a/arduino/measure-voltage/Makefile b/arduino/measure-voltage/Makefile deleted file mode 100644 index e14496e44..000000000 --- a/arduino/measure-voltage/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -BOARD_TAG = leonardo -ISP_PROG = gpio -ISP_PORT = /dev/ttyACM0 -MONITOR_PORT = /dev/ttyACM0 -AVRDUDE = /usr/bin/avrdude -AVRDUDE_CONF = /etc/avrdude.conf - -include /usr/share/arduino/Arduino.mk diff --git a/arduino/measure-voltage/measure-voltage.ino b/arduino/measure-voltage/measure-voltage.ino deleted file mode 100644 index eea565192..000000000 --- a/arduino/measure-voltage/measure-voltage.ino +++ /dev/null @@ -1,12 +0,0 @@ -/* - print voltage on A0 - */ - -void setup() { - Serial.begin(9600); -} - -void loop() { - Serial.println(analogRead(A0) * (5.0 / 1023.0)); - delay(1000); -} diff --git a/arduino/mma7455/MMA_7455.cpp b/arduino/mma7455/MMA_7455.cpp deleted file mode 100644 index 4b509ba26..000000000 --- a/arduino/mma7455/MMA_7455.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// MMA_7455.cpp - 3 Axis Accelerometer Library -// Moritz Kemper, IAD Physical Computing Lab -// moritz.kemper@zhdk.ch -// ZHdK, 03/04/2012 -// Released under Creative Commons Licence - -#include "MMA_7455.h" - -#define MMA_7455_ADDRESS 0x1D //I2C Adress for the sensor -#define MMA_7455_MODE_CONTROLL 0x16 //Call the sensors Mode Control - -#define MMA_7455_2G_MODE 0x05 //Set Sensitivity to 2g -#define MMA_7455_4G_MODE 0x09 //Set Sensitivity to 4g -#define MMA_7455_8G_MODE 0x01 //Set Sensitivity to 8g - -#define X_OUT 0x06 //Register for reading the X-Axis -#define Y_OUT 0x07 //Register for reading the Y-Axis -#define Z_OUT 0x08 //Register for reading the Z-Axis - -MMA_7455::MMA_7455() -{ - Wire.begin(); -} - -void MMA_7455::initSensitivity(int sensitivity) -{ - delay(1000); - Wire.beginTransmission(MMA_7455_ADDRESS); - Wire.write(MMA_7455_MODE_CONTROLL); - if(sensitivity == 2) - { - Wire.write(MMA_7455_2G_MODE); //Set Sensitivity to 2g Detection - } - if(sensitivity == 4) - { - Wire.write(MMA_7455_2G_MODE); //Set Sensitivity to 4g Detection - } - if(sensitivity == 8) - { - Wire.write(MMA_7455_2G_MODE); //Set Sensitivity to 8g Detection - } - Wire.endTransmission(); - delay(1000); -} - -void MMA_7455::calibrateOffset(float x_axis_offset, float y_axis_offset, float z_axis_offset) -{ - _x_axis_offset = x_axis_offset; - _y_axis_offset = y_axis_offset; - _z_axis_offset = z_axis_offset; -} -unsigned char MMA_7455::readAxis(char axis) -{ - Wire.beginTransmission(MMA_7455_ADDRESS); - if(axis == 'x' || axis == 'X') - { - Wire.write(X_OUT); - } - if(axis == 'y' || axis == 'Y') - { - Wire.write(Y_OUT); - } - if(axis == 'z' || axis == 'Z') - { - Wire.write(Z_OUT); - } - Wire.endTransmission(); - Wire.beginTransmission(MMA_7455_ADDRESS); - Wire.requestFrom(MMA_7455_ADDRESS, 1); - if(Wire.available()) - { - _buffer = Wire.read(); - } - if(axis == 'x' || axis == 'X') - { - _buffer = _buffer + _x_axis_offset; - } - if(axis == 'y' || axis == 'Y') - { - _buffer = _buffer + _y_axis_offset; - } - if(axis == 'z' || axis == 'Z') - { - _buffer = _buffer + _z_axis_offset; - } - - return _buffer; -} diff --git a/arduino/mma7455/MMA_7455.h b/arduino/mma7455/MMA_7455.h deleted file mode 100644 index 5ca387a98..000000000 --- a/arduino/mma7455/MMA_7455.h +++ /dev/null @@ -1,27 +0,0 @@ -// MMA_7455.h - 3 Axis Accelerometer Library -// Moritz Kemper, IAD Physical Computing Lab -// moritz.kemper@zhdk.ch -// ZHdK, 03/04/2012 -// Released under Creative Commons Licence - -#ifndef MMA_7455_h -#define MMA_7455_h - -#include "Arduino.h" -#include "Wire.h" - -class MMA_7455 -{ - public: - MMA_7455(); - void initSensitivity(int sensitivity); - void calibrateOffset(float x_axis_offset, float y_axis_offset, float z_axis_offset); - unsigned char readAxis(char axis); - private: - unsigned char _buffer; - float _x_axis_offset; - float _y_axis_offset; - float _z_axis_offset; -}; - -#endif diff --git a/arduino/mma7455/mma7455.ino b/arduino/mma7455/mma7455.ino deleted file mode 100644 index 8cd36a592..000000000 --- a/arduino/mma7455/mma7455.ino +++ /dev/null @@ -1,59 +0,0 @@ -// Example which uses the MMA_7455 library -// Moritz Kemper, IAD Physical Computing Lab -// moritz.kemper@zhdk.ch -// ZHdK, 03/04/2012 -// Released under Creative Commons Licence - -#include //Include the Wire library -#include "MMA_7455.h" //Include the MMA_7455 library - -MMA_7455 mySensor = MMA_7455(); //Make an instance of MMA_7455 - -long xVal, yVal, zVal; //Variables for the values from the sensor -long xVal_base, yVal_base, zVal_base; - -long cnt = 0; - -void setup() -{ - Serial.begin(9600); - // Set the sensitivity you want to use - // 2 = 2g, 4 = 4g, 8 = 8g - mySensor.initSensitivity(2); - // Calibrate the Offset, that values corespond in - // flat position to: xVal = -30, yVal = -20, zVal = +20 - // !!!Activate this after having the first values read out!!! - mySensor.calibrateOffset(0, 0, 0); - - xVal = 0; - yVal = 0; - zVal = 0; - - xVal_base = mySensor.readAxis('x'); //Read out the 'x' Axis - yVal_base = mySensor.readAxis('y'); //Read out the 'y' Axis - zVal_base = mySensor.readAxis('z'); //Read out the 'z' Axis - - Serial.print("start"); -} - -void loop() -{ - cnt++; - xVal += abs(mySensor.readAxis('x') - xVal_base); //Read out the 'x' Axis - yVal += abs(mySensor.readAxis('y') - yVal_base); //Read out the 'y' Axis - zVal += abs(mySensor.readAxis('z') - zVal_base); //Read out the 'z' Axis - - if (cnt > 99) { - Serial.print("x: "); - Serial.println(xVal, 10); - Serial.print("y: "); - Serial.println(yVal, 10); - Serial.print("z: "); - Serial.println(zVal, 10); - cnt = 0; - xVal = 0; - yVal = 0; - zVal = 0; - } - delay(1); -} diff --git a/arduino/ppd42ns-redflywifi/.gitignore b/arduino/ppd42ns-redflywifi/.gitignore deleted file mode 100644 index 713ba9626..000000000 --- a/arduino/ppd42ns-redflywifi/.gitignore +++ /dev/null @@ -1 +0,0 @@ -sensor_id.h diff --git a/arduino/ppd42ns-redflywifi/Makefile b/arduino/ppd42ns-redflywifi/Makefile deleted file mode 100644 index f1bf43c17..000000000 --- a/arduino/ppd42ns-redflywifi/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -BOARD_TAG = leonardo -ISP_PROG = gpio -ISP_PORT = /dev/ttyACM0 -MONITOR_PORT = /dev/ttyACM0 -AVRDUDE = /usr/bin/avrdude -AVRDUDE_CONF = /etc/avrdude.conf - -ARDUINO_LIBS = RedFly -USER_LIB_PATH = ../libs - -include /usr/share/arduino/Arduino.mk diff --git a/arduino/ppd42ns-redflywifi/ppd42ns-redflywifi.ino b/arduino/ppd42ns-redflywifi/ppd42ns-redflywifi.ino deleted file mode 100644 index 4c81ec1df..000000000 --- a/arduino/ppd42ns-redflywifi/ppd42ns-redflywifi.ino +++ /dev/null @@ -1,286 +0,0 @@ -/* - Shinyei PPD42NS Particle Sensor - publish via redfly-wifi-shield - - specification: http://www.sca-shinyei.com/pdf/PPD42NS.pdf - - pin 1 (grey) -> Arduino GND - pin 3 (black) -> Arduino 5V - pin 2 (green) -> Arduino Pin 9 - pin 4 (white) -> Arduino Pin 8 - pin 5 (red) -> unused! - -*/ - - -/* ATTENTION: - - THIS CODE FAILS ON A LEONARDO + RedFly-Wifi-Shield with a DNS ERR. - Or a JOIN ERR or a BEGIN ERR. But the best was DNS ERR. - - */ - - -#include -#include - -// to store the secret ID used to authenticate the sensor -#include "sensor_id.h" - -byte server[] = {104, 31, 92, 177 }; -#define HOSTNAME "api.dusti.xyz" //host - -unsigned int len=0; //receive buffer length -int sensor[100]; -int count = 0; - -RedFlyClient client(server, 80); - -/* sensor variables */ - -boolean valP1 = HIGH; -boolean valP2 = HIGH; - -unsigned long starttime; -unsigned long durationP1; -unsigned long durationP2; - -boolean trigP1 = false; -boolean trigP2 = false; -unsigned long trigOnP1; -unsigned long trigOnP2; - -unsigned long sampletime_ms = 15000; -unsigned long lowpulseoccupancyP1 = 0; -unsigned long lowpulseoccupancyP2 = 0; -unsigned long counter = 0; - - -String Float2String(float value) -{ - // Convert a float to String with two decimals. - String s; - s = String(int(value)); - s += '.'; - s += int((value - int(value)) * 100); - - return s; -} - - -void setup() { - Serial.begin(9600); - pinMode(8,INPUT); - pinMode(9,INPUT); - starttime = millis(); -} - - -void sendData(const String& sensor_id, - const String& data) { - - char buffer[1000]; - String ln; - - Serial.println("start sending ..."); - - client.print_P(PSTR("POST /v1/push-sensor-data/ HTTP/1.1\n")); - - client.print_P(PSTR("Host: api.dusti.xyz\n")); - client.print_P(PSTR("Sensor: ")); - sensor_id.toCharArray(buffer, sensor_id.length()+1); - client.println(buffer); - - client.println_P(PSTR("User-Agent: Arduino")); - client.println_P(PSTR("Accept: text/html")); - client.print_P(PSTR("Content-Length: ")); - ln = String(data.length(), DEC); - ln.toCharArray(buffer, ln.length()+1); - client.println(buffer); - - client.print_P(PSTR("Content-Type: text/json\n")); - client.println_P(PSTR("Connection: close\n")); - - data.toCharArray(buffer, data.length()+1); - client.println(buffer); - - counter += 1; - Serial.println("sent..."); -} - - -int send_data_via_wifi(const String& data) -{ - uint8_t ret; - String sensor_id; - uint8_t c_ip[4]; - - Serial.println("wifi connect start"); - //init the WiFi module on the shield - ret = RedFly.init(); - if(ret) - { - Serial.println("INIT ERR"); //there are problems with the communication between the Arduino and the RedFly - } - else - { - //scan for wireless networks (must be run before join command) - RedFly.scan(); - - //join network - ret = RedFly.join("Freifunk"); - if(ret) - { - Serial.println("JOIN ERR"); - // try again later - return 1; - } - else - { - //set ip config - ret = RedFly.begin(); //DHCP - if(ret) - { - Serial.println("BEGIN ERR"); - RedFly.disconnect(); - // try again later - return 1; - } - else - { - RedFly.getlocalip(c_ip); - Serial.print(c_ip[0]); - Serial.print("-"); - Serial.print(c_ip[1]); - Serial.print("-"); - Serial.print(c_ip[2]); - Serial.print("-"); - Serial.print(c_ip[3]); - Serial.print("\n"); - - if(RedFly.getip(HOSTNAME, server) == 0) //get ip - { - if(client.connect(server, 80)) - { - sensor_id = String(SENSOR_ID) + String("PPD42NS"); - sendData(sensor_id, data); - } - else - { - Serial.println("CLIENT ERR"); - RedFly.disconnect(); - // try again later - return 1; - } - } - else - { - Serial.println("DNS ERR"); - RedFly.disconnect(); - // try again later - return 1; - } - } - } - - } - Serial.println("senddata end"); - return 0; -} - - -void loop() { - int ret; - int c; - String data; - char receive[512]; //receive buffer - - float ratio = 0; - float concentration = 0; - - valP1 = digitalRead(8); - valP2 = digitalRead(9); - - if(valP1 == LOW && trigP1 == false){ - trigP1 = true; - trigOnP1 = micros(); - } - - if (valP1 == HIGH && trigP1 == true){ - durationP1 = micros() - trigOnP1; - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1; - trigP1 = false; - } - - if(valP2 == LOW && trigP2 == false){ - trigP2 = true; - trigOnP2 = micros(); - } - - if (valP2 == HIGH && trigP2 == true){ - durationP2 = micros() - trigOnP2; - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2; - trigP2 = false; - } - - if ((millis() - starttime) > sampletime_ms) - { - ratio = lowpulseoccupancyP1/(sampletime_ms*10.0); // int percentage 0 to 100 - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // spec sheet curve - - data = "{"; - data += "\"durP1\":"; - data += Float2String(lowpulseoccupancyP1); - data += "\";ratioP1\":"; - data += Float2String(ratio); - data += "\";P1\":"; - data += Float2String(concentration); - - ratio = lowpulseoccupancyP2/(sampletime_ms*10.0); - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; - - data += "\";durP2\":"; - data += Float2String(lowpulseoccupancyP2); - data += "\";ratioP2\":"; - data += Float2String(ratio); - data += "\";P2\":"; - data += Float2String(concentration); - data += "}"; - - // send data to API - send_data_via_wifi(data); - } - - //if there are incoming bytes available - //from the server then read them - if(client.available()) - { - do - { - c = client.read(); - if((c != -1) && (len < (sizeof(receive)-1))) - { - receive[len++] = c; - } - }while(c != -1); - } - - //if the server's disconnected, stop the client and print the received data - if(len && !client.connected()) - { - client.stop(); - RedFly.disconnect(); - - receive[len] = 0; - Serial.print(receive); - - len = 0; - - // IMPORTANT: - // start again after disconnect, so no http interaction can harm data collection - lowpulseoccupancyP1 = 0; - lowpulseoccupancyP2 = 0; - starttime = millis(); - } - -} diff --git a/arduino/ppd42ns-redflywifi/sensor_id.h-template b/arduino/ppd42ns-redflywifi/sensor_id.h-template deleted file mode 100644 index 6731e0943..000000000 --- a/arduino/ppd42ns-redflywifi/sensor_id.h-template +++ /dev/null @@ -1 +0,0 @@ -#define SENSOR_ID "arduino-RANDOM-SECRET-" diff --git a/arduino/ppd42ns-serial/Makefile b/arduino/ppd42ns-serial/Makefile deleted file mode 100644 index e14496e44..000000000 --- a/arduino/ppd42ns-serial/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -BOARD_TAG = leonardo -ISP_PROG = gpio -ISP_PORT = /dev/ttyACM0 -MONITOR_PORT = /dev/ttyACM0 -AVRDUDE = /usr/bin/avrdude -AVRDUDE_CONF = /etc/avrdude.conf - -include /usr/share/arduino/Arduino.mk diff --git a/arduino/ppd42ns-serial/ppd42ns-serial.ino b/arduino/ppd42ns-serial/ppd42ns-serial.ino deleted file mode 100644 index d544ab5fb..000000000 --- a/arduino/ppd42ns-serial/ppd42ns-serial.ino +++ /dev/null @@ -1,92 +0,0 @@ -/* - Shinyei PPD42NS Particle Sensor - publish via serial and raspberry pi/python - - specification: http://www.sca-shinyei.com/pdf/PPD42NS.pdf - - pin 1 (grey) -> Arduino GND - pin 3 (black) -> Arduino 5V - pin 2 (green) -> Arduino Pin 9 - pin 4 (white) -> Arduino Pin 8 - pin 5 (red) -> unused! - -*/ - -boolean valP1 = HIGH; -boolean valP2 = HIGH; - -unsigned long starttime; -unsigned long durationP1; -unsigned long durationP2; - -boolean trigP1 = false; -boolean trigP2 = false; -unsigned long trigOnP1; -unsigned long trigOnP2; - -unsigned long sampletime_ms = 15000; -unsigned long lowpulseoccupancyP1 = 0; -unsigned long lowpulseoccupancyP2 = 0; - -void setup() { - Serial.begin(9600); - pinMode(8,INPUT); - pinMode(9,INPUT); - starttime = millis(); -} - -void loop() { - float ratio = 0; - float concentration = 0; - - valP1 = digitalRead(8); - valP2 = digitalRead(9); - - if(valP1 == LOW && trigP1 == false){ - trigP1 = true; - trigOnP1 = micros(); - } - - if (valP1 == HIGH && trigP1 == true){ - durationP1 = micros() - trigOnP1; - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1; - trigP1 = false; - } - - if(valP2 == LOW && trigP2 == false){ - trigP2 = true; - trigOnP2 = micros(); - } - - if (valP2 == HIGH && trigP2 == true){ - durationP2 = micros() - trigOnP2; - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2; - trigP2 = false; - } - - if ((millis()-starttime) > sampletime_ms) - { - ratio = lowpulseoccupancyP1/(sampletime_ms*10.0); // int percentage 0 to 100 - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // spec sheet curve - Serial.print("lowpulseoccupancyP1:"); - Serial.print(lowpulseoccupancyP1); - Serial.print(";ratioP1:"); - Serial.print(ratio); - Serial.print(";countP1:"); - Serial.print(concentration); - - ratio = lowpulseoccupancyP2/(sampletime_ms*10.0); - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; - - Serial.print(";lowpulseoccupancyP2:"); - Serial.print(lowpulseoccupancyP2); - Serial.print(";ratioP2:"); - Serial.print(ratio); - Serial.print(";countP2:"); - Serial.println(concentration); - - lowpulseoccupancyP1 = 0; - lowpulseoccupancyP2 = 0; - starttime = millis(); - } -} diff --git a/arduino/ppd42ns-sht10-serial/Makefile b/arduino/ppd42ns-sht10-serial/Makefile deleted file mode 100644 index 0b2ee36cb..000000000 --- a/arduino/ppd42ns-sht10-serial/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -BOARD_TAG = leonardo -ISP_PROG = gpio -ISP_PORT = /dev/ttyACM0 -MONITOR_PORT = /dev/ttyACM0 -AVRDUDE = /usr/bin/avrdude -AVRDUDE_CONF = /etc/avrdude.conf - -ARDUINO_LIBS = SHT1x -USER_LIB_PATH = ../libs - -include /usr/share/arduino/Arduino.mk diff --git a/arduino/ppd42ns-sht10-serial/ppd42ns-sht10-serial.ino b/arduino/ppd42ns-sht10-serial/ppd42ns-sht10-serial.ino deleted file mode 100644 index 94709f691..000000000 --- a/arduino/ppd42ns-sht10-serial/ppd42ns-sht10-serial.ino +++ /dev/null @@ -1,108 +0,0 @@ -/* - Shinyei PPD42NS Particle Sensor - publish via serial and raspberry pi/python - - specification: http://www.sca-shinyei.com/pdf/PPD42NS.pdf - - pin 1 (grey) -> Arduino GND - pin 3 (black) -> Arduino 5V - pin 2 (green) -> Arduino Pin 9 - pin 4 (white) -> Arduino Pin 8 - pin 5 (red) -> unused! - -*/ - -#include - -// SHT10 -#define shtdataPin 10 -#define shtclockPin 11 -SHT1x sht10(shtdataPin, shtclockPin); - -// particles -boolean valP1 = HIGH; -boolean valP2 = HIGH; - -unsigned long starttime; -unsigned long durationP1; -unsigned long durationP2; - -boolean trigP1 = false; -boolean trigP2 = false; -unsigned long trigOnP1; -unsigned long trigOnP2; - -unsigned long sampletime_ms = 15000; -unsigned long lowpulseoccupancyP1 = 0; -unsigned long lowpulseoccupancyP2 = 0; - - -void setup() { - Serial.begin(9600); - pinMode(5,OUTPUT); - digitalWrite(5, HIGH); - pinMode(8,INPUT); - pinMode(9,INPUT); - starttime = millis(); -} - -void loop() { - float ratio = 0; - float concentration = 0; - - valP1 = digitalRead(8); - valP2 = digitalRead(9); - - if(valP1 == LOW && trigP1 == false){ - trigP1 = true; - trigOnP1 = micros(); - } - - if (valP1 == HIGH && trigP1 == true){ - durationP1 = micros() - trigOnP1; - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1; - trigP1 = false; - } - - if(valP2 == LOW && trigP2 == false){ - trigP2 = true; - trigOnP2 = micros(); - } - - if (valP2 == HIGH && trigP2 == true){ - durationP2 = micros() - trigOnP2; - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2; - trigP2 = false; - } - - if ((millis()-starttime) > sampletime_ms) - { - ratio = lowpulseoccupancyP1/(sampletime_ms*10.0); // int percentage 0 to 100 - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // spec sheet curve - Serial.print("ppd42ns_durP1:"); - Serial.print(lowpulseoccupancyP1); - Serial.print(";ppd42ns_ratioP1:"); - Serial.print(ratio); - Serial.print(";ppd42ns_P1:"); - Serial.print(concentration); - - ratio = lowpulseoccupancyP2/(sampletime_ms*10.0); - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; - - Serial.print(";ppd42ns_durP2:"); - Serial.print(lowpulseoccupancyP2); - Serial.print(";ppd42ns_ratioP2:"); - Serial.print(ratio); - Serial.print(";ppd42ns_P2:"); - Serial.print(concentration); - - Serial.print(";sht10_temperature:"); - Serial.print(sht10.readTemperatureC()); - Serial.print(";sht10_humidity:"); - Serial.println(sht10.readHumidity()); - - lowpulseoccupancyP1 = 0; - lowpulseoccupancyP2 = 0; - starttime = millis(); - } -} diff --git a/arduino/sht10-dht11-bmp180-ethernet/.gitignore b/arduino/sht10-dht11-bmp180-ethernet/.gitignore deleted file mode 100644 index 713ba9626..000000000 --- a/arduino/sht10-dht11-bmp180-ethernet/.gitignore +++ /dev/null @@ -1 +0,0 @@ -sensor_id.h diff --git a/arduino/sht10-dht11-bmp180-ethernet/Makefile b/arduino/sht10-dht11-bmp180-ethernet/Makefile deleted file mode 100644 index 8ccd52fb5..000000000 --- a/arduino/sht10-dht11-bmp180-ethernet/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -BOARD_TAG = uno -ISP_PROG = gpio -ISP_PORT = /dev/ttyACM0 -MONITOR_PORT = /dev/ttyACM0 -AVRDUDE = /usr/bin/avrdude -AVRDUDE_CONF = /etc/avrdude.conf - -ARDUINO_LIBS = Ethernet Ethernet/utility SPI SHT1x Wire/utility Wire DHT-sensor-library BMP180 -USER_LIB_PATH = ../libs - -include /usr/share/arduino/Arduino.mk diff --git a/arduino/sht10-dht11-bmp180-ethernet/sensor_id.h-template b/arduino/sht10-dht11-bmp180-ethernet/sensor_id.h-template deleted file mode 100644 index 6731e0943..000000000 --- a/arduino/sht10-dht11-bmp180-ethernet/sensor_id.h-template +++ /dev/null @@ -1 +0,0 @@ -#define SENSOR_ID "arduino-RANDOM-SECRET-" diff --git a/arduino/sht10-dht11-bmp180-ethernet/sht10-dht11-bmp180-ethernet.ino b/arduino/sht10-dht11-bmp180-ethernet/sht10-dht11-bmp180-ethernet.ino deleted file mode 100644 index c2d159268..000000000 --- a/arduino/sht10-dht11-bmp180-ethernet/sht10-dht11-bmp180-ethernet.ino +++ /dev/null @@ -1,246 +0,0 @@ -/* - -SHT11 - + -> 3.3V - - -> GND - data -> 8 - Clock -> 9 - - -DHT11 - + -> 5V - - -> GND - data -> 2 - - -photoresistor - + -> 5V - data -> analog 0 - -BMP180 - + -> 3.3V - - -> GND - data -> analog 4 - Clock -> analog 5 - - */ - -#include -#include -#include "Wire.h" -#include -#include "DHT.h" - -// to store the secret ID used to authenticate the sensor -#include "sensor_id.h" - -//////////////////////////////////////////////////////////////////////////////// -// Specify data and clock connections and instantiate SHT1x object -#define dataPin 8 -#define clockPin 9 -SHT1x sht11(dataPin, clockPin); - -//////////////////////////////////////////////////////////////////////////////// -// DHT11 -#define DHTTYPE DHT11 // DHT 11 -#define DHTPIN1 2 // pin of first DHT - -DHT dht1(DHTPIN1, DHTTYPE); - -//////////////////////////////////////////////////////////////////////////////// -// Photocell - -int photocellPin = 0; // the cell and 10K pulldown are connected to a0 -int photocellReading; // the analog reading from the sensor divider - - -//////////////////////////////////////////////////////////////////////////////// -// BMP180 - -Adafruit_BMP085 bmp; - -//////////////////////////////////////////////////////////////////////////////// -// Ethernet data -byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }; -byte gateway[] = { 192, 168, 1, 1}; -byte subnet[] = { 255, 255, 255, 0 }; - -char server[] = "api.luftdaten.info"; - -// initialize the library instance: -IPAddress ip(192,168,1, 42); -EthernetClient client; - -const int postingInterval = 29000; // delay between updates -long lastConnectionTime = 0; // last time connected to the server -boolean lastConnected = false; // state of the connection -long counter = 1; - -void sendData(const String& sensor_id, - const String& data) { - - Serial.print("Sensor: "); - Serial.println(sensor_id); - Serial.println(data); - - if (client.connect(server, 80)) { - Serial.println("connecting..."); - - client.print("POST /v1/push-sensor-data/ HTTP/1.1\n"); - - client.print("Host: api.dusti.xyz\n"); - client.print("Sensor: "); - client.println(sensor_id); - - client.println("User-Agent: Arduino"); - client.println("Accept: application/json"); - client.print("Content-Length: "); - client.println(data.length(), DEC); - - client.print("Content-Type: application/json\n"); - client.println("Connection: close\n"); - - client.println(data); - - lastConnectionTime = millis(); - counter += 1; - Serial.println("sent..."); - } - else { - Serial.println("connection failed"); - delay(1000); - } -} - -//////////////////////////////////////////////////////////////////////////////// - -String Float2String(float value) -{ - // Convert a float to String with two decimals. - String s; - s = String(int(value)); - s += '.'; - s += int((value - int(value)) * 100); - - return s; -} - -void setup() -{ - // start the Ethernet connection: - Ethernet.begin(mac, ip); - Wire.begin(); - - Serial.begin(9600); - - // DHT init - dht1.begin(); - - if (!bmp.begin()) { - Serial.println("# Could not find a valid BMP085 sensor!"); - } - - // delay for the ethernet to get up - delay(1000); -} - -int disconnected = 0; -int next = 1; - -void loop() -{ - float sht11_c, sht11_h; - float dht1_c, dht1_h; - String data; - String sensor_id; - - if (client.available()) { - char c = client.read(); - Serial.print(c); - } - - if (!client.connected()) { - Serial.print("next: "); - Serial.println(next); - - client.stop(); - - delay(1000); - - switch(next) - { - case 1: - // Read values from the SHT11 - sht11_c = sht11.readTemperatureC(); - sht11_h = sht11.readHumidity(); - - // SHT11 - if(sht11_h > 0.0) - { - data = "{\"sensordatavalues\":[{"; - data += "\"value_type\":\"temperature\",\"value\":\""; - data += Float2String(sht11_c); - data += "\"},{"; - data += "\"value_type\":\"humidity\",\"value\":\""; - data += Float2String(sht11_h); - data += "\"}]}"; - sensor_id = String(SENSOR_ID) + String("SHT11"); - sendData(sensor_id, data); - } - next=2; - break; - case 2: - // Read values from DHT11 - dht1_h = dht1.readHumidity(); - dht1_c = dht1.readTemperature(); - - // DHT11 - data = "{\"sensordatavalues\":[{"; - data += "\"value_type\":\"temperature\",\"value\":\""; - data += Float2String(dht1_c); - data += "\"},{"; - data += "\"value_type\":\"humidity\",\"value\":\""; - data += Float2String(dht1_h); - data += "\"}]}"; - sensor_id = String(SENSOR_ID) + String("DHT11"); - sendData(sensor_id, data); - - next=3; - break; - case 3: - // bmp180 - data = "{\"sensordatavalues\":[{"; - data += "\"value_type\":\"temperature\",\"value\":\""; - data += Float2String(bmp.readTemperature()); - data += "\"},{"; - data += "\"value_type\":\"pressure\",\"value\":\""; - data += Float2String(bmp.readPressure()); - data += "\"},{"; - data += "\"value_type\":\"altitude\",\"value\":\""; - data += Float2String(bmp.readAltitude()); - // data += "\"},{"; - // data += "\"value_type\":\"pressure_sealevel\",\"value\":\""; - // data += Float2String(bmp.readSealevelPressure()); - data += "\"}]}"; - sensor_id = String(SENSOR_ID) + String("BMP180"); - sendData(sensor_id, data); - next=4; - break; - case 4: - // photocell - photocellReading = analogRead(photocellPin); - data = "{\"sensordatavalues\":[{"; - data += "\"value_type\":\"brightness\",\"value\":\""; - data += photocellReading; - data += "\"}]}"; - sensor_id = String(SENSOR_ID) + String("photoresistor"); - sendData(sensor_id, data); - next=5; - break; - case 5: - delay(60000); - next=1; - break; - } - } -} diff --git a/airrohr-firmware/astyle.rc b/astyle.rc similarity index 100% rename from airrohr-firmware/astyle.rc rename to astyle.rc diff --git a/airrohr-firmware/bmx280_i2c.cpp b/bmx280_i2c.cpp similarity index 100% rename from airrohr-firmware/bmx280_i2c.cpp rename to bmx280_i2c.cpp diff --git a/airrohr-firmware/bmx280_i2c.h b/bmx280_i2c.h similarity index 100% rename from airrohr-firmware/bmx280_i2c.h rename to bmx280_i2c.h diff --git a/builds/firmware.elf b/builds/firmware.elf new file mode 100755 index 000000000..6421c27be Binary files /dev/null and b/builds/firmware.elf differ diff --git a/builds/latest_en.bin b/builds/latest_en.bin new file mode 100644 index 000000000..2740b08c2 Binary files /dev/null and b/builds/latest_en.bin differ diff --git a/builds/latest_en.bin.md5 b/builds/latest_en.bin.md5 new file mode 100644 index 000000000..71f1cab96 --- /dev/null +++ b/builds/latest_en.bin.md5 @@ -0,0 +1 @@ +640cd4fb9b7b0bbfb405619f55f9a36b diff --git a/builds/latest_ru.bin b/builds/latest_ru.bin new file mode 100644 index 000000000..b92a5e253 Binary files /dev/null and b/builds/latest_ru.bin differ diff --git a/builds/latest_ru.bin.md5 b/builds/latest_ru.bin.md5 new file mode 100644 index 000000000..52d0c807a --- /dev/null +++ b/builds/latest_ru.bin.md5 @@ -0,0 +1 @@ +056517425e051726c4ee6ef8f3d9a4c8 diff --git a/builds/main_en.bin b/builds/main_en.bin new file mode 100644 index 000000000..403eddabd Binary files /dev/null and b/builds/main_en.bin differ diff --git a/airrohr-firmware/ca-root.h b/ca-root.h similarity index 100% rename from airrohr-firmware/ca-root.h rename to ca-root.h diff --git a/config-via-raspberry/Readme.md b/config-via-raspberry/Readme.md deleted file mode 100644 index 1c2e05302..000000000 --- a/config-via-raspberry/Readme.md +++ /dev/null @@ -1,7 +0,0 @@ -** Config script for dust sensor - -Dependencies: - -platform.io: compile and upload firmware - -perl modules: Curses, Curses::UI diff --git a/config-via-raspberry/firmware_update.pl b/config-via-raspberry/firmware_update.pl deleted file mode 100755 index 89bec9e28..000000000 --- a/config-via-raspberry/firmware_update.pl +++ /dev/null @@ -1,238 +0,0 @@ -#!/usr/bin/perl - -use Curses::UI; - -my $val_wlan_id; -my $val_wlan_pwd; -my $val_SEND2DUSTI = 1; -my $val_SEND2MADAVI = 0; -my $val_SEND2MQTT = 0; -my $val_SEND2CSV = 0; -my $val_DHT22 = 0; -my $val_PPD = 1; -my $val_SDS = 0; - -my $cui = new Curses::UI( -color_support => 1, -language => "de", -clear_on_exit => 1); - -sub init_vars() { - $val_wlan_id = 'Freifunk'; - $val_wlan_pwd = ''; - $val_SEND2DUSTI = 1; - $val_SEND2MADAVI = 0; - $val_SEND2MQTT = 0; - $val_SEND2CSV = 0; - - $val_DHT22 = 0; - $val_PPD = 1; - $val_SDS = 0; - $val_DISPLAY = 0; - $val_DEBUG = 1; -} - -sub write_ext_def() { - open(OUTFILE,">","source/src/ext_def.h"); - print "Test"; - print OUTFILE '#define WLANSSID "'.$val_wlan_id."\"\n"; - print OUTFILE '#define WLANPWD "'.$val_wlan_pwd."\"\n"; - - print OUTFILE '#define SEND2DUSTI '.($val_SEND2DUSTI ? '1' : '0')."\n"; - print OUTFILE '#define SEND2MADAVI '.($val_SEND2MADAVI ? '1' : '0')."\n"; - print OUTFILE '#define SEND2MQTT '.($val_SEND2MQTT ? '1' : '0')."\n"; - print OUTFILE '#define SEND2CSV '.($val_SEND2CSV ? '1' : '0')."\n"; - - print OUTFILE '#define HOST_MQTT "mqtt.opensensors.io"'."\n"; - print OUTFILE '#define MQTT_PORT 1883'."\n"; - print OUTFILE '#define MQTT_USER ""'."\n"; - print OUTFILE '#define MQTT_PWD ""'."\n"; - print OUTFILE '#define MQTT_CLIENT_ID ""'."\n"; - print OUTFILE '#define MQTT_TOPIC ""'."\n"; - - print OUTFILE '#define DHT_READ '.($val_DHT22 ? '1' : '0')."\n"; - print OUTFILE '#define DHT_PIN 13'."\n"; - print OUTFILE '#define DHT_TYPE DHT22'."\n"; - - print OUTFILE '#define PPD_READ '.($val_PPD ? '1' : '0')."\n"; - print OUTFILE '#define PPD_PIN_PM1 12'."\n"; - print OUTFILE '#define PPD_PIN_PM2 14'."\n"; - - print OUTFILE '#define SDS_READ '.($val_SDS ? '1' : '0')."\n"; - print OUTFILE '#define SDS_PIN_RX 5'."\n"; - print OUTFILE '#define SDS_PIN_TX 4'."\n"; - - print OUTFILE '#define HAS_DISPLAY '.($val_DISPLAY ? '1' : '0')."\n"; - - print OUTFILE '#define DEBUG '.($val_DEBUG ? '3' : '0')."\n"; - - print OUTFILE '#define DEBUG_ERROR 1'."\n"; - print OUTFILE '#define DEBUG_WARNING 2'."\n"; - print OUTFILE '#define DEBUG_MIN_INFO 3'."\n"; - print OUTFILE '#define DEBUG_MED_INFO 4'."\n"; - print OUTFILE '#define DEBUG_MAX_INFO 5'."\n"; - - close OUTFILE; - $cui->delete('win1'); - $cui->leave_curses(); - print "Shell?\n"; - sleep(5); - $cui->reset_curses(); - init_vars(); - main_window(); - $cui->draw(); - $cui->focus(); -} - -sub write_dialog() { - my $return = $cui->dialog( - -message => "Wollen Sie den Sensor wirklich neu programmieren?", - -title => "Sind Sie sicher?", - -buttons => ['yes', 'no'], - ); - - if ($return) { write_ext_def();}; -} - -sub exit_dialog_burn() { - my $return = $cui->dialog( - -message => "Wollen Sie das Programm wirklich verlassen?", - -title => "Sind Sie sicher?", - -buttons => ['yes', 'no'], - ); - - if ($return) { exit(0);}; -} - - -sub main_window() { - init_vars(); - my $win = $cui->add( - 'win1', 'Window', - -border => 1, - -centered => 1, - -width => 60, - -height => 25, -# -y => 1, - -bfg => 'red', - ); - - my $wlan_id_label = $win->add( - 'wlan_id_label', 'Label', - -text => 'WLAN Name: ', - -x => 2, -y => 1, - ); - - my $wlan_id = $win->add( - 'wlan_id', 'TextEntry', - -text => $val_wlan_id, - -showlines => 1, - -maxlength => 24, - -width => 25, - -x => 14, -y => 1, - -onblur => sub { my $field = shift; $val_wlan_id = $field->get();}, - ); - $wlan_id->focus(); - - my $wlan_pwd_label = $win->add( - 'wlan_pwd_label', 'Label', - -text => 'WLAN Passwort: ', - -x => 2, -y => 2, - ); - - my $wlan_pwd = $win->add( - 'wlan_pwd', 'PasswordEntry', - -text => $val_wlan_pwd, - -showlines => 1, - -maxlength => 24, - -width => 25, - -x => 14, -y => 2, - -onblur => sub { my $field = shift; $val_wlan_pwd = $field->get();}, - ); - - my $checkbox_PPD = $win->add( - 'checkbox_PPD', 'Checkbox', - -label => 'Sensor PPD42NS (Feinstaub, Standard)', - -checked => $val_PPD, - -x => 2, -y => 4, - -onblur => sub { my $field = shift; $val_PPD = $field->get();}, - ), - - my $checkbox_SDS = $win->add( - 'checkbox_SDS', 'Checkbox', - -label => 'Sensor SDS011 (Feinstaub, optional)', - -checked => $val_SDS, - -x => 2, -y => 5, - -onblur => sub { my $field = shift; $val_SDS = $field->get();}, - ); - - my $checkbox_DHT22 = $win->add( - 'checkbox_DHT22', 'Checkbox', - -label => 'Sensor DHT22 (Temperatur ,Luftfeuchte, optional)', - -checked => $val_DHT22, - -x => 2, -y => 6, - -onblur => sub { my $field = shift; $val_DHT22 = $field->get();}, - ); - - my $checkbox_LUFTDATEN = $win->add( - 'checkbox_LUFTDATEN', 'Checkbox', - -label => 'Senden an Luftdaten-API (Standard)', - -checked => $val_SEND2DUSTI, - -x => 2, -y => 8, - -onblur => sub { my $field = shift; $val_SEND2DUSTI = $field->get();}, - ); - - my $checkbox_MADAVI = $win->add( - 'checkbox_MADAVI', 'Checkbox', - -label => 'Senden an Madavi-API (optional)', - -checked => $val_SEND2MADAVI, - -x => 2, -y => 9, - -onblur => sub { my $field = shift; $val_SEND2MADAVI = $field->get();}, - ); - - my $checkbox_DISPLAY = $win->add( - 'checkbox_DISPLAY', 'Checkbox', - -label => 'Display vorhanden (optional)', - -checked => $val_DISPLAY, - -x => 2, -y => 11, - -onblur => sub { my $field = shift; $val_DISPLAY = $field->get();}, - ); - - my $checkbox_DEBUG = $win->add( - 'checkbox_DEBUG', 'Checkbox', - -label => 'Debug Ausgabe via USB (empfohlen zu Fehlersuche)', - -checked => $val_DEBUG, - -x => 2, -y => 12, - -onblur => sub { my $field = shift; $val_DEBUG = $field->get();}, - ); - - my $buttons = $win->add( - 'buttons', 'Buttonbox', - -buttons => [{ - -label => '< Firmware schreiben >', - -value => 1, - -shortcut => B, - -onpress => \&write_dialog, - },{ - -label => '< Programm verlassen >', - -value => 2, - -shortcut => X, - -onpress => \&exit_dialog_burn, - }], - -x => 2, -y => 14, - ); - - my $helptext1 = $win->add( - 'helptext1', 'Label', - -text => '[TAB] zum Wechseln zwischen den Feldern', - -x => 2, -y => 16, - ); - - my $helptext2 = $win->add( - 'helptext2', 'Label', - -text => '[SPACE] Markieren der Auswahlfelder', - -x => 2, -y => 17, - ); - -} - -main_window(); - -$cui->mainloop(); diff --git a/contributing.md b/contributing.md deleted file mode 120000 index 081061cb1..000000000 --- a/contributing.md +++ /dev/null @@ -1 +0,0 @@ -airrohr-firmware/Contributing.md \ No newline at end of file diff --git a/airrohr-firmware/dbmeter_regs.h b/dbmeter_regs.h similarity index 100% rename from airrohr-firmware/dbmeter_regs.h rename to dbmeter_regs.h diff --git a/airrohr-firmware/defines.h b/defines.h similarity index 100% rename from airrohr-firmware/defines.h rename to defines.h diff --git a/airrohr-firmware/dnms_i2c.cpp b/dnms_i2c.cpp similarity index 100% rename from airrohr-firmware/dnms_i2c.cpp rename to dnms_i2c.cpp diff --git a/airrohr-firmware/dnms_i2c.h b/dnms_i2c.h similarity index 100% rename from airrohr-firmware/dnms_i2c.h rename to dnms_i2c.h diff --git a/esp8266-arduino/Readme.md b/esp8266-arduino/Readme.md deleted file mode 100644 index 48ca33774..000000000 --- a/esp8266-arduino/Readme.md +++ /dev/null @@ -1,33 +0,0 @@ -## dht22-shack - -temperature sensors for shackspace, powered over selfmade PoE - -## dht22-wifi - -## mma7455 - -working code for gravity sensor - -## mqtt - -## multisens - -## pintester - -## ppd42ns-wificonfig-ppd-sds-dht - -maintained version, includes config over wifi, code for sensors ppd42ns, sds011, dht11/22, bmp160 and oled display - -## restapi-test - -## sensordev - -## setrgbledbyphoto - -## archive -- i2scan (i2c scanner for esp8266) -- minimal (minimal arduino sketch) -- ppd42ns -- ppd42ns-wifi-dht -- ppd42ns-wifi-dht-mqtt - diff --git a/esp8266-arduino/TODO.md b/esp8266-arduino/TODO.md deleted file mode 100644 index 886a69def..000000000 --- a/esp8266-arduino/TODO.md +++ /dev/null @@ -1,8 +0,0 @@ -# Diskussion notwendiger Features - -2016-04-05 - - -* OTA update: what about the SPIFF/Memory size? can SPIFF be reduced in favour of - * https://harizanov.com/2015/06/firmware-over-the-air-fota-for-esp8266-soc/ - diff --git a/esp8266-arduino/archive/i2cscan/i2cscan.ino b/esp8266-arduino/archive/i2cscan/i2cscan.ino deleted file mode 100644 index 66da51655..000000000 --- a/esp8266-arduino/archive/i2cscan/i2cscan.ino +++ /dev/null @@ -1,58 +0,0 @@ - -// -------------------------------------- -// i2c_scanner -// -// - -#include - - -void setup() -{ - Wire.begin(0,2); //SDA=0 (D3), SCL=2 (D4) - Serial.begin(9600); - Serial.println("\nI2C Scanner"); -} - - -void loop() -{ - byte error, address; - int nDevices; - - Serial.println("Scanning..."); - - nDevices = 0; - for(address = 1; address < 127; address++ ) - { - // The i2c_scanner uses the return value of - // the Write.endTransmisstion to see if - // a device did acknowledge to the address. - Wire.beginTransmission(address); - error = Wire.endTransmission(); - - if (error == 0) - { - Serial.print("I2C device found at address 0x"); - if (address<16) - Serial.print("0"); - Serial.print(address,HEX); - Serial.println(" !"); - - nDevices++; - } - else if (error==4) - { - Serial.print("Unknow error at address 0x"); - if (address<16) - Serial.print("0"); - Serial.println(address,HEX); - } - } - if (nDevices == 0) - Serial.println("No I2C devices found\n"); - else - Serial.println("done\n"); - - delay(1000); // wait 5 seconds for next scan -} diff --git a/esp8266-arduino/archive/minimal/minimal.ino b/esp8266-arduino/archive/minimal/minimal.ino deleted file mode 100644 index 95ce0d363..000000000 --- a/esp8266-arduino/archive/minimal/minimal.ino +++ /dev/null @@ -1,14 +0,0 @@ - - -void setup() -{ - Serial.begin(9600); - delay(500); - Serial.println("SETUP"); -} - -void loop() -{ - Serial.print('-'); - delay(100); -} diff --git a/esp8266-arduino/archive/ppd42ns-wifi-dht-mqtt/ppd42ns-wifi-dht-mqtt.ino b/esp8266-arduino/archive/ppd42ns-wifi-dht-mqtt/ppd42ns-wifi-dht-mqtt.ino deleted file mode 100644 index bf8d1ca6d..000000000 --- a/esp8266-arduino/archive/ppd42ns-wifi-dht-mqtt/ppd42ns-wifi-dht-mqtt.ino +++ /dev/null @@ -1,371 +0,0 @@ -/************************************************************/ -/* OK LAB Particulate Matter Sensor */ -/* - nodemcu-LoLin board */ -/* - Shinyei PPD42NS */ -/* http://www.sca-shinyei.com/pdf/PPD42NS.pdf */ -/* */ -/* Wiring Instruction: */ -/* Pin 2 of dust sensor PM2.5 -> Digital 6 (PWM) */ -/* Pin 3 of dust sensor -> +5V */ -/* Pin 4 of dust sensor PM1 -> Digital 3 (PMW) */ -/* */ -/* - PPD42NS Pin 1 (grey or green) => GND */ -/* - PPD42NS Pin 2 (green or white)) => Pin D5 /GPIO14 */ -/* counts particles PM25 */ -/* - PPD42NS Pin 3 (black or yellow) => Vin */ -/* - PPD42NS Pin 4 (white or black) => Pin D6 / GPIO12 */ -/* counts particles PM10 */ -/* - PPD42NS Pin 5 (red) => unused */ -/* */ -/************************************************************/ - -// increment on change -#define SOFTWARE_VERSION "MFA-2015-001" - -/**********************************************/ -/* DHT declaration - /**********************************************/ -#include "DHT.h" -#define DHTPIN 4 -#define DHTTYPE DHT22 -DHT dht(DHTPIN, DHTTYPE); - -/**********************************************/ -/* WiFi declarations - /**********************************************/ -#include - -const char* ssid = ""; -const char* password = ""; -// const char* host = ""; -const char* host = "api.dusti.xyz"; -// const int httpPort = 8000; -const int httpPort = 80; -int value = 0; - - -/**********************************************/ -/* MQTT -**********************************************/ -#include - -const char* mqtt_server = "mqtt.opensensors.io"; -const char* mqtt_user = ""; -const char* mqtt_pw = ""; -const char* mqtt_client_id = ""; -const char* mqtt_topic = ""; - -boolean send_mqtt = true; -boolean send_http = false; - -WiFiClient espClient; -PubSubClient mqttClient(espClient); - -long lastMsg = 0; -char msg[50]; - - -/**********************************************/ -/* Variable Definitions for PPD24NS - /**********************************************/ -// P1 for PM10 & P2 for PM25 -boolean valP1 = HIGH; -boolean valP2 = HIGH; - -unsigned long starttime; -unsigned long durationP1; -unsigned long durationP2; - -boolean trigP1 = false; -boolean trigP2 = false; -unsigned long trigOnP1; -unsigned long trigOnP2; - -unsigned long sampletime_ms = 30000; -unsigned long lowpulseoccupancyP1 = 0; -unsigned long lowpulseoccupancyP2 = 0; - -float ratio = 0; -float concentration = 0; - -// DHT22 Sensor -void sensorDHT() { - float h = dht.readHumidity(); //Read Humidity - float t = dht.readTemperature(); //Read Temperature - - // Check if valid number if non NaN (not a number) will be send. - if (isnan(t) || isnan(h)) { - Serial.println("DHT22 couldn’t be read"); - } else { - Serial.print("Humidity : "); - Serial.print(h); - Serial.print(" %\n"); - Serial.print("Temperature : "); - Serial.print(t); - Serial.println(" C"); - - //Serial.println("#### Sending to Dusty: "); - //connect2API(); - //Serial.print("\n"); - } -} - -/**********************************************/ -/* WiFi connecting script - /**********************************************/ -void connectWifi() { - WiFi.begin(ssid, password); // Start WiFI - - Serial.print("Connecting "); - while (WiFi.status() != WL_CONNECTED) - { - delay(500); - Serial.print("."); - } - Serial.println("WiFi connected"); - Serial.print("IP address: "); - Serial.println(WiFi.localIP()); -} -/**********************************************/ -/* send data to rest api - /**********************************************/ -void sendData(const String& data) { - // delay(60000); - ++value; - - Serial.print("connecting to "); - Serial.println(host); - - // Use WiFiClient class to create TCP connections - WiFiClient client; - if (!client.connect(host, httpPort)) { - Serial.println("connection failed"); - return; - } - - // create an URI for the request - String url = "/v1/push-sensor-data/"; - - Serial.print("Requesting URL: "); - Serial.println(url); - Serial.println(data); - - // send request to the server - // "PIN: ": + "-" + "\r\n" + - client.print(String("POST ") + url + " HTTP/1.1\r\n" + - "Host: " + host + "\r\n" + - "Content-Type: application/json\r\n" + - "Sensor: esp8266-"); - client.println(ESP.getChipId()); - client.print("Content-Length: "); - client.println(data.length(), DEC); - client.println("Connection: close\r\n"); - - client.println(data); - - delay(1); - - // Read reply from server and print them - while (client.available()) { - char c = client.read(); - Serial.print(c); - } - - Serial.println(); - Serial.println("closing connection"); -} - -/**********************************************/ -/* publish data to broker -/**********************************************/ -void reconnectBroker() { - // Loop until we're reconnected - while (!mqttClient.connected()) { - Serial.println("mqtt attempting connection..."); - // Attempt to connect - if (mqttClient.connect(mqtt_client_id, mqtt_user, mqtt_pw)) { - Serial.println("mqtt connected"); - } else { - Serial.print("mqtt failed, rc="); - Serial.print(mqttClient.state()); - Serial.println("mqtt try again in 5 seconds"); - // Wait 5 seconds before retrying - delay(5000); - } - } -} - - -String Float2String(float value) -{ - // Convert a float to String with two decimals. - char temp[15]; - String s; - - dtostrf(value, 13, 2, temp); - s = String(temp); - s.trim(); - return s; -} - -/**********************************************/ -/* The Setup - /**********************************************/ -void setup() { - Serial.begin(9600); //Output to Serial at 9600 baud - delay(10); - pinMode(12, INPUT); // Listen at the designated PIN - pinMode(14, INPUT); //Listen at the designated PIN - starttime = millis(); // store the start time - // dht.begin(); // Start DHT - delay(10); - connectWifi(); // Start ConnecWifi - Serial.print("\n"); - Serial.println("ChipId: "); - Serial.println(ESP.getChipId()); - // broker address and port - mqttClient.setServer(mqtt_server, 1883); -} - -/**********************************************/ -/* And action - /**********************************************/ -void loop() { - String data; - String msg; - - if (send_mqtt == true){ - if (!mqttClient.connected()) { - reconnectBroker(); - } - mqttClient.loop(); - } - - // Read pins connected to ppd42ns - valP1 = digitalRead(12); - valP2 = digitalRead(14); - - if (valP1 == LOW && trigP1 == false) { - trigP1 = true; - trigOnP1 = micros(); - } - - if (valP1 == HIGH && trigP1 == true) { - durationP1 = micros() - trigOnP1; - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1; - trigP1 = false; - } - - if (valP2 == LOW && trigP2 == false) { - trigP2 = true; - trigOnP2 = micros(); - } - - if (valP2 == HIGH && trigP2 == true) { - durationP2 = micros() - trigOnP2; - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2; - trigP2 = false; - } - - // Checking if it is time to sample - if ((millis() - starttime) > sampletime_ms) - { - ratio = lowpulseoccupancyP1 / (sampletime_ms * 10.0); // int percentage 0 to 100 - concentration = 1.1 * pow(ratio, 3) - 3.8 * pow(ratio, 2) + 520 * ratio + 0.62; // spec sheet curve - // Begin printing - Serial.print("LPO P10 : "); - Serial.println(lowpulseoccupancyP1); - Serial.print("Ratio PM10 : "); - Serial.print(ratio); - Serial.println(" %"); - Serial.print("PM10 Count : "); - Serial.println(concentration); - - // json for push to api / P1 - data = "{\"software_version\": \""; - data += SOFTWARE_VERSION; - data += "\","; - data += "\"sensordatavalues\":[{"; - data += "\"value_type\":\"durP1\",\"value\":\""; - data += long(lowpulseoccupancyP1); - data += "\"},{"; - data += "\"value_type\":\"ratioP1\",\"value\":\""; - data += Float2String(ratio); - data += "\"},{"; - data += "\"value_type\":\"P1\",\"value\":\""; - data += Float2String(concentration); - data += "\"},{"; - - msg = "{"+ - //msg += "\"v\":\""; - //msg += SOFTWARE_VERSION; - //msg += "\","; - msg += "\"dP1\":\""; - msg += long(lowpulseoccupancyP1); - msg += "\","; - msg += "\"rP1\":\""; - msg += Float2String(ratio); - msg += "\","; - msg += "\"P1\":\""; - msg += Float2String(concentration); - msg += "\","; - - ratio = lowpulseoccupancyP2 / (sampletime_ms * 10.0); - concentration = 1.1 * pow(ratio, 3) - 3.8 * pow(ratio, 2) + 520 * ratio + 0.62; - // Begin printing - Serial.print("LPO PM25 : "); - Serial.println(lowpulseoccupancyP2); - Serial.print("Ratio PM25 : "); - Serial.print(ratio); - Serial.println(" %"); - Serial.print("PM25 Count : "); - Serial.println(concentration); - - // json for push to api / P2 - data += "\"value_type\":\"durP2\",\"value\":\""; - data += long(lowpulseoccupancyP2); - data += "\"},{"; - data += "\"value_type\":\"ratioP2\",\"value\":\""; - data += Float2String(ratio); - data += "\"},{"; - data += "\"value_type\":\"P2\",\"value\":\""; - data += Float2String(concentration); - data += "\"}]}"; - - msg += "\"dP2\":\""; - msg += long(lowpulseoccupancyP2); - msg += "\","; - msg += "\"rP2\":\""; - msg += Float2String(ratio); - msg += "\","; - msg += "\"P2\":\""; - msg += Float2String(concentration); - msg += "\"}"; - - //sending to dustix api - if (send_http == true){ - Serial.println("#### Sending to dusti.xyz: "); - sendData(data); - } - - // MQTT publish - if (send_mqtt == true){ - Serial.println("#### Sending to broker: "); - const char * c = msg.c_str(); - Serial.println(c); - - if (!mqttClient.publish(mqtt_topic, c)) { - Serial.println("Publish failed"); - } - } - - // Resetting for next sampling - lowpulseoccupancyP1 = 0; - lowpulseoccupancyP2 = 0; - starttime = millis(); // store the start time - - // FIXME: option to send PIN - // sensorDHT(); // getting temperature and humidity (optional) - Serial.println("------------------------------"); - } -} diff --git a/esp8266-arduino/archive/ppd42ns-wifi-dht/DHT.cpp b/esp8266-arduino/archive/ppd42ns-wifi-dht/DHT.cpp deleted file mode 100644 index 86ad91c43..000000000 --- a/esp8266-arduino/archive/ppd42ns-wifi-dht/DHT.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* DHT library - -MIT license -written by Adafruit Industries -*/ - -#include "DHT.h" - -#define MIN_INTERVAL 2000 - -DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { - _pin = pin; - _type = type; - #ifdef __AVR - _bit = digitalPinToBitMask(pin); - _port = digitalPinToPort(pin); - #endif - _maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for - // reading pulses from DHT sensor. - // Note that count is now ignored as the DHT reading algorithm adjusts itself - // basd on the speed of the processor. -} - -void DHT::begin(void) { - // set up the pins! - pinMode(_pin, INPUT_PULLUP); - // Using this value makes sure that millis() - lastreadtime will be - // >= MIN_INTERVAL right away. Note that this assignment wraps around, - // but so will the subtraction. - _lastreadtime = -MIN_INTERVAL; - DEBUG_PRINT("Max clock cycles: "); DEBUG_PRINTLN(_maxcycles, DEC); -} - -//boolean S == Scale. True == Fahrenheit; False == Celcius -float DHT::readTemperature(bool S, bool force) { - float f = NAN; - - if (read(force)) { - switch (_type) { - case DHT11: - f = data[2]; - if(S) { - f = convertCtoF(f); - } - break; - case DHT22: - case DHT21: - f = data[2] & 0x7F; - f *= 256; - f += data[3]; - f *= 0.1; - if (data[2] & 0x80) { - f *= -1; - } - if(S) { - f = convertCtoF(f); - } - break; - } - } - return f; -} - -float DHT::convertCtoF(float c) { - return c * 1.8 + 32; -} - -float DHT::convertFtoC(float f) { - return (f - 32) * 0.55555; -} - -float DHT::readHumidity(bool force) { - float f = NAN; - if (read()) { - switch (_type) { - case DHT11: - f = data[0]; - break; - case DHT22: - case DHT21: - f = data[0]; - f *= 256; - f += data[1]; - f *= 0.1; - break; - } - } - return f; -} - -//boolean isFahrenheit: True == Fahrenheit; False == Celcius -float DHT::computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit) { - // Using both Rothfusz and Steadman's equations - // http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml - float hi; - - if (!isFahrenheit) - temperature = convertCtoF(temperature); - - hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (percentHumidity * 0.094)); - - if (hi > 79) { - hi = -42.379 + - 2.04901523 * temperature + - 10.14333127 * percentHumidity + - -0.22475541 * temperature*percentHumidity + - -0.00683783 * pow(temperature, 2) + - -0.05481717 * pow(percentHumidity, 2) + - 0.00122874 * pow(temperature, 2) * percentHumidity + - 0.00085282 * temperature*pow(percentHumidity, 2) + - -0.00000199 * pow(temperature, 2) * pow(percentHumidity, 2); - - if((percentHumidity < 13) && (temperature >= 80.0) && (temperature <= 112.0)) - hi -= ((13.0 - percentHumidity) * 0.25) * sqrt((17.0 - abs(temperature - 95.0)) * 0.05882); - - else if((percentHumidity > 85.0) && (temperature >= 80.0) && (temperature <= 87.0)) - hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2); - } - - return isFahrenheit ? hi : convertFtoC(hi); -} - -boolean DHT::read(bool force) { - // Check if sensor was read less than two seconds ago and return early - // to use last reading. - uint32_t currenttime = millis(); - if (!force && ((currenttime - _lastreadtime) < 2000)) { - return _lastresult; // return last correct measurement - } - _lastreadtime = currenttime; - - // Reset 40 bits of received data to zero. - data[0] = data[1] = data[2] = data[3] = data[4] = 0; - - // Send start signal. See DHT datasheet for full signal diagram: - // http://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf - - // Go into high impedence state to let pull-up raise data line level and - // start the reading process. - digitalWrite(_pin, HIGH); - delay(250); - - // First set data line low for 20 milliseconds. - pinMode(_pin, OUTPUT); - digitalWrite(_pin, LOW); - delay(20); - - uint32_t cycles[80]; - { - // Turn off interrupts temporarily because the next sections are timing critical - // and we don't want any interruptions. - InterruptLock lock; - - // End the start signal by setting data line high for 40 microseconds. - digitalWrite(_pin, HIGH); - delayMicroseconds(40); - - // Now start reading the data line to get the value from the DHT sensor. - pinMode(_pin, INPUT_PULLUP); - delayMicroseconds(10); // Delay a bit to let sensor pull data line low. - - // First expect a low signal for ~80 microseconds followed by a high signal - // for ~80 microseconds again. - if (expectPulse(LOW) == 0) { - DEBUG_PRINTLN(F("Timeout waiting for start signal low pulse.")); - _lastresult = false; - return _lastresult; - } - if (expectPulse(HIGH) == 0) { - DEBUG_PRINTLN(F("Timeout waiting for start signal high pulse.")); - _lastresult = false; - return _lastresult; - } - - // Now read the 40 bits sent by the sensor. Each bit is sent as a 50 - // microsecond low pulse followed by a variable length high pulse. If the - // high pulse is ~28 microseconds then it's a 0 and if it's ~70 microseconds - // then it's a 1. We measure the cycle count of the initial 50us low pulse - // and use that to compare to the cycle count of the high pulse to determine - // if the bit is a 0 (high state cycle count < low state cycle count), or a - // 1 (high state cycle count > low state cycle count). Note that for speed all - // the pulses are read into a array and then examined in a later step. - for (int i=0; i<80; i+=2) { - cycles[i] = expectPulse(LOW); - cycles[i+1] = expectPulse(HIGH); - } - } // Timing critical code is now complete. - - // Inspect pulses and determine which ones are 0 (high state cycle count < low - // state cycle count), or 1 (high state cycle count > low state cycle count). - for (int i=0; i<40; ++i) { - uint32_t lowCycles = cycles[2*i]; - uint32_t highCycles = cycles[2*i+1]; - if ((lowCycles == 0) || (highCycles == 0)) { - DEBUG_PRINTLN(F("Timeout waiting for pulse.")); - _lastresult = false; - return _lastresult; - } - data[i/8] <<= 1; - // Now compare the low and high cycle times to see if the bit is a 0 or 1. - if (highCycles > lowCycles) { - // High cycles are greater than 50us low cycle count, must be a 1. - data[i/8] |= 1; - } - // Else high cycles are less than (or equal to, a weird case) the 50us low - // cycle count so this must be a zero. Nothing needs to be changed in the - // stored data. - } - - DEBUG_PRINTLN(F("Received:")); - DEBUG_PRINT(data[0], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[1], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[2], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[3], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[4], HEX); DEBUG_PRINT(F(" =? ")); - DEBUG_PRINTLN((data[0] + data[1] + data[2] + data[3]) & 0xFF, HEX); - - // Check we read 40 bits and that the checksum matches. - if (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) { - _lastresult = true; - return _lastresult; - } - else { - DEBUG_PRINTLN(F("Checksum failure!")); - _lastresult = false; - return _lastresult; - } -} - -// Expect the signal line to be at the specified level for a period of time and -// return a count of loop cycles spent at that level (this cycle count can be -// used to compare the relative time of two pulses). If more than a millisecond -// ellapses without the level changing then the call fails with a 0 response. -// This is adapted from Arduino's pulseInLong function (which is only available -// in the very latest IDE versions): -// https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_pulse.c -uint32_t DHT::expectPulse(bool level) { - uint32_t count = 0; - // On AVR platforms use direct GPIO port access as it's much faster and better - // for catching pulses that are 10's of microseconds in length: - #ifdef __AVR - uint8_t portState = level ? _bit : 0; - while ((*portInputRegister(_port) & _bit) == portState) { - if (count++ >= _maxcycles) { - return 0; // Exceeded timeout, fail. - } - } - // Otherwise fall back to using digitalRead (this seems to be necessary on ESP8266 - // right now, perhaps bugs in direct port access functions?). - #else - while (digitalRead(_pin) == level) { - if (count++ >= _maxcycles) { - return 0; // Exceeded timeout, fail. - } - } - #endif - - return count; -} diff --git a/esp8266-arduino/archive/ppd42ns-wifi-dht/DHT.h b/esp8266-arduino/archive/ppd42ns-wifi-dht/DHT.h deleted file mode 100644 index d81f6dbc9..000000000 --- a/esp8266-arduino/archive/ppd42ns-wifi-dht/DHT.h +++ /dev/null @@ -1,75 +0,0 @@ -/* DHT library - -MIT license -written by Adafruit Industries -*/ -#ifndef DHT_H -#define DHT_H - -#if ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - - -// Uncomment to enable printing out nice debug messages. -//#define DHT_DEBUG - -// Define where debug output will be printed. -#define DEBUG_PRINTER Serial - -// Setup debug printing macros. -#ifdef DHT_DEBUG - #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } - #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } -#else - #define DEBUG_PRINT(...) {} - #define DEBUG_PRINTLN(...) {} -#endif - -// Define types of sensors. -#define DHT11 11 -#define DHT22 22 -#define DHT21 21 -#define AM2301 21 - - -class DHT { - public: - DHT(uint8_t pin, uint8_t type, uint8_t count=6); - void begin(void); - float readTemperature(bool S=false, bool force=false); - float convertCtoF(float); - float convertFtoC(float); - float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); - float readHumidity(bool force=false); - boolean read(bool force=false); - - private: - uint8_t data[5]; - uint8_t _pin, _type; - #ifdef __AVR - // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask - // for the digital pin connected to the DHT. Other platforms will use digitalRead. - uint8_t _bit, _port; - #endif - uint32_t _lastreadtime, _maxcycles; - bool _lastresult; - - uint32_t expectPulse(bool level); - -}; - -class InterruptLock { - public: - InterruptLock() { - noInterrupts(); - } - ~InterruptLock() { - interrupts(); - } - -}; - -#endif diff --git a/esp8266-arduino/archive/ppd42ns-wifi-dht/ppd42ns-wifi-dht.ino b/esp8266-arduino/archive/ppd42ns-wifi-dht/ppd42ns-wifi-dht.ino deleted file mode 100644 index bf4543a77..000000000 --- a/esp8266-arduino/archive/ppd42ns-wifi-dht/ppd42ns-wifi-dht.ino +++ /dev/null @@ -1,281 +0,0 @@ -/************************************************************/ -/* OK LAB Particulate Matter Sensor */ -/* - nodemcu-LoLin board */ -/* - Shinyei PPD42NS */ -/* http://www.sca-shinyei.com/pdf/PPD42NS.pdf */ -/* */ -/* Wiring Instruction: */ -/* Pin 2 of dust sensor PM2.5 -> Digital 6 (PWM) */ -/* Pin 3 of dust sensor -> +5V */ -/* Pin 4 of dust sensor PM1 -> Digital 3 (PMW) */ -/* */ -/* - PPD42NS Pin 1 (grey or green) => GND */ -/* - PPD42NS Pin 2 (green or white)) => Pin D5 /GPIO14 */ -/* counts particles PM25 */ -/* - PPD42NS Pin 3 (black or yellow) => Vin */ -/* - PPD42NS Pin 4 (white or black) => Pin D6 / GPIO12 */ -/* counts particles PM10 */ -/* - PPD42NS Pin 5 (red) => unused */ -/* */ -/************************************************************/ - -// increment on change -#define SOFTWARE_VERSION "MFA-2015-002" - -/**********************************************/ -/* DHT declaration -/**********************************************/ -#include "DHT.h" -#define DHTPIN 4 -#define DHTTYPE DHT22 -DHT dht(DHTPIN, DHTTYPE); - -/**********************************************/ -/* WiFi declarations -/**********************************************/ -#include - -const char* ssid = "Freifunk"; -const char* password = ""; -// const char* host = "192.168.1.12"; -const char* host = "api.luftdaten.info"; -// const int httpPort = 8000; -const int httpPort = 80; -int value = 0; - -/**********************************************/ -/* Variable Definitions for PPD24NS -/**********************************************/ -// P1 for PM10 & P2 for PM25 -boolean valP1 = HIGH; -boolean valP2 = HIGH; - -unsigned long starttime; -unsigned long durationP1; -unsigned long durationP2; - -boolean trigP1 = false; -boolean trigP2 = false; -unsigned long trigOnP1; -unsigned long trigOnP2; - -unsigned long sampletime_ms = 30000; -unsigned long lowpulseoccupancyP1 = 0; -unsigned long lowpulseoccupancyP2 = 0; - -float ratio = 0; -float concentration = 0; - -/**********************************************/ -/* The Setup -/**********************************************/ -void setup() { - Serial.begin(9600); //Output to Serial at 9600 baud - delay(10); - pinMode(12,INPUT); // Listen at the designated PIN - pinMode(14,INPUT); //Listen at the designated PIN - starttime = millis(); // store the start time -// dht.begin(); // Start DHT - delay(10); - connectWifi(); // Start ConnecWifi - Serial.print("\n"); - Serial.println("ChipId: "); - Serial.println(ESP.getChipId()); -} - -/**********************************************/ -/* And action -/**********************************************/ -void loop() { - String data; - - // Read pins connected to ppd42ns - valP1 = digitalRead(12); - valP2 = digitalRead(14); - - if(valP1 == LOW && trigP1 == false){ - trigP1 = true; - trigOnP1 = micros(); - } - - if (valP1 == HIGH && trigP1 == true){ - durationP1 = micros() - trigOnP1; - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1; - trigP1 = false; - } - - if(valP2 == LOW && trigP2 == false){ - trigP2 = true; - trigOnP2 = micros(); - } - - if (valP2 == HIGH && trigP2 == true){ - durationP2 = micros() - trigOnP2; - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2; - trigP2 = false; - } - - // Checking if it is time to sample - if ((millis()-starttime) > sampletime_ms) - { - ratio = lowpulseoccupancyP1/(sampletime_ms*10.0); // int percentage 0 to 100 - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // spec sheet curve - // Begin printing - Serial.print("LPO P10 : "); - Serial.println(lowpulseoccupancyP1); - Serial.print("Ratio PM10 : "); - Serial.print(ratio); - Serial.println(" %"); - Serial.print("PM10 Count : "); - Serial.println(concentration); - - // json for push to api / P1 - data = "{\"software_version\": \""; - data += SOFTWARE_VERSION; - data += "\","; - data += "\"sensordatavalues\":[{"; - data += "\"value_type\":\"durP1\",\"value\":\""; - data += long(lowpulseoccupancyP1); - data += "\"},{"; - data += "\"value_type\":\"ratioP1\",\"value\":\""; - data += Float2String(ratio); - data += "\"},{"; - data += "\"value_type\":\"P1\",\"value\":\""; - data += Float2String(concentration); - data += "\"},{"; - - ratio = lowpulseoccupancyP2/(sampletime_ms*10.0); - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; - // Begin printing - Serial.print("LPO PM25 : "); - Serial.println(lowpulseoccupancyP2); - Serial.print("Ratio PM25 : "); - Serial.print(ratio); - Serial.println(" %"); - Serial.print("PM25 Count : "); - Serial.println(concentration); - - // json for push to api / P2 - data += "\"value_type\":\"durP2\",\"value\":\""; - data += long(lowpulseoccupancyP2); - data += "\"},{"; - data += "\"value_type\":\"ratioP2\",\"value\":\""; - data += Float2String(ratio); - data += "\"},{"; - data += "\"value_type\":\"P2\",\"value\":\""; - data += Float2String(concentration); - data += "\"}]}"; - - //sending to dustix api - Serial.println("#### Sending to luftdaten.info: "); - sendData(data); - - // Resetting for next sampling - lowpulseoccupancyP1 = 0; - lowpulseoccupancyP2 = 0; - starttime = millis(); // store the start time - - // FIXME: option to send PIN - // sensorDHT(); // getting temperature and humidity (optional) - Serial.println("------------------------------"); - } -} -// DHT22 Sensor -void sensorDHT(){ - float h = dht.readHumidity(); //Read Humidity - float t = dht.readTemperature(); //Read Temperature - - // Check if valid number if non NaN (not a number) will be send. - if (isnan(t) || isnan(h)) { - Serial.println("DHT22 couldn’t be read"); - } else { - Serial.print("Humidity : "); - Serial.print(h); - Serial.print(" %\n"); - Serial.print("Temperature : "); - Serial.print(t); - Serial.println(" C"); - - //Serial.println("#### Sending to luftdaten.info: "); - //connect2API(); - //Serial.print("\n"); - } -} - -/**********************************************/ -/* WiFi connecting script -/**********************************************/ -void connectWifi() { - WiFi.begin(ssid, password); // Start WiFI - - Serial.print("Connecting "); - while (WiFi.status() != WL_CONNECTED) - { - delay(500); - Serial.print("."); - } - Serial.println("WiFi connected"); - Serial.print("IP address: "); - Serial.println(WiFi.localIP()); -} -/**********************************************/ -/* send data to rest api -/**********************************************/ -void sendData(const String& data) { - // delay(60000); - ++value; - - Serial.print("connecting to "); - Serial.println(host); - - // Use WiFiClient class to create TCP connections - WiFiClient client; - if (!client.connect(host, httpPort)) { - Serial.println("connection failed"); - return; - } - - // create an URI for the request - String url = "/v1/push-sensor-data/"; - - Serial.print("Requesting URL: "); - Serial.println(url); - Serial.println(data); - - // send request to the server - // "PIN: ": + "-" + "\r\n" + - client.print(String("POST ") + url + " HTTP/1.1\r\n" + - "Host: " + host + "\r\n" + - "Content-Type: application/json\r\n" + - "Sensor: esp8266-"); - client.println(ESP.getChipId()); - client.print("Content-Length: "); - client.println(data.length(), DEC); - client.println("Connection: close\r\n"); - - client.println(data); - - delay(1); - - // Read reply from server and print them - while(client.available()){ - char c = client.read(); - Serial.print(c); - } - - Serial.println(); - Serial.println("closing connection"); -} - -String Float2String(float value) -{ - // Convert a float to String with two decimals. - char temp[15]; - String s; - - dtostrf(value,13, 2, temp); - s = String(temp); - s.trim(); - return s; -} - diff --git a/esp8266-arduino/archive/ppd42ns-wifi-dht/readme.txt b/esp8266-arduino/archive/ppd42ns-wifi-dht/readme.txt deleted file mode 100644 index 2ba7bf630..000000000 --- a/esp8266-arduino/archive/ppd42ns-wifi-dht/readme.txt +++ /dev/null @@ -1,4 +0,0 @@ - - - -source of DHT.h and DHT.cpp: https://github.com/adafruit/DHT-sensor-library diff --git a/esp8266-arduino/archive/ppd42ns/ppd42ns.ino b/esp8266-arduino/archive/ppd42ns/ppd42ns.ino deleted file mode 100644 index 05a281f8c..000000000 --- a/esp8266-arduino/archive/ppd42ns/ppd42ns.ino +++ /dev/null @@ -1,94 +0,0 @@ -/* - Shinyei PPD42NS Particle Sensor - - using nodemcu-LoLin board - - specification: http://www.sca-shinyei.com/pdf/PPD42NS.pdf - - pin 1 (grey) -> GND - pin 3 (black) -> Vin - pin 2 (green) -> Pin D5 / GPIO14 - pin 4 (white) -> Pin D6 / GPIO12 - pin 5 (red) -> unused! - -*/ - -boolean valP1 = HIGH; -boolean valP2 = HIGH; - -unsigned long starttime; -unsigned long durationP1; -unsigned long durationP2; - -boolean trigP1 = false; -boolean trigP2 = false; -unsigned long trigOnP1; -unsigned long trigOnP2; - -unsigned long sampletime_ms = 15000; -unsigned long lowpulseoccupancyP1 = 0; -unsigned long lowpulseoccupancyP2 = 0; - -void setup() { - Serial.begin(9600); - pinMode(12,INPUT); - pinMode(14,INPUT); - starttime = millis(); -} - -void loop() { - float ratio = 0; - float concentration = 0; - - valP1 = digitalRead(12); - valP2 = digitalRead(14); - - if(valP1 == LOW && trigP1 == false){ - trigP1 = true; - trigOnP1 = micros(); - } - - if (valP1 == HIGH && trigP1 == true){ - durationP1 = micros() - trigOnP1; - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1; - trigP1 = false; - } - - if(valP2 == LOW && trigP2 == false){ - trigP2 = true; - trigOnP2 = micros(); - } - - if (valP2 == HIGH && trigP2 == true){ - durationP2 = micros() - trigOnP2; - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2; - trigP2 = false; - } - - if ((millis()-starttime) > sampletime_ms) - { - ratio = lowpulseoccupancyP1/(sampletime_ms*10.0); // int percentage 0 to 100 - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // spec sheet curve - Serial.print("lowpulseoccupancyP1:"); - Serial.print(lowpulseoccupancyP1); - Serial.print(";ratioP1:"); - Serial.print(ratio); - Serial.print(";countP1:"); - Serial.print(concentration); - - ratio = lowpulseoccupancyP2/(sampletime_ms*10.0); - concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; - - Serial.print(";lowpulseoccupancyP2:"); - Serial.print(lowpulseoccupancyP2); - Serial.print(";ratioP2:"); - Serial.print(ratio); - Serial.print(";countP2:"); - Serial.println(concentration); - - lowpulseoccupancyP1 = 0; - lowpulseoccupancyP2 = 0; - starttime = millis(); - } -} - diff --git a/esp8266-arduino/dht22-shack/DHT.cpp b/esp8266-arduino/dht22-shack/DHT.cpp deleted file mode 100644 index 86ad91c43..000000000 --- a/esp8266-arduino/dht22-shack/DHT.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* DHT library - -MIT license -written by Adafruit Industries -*/ - -#include "DHT.h" - -#define MIN_INTERVAL 2000 - -DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { - _pin = pin; - _type = type; - #ifdef __AVR - _bit = digitalPinToBitMask(pin); - _port = digitalPinToPort(pin); - #endif - _maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for - // reading pulses from DHT sensor. - // Note that count is now ignored as the DHT reading algorithm adjusts itself - // basd on the speed of the processor. -} - -void DHT::begin(void) { - // set up the pins! - pinMode(_pin, INPUT_PULLUP); - // Using this value makes sure that millis() - lastreadtime will be - // >= MIN_INTERVAL right away. Note that this assignment wraps around, - // but so will the subtraction. - _lastreadtime = -MIN_INTERVAL; - DEBUG_PRINT("Max clock cycles: "); DEBUG_PRINTLN(_maxcycles, DEC); -} - -//boolean S == Scale. True == Fahrenheit; False == Celcius -float DHT::readTemperature(bool S, bool force) { - float f = NAN; - - if (read(force)) { - switch (_type) { - case DHT11: - f = data[2]; - if(S) { - f = convertCtoF(f); - } - break; - case DHT22: - case DHT21: - f = data[2] & 0x7F; - f *= 256; - f += data[3]; - f *= 0.1; - if (data[2] & 0x80) { - f *= -1; - } - if(S) { - f = convertCtoF(f); - } - break; - } - } - return f; -} - -float DHT::convertCtoF(float c) { - return c * 1.8 + 32; -} - -float DHT::convertFtoC(float f) { - return (f - 32) * 0.55555; -} - -float DHT::readHumidity(bool force) { - float f = NAN; - if (read()) { - switch (_type) { - case DHT11: - f = data[0]; - break; - case DHT22: - case DHT21: - f = data[0]; - f *= 256; - f += data[1]; - f *= 0.1; - break; - } - } - return f; -} - -//boolean isFahrenheit: True == Fahrenheit; False == Celcius -float DHT::computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit) { - // Using both Rothfusz and Steadman's equations - // http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml - float hi; - - if (!isFahrenheit) - temperature = convertCtoF(temperature); - - hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (percentHumidity * 0.094)); - - if (hi > 79) { - hi = -42.379 + - 2.04901523 * temperature + - 10.14333127 * percentHumidity + - -0.22475541 * temperature*percentHumidity + - -0.00683783 * pow(temperature, 2) + - -0.05481717 * pow(percentHumidity, 2) + - 0.00122874 * pow(temperature, 2) * percentHumidity + - 0.00085282 * temperature*pow(percentHumidity, 2) + - -0.00000199 * pow(temperature, 2) * pow(percentHumidity, 2); - - if((percentHumidity < 13) && (temperature >= 80.0) && (temperature <= 112.0)) - hi -= ((13.0 - percentHumidity) * 0.25) * sqrt((17.0 - abs(temperature - 95.0)) * 0.05882); - - else if((percentHumidity > 85.0) && (temperature >= 80.0) && (temperature <= 87.0)) - hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2); - } - - return isFahrenheit ? hi : convertFtoC(hi); -} - -boolean DHT::read(bool force) { - // Check if sensor was read less than two seconds ago and return early - // to use last reading. - uint32_t currenttime = millis(); - if (!force && ((currenttime - _lastreadtime) < 2000)) { - return _lastresult; // return last correct measurement - } - _lastreadtime = currenttime; - - // Reset 40 bits of received data to zero. - data[0] = data[1] = data[2] = data[3] = data[4] = 0; - - // Send start signal. See DHT datasheet for full signal diagram: - // http://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf - - // Go into high impedence state to let pull-up raise data line level and - // start the reading process. - digitalWrite(_pin, HIGH); - delay(250); - - // First set data line low for 20 milliseconds. - pinMode(_pin, OUTPUT); - digitalWrite(_pin, LOW); - delay(20); - - uint32_t cycles[80]; - { - // Turn off interrupts temporarily because the next sections are timing critical - // and we don't want any interruptions. - InterruptLock lock; - - // End the start signal by setting data line high for 40 microseconds. - digitalWrite(_pin, HIGH); - delayMicroseconds(40); - - // Now start reading the data line to get the value from the DHT sensor. - pinMode(_pin, INPUT_PULLUP); - delayMicroseconds(10); // Delay a bit to let sensor pull data line low. - - // First expect a low signal for ~80 microseconds followed by a high signal - // for ~80 microseconds again. - if (expectPulse(LOW) == 0) { - DEBUG_PRINTLN(F("Timeout waiting for start signal low pulse.")); - _lastresult = false; - return _lastresult; - } - if (expectPulse(HIGH) == 0) { - DEBUG_PRINTLN(F("Timeout waiting for start signal high pulse.")); - _lastresult = false; - return _lastresult; - } - - // Now read the 40 bits sent by the sensor. Each bit is sent as a 50 - // microsecond low pulse followed by a variable length high pulse. If the - // high pulse is ~28 microseconds then it's a 0 and if it's ~70 microseconds - // then it's a 1. We measure the cycle count of the initial 50us low pulse - // and use that to compare to the cycle count of the high pulse to determine - // if the bit is a 0 (high state cycle count < low state cycle count), or a - // 1 (high state cycle count > low state cycle count). Note that for speed all - // the pulses are read into a array and then examined in a later step. - for (int i=0; i<80; i+=2) { - cycles[i] = expectPulse(LOW); - cycles[i+1] = expectPulse(HIGH); - } - } // Timing critical code is now complete. - - // Inspect pulses and determine which ones are 0 (high state cycle count < low - // state cycle count), or 1 (high state cycle count > low state cycle count). - for (int i=0; i<40; ++i) { - uint32_t lowCycles = cycles[2*i]; - uint32_t highCycles = cycles[2*i+1]; - if ((lowCycles == 0) || (highCycles == 0)) { - DEBUG_PRINTLN(F("Timeout waiting for pulse.")); - _lastresult = false; - return _lastresult; - } - data[i/8] <<= 1; - // Now compare the low and high cycle times to see if the bit is a 0 or 1. - if (highCycles > lowCycles) { - // High cycles are greater than 50us low cycle count, must be a 1. - data[i/8] |= 1; - } - // Else high cycles are less than (or equal to, a weird case) the 50us low - // cycle count so this must be a zero. Nothing needs to be changed in the - // stored data. - } - - DEBUG_PRINTLN(F("Received:")); - DEBUG_PRINT(data[0], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[1], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[2], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[3], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[4], HEX); DEBUG_PRINT(F(" =? ")); - DEBUG_PRINTLN((data[0] + data[1] + data[2] + data[3]) & 0xFF, HEX); - - // Check we read 40 bits and that the checksum matches. - if (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) { - _lastresult = true; - return _lastresult; - } - else { - DEBUG_PRINTLN(F("Checksum failure!")); - _lastresult = false; - return _lastresult; - } -} - -// Expect the signal line to be at the specified level for a period of time and -// return a count of loop cycles spent at that level (this cycle count can be -// used to compare the relative time of two pulses). If more than a millisecond -// ellapses without the level changing then the call fails with a 0 response. -// This is adapted from Arduino's pulseInLong function (which is only available -// in the very latest IDE versions): -// https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_pulse.c -uint32_t DHT::expectPulse(bool level) { - uint32_t count = 0; - // On AVR platforms use direct GPIO port access as it's much faster and better - // for catching pulses that are 10's of microseconds in length: - #ifdef __AVR - uint8_t portState = level ? _bit : 0; - while ((*portInputRegister(_port) & _bit) == portState) { - if (count++ >= _maxcycles) { - return 0; // Exceeded timeout, fail. - } - } - // Otherwise fall back to using digitalRead (this seems to be necessary on ESP8266 - // right now, perhaps bugs in direct port access functions?). - #else - while (digitalRead(_pin) == level) { - if (count++ >= _maxcycles) { - return 0; // Exceeded timeout, fail. - } - } - #endif - - return count; -} diff --git a/esp8266-arduino/dht22-shack/DHT.h b/esp8266-arduino/dht22-shack/DHT.h deleted file mode 100644 index d81f6dbc9..000000000 --- a/esp8266-arduino/dht22-shack/DHT.h +++ /dev/null @@ -1,75 +0,0 @@ -/* DHT library - -MIT license -written by Adafruit Industries -*/ -#ifndef DHT_H -#define DHT_H - -#if ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - - -// Uncomment to enable printing out nice debug messages. -//#define DHT_DEBUG - -// Define where debug output will be printed. -#define DEBUG_PRINTER Serial - -// Setup debug printing macros. -#ifdef DHT_DEBUG - #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } - #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } -#else - #define DEBUG_PRINT(...) {} - #define DEBUG_PRINTLN(...) {} -#endif - -// Define types of sensors. -#define DHT11 11 -#define DHT22 22 -#define DHT21 21 -#define AM2301 21 - - -class DHT { - public: - DHT(uint8_t pin, uint8_t type, uint8_t count=6); - void begin(void); - float readTemperature(bool S=false, bool force=false); - float convertCtoF(float); - float convertFtoC(float); - float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); - float readHumidity(bool force=false); - boolean read(bool force=false); - - private: - uint8_t data[5]; - uint8_t _pin, _type; - #ifdef __AVR - // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask - // for the digital pin connected to the DHT. Other platforms will use digitalRead. - uint8_t _bit, _port; - #endif - uint32_t _lastreadtime, _maxcycles; - bool _lastresult; - - uint32_t expectPulse(bool level); - -}; - -class InterruptLock { - public: - InterruptLock() { - noInterrupts(); - } - ~InterruptLock() { - interrupts(); - } - -}; - -#endif diff --git a/esp8266-arduino/dht22-shack/dht22-shack.ino b/esp8266-arduino/dht22-shack/dht22-shack.ino deleted file mode 100644 index 2caa93a91..000000000 --- a/esp8266-arduino/dht22-shack/dht22-shack.ino +++ /dev/null @@ -1,154 +0,0 @@ -/************************************************************/ -/* */ -/* dht22 in shackspace with mqtt */ -/* */ - -// https://home-assistant.io/blog/2015/10/11/measure-temperature-with-esp8266-and-report-to-mqtt/ - -/************************************************************/ - -// increment on change -#define SOFTWARE_VERSION "MFA-2016-001" - -/**********************************************/ -/* DHT declaration -/**********************************************/ -#include "DHT.h" -#define DHTPIN 2 // pin D4 auf nodemcu -#define DHTTYPE DHT22 -DHT dht(DHTPIN, DHTTYPE); - -/**********************************************/ -/* WiFi declarations -/**********************************************/ -#include - -const char* ssid = "Freifunk"; -const char* password = ""; - -/**********************************************/ -/* MQTTdeclarations -/**********************************************/ - -#include - -#define mqtt_server "hass.shack" - -WiFiClient espClient; -PubSubClient mqttClient(espClient); -long lastMsg = 0; -char msg[50]; - -unsigned long sampletime_ms = 10000; // 10 seconds - -/**********************************************/ -/* The Setup -/**********************************************/ -void setup() { - Serial.begin(9600); //Output to Serial at 9600 baud - dht.begin(); // Start DHT - delay(10); - connectWifi(); // Start ConnecWifi - Serial.print("\n"); - Serial.println("ChipId: "); - Serial.println(String(ESP.getChipId())); - mqttClient.setServer(mqtt_server, 1883); - -} - -/**********************************************/ -/* And action -/**********************************************/ -void loop() { - - if (!mqttClient.connected()) { - reconnect(); - } - mqttClient.loop(); - - long now = millis(); - if (now - lastMsg > sampletime_ms) { - lastMsg = now; - sensorDHT(); // getting temperature and humidity - } -} - -// DHT22 Sensor -void sensorDHT(){ - float h = dht.readHumidity(); //Read Humidity - float t = dht.readTemperature(); //Read Temperature - - // Check if valid number if non NaN (not a number) will be send. - if (isnan(t) || isnan(h)) { - Serial.println("DHT22 couldn’t be read"); - } else { - Serial.print("Humidity : "); - Serial.print(h); - Serial.println(" %"); - Serial.print("Temperature : "); - Serial.print(t); - Serial.println(" C"); - - if(!mqttClient.publish((String("home-assistant/") + String(ESP.getChipId()) + String("/humidity")).c_str(), - String(dht.readHumidity()).c_str())) { - Serial.println("Publish failed"); - } - if(!mqttClient.publish((String("home-assistant/") + String(ESP.getChipId()) + String("/temperature")).c_str(), - String(dht.readTemperature()).c_str())) { - Serial.println("Publish failed"); - } - - } -} - -/**********************************************/ -/* WiFi connecting script -/**********************************************/ -void connectWifi() { - WiFi.mode(WIFI_STA); - WiFi.begin(ssid, password); // Start WiFI - - Serial.print("Connecting "); - while (WiFi.status() != WL_CONNECTED) - { - delay(500); - Serial.print("."); - } - Serial.println("WiFi connected"); - Serial.print("IP address: "); - Serial.println(WiFi.localIP()); -} - -String Float2String(float value) -{ - // Convert a float to String with two decimals. - char temp[15]; - String s; - - dtostrf(value,13, 2, temp); - s = String(temp); - s.trim(); - return s; -} - -/**********************************************/ -/* -/**********************************************/ - -void reconnect() { - // Loop until we're reconnected - while (!mqttClient.connected()) { - Serial.print("Attempting MQTT connection..."); - // Attempt to connect - if (mqttClient.connect(String(ESP.getChipId()).c_str())) { - Serial.println("connected"); - } else { - Serial.print("failed, rc="); - Serial.print(mqttClient.state()); - Serial.println(" try again in 5 seconds"); - // Wait 5 seconds before retrying - delay(5000); - } - } -} - diff --git a/esp8266-arduino/dht22-shack/readme.md b/esp8266-arduino/dht22-shack/readme.md deleted file mode 100644 index f2b1609af..000000000 --- a/esp8266-arduino/dht22-shack/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# requirements - -pubsublib: https://github.com/knolleary/pubsubclient diff --git a/esp8266-arduino/dht22-wifi/DHT.cpp b/esp8266-arduino/dht22-wifi/DHT.cpp deleted file mode 100644 index 86ad91c43..000000000 --- a/esp8266-arduino/dht22-wifi/DHT.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* DHT library - -MIT license -written by Adafruit Industries -*/ - -#include "DHT.h" - -#define MIN_INTERVAL 2000 - -DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { - _pin = pin; - _type = type; - #ifdef __AVR - _bit = digitalPinToBitMask(pin); - _port = digitalPinToPort(pin); - #endif - _maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for - // reading pulses from DHT sensor. - // Note that count is now ignored as the DHT reading algorithm adjusts itself - // basd on the speed of the processor. -} - -void DHT::begin(void) { - // set up the pins! - pinMode(_pin, INPUT_PULLUP); - // Using this value makes sure that millis() - lastreadtime will be - // >= MIN_INTERVAL right away. Note that this assignment wraps around, - // but so will the subtraction. - _lastreadtime = -MIN_INTERVAL; - DEBUG_PRINT("Max clock cycles: "); DEBUG_PRINTLN(_maxcycles, DEC); -} - -//boolean S == Scale. True == Fahrenheit; False == Celcius -float DHT::readTemperature(bool S, bool force) { - float f = NAN; - - if (read(force)) { - switch (_type) { - case DHT11: - f = data[2]; - if(S) { - f = convertCtoF(f); - } - break; - case DHT22: - case DHT21: - f = data[2] & 0x7F; - f *= 256; - f += data[3]; - f *= 0.1; - if (data[2] & 0x80) { - f *= -1; - } - if(S) { - f = convertCtoF(f); - } - break; - } - } - return f; -} - -float DHT::convertCtoF(float c) { - return c * 1.8 + 32; -} - -float DHT::convertFtoC(float f) { - return (f - 32) * 0.55555; -} - -float DHT::readHumidity(bool force) { - float f = NAN; - if (read()) { - switch (_type) { - case DHT11: - f = data[0]; - break; - case DHT22: - case DHT21: - f = data[0]; - f *= 256; - f += data[1]; - f *= 0.1; - break; - } - } - return f; -} - -//boolean isFahrenheit: True == Fahrenheit; False == Celcius -float DHT::computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit) { - // Using both Rothfusz and Steadman's equations - // http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml - float hi; - - if (!isFahrenheit) - temperature = convertCtoF(temperature); - - hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (percentHumidity * 0.094)); - - if (hi > 79) { - hi = -42.379 + - 2.04901523 * temperature + - 10.14333127 * percentHumidity + - -0.22475541 * temperature*percentHumidity + - -0.00683783 * pow(temperature, 2) + - -0.05481717 * pow(percentHumidity, 2) + - 0.00122874 * pow(temperature, 2) * percentHumidity + - 0.00085282 * temperature*pow(percentHumidity, 2) + - -0.00000199 * pow(temperature, 2) * pow(percentHumidity, 2); - - if((percentHumidity < 13) && (temperature >= 80.0) && (temperature <= 112.0)) - hi -= ((13.0 - percentHumidity) * 0.25) * sqrt((17.0 - abs(temperature - 95.0)) * 0.05882); - - else if((percentHumidity > 85.0) && (temperature >= 80.0) && (temperature <= 87.0)) - hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2); - } - - return isFahrenheit ? hi : convertFtoC(hi); -} - -boolean DHT::read(bool force) { - // Check if sensor was read less than two seconds ago and return early - // to use last reading. - uint32_t currenttime = millis(); - if (!force && ((currenttime - _lastreadtime) < 2000)) { - return _lastresult; // return last correct measurement - } - _lastreadtime = currenttime; - - // Reset 40 bits of received data to zero. - data[0] = data[1] = data[2] = data[3] = data[4] = 0; - - // Send start signal. See DHT datasheet for full signal diagram: - // http://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf - - // Go into high impedence state to let pull-up raise data line level and - // start the reading process. - digitalWrite(_pin, HIGH); - delay(250); - - // First set data line low for 20 milliseconds. - pinMode(_pin, OUTPUT); - digitalWrite(_pin, LOW); - delay(20); - - uint32_t cycles[80]; - { - // Turn off interrupts temporarily because the next sections are timing critical - // and we don't want any interruptions. - InterruptLock lock; - - // End the start signal by setting data line high for 40 microseconds. - digitalWrite(_pin, HIGH); - delayMicroseconds(40); - - // Now start reading the data line to get the value from the DHT sensor. - pinMode(_pin, INPUT_PULLUP); - delayMicroseconds(10); // Delay a bit to let sensor pull data line low. - - // First expect a low signal for ~80 microseconds followed by a high signal - // for ~80 microseconds again. - if (expectPulse(LOW) == 0) { - DEBUG_PRINTLN(F("Timeout waiting for start signal low pulse.")); - _lastresult = false; - return _lastresult; - } - if (expectPulse(HIGH) == 0) { - DEBUG_PRINTLN(F("Timeout waiting for start signal high pulse.")); - _lastresult = false; - return _lastresult; - } - - // Now read the 40 bits sent by the sensor. Each bit is sent as a 50 - // microsecond low pulse followed by a variable length high pulse. If the - // high pulse is ~28 microseconds then it's a 0 and if it's ~70 microseconds - // then it's a 1. We measure the cycle count of the initial 50us low pulse - // and use that to compare to the cycle count of the high pulse to determine - // if the bit is a 0 (high state cycle count < low state cycle count), or a - // 1 (high state cycle count > low state cycle count). Note that for speed all - // the pulses are read into a array and then examined in a later step. - for (int i=0; i<80; i+=2) { - cycles[i] = expectPulse(LOW); - cycles[i+1] = expectPulse(HIGH); - } - } // Timing critical code is now complete. - - // Inspect pulses and determine which ones are 0 (high state cycle count < low - // state cycle count), or 1 (high state cycle count > low state cycle count). - for (int i=0; i<40; ++i) { - uint32_t lowCycles = cycles[2*i]; - uint32_t highCycles = cycles[2*i+1]; - if ((lowCycles == 0) || (highCycles == 0)) { - DEBUG_PRINTLN(F("Timeout waiting for pulse.")); - _lastresult = false; - return _lastresult; - } - data[i/8] <<= 1; - // Now compare the low and high cycle times to see if the bit is a 0 or 1. - if (highCycles > lowCycles) { - // High cycles are greater than 50us low cycle count, must be a 1. - data[i/8] |= 1; - } - // Else high cycles are less than (or equal to, a weird case) the 50us low - // cycle count so this must be a zero. Nothing needs to be changed in the - // stored data. - } - - DEBUG_PRINTLN(F("Received:")); - DEBUG_PRINT(data[0], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[1], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[2], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[3], HEX); DEBUG_PRINT(F(", ")); - DEBUG_PRINT(data[4], HEX); DEBUG_PRINT(F(" =? ")); - DEBUG_PRINTLN((data[0] + data[1] + data[2] + data[3]) & 0xFF, HEX); - - // Check we read 40 bits and that the checksum matches. - if (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) { - _lastresult = true; - return _lastresult; - } - else { - DEBUG_PRINTLN(F("Checksum failure!")); - _lastresult = false; - return _lastresult; - } -} - -// Expect the signal line to be at the specified level for a period of time and -// return a count of loop cycles spent at that level (this cycle count can be -// used to compare the relative time of two pulses). If more than a millisecond -// ellapses without the level changing then the call fails with a 0 response. -// This is adapted from Arduino's pulseInLong function (which is only available -// in the very latest IDE versions): -// https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_pulse.c -uint32_t DHT::expectPulse(bool level) { - uint32_t count = 0; - // On AVR platforms use direct GPIO port access as it's much faster and better - // for catching pulses that are 10's of microseconds in length: - #ifdef __AVR - uint8_t portState = level ? _bit : 0; - while ((*portInputRegister(_port) & _bit) == portState) { - if (count++ >= _maxcycles) { - return 0; // Exceeded timeout, fail. - } - } - // Otherwise fall back to using digitalRead (this seems to be necessary on ESP8266 - // right now, perhaps bugs in direct port access functions?). - #else - while (digitalRead(_pin) == level) { - if (count++ >= _maxcycles) { - return 0; // Exceeded timeout, fail. - } - } - #endif - - return count; -} diff --git a/esp8266-arduino/dht22-wifi/DHT.h b/esp8266-arduino/dht22-wifi/DHT.h deleted file mode 100644 index d81f6dbc9..000000000 --- a/esp8266-arduino/dht22-wifi/DHT.h +++ /dev/null @@ -1,75 +0,0 @@ -/* DHT library - -MIT license -written by Adafruit Industries -*/ -#ifndef DHT_H -#define DHT_H - -#if ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - - -// Uncomment to enable printing out nice debug messages. -//#define DHT_DEBUG - -// Define where debug output will be printed. -#define DEBUG_PRINTER Serial - -// Setup debug printing macros. -#ifdef DHT_DEBUG - #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } - #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } -#else - #define DEBUG_PRINT(...) {} - #define DEBUG_PRINTLN(...) {} -#endif - -// Define types of sensors. -#define DHT11 11 -#define DHT22 22 -#define DHT21 21 -#define AM2301 21 - - -class DHT { - public: - DHT(uint8_t pin, uint8_t type, uint8_t count=6); - void begin(void); - float readTemperature(bool S=false, bool force=false); - float convertCtoF(float); - float convertFtoC(float); - float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); - float readHumidity(bool force=false); - boolean read(bool force=false); - - private: - uint8_t data[5]; - uint8_t _pin, _type; - #ifdef __AVR - // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask - // for the digital pin connected to the DHT. Other platforms will use digitalRead. - uint8_t _bit, _port; - #endif - uint32_t _lastreadtime, _maxcycles; - bool _lastresult; - - uint32_t expectPulse(bool level); - -}; - -class InterruptLock { - public: - InterruptLock() { - noInterrupts(); - } - ~InterruptLock() { - interrupts(); - } - -}; - -#endif diff --git a/esp8266-arduino/dht22-wifi/dht22-wifi.ino b/esp8266-arduino/dht22-wifi/dht22-wifi.ino deleted file mode 100644 index 128e221d4..000000000 --- a/esp8266-arduino/dht22-wifi/dht22-wifi.ino +++ /dev/null @@ -1,176 +0,0 @@ -/************************************************************/ -/* DHT22 -> luftdaten.info api */ -/************************************************************/ - -// increment on change -#define SOFTWARE_VERSION "MFA-2015-002-DHT22" - -/**********************************************/ -/* DHT declaration -/**********************************************/ -#include "DHT.h" -#define DHTPIN 4 // D2 -#define DHTTYPE DHT22 -DHT dht(DHTPIN, DHTTYPE); - -/**********************************************/ -/* WiFi declarations -/**********************************************/ -#include - -const char* ssid = "Freifunk"; -const char* password = ""; -// const char* host = "192.168.1.12"; -const char* host = "api.luftdaten.info"; -// const int httpPort = 8000; -const int httpPort = 80; -int value = 0; - - -unsigned long starttime; -unsigned long sampletime_ms = 30000; - - -/**********************************************/ -/* WiFi connecting script -/**********************************************/ -void connectWifi() { - WiFi.begin(ssid, password); // Start WiFI - - Serial.print("Connecting "); - while (WiFi.status() != WL_CONNECTED) - { - delay(500); - Serial.print("."); - } - Serial.println("WiFi connected"); - Serial.print("IP address: "); - Serial.println(WiFi.localIP()); -} -/**********************************************/ -/* send data to rest api -/**********************************************/ -void sendData(const String& data, int pin=-1) { - // delay(60000); - ++value; - - Serial.print("connecting to "); - Serial.println(host); - - // Use WiFiClient class to create TCP connections - WiFiClient client; - if (!client.connect(host, httpPort)) { - Serial.println("connection failed"); - return; - } - - // create an URI for the request - String url = "/v1/push-sensor-data/"; - - Serial.print("Requesting URL: "); - Serial.println(url); - Serial.println(data); - - String pinstr=String('-'); - if (pin > 0 ){pinstr=String(pin);} - // send request to the server - client.print(String("POST ") + url + " HTTP/1.1\r\n" + - "Host: " + host + "\r\n" + - "Pin: " + pinstr + "\r\n" + - "Content-Type: application/json\r\n" + - "Sensor: esp8266-"); - client.println(ESP.getChipId()); - client.print("Content-Length: "); - client.println(data.length(), DEC); - client.println("Connection: close\r\n"); - - client.println(data); - - delay(1); - - // Read reply from server and print them - while(client.available()){ - char c = client.read(); - Serial.print(c); - } - - Serial.println(); - Serial.println("closing connection"); -} - -String Float2String(float value) -{ - // Convert a float to String with two decimals. - char temp[15]; - String s; - - dtostrf(value,13, 2, temp); - s = String(temp); - s.trim(); - return s; -} - -// DHT22 Sensor -void sensorDHT(){ - String data; - float h = dht.readHumidity(); //Read Humidity - float t = dht.readTemperature(); //Read Temperature - - // Check if valid number if non NaN (not a number) will be send. - if (isnan(t) || isnan(h)) { - Serial.println("DHT22 couldn’t be read"); - } else { - Serial.print("Humidity : "); - Serial.print(h); - Serial.print(" %\n"); - Serial.print("Temperature : "); - Serial.print(t); - Serial.println(" C"); - - // json for push to api: h t - data = "{\"software_version\": \""; - data += SOFTWARE_VERSION; - data += "\","; - data += "\"sensordatavalues\":[{"; - data += "\"value_type\":\"temperature\",\"value\":\""; - data += Float2String(t); - data += "\"},{"; - data += "\"value_type\":\"humidity\",\"value\":\""; - data += Float2String(h); - data += "\"}]}"; - sendData(data, DHTPIN); - - } -} - - -/**********************************************/ -/* The Setup -/**********************************************/ -void setup() { - Serial.begin(9600); //Output to Serial at 9600 baud - pinMode(DHTPIN,INPUT); - delay(10); - starttime = millis(); // store the start time - dht.begin(); // Start DHT - delay(1000); - connectWifi(); // Start ConnecWifi - Serial.print("\n"); - Serial.println("ChipId: "); - Serial.println(ESP.getChipId()); -} - -/**********************************************/ -/* And action -/**********************************************/ -void loop() { - // Checking if it is time to sample - if ((millis()-starttime) > sampletime_ms) - { - starttime = millis(); // store the start time - sensorDHT(); // getting temperature and humidity - Serial.println("------------------------------"); - } -} - - diff --git a/esp8266-arduino/mma7455/Readme.md b/esp8266-arduino/mma7455/Readme.md deleted file mode 100644 index 436f0004b..000000000 --- a/esp8266-arduino/mma7455/Readme.md +++ /dev/null @@ -1,3 +0,0 @@ -## MMA7455 - -is now a library and has moved to https://github.com/ricki-z/MMA7455 . diff --git a/esp8266-arduino/mqtt/README.md b/esp8266-arduino/mqtt/README.md deleted file mode 100644 index 10213db3f..000000000 --- a/esp8266-arduino/mqtt/README.md +++ /dev/null @@ -1,74 +0,0 @@ -# MQTT implementations - -Other repos with MQTT implementations: - -git clone https://github.com/Pfannex/AktSen -git clone https://github.com/tuanpmt/espduino -git clone https://github.com/adafruit/Adafruit_MQTT_Library/ -git clone https://github.com/tuanpmt/esp_mqtt - -http://pubsubclient.knolleary.net/ -Arduino Client for MQTT -git clone https://github.com/knolleary/pubsubclient/ - -Adafruit API only? did not evaluate for other servers -* https://github.com/adafruit/Adafruit_MQTT_Library/ -* https://www.youtube.com/watch?v=VjpONmC2tac very nice intro into Adafruit MQTT with an ESP - -# aREST - -aREST can be used to control ESP8266 boards from anywhere in the world, by communicating with the board via MQTT commands. - -* https://arest.io/esp8266-cloud/ - - -# InfluxDB - - -The following instruction appears, if you get rid of the nagging overlay on https://influxdata.com/downloads/ - -## Install on Ubuntu & Debian - -Telegraf - - wget http://get.influxdb.org/telegraf/telegraf_0.12.0-1_amd64.deb - sudo dpkg -i telegraf_0.12.0-1_amd64.deb - #MD5: 6fc5150433655fedd91bd8c124d30fab - -InfluxDB - - #MD5: 465e6cd66eb6dd23592386ce7d19136f - wget https://s3.amazonaws.com/influxdb/influxdb_0.12.1-1_amd64.deb - sudo dpkg -i influxdb_0.12.1-1_amd64.deb - - -Chronograf - - #MD5: 3392f10416e43ae818d1fda2f83e3514 - wget https://s3.amazonaws.com/get.influxdb.org/chronograf/chronograf_0.12.0_amd64.deb - sudo dpkg -i chronograf_0.12.0_amd64.deb - -Kapacitor - - - #MD5: a74a7a20a67fd7f061c3179061250b17 - wget https://s3.amazonaws.com/kapacitor/kapacitor_0.12.0-1_amd64.deb - sudo dpkg -i kapacitor_0.12.0-1_amd64.deb - - -## Standalone Binaries (64-bit) - -Telegraf - - wget http://get.influxdb.org/telegraf/telegraf-0.12.0-1_linux_amd64.tar.gz - tar xvfz telegraf-0.12.0-1_linux_amd64.tar.gz - #MD5: e44b7c959d168ef03f4e8f2854384a77 - -InfluxDB - - #MD5: 203e98cdd3dd050c78b06c083d2d5d3e - wget https://s3.amazonaws.com/influxdb/influxdb-0.12.1-1_linux_amd64.tar.gz - tar xvfz influxdb-0.12.1-1_linux_amd64.tar.gz - - - diff --git a/esp8266-arduino/mqtt/arest_cloud/arest_cloud.ino b/esp8266-arduino/mqtt/arest_cloud/arest_cloud.ino deleted file mode 100644 index d3550fbc1..000000000 --- a/esp8266-arduino/mqtt/arest_cloud/arest_cloud.ino +++ /dev/null @@ -1,84 +0,0 @@ -/* - This a simple example of the aREST Library for the ESP8266 WiFi chip. - This example illustrate the cloud part of aREST that makes the board accessible from anywhere - See the README file for more details. - - Written in 2015 by Marco Schwartz under a GPL license. -*/ - -// Import required libraries -#include -#include -#include - -// Clients -WiFiClient espClient; -PubSubClient client(espClient); - -// Create aREST instance -aREST rest = aREST(client);//,"mqtt.opendataset.click"); - -// Unique ID to identify the device for cloud.arest.io -char device_id[16]="aRESTtest"; - -// WiFi parameters -const char* ssid = "Freifunk"; -const char* password = ""; - -// Variables to be exposed to the API -int temperature; -int humidity; - -// Functions -void callback(char* topic, byte* payload, unsigned int length); - -void setup(void) -{ - ltoa(ESP.getChipId(),device_id,10); -// device_id="aRESTtest"; - // Start Serial - Serial.begin(115200); - Serial.println(ESP.getChipId()); - - // Set callback - client.setCallback(callback); - - // Init variables and expose them to REST API - temperature = 24; - humidity = 40; - rest.variable("temperature",&temperature); - rest.variable("humidity",&humidity); - - // Give name and ID to device - rest.set_id(device_id); - rest.set_name("esp8266"); - - // Connect to WiFi - WiFi.begin(ssid, password); - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } - Serial.println(""); - Serial.println("WiFi connected"); - WiFi.printDiag(Serial); - Serial.println(WiFi.localIP()); - Serial.println(WiFi.RSSI()); - // Set output topic - char* out_topic = rest.get_topic(); - -} - -void loop() { - - // Connect to the cloud - rest.handle(client); - -} - -// Handles message arrived on subscribed topic(s) -void callback(char* topic, byte* payload, unsigned int length) { - - rest.handle_callback(client, topic, payload, length); - -} \ No newline at end of file diff --git a/esp8266-arduino/mqtt/arest_esp/arest_esp.ino b/esp8266-arduino/mqtt/arest_esp/arest_esp.ino deleted file mode 100644 index 11f4c5a35..000000000 --- a/esp8266-arduino/mqtt/arest_esp/arest_esp.ino +++ /dev/null @@ -1,114 +0,0 @@ -/* - This a simple example of the aREST Library for the ESP8266 WiFi chip. - See the README file for more details. - - Written in 2015 by Marco Schwartz under a GPL license. -*/ - -// Import required libraries -#include -#include - -// Create aREST instance -aREST rest = aREST(); - -// WiFi parameters -const char* ssid = "Freifunk"; -const char* password = ""; - -// The port to listen for incoming TCP connections -#define LISTEN_PORT 80 -#define PIN_LED BUILTIN_LED - -// Create an instance of the server -WiFiServer server(LISTEN_PORT); - -// Variables to be exposed to the API -int temperature; -int humidity; -int myvar=0; - -// Declare functions to be exposed to the API -int ledControl(String command); - -void setup(void) -{ - - pinMode(PIN_LED, OUTPUT); - // Start Serial - Serial.begin(115200); - - // Init variables and expose them to REST API - temperature = 24; - humidity = 40; - rest.variable("temperature",&temperature); - rest.variable("humidity",&humidity); - rest.variable("myvar",&myvar); - - // Function to be exposed - rest.function("led",ledControl); - rest.function("myvar",myvarControl); - - String idstr=String(ESP.getChipId()); - // Give name and ID to device - rest.set_id(idstr.c_str()); - Serial.print("DeviceID: "); - Serial.println(idstr); - idstr=String("esp8266-")+idstr; - Serial.print("Name: "); - Serial.println(idstr); - rest.set_name(idstr.c_str()); - - // Connect to WiFi - WiFi.begin(ssid, password); - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } - Serial.println(""); - Serial.println("WiFi connected"); - - // Start the server - server.begin(); - Serial.println("Server started"); - - // Print the IP address - Serial.println(WiFi.localIP()); -} - -void loop() { - - // Handle REST calls - WiFiClient client = server.available(); - if (!client) { - return; - } - while(!client.available()){ - delay(1); - } - rest.handle(client); - -} - -// Custom function accessible by the API -int ledControl(String command) { - - // Get state from command - int state = command.toInt(); - - digitalWrite(PIN_LED,state); - return 1; -} - -// Custom function accessible by the API -int myvarControl(String command){ - - // Get var value from command - myvar = command.toInt(); - - Serial.print("set myvar from"); - Serial.print(command); - Serial.print(" to "); - Serial.println(myvar); - return 1; -} \ No newline at end of file diff --git a/esp8266-arduino/multisens/.gitignore b/esp8266-arduino/multisens/.gitignore deleted file mode 100644 index 0fda9231b..000000000 --- a/esp8266-arduino/multisens/.gitignore +++ /dev/null @@ -1 +0,0 @@ -sensorconfig.h diff --git a/esp8266-arduino/multisens/README.md b/esp8266-arduino/multisens/README.md deleted file mode 100644 index cb0894dd0..000000000 --- a/esp8266-arduino/multisens/README.md +++ /dev/null @@ -1,27 +0,0 @@ -Arduino sketch for multiple sensors - -Configure your sensors in sensorconfig.h (copy sensorconfig.h.template if not yet done) - - cp sensorconfig.h.template sensorconfig.h - -* #include _ACTIVE statements to compile sensor type -* PINS (=GPIO of esp8266) -* WiFi credentials -* server name, api to push to - -You will need to set the additional boards manager URL in file->settings (Datei->Voreinstellungen): -http://arduino.esp8266.com/stable/package_esp8266com_index.json - -for the esp8266 board then select: - -* select in Werkzeuge->Platine->BoardsManager (tools->boards->BoardsManager): esp8266 -* select board "NodeMCU 0.9 (ESP-12 Module)" - -Libraries: - -* Sketch -> Include library -> Library manager -* Add "DHT sensor library" -* "OneWire" should be there already -* MQTT PubSubClient https://github.com/knolleary/pubsubclient/ - -* MQTT home assistant stack HASS https://home-assistant.io/ diff --git a/esp8266-arduino/multisens/TODO.md b/esp8266-arduino/multisens/TODO.md deleted file mode 100644 index b2879f87f..000000000 --- a/esp8266-arduino/multisens/TODO.md +++ /dev/null @@ -1,40 +0,0 @@ -MQTT: reconnecting does not work, what to re-init, if network changes? -MQTT: howto timestamps (must be on server side or we need to use a "timestamp ticker" topic to subscribe to) - -DONE implement MQTT -DONE merge software ID from esp8266-arduino/ppd42ns-wifi-dht/ppd42ns-wifi-dht.ino -DONE implement status LEDs -DONE Move sensor specific code to header files, add conditionals to include/exclude via #define #ifdef -DONE dhtpush.h -DONE ds18x20push.h -DONE also for PPD? -> yes, via #define -DONE use sensorconfig.h to configure also the #define statements -DONE WIRELESS_ACTIVE option to log only via serial (HDM copter) - -# TODOs - -* config might be done via aREST https://arest.io/esp8266-cloud/ - -# optimised Onewire code: -http://www.cupidcontrols.com/2014/10/moteino-arduino-and-1wire-optimize-your-read-for-speed/ -see also Asynchronous vs. Synchronous read/write on -http://playground.arduino.cc/Learning/OneWire - -* non-parasitic mode read? is it really -ds.write(0x44, 0); // start conversion, with parasite power off at the end -From the header file OneWire.h: - - // Write a byte. If 'power' is one then the wire is held high at - // the end for parasitically powered devices. - -http://openenergymonitor.org/emon/buildingblocks/DS18B20-temperature-sensing -what lib is this? -// int numberOfDevices = ds.getDeviceCount(); -// Serial.print("Found "); -// Serial.print(numberOfDevices, DEC); -// Serial.println(" devices."); - -// Serial.print("Parasite power is: "); -// if (ds.isParasitePowerMode()) Serial.println("ON"); -// else Serial.println("OFF"); - diff --git a/esp8266-arduino/multisens/apifunctions.h b/esp8266-arduino/multisens/apifunctions.h deleted file mode 100644 index ea06bff23..000000000 --- a/esp8266-arduino/multisens/apifunctions.h +++ /dev/null @@ -1,184 +0,0 @@ -#ifndef APIFUNCTIONS_H -#define APIFUNCTIONS_H -// #include - -/**********************************************/ -/* MAC adresses -/**********************************************/ - -void PrintMacAddress(void) { -#ifndef WIRELESS_ACTIVE - Serial.println("MAC: no WiFi -> no MAC"); -#endif -#ifdef WIRELESS_ACTIVE - uint8_t MAC_STA[6]; - uint8_t MAC_softAP[] = {0,0,0,0,0,0}; - char temp[20]; // buffer for formatting the output (xx:xx:xx:xx:xx:xx\r\n) = 20 bytes - uint8_t macaddr[6]; // array that will receive the MAC address from the chip - Serial.print("MAC[SoftAP]"); - uint8_t* MAC = WiFi.softAPmacAddress(MAC_softAP); //get MAC address of softAP interface - for (int i = 0; i < sizeof(MAC)+2; ++i){ //this line needs cleaning up. - Serial.print(":"); - Serial.print(MAC[i],HEX); - MAC_softAP[i] = MAC[i]; //copy back to global variable - } - Serial.println(); - //wifi_get_macaddr(0x00, macaddr); - // - // format the a string into temp field as 6 hex numbers with a colon in between - // - Serial.println(); - Serial.print("MAC[STA]"); - MAC = WiFi.macAddress(MAC_STA); //get MAC address of STA interface - for (int i = 0; i < sizeof(MAC)+2; ++i){ - Serial.print(":"); - Serial.print(MAC[i],HEX); - MAC_STA[i] = MAC[i]; //copy back to global variable - } - Serial.println(); -#endif //WIRELESS_ACTIVE -} - -/***************************************************************** -/* WiFi auto connecting script * -/*****************************************************************/ -void connectWifi() { -#ifdef WIRELESS_ACTIVE - if (WiFi.status() == WL_CONNECTED){ - // nothing to do - return; - } - PrintMacAddress(); - WiFi.begin(ssid, password); // Start WiFI - Serial.print("Connecting to "); - Serial.print(ssid); - Serial.println(); - int counter=0; - while (WiFi.status() != WL_CONNECTED) - { - #ifdef PIN_LED_STATUS - digitalWrite(PIN_LED_STATUS, LOW); - #endif - delay(250+100*counter); - Serial.print(WiFi.status()); - if (counter++==50){ - Serial.println(); - counter =0; - } - #ifdef PIN_LED_STATUS - digitalWrite(PIN_LED_STATUS, HIGH); - #endif - delay(250); - } - Serial.println("WiFi connected"); - Serial.print("IP address: "); - Serial.println(WiFi.localIP()); - // print the received signal strength: - //Serial.print("MAC address: "); - // for (int i = 0; i < 6; ++i) { - // Serial.print(String(mac[i], 16)); - // if (i < 5) - // Serial.print(":"); - // } - long rssi = WiFi.RSSI(); - Serial.print("signal strength (RSSI):"); - Serial.println(rssi); - - //Serial.println(); - //WiFi.printDiag(Serial); -#endif -} - - -/**********************************************/ -/* send data to rest api -/**********************************************/ -void sendData(const String& data, int pin=-1) { - // delay(60000); - ++value; - -#ifdef WIRELESS_ACTIVE -#ifdef PUSHTO_DJANGOAPI -Serial.print("#### Sending to "); -Serial.print(String(host)); -Serial.print(":"); -Serial.print(httpPort); -#ifdef PIN_LED_STATUS -digitalWrite(PIN_LED_STATUS, LOW); -#endif - Serial.print("connecting to "); - Serial.println(host); - - // Use WiFiClient class to create TCP connections - WiFiClient wificlient; - if (!wificlient.connect(host, httpPort)) { - Serial.println("connection failed"); - return; - } - - // create an URI for the request - String url = "/v1/push-sensor-data/"; - - Serial.print("Requesting URL: "); - Serial.println(url); - Serial.println(ESP.getChipId()); - Serial.println(data); - - String pinstr=String('-'); - if (pin > 0 ){pinstr=String(pin);} - // send request to the server - wificlient.print(String("POST ") + url + " HTTP/1.1\r\n" + - "Host: " + host + "\r\n" + - "Pin: " + pinstr + "\r\n" + - "Content-Type: application/json\r\n" + - "Sensor: esp8266-"); - wificlient.println(ESP.getChipId()); - wificlient.print("Content-Length: "); - wificlient.println(data.length(), DEC); - wificlient.println("Connection: close\r\n"); - wificlient.println(data); - delay(1); - - // Read reply from server and print them - while(wificlient.available()){ - char c = wificlient.read(); - Serial.print(c); - } - - Serial.println(); - Serial.println("closing connection"); -// endif PUSHTO_DJANGOAPI -#endif -#ifdef PIN_LED_STATUS -digitalWrite(PIN_LED_STATUS, HIGH); -#endif -#endif //WIRELESS_ACTIVE -#ifndef WIRELESS_ACTIVE - #ifdef PIN_LED_STATUS - digitalWrite(PIN_LED_STATUS, LOW); - delay(100); - digitalWrite(PIN_LED_STATUS, HIGH); - delay(100); - digitalWrite(PIN_LED_STATUS, LOW); - delay(100); - digitalWrite(PIN_LED_STATUS, HIGH); - delay(100); - #endif -#endif // WIRELESS_ACTIVE -} - -String Float2String(float value) -{ - // Convert a float to String with two decimals. - char temp[15]; - String s; - - dtostrf(value,13, 2, temp); - s = String(temp); - s.trim(); - return s; -} - - - -#endif // APIFUNCTIONS_H diff --git a/esp8266-arduino/multisens/configs/.gitignore b/esp8266-arduino/multisens/configs/.gitignore deleted file mode 100644 index 424c745c1..000000000 --- a/esp8266-arduino/multisens/configs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.h diff --git a/esp8266-arduino/multisens/configs/101747.h.asc b/esp8266-arduino/multisens/configs/101747.h.asc deleted file mode 100644 index a0d7c5cc6..000000000 --- a/esp8266-arduino/multisens/configs/101747.h.asc +++ /dev/null @@ -1,68 +0,0 @@ ------BEGIN PGP MESSAGE----- -Version: GnuPG v1 - -hQQOA6oIqzfD9HVBEBAAoEmPLZkMdIXOxG9YKszRcJ1ggWQS/JaB93iCg1VHkyLh -aE2uxkOu/4bXp6vcnHmLbubqW9fCFA/v8S5nS9YyfJqwDkbUoqytxvJOg4/BRo+c -MGd2fRnnV7LOqOFvX/bB69pc3kph0LKfwq6rnmCsrzcy1M70Ql0jPIus+edUx/75 -6r2FaqCIgz5TjR15E2yGt47lSn6QYTC79QrnIegtPe/MIT9VxNf87/DR/fqJQkZL -G5bHiZYNbaqy577QB+6tmZShxyooRo+xEDYpGQPvjOF9ORJBvTSSRFYGzyVtyi0U -qCmIsVNOiuewXtTXpa/2iyatL41AQcA1B222lyFjXscezp4MKV7AcOKZWNG99o3n -ZyjhYssMBNe3YnlDNiKPv7ZAAQSvNxM4F7znQEmPV9meYvdleHKLlIT1cQhqdUF2 -tsELIsBqNHrZD4n4uTnXLOf2I1VeWLL02lzNsExVQ1HYrkFr70tkhOgTE9j4mzoH -0YCTueT44gY2a99TpLjqmsvJYMv4X+rKP2O3QPRN9JW/hQOpny6FAwldPb/j2BJG -DiqCnZLOjDLrmCf4o7ZmvgRmucQ9toPU5sTMKRiRjhAoUzuTyuzYHcikjFynld2W -7Lz/3wA1+DdZI2dilHxSmxg1CbpOEmbqGfYt3NzAd1sO539VkJv0zI0hAQ/Tv4QP -/3B+hToP2nzgPewK9kECglI3FUrlBdd3SgO9elc6wWT3uh7bHJsZdisdMSCQDMgr -Pu8MvnMKv90jF6kMv4bE/k2jlJjExv5AJBpDl49hm0gFTfKarL3Wk6EG0OXI888Q -2bsCLxQTqIOAh/auJu+1h+tTo2A3xlw96t9hZymfneOaLLFmvnfaA0N7/KtmzP5o -l4U0sF0h2aXmzufrp0BtPEOR8QgCwDIRaIsP5s9zxxApzAGXfSZxkOvOgCehXtJK -ZyvXHUehoKn4ZuZZPQb5400OWUsFwKKKDFOImPrIbRrpQ4lP8J0Otjau9iXYisD+ -oGKy2V4TaG/a4BERBpRltTJMH3FQ47tHfbIm7vwEYOoTx5LY8xbwl/Nvljbe6Szw -z6pkyfJjKS983pa5L8camqLSX7ZoraHbvcy80yqoLo/h2qeeQgjEj3jVjeXrGLVW -ysnw/NhOOt9/6ZNaBswrw02fWUuBx9VWPX9oNJY33b1jkTKern6Ksp/9I5RS4zn/ -rlx7GbsqIyslyvm2s9KzDUykZwReJTDcwuY8axmpItsXjmVaqaF5YhmkaXsJBoxR -hGBcR7D+ceMz4o1G5EfUAmII6D135NUxSiE/Fx9i71HQxhImfHA3hxDiMfrYO0RT -S/kfOcjjI7tzD4I1JyGSdCrgR2Ns4Zm3Vulqz4MHmTPs0uoBjB6xceb041JU7TIU -RXKMGWTPJ+Z04+hV2Ayh7reWLGwdLbu6HtviP7WL2c3udvNGVHmo+xRohJ5oMMc6 -uFt2satFd96MWxS4DDJwDgVo/8SbpSkL7pL+GkSWw5bj0NlxA7r3qfzuTcn5IDMm -oUOqSn2BvQ4ZmSPJhynHP5BgoFKV5/nHp7XZPAm1Dzpj45s1aQ9TAa0w6dJBVS6/ -80BWkQtE7wo6v6d7n6bhMKLJp9USWA4fg8ecyHKw7ZY3MEScVRxtrQUckPnaUr9c -ukVjz+4cvZltk8FDHU6/pKzIScuaGdyZOylXYnx0OyBfnpOwQ+S2iXdSBti8fR1l -jwlVSABd67FzAZDBH/ya7cAt0k52BPN8Zz14mC4xTGFR4VhpwxSbanBnYNwocPu/ -CTnsF2BLULAReoNVgFH0H2UlGrYz57M213yuOQYbiyDkNTcTvp/S0sCNl4xHJH4T -6Xl2jnrzryNS1OAnDeF83dmfyFPgDHo3nwQ0PsmYgeAYR7IzuEc+onKYTc+qbnFp -rQZ+UNEYz61GtdPURnNAt9pCFBhYPT50B9/i8LeQ3kXDSFmJSpEW2JE/eXYf302c -5aB1IIVeQ9c0wZwEB2j8vpcaEU5nzRHSZq+z1nQEU86i92qgbS/paBD3uUkUfewr -5K2FkTtyBUowFJc2FQZbW60jU6//eeDelrlC3drQzjy3bf6DoJUmn9RMUEfwbx8p -ykBEBb0dWYSbpHTdA5L4zLBdF791643ff4jNEPDV3lbt1zL5kTuGpjjf7Fl4TyA3 -SUEe1pGjNWzi+LAR03aOqgKO88Ul6viXrbtHMYIlBZYkS3M6AfRnNpsuXE+Wz6l3 -Z2pOI/x0eTX1zZHkgTJgO7BplAg9aSdp35lyt6EfrYAq7VCXGAFfFT7KeaEniSAV -5TNME9gCOU88ivCPOwfKDDejMbS6/lSc1xa5ptGhzA7xYSEwH+Xpo/hcPqAW2X45 -MzhxqzkGqs9nb5PGT9pd9oMNj4ioky0mhTkYLs0jejlzR6NcArkrZII4lC7bYFoZ -IbS2AulnziLixen8vBUMeSzD44xI8s1MBvJzhv7EvlZSSs+cPvd8Zf1+X+/UYoEO -6hKuMGGyfOjZp4IANE13g3EzmpvRYJQ9lTDfchU+wSnmEAJTwFmT/kBjNQEU2bMv -x9ryUC7jFSgcipV6+cSdDIN3OmRx66HerfXdeASm6LU890i3Ey2aOQqmbaQhUzHU -YA7VwnHy24RZQlkIRjoGkyFHpbe62vt6jpVFsYuMqP5WC8K/rBrZfjrU9+qGbIkd -ADZE55M+Ms3LS/9Sg30XZQZdYhRJqzeufepW3msuA66OP9SXtRuELnDHuBkOyCOf -hyoD6fRkcWA+U7dORmhih6brCxhUgClxilTdqK/Al2I/m0tI5Fww3iqXHIDQqne9 -NTTQti6/ZGn6W95Gmz7drhZTwgDzP7ereamxQrA3AG1hdvUTWGG/DJEs6+U5WzXS -PpqvSh586MKo0SolxFROjkeY5NCdCATcGNZmSjKQm+bm3h5w5VaAh7XvFYE9NM3K -raDzuFAHdZwVqNXgMyKeQ9HYI3I5R+kyalUhAVBsAfFUzjzjdClTyrYMc3keuKSa -RuIMaHPdJJokOfRr3bU32xq0TVSUTkyQG8VSI4vPQKzaF/m5VyttH8DJ9SBNOyOk -Mn0abyyHFkn6QxOGf/u3UpW9w9ugkY3Lg0FSZFLWaOY1/745D8rwfRXkTGrnhScn -01RagNhP8s+Ol7bINe4qRJRUwwD0dvAMYYp9XjoSonelYeq9WIbQ9TKVdFrBD3iK -l8nrvU11UVNcyHOtHqcYNHaqx0qMfqUoDaZrVWKfErEZHi59exXFdAtCxyhkqNyr -4SQUf1xDk1Y8yt9s/7XKUErhtBtQYK8TpQ8HObGO+YCvJESDHsA9mLuk9V4vtiSV -2HVuXbB3FIln+gTrZcNjzYw0cg/Yucdi0CrFQsJv/9DYacz8/BEjoQ9lzhlEHMi6 -xkvVO0srgsdRqAb06LfygGo+BhjWCTDm7M204oLpLgVoXzi4wOy5hImCUvdXo8J4 -vRIMR4xu1nqJm2RG09ttTgWOBhQKIIl0ArMRoSAT5cd5LpR9Z+L6FLeRYv+54Dj9 -ZKJIF6JSmlhbj9Xn3aEVSPVKsdwE9fm9O4YSBQdpT2YNQzrOJLn+fIfEEj8sgM+N -Z9jtCVX/byOSouR8PmLYOGjTn3l/qXd/vvsTS5Y5/zNSkdmo/ATyrmEx/Ieg6PDq -jwwFgBYpxwSy01ToYuomEsFpKUeLllQAybNZNWMA5wg9gO3M0E2p+LhKzMnpnWty -thOCKTQ8GAeQBKze8vSQVUaV/BDSMAmER3yH1mgLIOgBUEk+w/zaws/Y4nDjeRC9 -tHq5gBPG9GWZ+AEU+/LOq8DjIQWN8Tvrim1AmX1i2lWiR4NppY7c5w7/hpUnSKKR -joEMzWEzdDRc+WbbZqWoAJabBpQB1aY9MJX3PIZAbF9GJphL6h33fyttzDcEvJrb -5hUp/uTYVQoS3uBmPAKIMzQRuCPGWZmjrTuLPH5nJeeX0Hi4ccTFu1lG6MqeD+/H -pDiwlDTY6CUNm5ZgcyPYtdXNuPwnfSsnIxhoDr4dLhCF1Q== -=zLZ4 ------END PGP MESSAGE----- diff --git a/esp8266-arduino/multisens/configs/13596969.h.asc b/esp8266-arduino/multisens/configs/13596969.h.asc deleted file mode 100644 index f40e90f45..000000000 --- a/esp8266-arduino/multisens/configs/13596969.h.asc +++ /dev/null @@ -1,67 +0,0 @@ ------BEGIN PGP MESSAGE----- -Version: GnuPG v1 - -hQQOA6oIqzfD9HVBEA/9H61DYaOd36PEoIc9GlCG309BeyHgZT/fmWuVkckHZ9pq -5jPi/r8d357oZY2DVJLuoBamlhZPWYTgFLqoh9NsMJrtF+CzMz1L/XJ0kAcasBp4 -YdyIr/+xbAyuIocQgRz9iRrHC8zcbP3Hp0RYX1dYv4/EfhANSqi0GBYTR1ekGK75 -edIMQBNJXAR2FLDBmaGJ63EM+Ewmr8xMvYZCasGsicHyF5/aL32zyN9RU2e36Fok -tENrGP/Ud/w2bpjS/YWKiM19qqNBxfDQSAQNfPggV7I5BCWxmvXCQSf2FKHHGP5t -fil2ZGdQCsX4qljG/b0N1SLnexh3+e7Z88ze+8PAMtvcZKkEZfuqAR1iPTv4l2n1 -Sw2AW8SRwN36ZKh5a6qbqfel97HjdjeOVzNmCUxoIjESzSBtoaIV9U5NiSjiuGPK -FS8pjP+lmaJHwRfEmmx0mUx3lyH3MBGo7peDUnjDCV1zXlckHCdLmUr3DaBrvo/n -8Tgu5UQFkPcnazuQ/90CBKtO5592IHO571OE8vkQeghMziyqCa8nlO8zq9m8g5uT -ryvHNDoE93RFLX0M3/WBU5/mCntt0jxPO3q4eD5eeN9WkmPKjaEZqFmRojCXlNmH -03XE9MagqaNHDndiMA52qBhdnaM9b/NlWudeoExK6VGuyMcVbEN2k2Bf69CQEWkP -/i+h4hz+STmjuzEsc5Looz8rjcLpDOlE+uiYiQZyuRtHPiVtCQ+FEKWVN8j1Zxf4 -We5bU/sAxYAimeYoZ0dkAU5Xx24rkJhhJVu2qqxLWujkeuMO88qq9UqMkS71ZSNQ -MywOA3ht9coN34xeBJXWbGMT+FvOJSfxRkc0jEDByoXF4oftLfBLNkJao3w6QS4c -jZBOM3h+nepMoAmloQSfp5LGZ1RVfqBUY1hBXN0z/EpLrA8/a5sMuLpChJ1QxGqJ -YF8vSqzNOdkGb/3OCH+P/m7iuaXLZja1rp+mpaMdKkr42VXfwqRTGh6cLuA/9ey6 -HmSw4u/UsUKN6HRs/bVk/lQRA6Ar+GPfyp9v/fEbqJ+MsOOEv0jbPR56LXrnMcHP -W6aTv0lavQKfY4P4dNazejvNGBL+1eirpJ+9V6ca7UHa1Omc3Zk3l3BkIaCnksFn -lWiBkRpyuqNNaa4V7R4OWv5t/YFSR9jA18w2hOAIygoVKmy9zre4hHD4uYeOHrdA -kDPMReMTgOzoCl+XfoyuqbVz9lIhXDadNPa5HBMcsVDbC1QtaPTE24CyIknvxvIR -3ICWhL7+CgcwK0Sles5iHHxP4ub4pl08Ic3qbau0QAXsrxCxZjHypwcb47L1hnNT -ZmrPR7k1Yr9l4fdSRjYdNBkt7cJy6U24yCF/vMkaQxpd0uoB77TzBAqhel2tzFjZ -8uoasawvGD0iUg0vYYJur5juSOttilNarZLs1yRrG82NzHCfGP7d8AqWbBLE5BpG -BZYYzvnm3hOCouT4H6XJ8J7Ya73ynjHmrPqqNoEBPIJ/vKkRzYkJwgzP4ph/ZSEg -qvTf2pFgT4mtTcOdqYEE/SBNubHUobAEfAwrlte9+o//8e5391yXJ6ZOBQaKUe66 -KHj5tkniL1cZ1VHgemWLCRqBP1S4zmMSoM6VKsfqd7ntqWC7+mEPw2yXxbHE5Aya -aZnvXAPz3U6Fm1CSPF0/JtcOH+5lU8bfbVhfGzbXNfkEGqvyCy5bipvNNuoosqF+ -i1Pig8kKiIhqF0NzcK3FQPZ5CKZgB8hT5jW+8slqKDwPOxS+9bebERCYP9wmLkkk -BkuVyIOKJ7fzw1gMhjj7hqfctAN8e3JLXjBTjbvmS8/YayLQuK/EH1riRG32qEqX -myC1BHpsD9faBhPCYAkJ8krdZrJSM5fXMONCoqerpwzhK9VfdXk11EbQz1nVOhTa -bZe5dzktu6/BXFFkmyhaxXFPEqLLz3QT7Qa8hgHCFKNygmquCgClB/TitiXjIfp0 -vg9AGoPb/0yrl6ybytwwAxEn51qAUinjvmjIwACjXRPwgvySR0b6Ol7VSBW3hYdT -eAAY7lll5nCZu9fh3ygelZF0pCxuIzNYIkXeNkhhx/C4lmIjHgvhHSeaAkhyhKr5 -Fea4qHtfchsLz/fQYoy9kwxzRD0B8ih82ao99Zlna2DTZvQNJDibMw4s5Kf89/bL -u9pT7mB6y8wa6jhIE6PghUhcIQ60a5cESYOQtUM2lcg7KJAicuPgzL8nNYdV1DGy -d+p0zoBq/eYL9O0zyQkwtbR4+Ho94S/NGLerbrm3QB3EKD8dkXsc4/+jsrSBidcC -i64WJ7ZNY669VtGzkD7AspeXC3bdSPw++KC3gVw65IFpd8tXtmfBDZsKEs3NN43Y -6DlKRA1CRUinfApEwVktiqrJYk+7Z+ReZaMtNbZ4d+prHAUJ9z5ScjQNVylCnzMp -89ZgpDPVKQrVYxR2fAC7lF6LPnF6Euly9btv8sc5ifukp54fsMdm4WBlfGd+imvA -60xyYRiAiuB8aNiFmcmj7Nq8yeqH0ykSRdQ6Q1TiRwtWu8eLB93v45elteNFtGLT -kqATrn0mMPFzxyfMcpOELLYegBI5WUQhn1xYWgXZ5KNtPxPRIgWI00mcoDqQOPsa -vnUO/h6+gYSeLVSoZdgn99EvJFy1kd9KnLuzDWLSc6fmQmXLHnz8N6+noU7Rz46H -Wyto2vaGTvSbyVVHUBn0YqM5gBU5KnhWnLN/EkgLCxT8lu5Og/EoZv8TrlqRSPhg -HZlc6dm+uYUTkNG4cfAwa0ufTZOALpY+8mPBdBHH4NWAX9uK28Ocmf4FJMQYFgyU -BhbPVFXSJhBodWUABldKCEphcnh9USPL75R3mkKhKU2tOY+rlXWbLRXZsim3B9H8 -Yx5NAXlJ2KEePKzjaYFlQZJFWqhX7stCa/mTvvKl/P6LMm/u8sXOxtElBfEUFBS1 -lsCHy/vVSQWDDCdxSkFx0wRux0u8ulduU56lAqjqal6scS1Zy7CvGZpCOqt9opI5 -NdrJ43DF5MvpNOdt4RpPvTrPKDqncnSsw/Ovd6UHMeYqtEJwutnAuRedhTLtIzfP -+qdIOJCBsIm2mo8nVCs1LMHN6s+s5Ah+Ekf7mZV7KvTWF2k5NMstPhE460H3DWPK -v4Ny4q7JhOAwI9lqZcQJLhsQ9Gj9ZpnWHrZ0evzZjB65fHCA1KoUWjus65ehf5WO -4SrZk9kamqkv90hzcIbvVhqTYMOv7AmU6CUYfNtGpE0mkMmLy+ys3aGfd23ek1OW -YrOdTEtrSN5RGHllDJtb8DcZcP3gNAZE8O/Q1PEe6eSmyifmSLE6D/FHC23PEK2J -u7RNU78bWjS7+L9hHZ/+rULACrIJHExVsygKup57mf0py5Medfjc23e6PewABsMw -QYs8jrJPr5Fkq5rZcpt9d5xd6QpxVdIn1tgCbwyuzrfFCMSvwMaEB4gBeJNM6MSX -B/4bBcXDRo5i9glfM9i5LOjtdnT2kAVlaUQZqTrHdwmI7YNvsa/7VyMiiOs4iyMc -x+XRoyw7M+9qEWOC+76IUK+HMIeQ0UKlbsRfWAEM8Z+9ZN53LDwJOcapJILAnCCs -6uY0PjvIwRND3yWn31x74H1FXDHz4bRjnnhIw29M7PqeXrKfr8oMcAPp+6Lv0chH -juiKc2Ts+xXE/QZ/V5KQEJJCPbG7VKqIedXoBG8gKfMf+Td5jSuaFVrUMhC8wM+f -sAWk8ON9tuyTOcxyMcdOLdnrD+L5deMZhgfDykpU8RX7601QqJFAkqt//VVEJpUf -fGslTXCfEJxA+7z7QnJyzY4HdQAmAl1V9U9jYx/KqQZdEX3nK74a6b3hHEU/9bRD -+yWav5s8H08A6ffRgpD1HD+p4gQTebcDfWzO5GMTF6UmX70nIniqAyv1NSHuqB6h -JW8Lfjvs9+cGOXBXOI8lP0bzh7BZYRlY7jDJq+gNGSIxc3R5vHa4dGPUdz0= -=Dk+g ------END PGP MESSAGE----- diff --git a/esp8266-arduino/multisens/configs/dhtmqtthome.h.asc b/esp8266-arduino/multisens/configs/dhtmqtthome.h.asc deleted file mode 100644 index 59bb9168b..000000000 --- a/esp8266-arduino/multisens/configs/dhtmqtthome.h.asc +++ /dev/null @@ -1,69 +0,0 @@ ------BEGIN PGP MESSAGE----- -Version: GnuPG v1 - -hQQOA6oIqzfD9HVBEBAAo6buEsMsK8vo1O1MsylfuUpGL8SfR9GAZbgBR7D0VRUl -fsX8xIREph4vDr9fVnjOaXRbAPEFAEe7TuIFSeSEo9pr9jSRU1TgrooQK/VPqeBS -/FRDjG0UIIa6pXAs+SdvHgO46euE7zFdmod2d5tM8XL1mF2HSV9riZ+VTrAZEZcA -iw6HYpxZd7X8kV2k910+KF+BQjovFB5ZoahzMMgpZFIOQucO2Dr8FJ33y9RGVgtX -+tt0ps2NAdLDH7tEp++cPBFsRigklUKmx2oQiBxOAxtOeOnoCmXFWMGbK/ki74M/ -zPrxrgdjqbOGPHf8//ANrjlh3My4FveNB774EouP8xG2k+YU45F8ewH7MdoR2rpu -8+6GPmwN27qlnI0H1ieHYa2IlcMgO7i2+IyXNW4T8MIXgv0GKV7Iuu/7mz/BKSGU -663URE8Wm+nhivdGjh7L60zq+vYoEU74t3rjT6wvv/w/H9hlCFO9ZpsjIemYwwbS -kpfYoS+ZSU5RzlXiGhn3uDv72h3gDq+oJbZJaIGXDNrcl+M0All/jQ5fzE3meIOo -WcHF2Xxa1lzRPthhvbzxoNllt09CajzGfj/j+olDhutraXqPvlt0Vw+82uVT4u2j -3s+Dy5++NP4+lQwN7VkxOgLsQ8x7kcUhibbKpzVX556Ndsinzx+rl+88XpO3+poP -/2kZvNJTSq7UjdWuOC12KuRL4nZcd6SVAKdx+DNnfBCa1s18VH1wMDdbr16NM7hH -cnmlB9wq+V53DEOwZf42xx19twVV+0S/EFYvj4Brqyzp0Avta4ZAQW19iA0W6lBL -O7l+0ZJu/in+4omxS2++Gev4aDdNjLcyWQH5iZEkNg19JcxxJv961TdlJRS6VA47 -Brv2q2ol9MwLQHxvLwiqsYob0sBzolnYy9F2kpPzQ0OmTUN37uQZLxkzL6a9wzyC -uKVS+fe0/Q7yqXut6D33o2Rd7RF+DB8zGQKRJf/Wn7m0W7+7aJjUzUmvpK6shGuw -KhoZnFlvc36KSy1cdldKmbEccHz/Vcab91wsIfxdbQ2NoVIwgfZe/BYt3Z8Kz2to -TJZX3KRxDxaBFQkvpRunKazhyP9sDrDpLvF6pF1RQ0ILIupf52iafPuR7/XcVx/M -tpbdgGjQ+RRRcUjky5MYEvSDIjabQLaK5l2woKXFH5Yvn97+pqtkqAUeJy/bkgB2 -EaaXM0pbyapnFsCAFjtWquER3Qm8fsBZs9Q6rjr9nQC9GJ7l7ONf/f0XwpdQeole -DXTV+bJu2mztkLEBIgHdyQ91i/OiJ9m4m/lM4aFN1rt1oxsYFJaNtowgvD1iI/4v -oOTA7kp2BwsjctRCY7LdbQ5Gpi5v8JzR6GNqHoBBMoGf0uoBxm1/mL1mOMYQYvOl -W+xb/ci27p8w8wOsJxSPXLf805/qW0xdl1e1WrZVhnJnAv1jlG6Xm85iruW2B8iZ -P07XiiDs/7ywgmSTLPB2bRQTycT7NswQzRwwYrluyhbf+JvinY4ydks33pJ5LPbB -TXnpEB2J8NXfqJKGBe0HEM2nJXF9iKCdgbDgf3FBEVC8Fhu+2v2BFjCrtFF1HPfy -oWM3dx9tlPohFY2hLYjbiLTTT0hwwbPNNmDaA+4u1tdKrSQPQ3A3r+BK9x0LqncX -+lZ4ZfakgcvMSvVB/cItbHotEKCs3oXTlABktTcYIjTxKRH983tRC6LRnmejcj/P -iCRd9y3+sisbmXu8ZPEbVvki/smfSuhuhNzg7boRhbwioSJH4XDnxLH+sxWK0JiJ -aSPxLjjxLqRW8iIciM7WXHG5g00A6cQh613pNbtB690e7RvHsZTvOWhwKZxo8T1U -I5EdYtWSt9daijkaZL2SFLENMWxARY6xirDxoiaSBhcy187hKXcfqBKbBYLfu4wW -frQSS8PiL3n81i80E+TzWwDe+bkDbtjJHdkrDnXTg6adoS5qoCuiLKdLNbw8nKmB -zMb8Y3iCr7/U4vm59oRywL7jlHah4cfjddDvtNGE1qr1FBq4ju5PwAEsN6mb2ZeU -vdxLgxAmaEwQK3YkSaj4ePsRJ4FJwXZXGMgiTRySX6gRlcWryRyRazU25RfPw12H -+WnPcFD0cXRQFofStuynd/ggwofz3zIXkBzBPQwIf8EOyrwxAIPCQpuJmm/86Ott -bBlEi+HOtxxIzQPMu8NwCfDLsykWVFtBeLhj7vU/JHFOxvE8MKKW0lpBlz9KCLj8 -dHZAKtx2g2jwtfFYDUQLXMBLV2AMvEmFm/C42b46bJa6MAtEgk5T0mEgzRmvvH12 -+iSsXXXyyp/+xuifrCiNzIiq8UFvRb8rrmXLP/+RV7yoZDd8v6AMtiejz+i0xYOj -6kmJBBTUsBqxnZ3Xm/AvU43RhwHmL0kcXzZXN8ygkDewmabZWmbiAZ3CbW9itEc3 -U3vzxJd7fmpBt7pQxOV+euYxkBhzXjd6k5Pu6ZEBZiYDX6aA9qxn6gZWEjH4CEwl -Nn5RZWCd9JJocGtG77I5QRC+gw8wF0Zq+kXFumjK30YQxuQS/pHqBcX8k3eTkP03 -CEPqACls8Ih/jEOh478do+OBofjlHzkxnsJva6lB8FEiIqn2BEqEaohYtEBEZ5WG -o0dyvbqrduoZlNghNjk9ujOdsEkqnrsDxifVpliDgfDjteIzgT4N2mOwVucbIdn+ -4RmQbiSqtPHPq4mSOvWxogGYcBLxzGbyYq+BbWzqyZ6iUW/QmvrBlaYmC9qUs00D -I8ca6RhKKySURYrrZ3pWcsmmO2IxsrhLgqMh54EvcRMdjfCLtvhzrKiInS3rWFLW -/95Ijt4QJU/OIfB7my6zNH6xD/rHKqH/yQ7en3zsvBXDvDE7UjDSMzz6GuWCB0aI -Ad+rZxFRN6LFQYHmFv6AARWv+I0URVo6B7seyuXXeJktLlfNbsCidoUkF36eKm4F -dO+SXtEII/NlQI9QlS9jBbwDE4KtnPqEu7l7xZbD2UJPGTtR9TlOoOa/rxcuOdkX -odfE5DJNvvs77uDugqahtBO/K5+xNkdZNYzpD9xTh0gE3YrI6OFJZ48wDwFFzhUH -PyaCtmL99cEM9x0EOp9O/dAmht84YQp/S/onRvNhuL1uoWQzx33insp9zQ2f01Xr -w7tdnIB5U6ILB2+AQ+5FiGsa+OsGGB1oyxshwLqQGigbofagJa5INTiCYOSMQuUb -w2/RZISTJKAWlOJ91phsfUsA9FwzbpW3AEbto4ZqVtHv24AU6FLacRjBJNeAM+vc -D2n00xUhl6BeIlE6bMVzSuIiht47BfAirVvhGV0NFyZJGA0Rm7UMm3NFKDXPHP4W -TSI1VT+m4lBnPn+jzYPFuP1adoP+xBS/19Y4nYO2mRDoisGWFfpHRHl4J6bmSAPv -2iE7KkbUAv6F2m/dYLqFn6i9vD5O0+mWHl1tBzL23wlw8KYAwP0hrfj1Fa+u3L3d -6EHM1B3P6Yd6xZ2PT9AtRC74Og7FyOzPLrEbBzLR9WXE8XEousblxNBstzxfMe1p -8xV+UAQMjqGV5HpyDUo9NTX0adu9tzmSlr78bU6tXkmNx5F66iOKRluJQCn8bfFt -az5ydeIOcM3FTomdQBGH/yK3K54ycTpQGRRFi4bNqytMDanxKjXmyVRBjGsxjssy -orsVJwkZwTDypXwVrWEL03Fc+ax6ihOXuF86PZHznRSWl/XxlQNuR1bNt3IuphYt -NGEAWCFRibRBzXzsF3jNn4sindgf9JAbqnqX3MQJNADNhfQzSwir++yupfXsbjj0 -ncu9+Oai/FaOSl3HMgO7+IvA9DKB7yIKf51ZwXPX+ungOOW+eA+ORb6RqhBiSB04 -FiDgAQ2OxFX6Pnd0M3dIetVn8qIo8C50kEBGqi2iHCG+ZrgG8uab0qgXxifpUXwr -K0DQf2ZCjBSl3O58zBpBiytvCTE11O2loTcmKjS4D5O5w+aANutXUZz3UOuDp/W8 -liEzAT0eyqVAjVbBSE5quXABWl673B1Yd3kn0f14Je4FGc+bUW1yLzhWtLL3KADK -4KD8 -=N+aO ------END PGP MESSAGE----- diff --git a/esp8266-arduino/multisens/configs/martin.h.asc b/esp8266-arduino/multisens/configs/martin.h.asc deleted file mode 100644 index 8ef7708e3..000000000 --- a/esp8266-arduino/multisens/configs/martin.h.asc +++ /dev/null @@ -1,68 +0,0 @@ ------BEGIN PGP MESSAGE----- -Version: GnuPG v1 - -hQQOA6oIqzfD9HVBEA/9Gx2CtShh3MW9dwSvcox3Ie7GH0XiKr0/PvugsLvOyGD/ -dRF74mIsKyOon04ChWkm6bkur0Wb186lYKNXrau/oJ2w82Y7pmGXHXaZwKNzWNR8 -b8diGt+r4XkzKoxMDk9ZoZri7x/lxRSlpfs/XKzxXXrtkqOOQ4D18I1ZmOX1ZMdh -leRrJvpTXNHyGc3DoSqDpfJRPU8D3M/AAlgZ98/YaKx5CAthuH5YPCj3BxD7TVvL -vN9o4jXaGe9TtUXGKjDUBZjC2cBJzPR0SSXSQkJulD12yTwhvveVlbMsGFr5rCAZ -0jWomZij8+Ng+aq2g5Bdd2lgVHiJsECinYkvJDtUwsbJkn6+cmONsEZ6PJtdln4T -NKTwzV6A6HllB2HA2J8UeCCzZ5MmYeaCCWgKirn03K2O0z761kFUn33YJ7CMw9Ee -GA3j3GwojWu+MLoKHu8ExEZeRhyozRZaB5gqfcN8Mxj7+q/OTNdWSe2mLQUf8zXZ -tTXzjcqdHFui+46k1NMItPrHR8GBDtWwnRqcj0scKl6Kt28QKWppSVrlStNnaEnU -uBzQnbIwUAqZC3avz7axt2cLcrQpPXh7cOdwQfYhUeRT0n3KpavHUFtcuuITG51D -c3s082DoKDg1ZMH/ncf37/OO6PbhfgyiMuXoJJsS+nbsBQ3hlffJFlSD2O8MNLIP -/3fVFjgNBUsAHcc6u0nsRP2RtizueXqz9EJmfEqMu/UjO+29rooRSZKbXF0z7fGn -UIWbMwvD4OgF3i2maP+uj0SegVWIz/BRwyWLvDPgdH4iB02/vamOlg5XUdelwEbR -F/03517T+SJjpl8nGDc6BZVa/oC8aDQIkJsJXCWxlQVgHIqrxszKnZqaQ6ICmygk -8iYK47hkWoR4fx01O67p72UkKtRZ7PLQU/hqloKXd+lEM3LOoGwrHn2JsLi9RWGQ -3Pbk0b3Th775TmXpLw8MpW7b3hF6oGDa2xUIlpc7LwQI602JALJdGyjpIaK8/+Qp -+d17c24sn5aOIx17L3BpceCDI3xdlgkUf5dorTCZ2UbwULK5O6LN21MquEg+AHO8 -876ASVfPaorqkwOtBRbj0CybJ5OJRjMh+bXtNuTpaPZa7Gvnb7JKiS1kMp0+r0no -eijMy5o889+Izq7NLZBo1sXl2Tj7x6ry2vt1DZsa4vshJ7L9PIavFiSOxD37fm1w -9ne/p7GU7Uk2P9odhsHQqOB+j6wY+Uin3DfFB54UIRILKf/yYKBYqP5VBhI1j6iQ -+qtvkWnjeVa4qiTvRmUT++CKTmqkp/nM4xJjtcNcMqkZ+L36vL/paq1/XKfeOUxt -mdr7fInpxsW7DSEe/cZKKbt/Ij0N1s0FLSG5jnNJW3w+0uoB4zilnhqUoNf7IvR1 -g5bJmtv+x8g3Y/ijld9LgWPs2NlBd0/HkRU5BVBCQlMXfToztTDsYFW0J8st2zIL -PkrexUnS2aYfxyw2hREYTlgGWmT5vvI2JE84qUJtoTF9yDESAnUUBST00lVcB7Ss -18pP7u7t2KvYEgCM79YeAqrTV/rX3LdPjX8Ya1UFgqaObvbE0cUOxtuld7JhiMXz -OtO44yrVwXiQGh8p9Z+OyXiacQXq2Dmu2ROQyrLNlAHomogsvM6c1XzNmDSRPg9G -CswcwlEsLQQAW2SiaqWYLu1U2LsCmurCd5mM4jP3s32M3UVwP40ypZeV7P9gis+m -eF6nJBjanqVBXu0zj4079DwOCoY91hPEa+dFP1Puapk9a4rwIMTPRAeK99XBsD2m -eT5sQam6PiRnsGSSR0VO5Ib+tsQrgEjFZyBBzh60CMeVb4QL/tQCez2QEhU7nKRR -MHSz+bnYhihUicdm8iQ2ZIN38JtoAioCRp5IS+lY9IM0m82gnLkaq2uWTNyS5Xdg -5e8XKZgUfE68t9a7lMr0NGpytSBL0YR34dadWIdQc/0TYcE/cQDK/HgH3uF9nGoF -k3dT8btsGRCg0HjfL8XJfdU7krkzwRbBOodubEhHJK3eO8Ea8d7sc2boTumWvQID -VOGui2jrf3MCyF1BcTSlaHDcm9vca8N1tGV9/rNxjXdzyk7UAMD8Fda59Rpd5zmb -t6nmhl7ZpW9N33mqMtJ8clrIi1lxpnawmzoDj4o9IlX9KJcBP2+tw0MYrx4kgLoY -5wGIC4uuzAwBr84S8acrqLj8c3ElspJbMmj0SEXFiN4Us+IxM1S/PxIqqF1Qqffo -AmlTWeSTWQOJHkBdDpWy+7OcOBDqotxb5NDNA1pLC8Ba4E6JhKOgIUayQ/7Mq1GC -FWTu1yorvJ0HykE/4XCBSx/s1x6uYtzd91uRQQGGKEL4uirr5WcfIVxhpmSOrPQm -A8/RI6dHv9Ev6jCfAciMcVxnQWjZmMBkjdw01tKyn7iaYT//amcsM9LLhjJIJs2z -5PiChDZ62YWSTVuslZpMhADKoKgYPSwiULCX9EDzIOzsbMYNeXMc5F1GYKH6KM2+ -tbfiEmt8MRWjlx5NeKUeA4ulQROewtL0eWzWK6XzVuvob/emyw+x9n92ONrx3rlC -w5tW8ykouGyM8W9LCWu7SfXhwP5WcPJLFDcsmsCqjVl14YSI4+M04WpcBfBFWXIs -WEj5e/VmNY8nW7+TNl0hcs2djdgIjiKJwpI3J460QjP8mMJEHockw7FPqOhybWPI -l+5ifw7uk8UdRL+RcMqzdmCPT0McwN/OukComoAR1JsT80VsRO9QS3ROUN6zZbw+ -v+Qc6U0fDzcAaJb7OM7CBKJXK0fARtYO46SxixTN/FUYFAwOBmnkPceC889akT8y -sGpB/WrD+OmBtyURYL5uWXtk7TSxIHLdQFXXs5Y638N8PnzUMocv4C8/k0WpXFrB -ar8pD81X4y0IPsjJ5ZCee0IST3FvbpHm9fgnDTN8PTKbN9m9oINpPMd4qs40numX -KW7/CxFg8qAgmKLsfrHkWrqlb0n4JSXufAE8YD+CdvTCqdBR4IE4h252KzPaueXH -1bzkgt8ji4W2cKlMKN4mI0Rl2/Z7SvorX6+U/IW1Z4S1LMGfD09A5LDtSNHsAkUG -Th4XG8iBKgyb3kSB8tHVSeop7WOkouB4w49h+E5VnO1nPkuNXVyK96tzzWqtQyDg -XDUpricAlp8KuuozJbh3z48lG7knJGRWEnSrPRcFG4wYFFe/ypHjGCdf06rlTMne -lD+NLcHiB9j1M1HJCGUpY6ywcUNVHQC5dFWCfK0y2IXZaf7czUhqUoj8ruvq6QLk -2eE5bCl5913HITpMdKxYQNqjSF7pg+TKDRM63qD7vZxum8kBJ3FR5c7vhArMxgY1 -QU9vSk1s/C7V/OcE0nvXGTk1X53roMGmM4fk7wEDxNSuwMPSCstommlVdk8TQZVg -1vRENa3pzIQTD4Gdhyc/WNBdwEVj2sZEm5eo1bzF+9R0KBS2wPrsuaMSlQri3CJM -loyQh1Be2+aCfqvQmDK+TMXRVLdw9eENcaVJVT2UJ/VTeUA/54ZVBEml8BjG4Tsd -Y7hwD4/I36U+FsYwRWp5yVKNVE6UIRmasr2XIxT/cgS2UonK1UkNce1yTRf2HjsK -5yYju6qQC+OK/yGSlf1I1YkMan9js77eVlQx7V5pCULAH+8PI4/dE+hLYfgLDAch -vlQuQrBI0PqMqEGfbWIuUNDler8zgScNrcqMDp4DSzfhR1+T7e7Ti/TAah2rZuo1 -vXwNKfUyJKSuRdmIuc0ek23wLg8FB9WRB1pGttPQXCjnAXcH3+GuwCJeAJO0/4o9 -+aOzSNvf15nziqod2A9N2auvjxyeFfHRTy19pg4MQI0xPNNRTn0RzLa2NAFyFSiM -Xa8bJFfabRIvukwU9WGbCpkgvw4HHcQkIfECmn/dWUQN3Oo7eNa5Tw8MptiSUaSr -jtsOhLQd0h/8jF7xW5st4TItA89Ikj+0VEvLv9t4X3ykRaHpHXLGXNwV+9aizPI/ -xS9wN9c+OjGCtiqncn6RpvZgmcUsDfpehtRtj0p8Xz5NCn716rARtgAlLYcRiOVm -=WM+X ------END PGP MESSAGE----- diff --git a/esp8266-arduino/multisens/dhtpush.h b/esp8266-arduino/multisens/dhtpush.h deleted file mode 100644 index 43082ea2a..000000000 --- a/esp8266-arduino/multisens/dhtpush.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef DHTPUSH_H -#define DHTPUSH_H - -#include // must be included in .ino - -// define defaults, if not already done -// change the following in sensorconfig.h -#ifndef DHTPIN -#define DHTPIN 4 // = GPIO PIN, not D -#endif -#ifndef DHTTYPE -#define DHTTYPE DHT22 -#endif - - -DHT dht(DHTPIN, DHTTYPE); - -String dht_s_temperature; -String dht_s_humidity; -String dht_s_hic; - -/* functions for DHT sensors */ - -// Connect pin 1 (on the left) of the sensor to +5V -// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 -// to 3.3V instead of 5V! -// Connect pin 2 of the sensor to whatever your DHTPIN is -// Connect pin 4 (on the right) of the sensor to GROUND -// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor - -/**********************************************/ -/* DHT22 Sensor -/**********************************************/ -void sensorDHT(){ - String data; - float h = dht.readHumidity(); //Read Humidity - float t = dht.readTemperature(); //Read Temperature - // Check if valid number if non NaN (not a number) will be send. - if (isnan(t) || isnan(h)) { - Serial.println("DHT22 could not be read"); -#ifdef PUSHTO_MQTT - mqtt_publish_topic(logtopic.c_str(),"DHT22 error: could not be read"); -#endif - - } else { - float hic = dht.computeHeatIndex(t, h, false); - dht_s_temperature=Float2String(t); - dht_s_humidity=Float2String(h); - dht_s_hic=Float2String(hic); - Serial.print("Humidity : "); - Serial.print(dht_s_humidity); - Serial.print(" %\n"); - Serial.print("Temperature : "); - Serial.print(dht_s_temperature); - Serial.println(" C"); - Serial.print("Heat index : "); - Serial.print(dht_s_hic); - Serial.println(" C"); - - if ((t>84.99) & (t<85.01)){ - Serial.println("Temperature looks like a reading after a power reset (85 °C), discarding..."); - return; - } - // json for push to api: h t - data = "{\"software_version\": \""; - data += SOFTWARE_VERSION_INITIALS; - data += "_"; - data += SOFTWARE_VERSION_NUMBER; - data += "\","; - data += "\"sensordatavalues\":[{"; - data += "\"value_type\":\"temperature\",\"value\":\""; - data += dht_s_temperature; - data += "\"},{"; - data += "\"value_type\":\"humidity\",\"value\":\""; - data += dht_s_humidity; - data += "\"}]}"; - sendData(data, DHTPIN); - // -#ifdef PUSHTO_MQTT - mqtt_publish_subtopic("json/DHT22",data); - mqtt_publish_subtopic("DHT22/temperature",dht_s_temperature); - mqtt_publish_subtopic("DHT22/humidity",dht_s_humidity); -#endif - } -} - -#endif diff --git a/esp8266-arduino/multisens/ds18x20push.h b/esp8266-arduino/multisens/ds18x20push.h deleted file mode 100644 index e87c13b9f..000000000 --- a/esp8266-arduino/multisens/ds18x20push.h +++ /dev/null @@ -1,196 +0,0 @@ -#ifndef DS18X20PUSH_H -#define DS18X20PUSH_H - -#ifndef ONEWIRE_PIN -#define ONEWIRE_PIN 15 // GPIO15=D8 -#endif - -#define DS18S20_ID 0x10 -#define DS18B20_ID 0x28 -#define DS1822_ID 0x22 - -OneWire ds(ONEWIRE_PIN); - -byte dsaddr[8]; -String sensortype; -String dstopic; -String t_celsius_s; - -void DSinit(){ - byte i; - byte type_s; - ds.reset_search(); - if (!ds.search(dsaddr)) { - Serial.println("No more addresses. No DS device found"); - Serial.println(); - ds.reset_search(); - delay(250); - return; - } - - Serial.print("ROM ="); - for( i = 0; i < 8; i++) { - Serial.write(' '); - Serial.print(dsaddr[i], HEX); - } - - if (OneWire::crc8(dsaddr, 7) != dsaddr[7]) { - Serial.println("CRC is not valid!"); - return; - } - Serial.println(); - - sensortype="DSunknown"; - // the first ROM byte indicates which chip - switch (dsaddr[0]) { - case DS18S20_ID: - Serial.println(" Chip = DS18S20"); // or old DS1820 - type_s = 1; - sensortype="DS18S20"; - break; - case DS18B20_ID: - Serial.println(" Chip = DS18B20"); - type_s = 0; - sensortype="DS18B20"; - break; - case DS1822_ID: - Serial.println(" Chip = DS1822"); - type_s = 0; - sensortype="DS1822"; - break; - default: - Serial.println("Device is not a DS18x20 family device."); - return; - ds.reset(); - } -} - -void DSpush(){ - String data; - byte i; - byte present = 0; - byte type_s; - byte dat[12]; -// byte addr[8]; // replaced by dsaddr - a global var - float celsius = -999; - float fahrenheit = -999; - - ds.reset(); - ds.select(dsaddr); -// ds.write(0x44, 1); // start conversion, with parasite power on at the end - ds.write(0x44, 0); // start conversion, with parasite power off at the end - - delay(750); // maybe 750ms is enough, maybe not - // we might do a ds.depower() here, but the reset will take care of it. - - present = ds.reset(); - ds.select(dsaddr); - ds.write(0xBE); // Read Scratchpad - Serial.print("---- DS ----"); - Serial.print(" Data = "); - Serial.print(present, HEX); - Serial.print(" "); - for ( i = 0; i < 9; i++) { // we need 9 bytes - dat[i] = ds.read(); - Serial.print(dat[i], HEX); - Serial.print(" "); - } - Serial.print(" CRC="); - Serial.print(OneWire::crc8(dat, 8), HEX); - Serial.println(); - - // check CRC, return if invalid - if (OneWire::crc8(dat, 8) != dat[8]) { - Serial.println("CRC is not valid, no measurement pushed!"); -#ifdef PUSHTO_MQTT - mqtt_publish_topic(logtopic.c_str(),"DS error: CRC invalid"); -#endif - return; - } - - // Convert the dat to actual temperature - // because the result is a 16 bit signed integer, it should - // be stored to an "int16_t" type, which is always 16 bits - // even when compiled on a 32 bit processor. - int16_t raw = (dat[1] << 8) | dat[0]; - if (type_s) { - raw = raw << 3; // 9 bit resolution default - if (dat[7] == 0x10) { - // "count remain" gives full 12 bit resolution - raw = (raw & 0xFFF0) + 12 - dat[6]; - } - } else { - byte cfg = (dat[4] & 0x60); - // at lower res, the low bits are undefined, so let's zero them - if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms - else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms - else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms - //// default is 12 bit resolution, 750 ms conversion time - } - celsius = (float)raw / 16.0; - fahrenheit = celsius * 1.8 + 32.0; - t_celsius_s=Float2String(celsius); - Serial.print(" Temperature = "); - Serial.print(t_celsius_s); - Serial.print(" Celsius, "); - Serial.print(fahrenheit); - Serial.println(" Fahrenheit"); - // TODO: call API - - // json for push to api: h t - data = "{\"software_version\": \""; - data += SOFTWARE_VERSION_INITIALS; - data += "_"; - data += SOFTWARE_VERSION_NUMBER; - data += "\","; - data += "\"sensordatavalues\":[{"; - data += "\"value_type\":\"temperature\",\"value\":\""; - data += t_celsius_s; - data += "\"}]}"; - sendData(data, ONEWIRE_PIN); -#ifdef PUSHTO_MQTT - dstopic=String("json/")+sensortype; - mqtt_publish_subtopic(dstopic.c_str(),data); - dstopic=String(sensortype)+"/temperature"; - mqtt_publish_subtopic(dstopic.c_str(),t_celsius_s); -#endif - -} - -float DSgetTemperature(){ - float temp; - byte i; - byte present = 0; - byte data[12]; - byte addr[8]; - //find a device - if (!ds.search(addr)) { - ds.reset_search(); - delay(250); - return -999; - } - if (OneWire::crc8( addr, 7) != addr[7]) { - return -999; - } - if (addr[0] != DS18S20_ID && addr[0] != DS18B20_ID) { - return -999; - } - ds.reset(); - ds.select(addr); - // Start conversion, 0=non-parasitic, 1= parasitic - ds.write(0x44, 0); - // Wait some time... - delay(150); - present = ds.reset(); - ds.select(addr); - // Issue Read scratchpad command - ds.write(0xBE); - // Receive 9 bytes - for ( i = 0; i < 9; i++) { - data[i] = ds.read(); - } - // Calculate temperature value - temp = ( (data[1] << 8) + data[0] )*0.0625; - return temp; -} -#endif diff --git a/esp8266-arduino/multisens/gpsfunctions.h b/esp8266-arduino/multisens/gpsfunctions.h deleted file mode 100644 index ff24912f9..000000000 --- a/esp8266-arduino/multisens/gpsfunctions.h +++ /dev/null @@ -1,229 +0,0 @@ -// GPS functions -#ifdef GPS_ACTIVE - -// include in .ino -// #include -// get from http://arduiniana.org/libraries/tinygpsplus/ -// #include - -// The TinyGPS++ object -TinyGPSPlus gps; -// The serial connection to the GPS device -SoftwareSerial serialGPS(pin_gps_rx,pin_gps_tx); - - -String last_gps_lat; -String last_gps_lng; -String last_gps_date; -String last_gps_time; -String last_gps_alt; -unsigned long starttime_GPS; - - - -void gps_setup(){ - serialGPS.begin(gps_baudrate); -} - -// This custom version of delay() ensures that the gps object -// is being "fed". -bool feedDelayGPS(unsigned long ms) -{ - unsigned long start = millis(); - do - { - while (serialGPS.available()) - gps.encode(serialGPS.read()); - if (gps.location.isUpdated()){ - return true; - } - } while (millis() - start < ms); - return false; -} - -bool push_gps_location(){ - if (!gps.location.isValid()){ - return false; - } -#ifdef PUSHTO_SERIAL -serial_out("LatLonAlt\t"); -serial_out(gps.location.lat(),6); -serial_out("\t"); -serial_out(gps.location.lng(),6); -serial_out("\t"); -serial_outln(gps.altitude.meters()); -#endif -} - -bool push_gps_datetime(){ - TinyGPSDate d=gps.date; - TinyGPSTime t=gps.time; - char sz[64]; - if (!d.isValid()){ - return false; - }else{ - sprintf(sz, "DateTimeAge\t%02d-%02d-%02d", d.year(), d.month(), d.day()); - #ifdef PUSHTO_SERIAL - serial_out(sz); - #endif - } - if (!t.isValid()){ - serial_outln(""); - return false; - }else{ - sprintf(sz, " %02d:%02d:%02d\t%02d", t.hour(), t.minute(), t.second(),gps.location.age()); - #ifdef PUSHTO_SERIAL - serial_outln(sz); - #endif - } - return true; -} - -bool push_gps_info(){ - bool retval = ( gps.hdop.isValid() & gps.satellites.isValid() ); - #ifdef PUSHTO_SERIAL - serial_out("HdopSat\t"); - if(gps.hdop.isValid()){ - serial_out(gps.hdop.value()); - } - serial_out("\t"); - if(gps.satellites.isValid()){ - serial_out(gps.satellites.value()); - } - serial_outln(""); - #endif - return retval; -} - -bool gps_pollread(){ - bool success=false; - #ifdef PUSHTO_SERIAL - serial_outln("gps_read", 5); - #endif - // serialGPS.flush(); //only outgoing data - if(!feedDelayGPS(gpsmaxtime_ms)){ - // no news from GPS - #ifdef PUSHTO_SERIAL - serial_out("no news from GPS"); - #endif - return false; - } -// if(gps.location.isUpdated()){ -// unsigned long starttime=millis(); -// while(millis()-gpsmaxtime_ms 0)){ -// if (gps.encode(serialGPS.read())){ -// if (gps.location.isUpdated()){ - success=(success|push_gps_location()); - success=(success|push_gps_datetime()); - success=(success|push_gps_info()); - return success; -// } -// } -// } -// } - -// serial_out("debug: starttime="); -// serial_outln (starttime); -// if(!success){ -// #ifdef PUSHTO_SERIAL -// serial_outln("error reading GPS"); -// #endif -// return false; -// } -// return success; -} - -#endif - - -/***************************************************************** -/* read GPS sensor values * -/*****************************************************************/ -String sensorGPS() { - String s = ""; -#if defined(ARDUINO_SAMD_ZERO) || defined(ESP8266) - String gps_lat = ""; - String gps_lng = ""; - String gps_alt = ""; - String gps_date = ""; - String gps_time = ""; - - debug_out("Reading GPS",DEBUG_MED_INFO,1); - - while (serialGPS.available() > 0) { - if (gps.encode(serialGPS.read())) { - if (gps.location.isValid()) { - last_gps_lat = String(gps.location.lat(),6); - last_gps_lng = String(gps.location.lng(),6); - } else { - debug_out("Lat/Lng INVALID",DEBUG_MAX_INFO,1); - } - if (gps.altitude.isValid()) { - last_gps_alt = String(gps.altitude.meters(),2); - } else { - debug_out("Altitude INVALID",DEBUG_MAX_INFO,1); - } - if (gps.date.isValid()) { - gps_date = ""; - if (gps.date.month() < 10) gps_date += "0"; - gps_date += String(gps.date.month()); - gps_date += "/"; - if (gps.date.day() < 10) gps_date += "0"; - gps_date += String(gps.date.day()); - gps_date += "/"; - gps_date += String(gps.date.year()); - last_gps_date = gps_date; - } else { - debug_out("Date INVALID",DEBUG_MAX_INFO,1); - } - if (gps.time.isValid()) { - gps_time = ""; - if (gps.time.hour() < 10) gps_time += "0"; - gps_time += String(gps.time.hour()); - gps_time += ":"; - if (gps.time.minute() < 10) gps_time += "0"; - gps_time += String(gps.time.minute()); - gps_time += ":"; - if (gps.time.second() < 10) gps_time += "0"; - gps_time += String(gps.time.second()); - gps_time += "."; - if (gps.time.centisecond() < 10) gps_time += "0"; - gps_time += String(gps.time.centisecond()); - last_gps_time = gps_time; - } else { - debug_out("Time: INVALID",DEBUG_MAX_INFO,1); - } - } - } - - if ((act_milli-starttime) > sampletime_ms) { - debug_out("Lat/Lng: "+last_gps_lat+","+last_gps_lng,DEBUG_MIN_INFO,1); - debug_out("Altitude: "+last_gps_alt,DEBUG_MIN_INFO,1); - debug_out("Date: "+last_gps_date,DEBUG_MIN_INFO,1); - debug_out("Time "+last_gps_time,DEBUG_MIN_INFO,1); - debug_out("------------------------------",DEBUG_MIN_INFO,1); - s += "{\"value_type\":\"GPS_Lat\",\"value\":\""; - s += last_gps_lat; - s += "\"},"; - s += "{\"value_type\":\"GPS_Lng\",\"value\":\""; - s += last_gps_lng; - s += "\"},"; - s += "{\"value_type\":\"GPS_Alt\",\"value\":\""; - s += last_gps_alt; - s += "\"},"; - s += "{\"value_type\":\"GPS_Date\",\"value\":\""; - s += last_gps_date; - s += "\"},"; - s += "{\"value_type\":\"GPS_Time\",\"value\":\""; - s += last_gps_time; - s += "\"},"; - last_gps_lat = ""; - last_gps_lng = ""; - last_gps_alt = ""; - last_gps_date = ""; - last_gps_time = ""; - } -#endif - return s; -} diff --git a/esp8266-arduino/multisens/ledfunctions.h b/esp8266-arduino/multisens/ledfunctions.h deleted file mode 100644 index 5963fd10b..000000000 --- a/esp8266-arduino/multisens/ledfunctions.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifdef PIN_LED_STATUS -int ledsstate=LOW; -#endif - -void setup_led(){ -#ifdef PIN_LED_STATUS -pinMode(pin_led_status, OUTPUT); -digitalWrite(pin_led_status, ledsstate); -ledsstate=HIGH; -digitalWrite(pin_led_status, ledsstate); -#endif -} - -void led_on(unsigned int delayafter=0){ -#ifdef PIN_LED_STATUS -ledsstate=HIGH; -digitalWrite(pin_led_status, ledsstate); -delay(delayafter); -#endif -} - -void led_off(unsigned int delayafter=0){ -#ifdef PIN_LED_STATUS -ledsstate=LOW; -digitalWrite(pin_led_status, ledsstate); -delay(delayafter); -#endif -} diff --git a/esp8266-arduino/multisens/mqttfunctions.h b/esp8266-arduino/multisens/mqttfunctions.h deleted file mode 100644 index d49763f63..000000000 --- a/esp8266-arduino/multisens/mqttfunctions.h +++ /dev/null @@ -1,157 +0,0 @@ -#if defined(PUSHTO_MQTT) || defined (SEND2MQTT) -#ifdef WIRELESS_ACTIVE -// connect/push to an MQTT server -// #include // include in .ino -// configure mqttserver, mqttport, mqtttopicbase in sensorconfig.h -// -// const char mqttserver[] = "mqtt.opendataset.click"; const int mqttport = 1883; const char mqtttopicbase[]="/dusti/"; -// derived from example of PubSubClient lib: mqtt_esp8266.ino -WiFiClient mqttwificlient; // a wificlient for our mqtt connection -String mqttclientid="esp8266-"+String(ESP.getChipId()); -String logtopic=String(String(mqtttopicbase) + "/" + mqttclientid + "/" + "log"); -PubSubClient psclient; -String mqttmsg; -// do everything without String? -//char msg [MQTT_MAX_PACKET_SIZE] = ""; - -boolean pubsubclient_reconnect(){ - // Loop to reconnect - int ccnt=10; - while ((!psclient.connected())&&(ccnt>0)) { - Serial.print("Attempting MQTT connection..."); - if(psclient.connect(mqttclientid.c_str())){ - Serial.println("OK"); - }else{ - Serial.print("try "); - Serial.print(ccnt); - ccnt=ccnt-1; - Serial.print(", client state: "); - Serial.print(psclient.state()); - } - } - if(psclient.connected()){ - mqttmsg="(re)connected, state: "+String(psclient.state()); - psclient.publish(logtopic.c_str(), mqttmsg.c_str()); - Serial.println(psclient.state()); - return true; - }else{ - Serial.println("connection failed, giving up"); - return false; - } -} - -void mqtt_publish_topic(const char* topic, const char* payload) { - //Serial.println("Publish to MQTT server..."); - boolean success=false; - if (!psclient.connected()) { - success=pubsubclient_reconnect(); - if(!success){ - Serial.println("connect failed, no publishing"); - return; - } - } - // Once connected, publish payload... - Serial.print("MQTT: publish topic "); - Serial.println(topic); - Serial.println(payload); - success=psclient.publish(topic, payload); - if (success){ - Serial.println(" OK"); - }else{ - Serial.print(" failed, state is "); - Serial.print(psclient.state()); - Serial.print(" publish return code is "); - Serial.println(success); - mqttmsg=String("topic pub fail: ") +topic; - psclient.publish(logtopic.c_str(), mqttmsg.c_str()); - } -} -// publish String -void mqtt_publish_topic(const char* subtopic, String payload) { - mqtt_publish_topic(subtopic, payload.c_str()); -} -void mqtt_publish_subtopic(const char* subtopic, const char* payload) { - String topictopub=String(mqtttopicbase) + "/" + mqttclientid + "/" + subtopic; - mqtt_publish_topic(topictopub.c_str(),payload); -} -// publish String -void mqtt_publish_subtopic(const char* subtopic, String payload) { - mqtt_publish_subtopic(subtopic, payload.c_str()); -} - -void mqttcallback(char* topic, byte* payload, unsigned int length) { - Serial.print("mqttcallback: message arrived ["); - Serial.print(topic); - Serial.print("] "); - for (int i = 0; i < length; i++) { - Serial.print((char)payload[i]); - } - // acknowledge reception - psclient.publish(logtopic.c_str(), "received incoming msg"); - //TODO: analyse message here (not yet used) -} - -// subscribe to subtopic -void mqtt_subscribetosubtopic(const char* subtopic){ - String subscribetopic=String(mqtttopicbase) + "/" + mqttclientid + "/" + String(subtopic); - Serial.print("mqtt_subscribetosubtopic to "); - Serial.print(subscribetopic); - // ... and subscribe - boolean success=false; - success=psclient.subscribe(subscribetopic.c_str()); - if (success){ - Serial.println("OK"); - mqtt_publish_topic(logtopic.c_str(), String("subscribed successfully to ")+subscribetopic); - }else{ - Serial.println("failed"); - mqtt_publish_topic(logtopic.c_str(), "subscribe failed"); - } -} - -void mqtt_setup() { - //setup_wifi(); - //Serial.begin(9600); - Serial.print("MQTT setup, client id: "); - Serial.println(mqttclientid); - int ccnt=10; - while((WiFi.status() != WL_CONNECTED)&&(ccnt>0)){ - Serial.print("MQTT: wifi not connected, trying to connect, try "); - Serial.println(ccnt); - connectWifi(); // in apifunctions.h - ccnt=ccnt-1; - } - if(WiFi.status() != WL_CONNECTED){ - Serial.print("MQTT error: wifi not connected, giving up"); - return; - } - psclient.setClient(mqttwificlient); - psclient.setServer(mqttserver, mqttport); - psclient.setCallback(mqttcallback); - pubsubclient_reconnect(); - //mqtt_publish_topic(logtopic.c_str(), "MQTT started"); - mqttmsg=String("MQTT start, max packet size is ")+String(MQTT_MAX_PACKET_SIZE)+String(" sampletime[ms]: ")+String(sampletime_ms); - mqtt_publish_topic(logtopic.c_str(), mqttmsg); - mqttmsg=String("heap free: ")+String(ESP.getFreeHeap())+String(" software version: ")+software_version_s; - mqtt_subscribetosubtopic(mqttintopic); -} - -void json2mqttpub(String jsondata){ - String svalue_type, svalue; - StaticJsonBuffer<2000> jsonBuffer; - JsonObject& json2data = jsonBuffer.parseObject(jsondata); - if (!json2data.success()) {return;} - // sensordatavalues - // "value_type\":\"durP1\",\"value - /* TODO: iterate here - for (JsonObject::iterator it=jsondata["sensordatavalues"].begin(); it!=jsondata["sensordatavalues"].end(); ++it){ - svalue_type=it["value_type"].asString(); - svalue=it["value"].asString(); - // Serial.println(it->value.asString()); - } - */ -} - -// endif WIRELESS_ACTIVE -#endif -// endif PUSHTO_MQTT -#endif diff --git a/esp8266-arduino/multisens/multisens.ino b/esp8266-arduino/multisens/multisens.ino deleted file mode 100644 index a48b666bd..000000000 --- a/esp8266-arduino/multisens/multisens.ino +++ /dev/null @@ -1,369 +0,0 @@ - /*******************************************************/ -/* OK LAB Particulate Matter Sensor */ -/* - nodemcu-LoLin board */ -/* - Shinyei PPD42NS */ -/* http://www.sca-shinyei.com/pdf/PPD42NS.pdf */ -/* */ -/*******************************************************/ - -/**********************************************/ -/* configure your sensors, */ -/* PINs and WIFI in sensorconfig.h */ -/**********************************************/ -#include "sensorconfig.h" -unsigned int debug = verbosity; -String software_version = String(SOFTWARE_VERSION_INITIALS)+String("_")+String(SOFTWARE_VERSION_NUMBER); - -#ifdef WIRELESS_ACTIVE -#include -#endif -int value = 0; -String software_version_s=String(SOFTWARE_VERSION_INITIALS)+"_"+String(SOFTWARE_VERSION_NUMBER); -#include "apifunctions.h" -#include "serialfunctions.h" -#include "ledfunctions.h" - -/**********************************************/ -/* MQTT declarations: see sensorconfig.h */ -/**********************************************/ -#ifdef PUSHTO_MQTT -// in PubSubClient.h, MQTT_MAX_PACKET_SIZE restricts -//the maximum length of a message to 128, this is not enough here: redefine -#define MQTT_MAX_PACKET_SIZE 4096 -#undef MAX_TRANSFER_SIZE -#include -#include -#include "mqttfunctions.h" -#endif - -/**********************************************/ -/* DHT declaration -/**********************************************/ -#ifdef DHT_ACTIVE -// The IDE requires all libraries to be #include’d in the main (.ino) file. -// http://jamesreubenknowles.com/multiple-source-files-with-the-arduino-ide-1618 -#include -#include "dhtpush.h" -#endif - -/**********************************************/ -/* onewire ds18x20 temperature sensor declaration -/**********************************************/ -// derived from https://github.com/esp8266/Arduino/blob/esp8266/libraries/OneWire/examples/DS18x20_Temperature/DS18x20_Temperature.pde -#ifdef DS_ACTIVE -#include -#include "ds18x20push.h" -// on pin ONEWIRE_PIN = GPIO (a 4.7K pullup resistor is necessary) -# endif - -/**********************************************/ -/* WiFi declarations: see sensorconfig.h */ -/**********************************************/ - -/* GPS */ -#ifdef GPS_ACTIVE -#include -#include -#include "gpsfunctions.h" -#endif //GPS_ACTIVE - - -/**********************************************/ -/* Variable Definitions for PPD24NS */ -/**********************************************/ -#ifndef PPD42_P1_PIN -#define PPD42_P1_PIN 12 -#endif - -#ifndef PPD42_P2_PIN -#define PPD42_P2_PIN 14 -#endif - -// P1 for PM10 & P2 for PM25 -boolean valP1 = HIGH; -boolean valP2 = HIGH; - -unsigned long starttime; -unsigned long durationP1; -unsigned long durationP2; - -boolean trigP1 = false; -boolean trigP2 = false; -unsigned long trigOnP1; -unsigned long trigOnP2; - -unsigned long lowpulseoccupancyP1 = 0; -unsigned long lowpulseoccupancyP2 = 0; - -float ratio_p1 = 0; -float concentration_p1 = 0; -float ratio_p2 = 0; -float concentration_p2 = 0; -// String versions (convert only once) -String ratio_p1s; -String ratio_p2s; -String concentration_p1s; -String concentration_p2s; -String lowpulseoccupancyP1s; -String lowpulseoccupancyP2s; - -#ifdef DEBUG_CYCLES -unsigned long cycount = 0; -#endif // DEBUG_CYCLES - - -/**********************************************/ -/* The Setup -/**********************************************/ - -void setup() { - -#ifdef PIN_LED_STATUS -pinMode(PIN_LED_STATUS, OUTPUT); -ledsstate=HIGH; -digitalWrite(PIN_LED_STATUS, ledsstate); -#endif - - Serial.begin(9600); //Output to Serial at 9600 baud - delay(10); - Serial.print("Software version: "); - Serial.print(software_version_s); - - Serial.println("ESP startup, chipid:"); - Serial.println(ESP.getChipId()); - Serial.print("Heap free:"); - Serial.println(ESP.getFreeHeap()); - Serial.print("sampletime [s]:"); - Serial.println(Float2String(sampletime_ms/1000.0)); - int i; - Serial.println("GPIOx Dx PIN matching"); - - for (i = 0; i < 13; i = i + 1) { - Serial.print(i); - Serial.print("\t"); - Serial.println(D[i]); - } - -#ifdef PPD_ACTIVE -#ifdef PIN_LED_STATUS -ledsstate=LOW; -digitalWrite(PIN_LED_STATUS, ledsstate); -#endif - pinMode(PPD42_P1_PIN,INPUT); // Listen at the designated PIN - pinMode(PPD42_P2_PIN,INPUT); //Listen at the designated PIN - Serial.println("Sensortype PPD active"); - Serial.print("PPD42_P1_PIN: "); - Serial.print(PPD42_P1_PIN); - Serial.print("PPD42_P2_PIN: "); - Serial.print(PPD42_P2_PIN); -#ifdef PIN_LED_STATUS -ledsstate=HIGH; -digitalWrite(PIN_LED_STATUS, ledsstate); -delay(50); -#endif -#endif - -#ifdef DHT_ACTIVE -#ifdef PIN_LED_STATUS -ledsstate=LOW; -digitalWrite(PIN_LED_STATUS, ledsstate); -#endif - Serial.println("Sensortype DHT active"); - Serial.print("DHTPIN: "); - Serial.println(DHTPIN); - Serial.println("init DHT"); - dht.begin(); // Start DHT - delay(50); -#ifdef PIN_LED_STATUS -ledsstate=HIGH; -digitalWrite(PIN_LED_STATUS, ledsstate); -#endif -#endif - - -#ifdef DS_ACTIVE -#ifdef PIN_LED_STATUS -ledsstate=LOW; -digitalWrite(PIN_LED_STATUS, ledsstate); -#endif - Serial.println("Sensortype DS active"); - Serial.print("ONEWIRE_PIN: "); - Serial.println(ONEWIRE_PIN); - Serial.print("init DS"); - Serial.println(); - DSinit(); - delay(50); - // try to read a temperature - float t; - t=DSgetTemperature(); - Serial.print("DSgetTemperature(): t="); - Serial.println(t); -#endif - connectWifi(); // Start ConnecWifi - Serial.print("\n"); -#ifdef PIN_LED_STATUS -ledsstate=HIGH; -digitalWrite(PIN_LED_STATUS, ledsstate); -#endif -#ifdef PUSHTO_MQTT -mqtt_setup(); -#endif -#ifdef GPS_ACTIVE -gps_setup(); -#endif //GPS_ACTIVE -#ifdef PIN_LED_STATUS -ledsstate=HIGH; -digitalWrite(PIN_LED_STATUS, ledsstate); -#endif - starttime = millis(); // store the start time -} - -/**********************************************/ -/* And action -/**********************************************/ -void loop() { - String data; -#ifndef PPD_ACTIVE - delay(10); -#endif - // Read pins connected to ppd42ns -#ifdef PPD_ACTIVE - valP1 = digitalRead(PPD42_P1_PIN); - valP2 = digitalRead(PPD42_P2_PIN); - - if(valP1 == LOW && trigP1 == false){ - trigP1 = true; - trigOnP1 = micros(); - } - - if (valP1 == HIGH && trigP1 == true){ - durationP1 = micros() - trigOnP1; - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1; - trigP1 = false; - } - - if(valP2 == LOW && trigP2 == false){ - trigP2 = true; - trigOnP2 = micros(); - } - - if (valP2 == HIGH && trigP2 == true){ - durationP2 = micros() - trigOnP2; - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2; - trigP2 = false; - } -#endif -#ifdef DEBUG_CYCLES -cycount++; -#endif //DEBUG_CYCLES - // Checking if it is time to sample - if ((millis()-starttime) > sampletime_ms) - { -#ifdef DEBUG_CYCLES -Serial.print("measurement cycles: "); -Serial.println(cycount); -cycount=0; -#endif //DEBUG_CYCLES - - #ifdef PPD_ACTIVE - ratio_p1 = lowpulseoccupancyP1/(sampletime_ms*10.0); // int percentage 0 to 100 - concentration_p1 = 1.1*pow(ratio_p1,3)-3.8*pow(ratio_p1,2)+520*ratio_p1+0.62; // spec sheet curve - ratio_p1s=Float2String(ratio_p1); - concentration_p1s=Float2String(concentration_p1); - lowpulseoccupancyP1s=String(lowpulseoccupancyP1); - // Begin printing - Serial.print("LPO P10 : "); - Serial.println(lowpulseoccupancyP1); - Serial.print("Ratio PM10 : "); - Serial.print(ratio_p1s); - Serial.println(" %"); - Serial.print("PM10 Count : "); - Serial.println(concentration_p1s); - - // json for push to api / P1 - data = "{\"software_version\": \""; - data += software_version_s; - data += "\","; - data += "\"sensordatavalues\":[{"; - data += "\"value_type\":\"durP1\",\"value\":\""; - data += lowpulseoccupancyP1s; - data += "\"},{"; - data += "\"value_type\":\"ratioP1\",\"value\":\""; - data += ratio_p1s; - data += "\"},{"; - data += "\"value_type\":\"P1\",\"value\":\""; - data += concentration_p1s; - data += "\"},{"; - - ratio_p2 = lowpulseoccupancyP2/(sampletime_ms*10.0); - concentration_p2 = 1.1*pow(ratio_p2,3)-3.8*pow(ratio_p2,2)+520*ratio_p2+0.62; - ratio_p2s=Float2String(ratio_p2); - concentration_p2s=Float2String(concentration_p2); - lowpulseoccupancyP2s=String(lowpulseoccupancyP2); - // Begin printing - Serial.print("LPO PM25 : "); - Serial.println(lowpulseoccupancyP2s); - Serial.print("Ratio PM25 : "); - Serial.print(ratio_p2s); - Serial.println(" %"); - Serial.print("PM25 Count : "); - Serial.println(concentration_p2s); - - // json for push to api / P2 - data += "\"value_type\":\"durP2\",\"value\":\""; - data += lowpulseoccupancyP2s; - data += "\"},{"; - data += "\"value_type\":\"ratioP2\",\"value\":\""; - data += ratio_p2s; - data += "\"},{"; - data += "\"value_type\":\"P2\",\"value\":\""; - data += concentration_p2s; - data += "\"}]}"; - - //sending to dustix api - Serial.println("#### Sending to dusti.xyz: "); - // -1 -> '-' is default for ppd - sendData(data,-1); - - #ifdef PUSHTO_MQTT - //process incoming data/ping - Serial.print("PubSubClient::loop"); - if (psclient.loop()){ - Serial.println("OK"); - }else{ - Serial.println("failed"); - } - mqtt_publish_subtopic("json/PPD42NS",data); - mqtt_publish_subtopic("PPD42NS/durP1",lowpulseoccupancyP1s); - mqtt_publish_subtopic("PPD42NS/durP2",lowpulseoccupancyP2s); - mqtt_publish_subtopic("PPD42NS/ratioP1",ratio_p1s); - mqtt_publish_subtopic("PPD42NS/ratioP2",ratio_p2s); - mqtt_publish_subtopic("PPD42NS/P1",concentration_p1s); - mqtt_publish_subtopic("PPD42NS/P2",concentration_p2s); - #endif //PUSHTO_MQTT - - #endif //PPD_ACTIVE - // FIXME: option to send PIN - #ifdef DHT_ACTIVE - sensorDHT(); // getting temperature and humidity (optional) - Serial.println("------------------------------"); - #endif //DHT_ACTIVE - #ifdef DS_ACTIVE - DSpush(); - #endif //DS_ACTIVE - #ifdef GPS_ACTIVE - gps_read(); - #endif //GPS_ACTIVE - - // Resetting for next sampling - lowpulseoccupancyP1 = 0; - lowpulseoccupancyP2 = 0; - #ifdef PIN_LED_STATUS - ledsstate=HIGH; - digitalWrite(PIN_LED_STATUS, ledsstate); - #endif - // reset start time at the very end - starttime = millis(); // store the start time - } - -}// loop() diff --git a/esp8266-arduino/multisens/ppdfunctions.h b/esp8266-arduino/multisens/ppdfunctions.h deleted file mode 100644 index ed92715eb..000000000 --- a/esp8266-arduino/multisens/ppdfunctions.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef PPDFUNCTIONS_H -#define PPDFUNCTIONS_H - -#ifdef PPD_ACTIVE - -// P1 for PM10 & P2 for PM25 -boolean valP1 = HIGH; -boolean valP2 = HIGH; -boolean trigP1 = false; -boolean trigP2 = false; - -unsigned long durationP1; -unsigned long durationP2; -unsigned long trigOnP1; -unsigned long trigOnP2; -unsigned long lowpulseoccupancyP1 = 0; -unsigned long lowpulseoccupancyP2 = 0; - -float ratio_p1 = 0; -float concentration_p1 = 0; -float ratio_p2 = 0; -float concentration_p2 = 0; - -// String versions (convert only once) -String ratio_p1s; -String ratio_p2s; -String concentration_p1s; -String concentration_p2s; -String lowpulseoccupancyP1s; -String lowpulseoccupancyP2s; - - -// #ifndef PPD42_P1_PIN -// #define PPD42_P1_PIN 12 -// #endif -// -// #ifndef PPD42_P2_PIN -// #define PPD42_P2_PIN 14 -// #endif - -void setup_ppd(unsigned int pin_p1, unsigned int pin_p2){ - pinMode(pin_p1,INPUT); // Listen at the designated PIN - pinMode(pin_p2,INPUT); //Listen at the designated PIN -} - -void ppd_measure(){ - if (!ppd_read){ - delay(10); - return; - } - // measure - // create string - // push - String data; - String serialmsg; - // Read pins connected to ppd42ns -#ifdef PPD_ACTIVE - valP1 = digitalRead(pin_ppd_p1); - valP2 = digitalRead(pin_ppd_p2); - - if(valP1 == LOW && trigP1 == false){ - trigP1 = true; - trigOnP1 = micros(); - } - - if (valP1 == HIGH && trigP1 == true){ - durationP1 = micros() - trigOnP1; - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1; - trigP1 = false; - } - - if(valP2 == LOW && trigP2 == false){ - trigP2 = true; - trigOnP2 = micros(); - } - - if (valP2 == HIGH && trigP2 == true){ - durationP2 = micros() - trigOnP2; - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2; - trigP2 = false; - } -#endif -} - -void push_ppd(){ -#ifdef PPD_ACTIVE - ratio_p1 = lowpulseoccupancyP1/(sampletime_ms*10.0); // int percentage 0 to 100 - concentration_p1 = 1.1*pow(ratio_p1,3)-3.8*pow(ratio_p1,2)+520*ratio_p1+0.62; // spec sheet curve - ratio_p1s=Float2String(ratio_p1); - concentration_p1s=Float2String(concentration_p1); - lowpulseoccupancyP1s=String(lowpulseoccupancyP1); - // Begin printing - serialmsg=String("LPO P10 : ")+String(lowpulseoccupancyP1) - serialmsg+="\nRatio PM10 : "; - serialmsg+=String(ratio_pls); - serialmsg+=String(" %\nPM10 Count : ")+concentration_p1s; - - // json for push to api / P1 - data = "{\"software_version\": \""; - data += software_version_s; - data += "\","; - data += "\"sensordatavalues\":[{"; - data += "\"value_type\":\"durP1\",\"value\":\""; - data += lowpulseoccupancyP1s; - data += "\"},{"; - data += "\"value_type\":\"ratioP1\",\"value\":\""; - data += ratio_p1s; - data += "\"},{"; - data += "\"value_type\":\"P1\",\"value\":\""; - data += concentration_p1s; - data += "\"},{"; - - ratio_p2 = lowpulseoccupancyP2/(sampletime_ms*10.0); - concentration_p2 = 1.1*pow(ratio_p2,3)-3.8*pow(ratio_p2,2)+520*ratio_p2+0.62; - ratio_p2s=Float2String(ratio_p2); - concentration_p2s=Float2String(concentration_p2); - lowpulseoccupancyP2s=String(lowpulseoccupancyP2); - // Begin printing - serialmsg+=String("LPO P25 : ")+String(lowpulseoccupancyP2); - serialmsg+="\nRatio PM25 : "+ratio_p2s; - serialmsg+=" %\nPM10 Count : "+concentration_p2s; - Serial.print("LPO PM25 : ")+lowpulseoccupancyP2s; - Serial.print("Ratio PM25 : ")+ratio_p2s+" %\n"; - Serial.print("PM25 Count : ")+concentration_p2s; - - // json for push to api / P2 - data += "\"value_type\":\"durP2\",\"value\":\""; - data += lowpulseoccupancyP2s; - data += "\"},{"; - data += "\"value_type\":\"ratioP2\",\"value\":\""; - data += ratio_p2s; - data += "\"},{"; - data += "\"value_type\":\"P2\",\"value\":\""; - data += concentration_p2s; - data += "\"}]}"; - - //sending to dustix api - Serial.println("#### Sending to dusti.xyz: "); - // -1 -> '-' is default for ppd - sendData(data,-1); - - #ifdef PUSHTO_MQTT//process incoming data/ping - Serial.print("PubSubClient::loop"); - if (psclient.loop()){ - Serial.println("OK"); - }else{ - Serial.println("failed"); - } - mqtt_publish_subtopic("json/PPD42NS",data); - mqtt_publish_subtopic("PPD42NS/durP1",lowpulseoccupancyP1s); - mqtt_publish_subtopic("PPD42NS/durP2",lowpulseoccupancyP2s); - mqtt_publish_subtopic("PPD42NS/ratioP1",ratio_p1s); - mqtt_publish_subtopic("PPD42NS/ratioP2",ratio_p2s); - mqtt_publish_subtopic("PPD42NS/P1",concentration_p1s); - mqtt_publish_subtopic("PPD42NS/P2",concentration_p2s); - #endif -#endif - -} - -#endif //PPD_ACTIVE -#endif //PPDFUNCTIONS_H \ No newline at end of file diff --git a/esp8266-arduino/multisens/sensorconfig.h.template b/esp8266-arduino/multisens/sensorconfig.h.template deleted file mode 100644 index 24ab3ae1e..000000000 --- a/esp8266-arduino/multisens/sensorconfig.h.template +++ /dev/null @@ -1,131 +0,0 @@ -/* -copy this file to sensorconfig.h -and change your config here -or link one from configs/ dir -*/ -#define SOFTWARE_VERSION_INITIALS "MULTISENS" -// additionally set SOFTWARE_VERSION_NUMBER in softwareversion.h -#include "softwareversion.h" - - -// GPIO PINSs <-> nodemcu PINs (Dx) mapping -// 0 1 2 3 4 5 6 7 8 9 10 11 12 -int D[13]={16, 5, 4, 0, 2, 14, 12, 13, 15, 3, 1, 9, 10}; - -/* defines to activate sensors */ -#define PPD_ACTIVE -//#define DHT_ACTIVE -// #define DS_ACTIVE -//#define GPS_ACTIVE - -//#define DEBUG_CYCLES - -unsigned int verbosity = 4; //TODO: implement; output levels over serial, increase to get more messages, like 0 no_messages, 1 warn, 2 info, 5 debug - -/* DHT PIN */ -// #define DHTPIN 4 // = GPIO PIN -#define DHTPIN D[2] // = Dx on devboard -#define DHTTYPE DHT22 - -/* ONEWIRE BUS PIN */ -// #define ONEWIRE_PIN 15 // GPIO15=D8 -#define ONEWIRE_PIN D[4] - -/* PPD PINs */ -#define PPD42_P1_PIN D[6] //12 // GPIO12=D6 -#define PPD42_P2_PIN D[5] //14 // GPIO14=D5 -unsigned long sampletime_ms = 30000; - - -/* WIFI definitions */ -#define WIRELESS_ACTIVE - -#ifdef WIRELESS_ACTIVE -const char* ssid = "Freifunk"; -const char* password = ""; -#define PUSHTO_DJANGOAPI -#ifdef PUSHTO_DJANGOAPI -const char host[] = "api.luftdaten.info"; -const int httpPort = 80; -#endif - -/* MQTT settings */ -#define PUSHTO_MQTT -#ifdef PUSHTO_MQTT -const char mqttserver[] = "mqtt.opendataset.click"; -const int mqttport = 1883; -const char mqtttopicbase[]="dusti"; // no "/" -const char mqttintopic[]="intopicforclient"; -// endif PUSHTO_MQTT -#endif - -#endif // WIRELESS_ACTIVE - -/* GPS settings */ -#ifdef GPS_ACTIVE -unsigned int pin_gps_rx=D[7]; -unsigned int pin_gps_tx=D[8]; -unsigned int gps_baudrate=9600; -unsigned long gpsmaxtime_ms=2100; // max time to wait for GPS messages on serial -#endif - -#define PIN_LED_STATUS BUILTIN_LED -//#define PIN_LED_STATUS D[8] // the GPIO of the LED pin -unsigned int pin_led_status = PIN_LED_STATUS ; // the GPIO of the LED pin - -// nodemcu pins Dx - GPIOx -// in this config use GPIO number -// 0 [*] GPIO16 -// 1 GPIO5 -// 2 GPIO4 -// 3 GPIO0 -// 4 GPIO2 -// 5 GPIO14 (SPI CLK) -// 6 GPIO12 (SPI MISO) -// 7 GPIO13 (SPI MOSI) -// 8 GPIO15 (SPI CS) -// 9 GPIO3 (UART RX) -// 10 GPIO1 (UART TX) -// 11 GPIO9 -// 12 GPIO10 - -/*******************************************************/ -/* Wiring Instruction: */ -/* Pin 2 of dust sensor PM2.5 -> Digital 6 (PWM) */ -/* Pin 3 of dust sensor -> +5V */ -/* Pin 4 of dust sensor PM1 -> Digital 3 (PMW) */ -/* */ -/* - PPD42NS Pin 1 (grey) => GND */ -/* - PPD42NS Pin 2 (green) => Pin D5 /GPIO14 */ -/* counts particles PM25 */ -/* - PPD42NS Pin 3 (black) => Vin */ -/* - PPD42NS Pin 4 (white) => Pin D6 / GPIO12 */ -/* counts particles PM10 */ -/* - PPD42NS Pin 5 (red) => unused */ -/* */ -/* ATTENTION this is another wiring, from lua version */ -/* -- esp8266-12 */ -/* pin_P1=6 -- gpio12 black */ -/* pin_P2=5 -- gpio14 white */ -/* green => GND */ -/* yellow => Vin (5V) */ -/* see datasheet http://sca-shinyei.com/pdf/PPD42NS.pdf */ -/* CN : S5B-EH(JST) (PINs on sensor board) */ -/* 1 : COMMON(GND) */ -/* 2 : OUTPUT(P2) */ -/* 3 : INPUT(5VDC 90mA) */ -/* 4 : OUTPUT(P1) */ -/* 5 : INPUT(T1) FOR THRESHOLD FOR [P2] */ -/* */ -/*******************************************************/ - -// If the include file is meant to be shared by multiple Sketches then... -// Close the Arduino IDE -// Navigate to the {Arduino}\hardware\libraries directory -// Create a subdirectory. I suggest something like MyCommon. -// In the new subdirectory, create a header file. I suggest something like MyCommon.h. -// Open the new header file, edit it as you wish, and save it -// Open the Arduino IDE -// Create or open a Sketch -// Add a #include to the top of the Sketch that references your new include file -// http://forum.arduino.cc/index.php?topic=37371.0 diff --git a/esp8266-arduino/multisens/sensorconfigdefs.h b/esp8266-arduino/multisens/sensorconfigdefs.h deleted file mode 100644 index 65631cc7c..000000000 --- a/esp8266-arduino/multisens/sensorconfigdefs.h +++ /dev/null @@ -1,21 +0,0 @@ -// all on, configure via variables -#define PPD_ACTIVE -#define DHT_ACTIVE -#define DS_ACTIVE - -/* WIFI definitions */ -#define WIRELESS_ACTIVE -#define PUSHTO_DJANGOAPI -#define PUSHTO_MQTT -#define PIN_LED_STATUS on //D[8] // the GPIO of the LED pin - -/* DHT PIN */ -//#define DHTPIN D[2] // = Dx on devboard - -/* ONEWIRE BUS PIN */ -//#define ONEWIRE_PIN D[4] - -/* PPD PINs */ -//#define PPD42_P1_PIN D[6] //12 // GPIO12=D6 -//#define PPD42_P2_PIN D[5] //14 // GPIO14=D5 - diff --git a/esp8266-arduino/multisens/serialfunctions.h b/esp8266-arduino/multisens/serialfunctions.h deleted file mode 100644 index f9757ed41..000000000 --- a/esp8266-arduino/multisens/serialfunctions.h +++ /dev/null @@ -1,150 +0,0 @@ -// serial functions, debug output, csv output - -void setup_serial(const unsigned int baudrate = 9600){ - Serial.begin(baudrate); //Output to Serial at x baud - delay(10); -} - -void serial_out(String msg, unsigned int level=1,boolean newline=false){ - if (level<=verbosity){return;} - Serial.print(String("")+msg); - if(newline){Serial.println("");} -} -/* -void serial_outln(String msg, unsigned int level=1){ - if (level<=verbosity){return;} - Serial.println(String("")+msg); -} -*/ -void serial_out(long msg, unsigned int level=1,boolean newline=false){ - if (level<=verbosity){return;} - Serial.print(msg); - if(newline){Serial.println("");} -} -/* -void serial_out(int32_t msg, unsigned int level=1,boolean newline=false){ - if (level<=verbosity){return;} - Serial.print(msg); - if(newline){Serial.println("");} - -} -*/ -/* -void serial_outln(long msg, unsigned int level=1){ - if (level<=verbosity){return;} - Serial.println(msg); -} -*/ -void serial_out(unsigned long msg, unsigned int level=1,boolean newline=false){ - if (level<=verbosity){return;} - Serial.print(msg); - if(newline){Serial.println("");} -} -void serial_out(double msg, unsigned int level=1,boolean newline=false){ - if (level<=verbosity){return;} - Serial.print(msg); - if(newline){Serial.println("");} -} -/* -void serial_outln(unsigned long msg, unsigned int level=1){ - if (level<=verbosity){return;} - Serial.println(msg); -} -*/ - -// print uint8_t as int -void serial_out(uint8_t msg, unsigned int level=1,boolean newline=false){ - if (level<=verbosity){return;} - Serial.print(int(msg)); - if(newline){Serial.println("");} -} -/* -void serial_outln(uint8_t msg, unsigned int level=1){ - if (level<=verbosity){return;} - Serial.println(int(msg)); -} -* - -void serial_out(float msg, unsigned int level=1){ - if (level<=verbosity){return;} - Serial.print(msg); -} -void serial_outln(float msg, unsigned int level=1){ - if (level<=verbosity){return;} - Serial.println(msg); -} - - -String system_info(String software_version="unknown"){ - String info="Software version: "+software_version; - info+="\nESP chipid: "; - info+=String(ESP.getChipId()); - info+="\nHeap free: "; - info+=String(ESP.getFreeHeap()); - info+="\nSketch size: "; - info+=String(ESP.getSketchSize()); - info+="\nFree size: "; - info+=String(ESP.getFreeSketchSpace()); - info+="\n"; - return (info); -} - -/* -String config_info(){ - String info="sampletime [s]: "; - info+=Float2String(sampletime_ms/1000.0); - info+="\n"; - info+="GPIOx Dx PIN matching:\n"; - int i; - for (i = 0; i < 13; i = i + 1) { - info+=String(i)+"\t"+String(D[i])+"\n"; - } - info+="Sensors:\n"; - info+="ppd_read = "+String(ppd_read)+"\n"; - info+="dht_read = "+String(dht_read)+"\n"; - info+="sds_read = "+String(sds_read)+"\n"; - info+="ds_read = "+String(ds_read)+"\n"; - - info+="Pins (GPIO):\n"; - info+="Pin PPD P1 = "+String(pin_ppd_p1)+"\n"; - info+="Pin PPD P2 = "+String(pin_ppd_p2)+"\n"; - info+="Pin DHT ="+String(pin_dht)+"\n"; - info+="Pin DS ="+String(pin_ds)+"\n"; - info+="Pin LED ="+String(pin_led_status)+"\n"; - - info+="Activations:\n"; - - info+="wireless_active = "+String(wireless_active)+"\n"; // use wireless - info+="wificonfig = "+String(wificonfig)+"\n"; // enable configuration via wifi (AP mode) - info+="send2dusti = "+String(send2dusti)+"\n"; // send data to api.luftdaten.info API - info+="send2madavi = "+String(send2madavi)+"\n"; // TODO: implement madavi - info+="send2mqtt = "+String(send2mqtt)+"\n"; // send data to MQTT - info+="send2csv = "+String(send2csv)+"\n"; // output as csv over serial - info+="debug = "+String(debug)+"\n"; // debug outputs over serial - - info+="SSID: "+ssid+"\n"; // do not output password - info+="Django API: "+djangoapihost+":"+String(djangoapihttpPort)+"\n"; - info+="MQTT API: "+mqttusername+"@"++mqttserver+":"+mqttport; - info+="\n\ttopicbase:"+mqtttopicbase; - info+="\n\tconfigtopic:"+mqttintopic; - - info+="\nMADAVI: "+madaviapihost+":"+madaviapihttpPort+madaviapiurl; - - return(info); -} -*/ - - -/***************************************************************** -/* Debug output * -/*****************************************************************/ -void debug_out(const String& text, int level, bool linebreak) { - if (level <= debug) { - if (linebreak) { - Serial.println(text); - } else { - Serial.print(text); - } - } -} - diff --git a/esp8266-arduino/multisens/softwareversion.h b/esp8266-arduino/multisens/softwareversion.h deleted file mode 100644 index 8a1cac3bd..000000000 --- a/esp8266-arduino/multisens/softwareversion.h +++ /dev/null @@ -1,22 +0,0 @@ -// version info, TODO generate/update externally? -// - -// your initials/acronym, put it into sensorconfig.h and change there -// #define SOFTWARE_VERSION_INITIALS "UNDEF" -// the version -// git tag 0.2.4814a5d // set tag -// git describe --tags // get tag -// set version in softwareversion.h -#ifndef SOFTWARE_VERSION_INITIALS -#define SOFTWARE_VERSION_INITIALS "MULTISENS" -#endif -#define SOFTWARE_VERSION_NUMBER "0.6" - -// changelog -// 0.6: MQTT loop (process incoming/ping) -// 0.5: MQTT implemented, -// counter restarts after sending to APIs -// Strings from values (avoid multiple Float2String) -// 0.4: mqtt tested -// 0.3 WIRELESS_ACTIVE option (for offline use) -// 0.2 introduce version number \ No newline at end of file diff --git a/esp8266-arduino/pintester/pintester.ino b/esp8266-arduino/pintester/pintester.ino deleted file mode 100644 index 118c1a268..000000000 --- a/esp8266-arduino/pintester/pintester.ino +++ /dev/null @@ -1,51 +0,0 @@ - - -void setup() { - Serial.begin(9600); - Serial.println("booted."); - - pinMode(1,INPUT); - pinMode(2,INPUT); - pinMode(3,INPUT); - pinMode(4,INPUT); - pinMode(5,INPUT); - pinMode(6,INPUT); - pinMode(7,INPUT); - pinMode(8,INPUT); - pinMode(9,INPUT); - pinMode(10,INPUT); -} - -void loop() { - Serial.print("1: "); - Serial.println(digitalRead(1)); - - Serial.print("2: "); - Serial.println(digitalRead(2)); - - Serial.print("3: "); - Serial.println(digitalRead(3)); - - Serial.print("4: "); - Serial.println(digitalRead(4)); - - Serial.print("5: "); - Serial.println(digitalRead(5)); - - Serial.print("6: "); - Serial.println(digitalRead(6)); - - Serial.print("7: "); - Serial.println(digitalRead(7)); - - Serial.print("8: "); - Serial.println(digitalRead(8)); - - Serial.print("9: "); - Serial.println(digitalRead(9)); - - Serial.print("10: "); - Serial.println(digitalRead(10)); - - delay(500); -} diff --git a/esp8266-arduino/ppd42ns-wificonfig-ppd-sds-dht/.gitignore b/esp8266-arduino/ppd42ns-wificonfig-ppd-sds-dht/.gitignore deleted file mode 100644 index 0ee071e5f..000000000 --- a/esp8266-arduino/ppd42ns-wificonfig-ppd-sds-dht/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -.pioenvs -.piolibdeps -examples -keywords.txt -library.json -TinyGPS++.cpp -TinyGPS++.h -builds/*.bin diff --git a/esp8266-arduino/ppd42ns-wificonfig-ppd-sds-dht/Readme.md b/esp8266-arduino/ppd42ns-wificonfig-ppd-sds-dht/Readme.md deleted file mode 100644 index db4eff1e9..000000000 --- a/esp8266-arduino/ppd42ns-wificonfig-ppd-sds-dht/Readme.md +++ /dev/null @@ -1 +0,0 @@ - This source code was moved to https://github.com/opendata-stuttgart/sensors-software/tree/master/airrohr-firmware diff --git a/esp8266-arduino/ppd42ns-wificonfig-ppd-sds-dht/configdefaults.md b/esp8266-arduino/ppd42ns-wificonfig-ppd-sds-dht/configdefaults.md deleted file mode 100644 index a2420422d..000000000 --- a/esp8266-arduino/ppd42ns-wificonfig-ppd-sds-dht/configdefaults.md +++ /dev/null @@ -1,24 +0,0 @@ -# Default configuration settings - -* power the sensor (via USB) -* wait 20 seconds -* connect to Wireless Access Point with the name: Feinstaubsensor- -* browse to/open [http://192.168.4.1/](http://192.168.4.1/) -* "Configure wifi" - - -SSID -password -Senden an luftdaten.info (0/1) ? -Senden an madavi.de (0/1) ? -Seriell als CSV (0/1) ? -DHT Sensor (0/1) ? -PPD42NS Sensor (0/1) ? -SDS Sensor (0/1) ? -BMP Sensor (0/1) ? -Display (0/1) ? -Senden an eigene API (0/1)? - -save - -Scan diff --git a/esp8266-arduino/restapi-test/restapi-test.ino b/esp8266-arduino/restapi-test/restapi-test.ino deleted file mode 100644 index 90a28ed66..000000000 --- a/esp8266-arduino/restapi-test/restapi-test.ino +++ /dev/null @@ -1,81 +0,0 @@ -/* - -HTTP POST to dusti.xyz api ... -atm without data. but dataset is created. - - */ - -#include - -const char* ssid = "........"; -const char* password = "........"; - -const char* host = "api.dusti.xyz"; - -void setup() { - Serial.begin(9600); - delay(10); - - // We start by connecting to a WiFi network - - Serial.println(); - Serial.println(); - Serial.print("Connecting to "); - Serial.println(ssid); - - WiFi.begin(ssid, password); - - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } - - Serial.println(""); - Serial.println("WiFi connected"); - Serial.println("IP address: "); - Serial.println(WiFi.localIP()); -} - -int value = 0; - -void loop() { - delay(60000); - ++value; - - Serial.print("connecting to "); - Serial.println(host); - - // Use WiFiClient class to create TCP connections - WiFiClient client; - const int httpPort = 8000; - if (!client.connect(host, httpPort)) { - Serial.println("connection failed"); - return; - } - - // We now create a URI for the request - String url = "/v1/push-sensor-data/"; - - Serial.print("Requesting URL: "); - Serial.println(url); - Serial.println(ESP.getChipId()); - - // This will send the request to the server - client.print(String("POST ") + url + " HTTP/1.1\r\n" + - "Host: " + host + "\r\n" + - "Content-Type: application/json\r\n" + - "Sensor: esp8266-"); - client.println(ESP.getChipId()); - client.println("Connection: close\r\n"); - delay(1); - - // Read all the lines of the reply from server and print them to Serial - while(client.available()){ - char c = client.read(); - Serial.print(c); - } - - Serial.println(); - Serial.println("closing connection"); -} - diff --git a/esp8266-arduino/sensordev/gps/README.md b/esp8266-arduino/sensordev/gps/README.md deleted file mode 100644 index 7c661e7bd..000000000 --- a/esp8266-arduino/sensordev/gps/README.md +++ /dev/null @@ -1,8 +0,0 @@ - -GPS NMEA Parser lib: -http://arduiniana.org/libraries/tinygpsplus/ - -ESP Software Serial (should be built in) -https://github.com/plerup/espsoftwareserial - -do not connect GPS to 3v3 of esp board, it might not be able to provide enough power, use a DC-DC voltage regulator diff --git a/esp8266-arduino/sensordev/gps/gps.ino b/esp8266-arduino/sensordev/gps/gps.ino deleted file mode 100644 index 520c18aa1..000000000 --- a/esp8266-arduino/sensordev/gps/gps.ino +++ /dev/null @@ -1,85 +0,0 @@ -/* config, move later to sensorconfig.h */ - -#define PUSHTO_SERIAL -// TODO implement -// #define PUSHTO_MQTT - -// GPIO PINSs <-> nodemcu PINs (Dx) mapping -// 0 1 2 3 4 5 6 7 8 9 10 11 12 -int D[13]={16, 5, 4, 0, 2, 14, 12, 13, 15, 3, 1, 9, 10}; - -#define GPS_ACTIVE -#ifdef GPS_ACTIVE -/* config, move later to sensorconfig.h */ -// wiring: GPS6MV2-RX->GPSRXPin -static const int GPSRXPin = D[7]; -static const int GPSTXPin = D[8]; -static const uint32_t GPSBaud = 9600; -unsigned long gpsmaxtime_ms=2100; -unsigned int pin_led = D[0]; - -#define DEBUG_GPS_NMEA - -#include -#include -#include "gpsfunctions.h" -#endif //GPS_ACTIVE - -void blink_led(unsigned int pin,unsigned int n=2, unsigned int interval=100){ -unsigned int i=0; - digitalWrite(pin, LOW); - delay(interval); - for (i=0; i -// get from http://arduiniana.org/libraries/tinygpsplus/ -// #include - -// The TinyGPS++ object -TinyGPSPlus gps; -// The serial connection to the GPS device -SoftwareSerial ss(GPSRXPin, GPSTXPin); - -void gps_setup(){ - ss.begin(GPSBaud); -} - -// This custom version of delay() ensures that the gps object -// is being "fed". -bool feedDelayGPS(unsigned long ms=200) -{ - #ifdef DEBUG_GPS_NMEA - char recchar; - #endif - unsigned long start = millis(); - do - { - while (ss.available()){ - #ifdef DEBUG_GPS_NMEA - recchar=ss.read(); - Serial.print(recchar); - gps.encode(recchar); - #endif - #ifndef DEBUG_GPS_NMEA - gps.encode(ss.read()); - #endif - yield(); - if (gps.location.isUpdated()){ - return true; - } - } - } while (millis() - start < ms); -#ifdef DEBUG_GPS_NMEA - Serial.println("charsProcessed() sentencesWithFix() failedChecksum() passedChecksum()"); - Serial.println(gps.charsProcessed()); - Serial.println(gps.sentencesWithFix()); - Serial.println(gps.failedChecksum()); - Serial.println(gps.passedChecksum()); -#endif - return false; -} - -bool push_gps_location(){ - if (!gps.location.isValid()){ - return false; - } -#ifdef PUSHTO_SERIAL -Serial.print("LatLonAlt\t"); -Serial.print(gps.location.lat(),6); -Serial.print("\t"); -Serial.print(gps.location.lng(),6); -Serial.print("\t"); -Serial.println(gps.altitude.meters()); -#endif - #ifdef PUSHTO_MQTT - mqtt_publish_subtopic("GPS/lat",gps.location.lat()); - mqtt_publish_subtopic("GPS/lon",gps.location.lng()); - mqtt_publish_subtopic("GPS/height",gps.altitude.meters()); - #endif -} - -bool push_gps_datetime(){ - TinyGPSDate d=gps.date; - TinyGPSTime t=gps.time; - char sz[64]; - if (!d.isValid()){ - return false; - }else{ - sprintf(sz, "%02d-%02d-%02d", d.year(), d.month(), d.day()); - #ifdef PUSHTO_SERIAL - Serial.print("DateTimeAge\t"); - Serial.print(sz); - #endif - #ifdef PUSHTO_MQTT - mqtt_publish_subtopic("GPS/date",gps.hdop.value()); - #endif - } - if (!t.isValid()){ - Serial.println(""); - return false; - }else{ - sprintf(sz, "%02d:%02d:%02d", t.hour(), t.minute(), t.second(),gps.location.age()); - #ifdef PUSHTO_SERIAL - Serial.print(" "); - Serial.println(sz); - #endif - #ifdef PUSHTO_MQTT - mqtt_publish_subtopic("GPS/time",sz); - #endif - sprintf(sz, "%02d", gps.location.age()); - #ifdef PUSHTO_SERIAL - Serial.print("\t"); - Serial.println(sz); - #endif - #ifdef PUSHTO_MQTT - mqtt_publish_subtopic("GPS/locationage",sz); - #endif - } - return true; -} -bool push_gps_info(){ - bool retval = (gps.hdop.isValid() & gps.satellites.isValid()); - #ifdef PUSHTO_SERIAL - Serial.print("HdopSat\t"); - if(gps.hdop.isValid()){ - Serial.print(gps.hdop.value()); - } - Serial.print("\t"); - if(gps.satellites.isValid()){ - Serial.print(gps.satellites.value()); - } - Serial.println(""); - #endif -#ifdef PUSHTO_MQTT - if(gps.hdop.isValid()){ - mqtt_publish_subtopic("GPS/HDOP",gps.hdop.value()); - } - if(gps.satellites.isValid()){ - mqtt_publish_subtopic("GPS/satellites",gps.satellites.value()); - } -#endif - return retval; -} -bool gps_read(){ - bool success=false; - // ss.flush(); //only outgoing data - if(!feedDelayGPS(gpsmaxtime_ms)){ - // no news from GPS - #ifdef PUSHTO_SERIAL - Serial.println("no news from GPS"); - #endif - return false; - } -// if(gps.location.isUpdated()){ -// unsigned long starttime=millis(); -// while(millis()-gpsmaxtime_ms 0)){ -// if (gps.encode(ss.read())){ -// if (gps.location.isUpdated()){ - success=(success|push_gps_location()); - success=(success|push_gps_datetime()); - success=(success|push_gps_info()); - return success; -// } -// } -// } -// } - -// Serial.print("debug: starttime="); -// Serial.println (starttime); -// if(!success){ -// #ifdef PUSHTO_SERIAL -// Serial.println("error reading GPS"); -// #endif -// return false; -// } -// return success; -} - -#endif // GPSFUNCTIONS_H \ No newline at end of file diff --git a/esp8266-arduino/sensordev/sdcard/README.md b/esp8266-arduino/sensordev/sdcard/README.md deleted file mode 100644 index 83a3072c2..000000000 --- a/esp8266-arduino/sensordev/sdcard/README.md +++ /dev/null @@ -1,81 +0,0 @@ -# SD card reader - -SPI interface, Arduino Micro SD Adapter, here: CATALEX v1.0 - -Default wiring, as in : - -* CS -> D8 -* SC(L)K -> D5 -* MOSI -> D7 -* MISO -> D6 -* VCC -> 3V3 -* GND -> GND - - - -Wiring according to nodemcu v3 schema, 'left' side (in order): - - -* (unused) ADC0 = TOUT -* (unused) GND -* (unused) VU = VUSB -* (unused) GPIO10 = SDD3 -* (unused) GPIO09 = SDD2 -* MOSI -> SD1 = MOSI = SDD1 -* CS -> CMD = CS = SDCMD -* MISO -> SD0 = MISO = SDD0 -* SC(L)K -> CLK = SCLK = SDCLK -* GND -> GND -* VCC -> 3V3 - -With the ESP8266, you need the Library that comes in the ESP8266 lib tree, not the original Arduino one (which won't work). I deleted the Arduino one from the tree, when there was an error message about the wrong board type (avr) and "multiple libraries, using " - -source location here is in esp8266 package: - - ~/.arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/SD/src/SD.h - - -http://www.esp8266.com/wiki/doku.php?id=esp8266_and_sd_cards - -* CS –> IO2 D4 - * D4 does not work as default -* DI(MOSI)–>IO13 D7 -* VSS1–> GND -* VDD–>3.3v -* SCLK–>IO14 D5 -* Vss2–>GND -* DO(MISO)–>IO12 D6 - - - -// boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN, uint32_t speed = SPI_HALF_SPEED); - - -/* -extender board ESP-12 via Book Kolban: -VCC 3.3V. -GPIO 13 Also used for SPI MOSI. -GPIO 12 Also used for SPI MISO. -GPIO 14 Also used for SPI Clock. -GPIO 16 -CH_PD -Chip enable. Should be high for normal operation. -• 0 – Disabled -• 1 – Enabled -ADC -REST External reset. -• 0 – Reset -• 1 – Normal -TXD UART 0 transmit. -RXD UART 0 Receive. -GPIO 4 Regular GPIO. -GPIO 5 Regular GPIO. -GPIO 0 Should be high on boot, low for flash update. -GPIO 2 Should be high on boot. -GND Ground. -*/ - -// GPIO PINSs <-> nodemcu PINs (Dx) mapping -// 0 1 2 3 4 5 6 7 8 9 10 11 12 -//int D[13]={16, 5, 4, 0, 2, 14, 12, 13, 15, 3, 1, 9, 10}; -//unsigned int pin_mosi=D[]; diff --git a/esp8266-arduino/sensordev/sdcard/sdcard.ino b/esp8266-arduino/sensordev/sdcard/sdcard.ino deleted file mode 100644 index 7416b39be..000000000 --- a/esp8266-arduino/sensordev/sdcard/sdcard.ino +++ /dev/null @@ -1,52 +0,0 @@ -/* SD Card */ - -// various necessary defs from sensorconfig -unsigned int verbosity=6; -unsigned long loopcounter=0; - -#include "serialfunctions.h" -#define SDCARD_ACTIVE -#ifdef SDCARD_ACTIVE - -#include -#include -// to config file -uint8_t pin_sd_cs=SD_CHIP_SELECT_PIN; -// uint8_t pin_sd_cs=D8; -#include "sdcardfunctions.h" - - -#endif - -unsigned long curmillis=0; -void setup() -{ - - setup_serial(); - serial_outln("\n------\nsetup()\n-------"); - serial_outln(system_info(String("sdcard"))); - setup_sd(); // pin_sd_cs will be used - sdcard_debug_info(); -// sdcard_echooutfile(); - -} - -void loop() -{ - curmillis=millis(); -#ifdef SDCARD_ACTIVE - outfile.print("loop "); - outfile.println(loopcounter,DEC); - outfile.print("millis "); - outfile.println(curmillis,DEC); - outfile.flush(); -#endif //SDCARD_ACTIVE - serial_out("loop+millis"); - serial_outln(loopcounter); - serial_outln(curmillis); - - loopcounter++; - delay(5000); -} - - diff --git a/esp8266-arduino/sensordev/sdcard/sdcardfunctions.h b/esp8266-arduino/sensordev/sdcard/sdcardfunctions.h deleted file mode 100644 index 02236eb24..000000000 --- a/esp8266-arduino/sensordev/sdcard/sdcardfunctions.h +++ /dev/null @@ -1,152 +0,0 @@ -#ifdef SDCARD_ACTIVE -// put includes in .ino -// #include -// #include - -File outfile; -String outfilename="dflt_out.tmp"; - -void sdcard_debug_info(){ - serial_out("Default SD_CHIP_SELECT_PIN: "); - serial_outln(SD_CHIP_SELECT_PIN); - serial_out("Current SD_CHIP_SELECT_PIN: "); - serial_outln(pin_sd_cs); -} - -// FAT names are 8.3, as in good old 80's -String genoutfilename(){ - outfilename=String(ESP.getChipId()); - if (outfilename.length()>8){ - // name too long, shorten - outfilename=outfilename.substring(0,8); - } - outfilename+=".txt"; - serial_out("outfilename ",5); - serial_outln(outfilename,5); - return (outfilename); -} - -/* -void sdcard_info(){ - // set up variables using the SD utility library functions: - Sd2Card sdcard; - - // print the type of card - serial_out("\nCard type: "); - switch (sdcard.type()) { - case SD_CARD_TYPE_SD1: - serial_outln("SD1"); - break; - case SD_CARD_TYPE_SD2: - serial_outln("SD2"); - break; - case SD_CARD_TYPE_SDHC: - serial_outln("SDHC"); - break; - default: - serial_outln("Unknown"); - } -} -*/ - -/* -void sdcard_listfiles(){ - - // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32 - SdVolume volume; - SdFile root; - - if (!volume.init(sdcard)) { - serial_outln("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card"); - return; - } - - // print the type and size of the first FAT-type volume - uint32_t volumesize; - serial_out("\nVolume type is FAT"); - serial_outln(volume.fatType(), DEC); - serial_outln(); - - volumesize = volume.blocksPerCluster(); // clusters are collections of blocks - volumesize *= volume.clusterCount(); // we'll have a lot of clusters - volumesize *= 512; // SD card blocks are always 512 bytes - serial_out("Volume size (bytes): "); - serial_outln(volumesize); - serial_out("Volume size (Kbytes): "); - volumesize /= 1024; - serial_outln(volumesize); - serial_out("Volume size (Mbytes): "); - volumesize /= 1024; - serial_outln(volumesize); - - serial_outln("\nFiles found on the card (name, date and size in bytes): "); - root.openRoot(volume); - - // list all files in the card with date and size - root.ls(LS_R | LS_DATE | LS_SIZE); - -} -*/ - -void outfilePrintString(String str){ - if (outfile){ - outfile.print(str.c_str()); - } -} -void outfilePrintStringln(String str){ - if (outfile){ - outfile.println(str.c_str()); - } -} - -void sdcard_echooutfile(){ - outfile.seek(0); - byte onechar=0; - while (onechar!=-1){ - onechar=outfile.read(); - serial_out(onechar); - } -} - -void setup_sd(){ - - if (!SD.begin(pin_sd_cs)){ - serial_outln("SD card initialization failed.",2); - serial_out("CS configured to GPIO ",2); - serial_outln(pin_sd_cs,2); - } - outfilename=genoutfilename(); - outfile=SD.open(outfilename.c_str(),FILE_WRITE); - if (!outfile){ - serial_out("SD.open file failed",2); - return; - } - outfile.println(""); - outfilePrintStringln(String("# debug: opened")); - outfile.flush(); -} - -void sdcard_printDirectory(File dir, int numTabs) { - while(true) { - File entry = dir.openNextFile(); - if (! entry) { - // no more files - break; - } - for (uint8_t i=0; i3 GPIO2->4 - - WIFI_SSID = 'Freifunk', - WIFI_KEY = '', - - PLUGINS = { - 'dht_reader', --- 'dht_test', --- 'reedswitch', - }, - --- PIN_REED_SWITCH = nil, -- gpio[4], --- PIN_GREEN_LED = gpio[5], --- PIN_RED_LED = nil, --- PIN_RGB_LED = nil --gpio[5], --- PIN_DHT = gpio[14], - - -- on dev-board: Dn == nodemcu n - PIN_DHT=2, - PIN_REED_SWITCH = nil, -- 5 -- GPIO 14 - PIN_GREEN_LED = 4, - PIN_RED_LED = nil - -} diff --git a/esp8266-lua/dht22_led/init.lua b/esp8266-lua/dht22_led/init.lua deleted file mode 100644 index 5a6586fc6..000000000 --- a/esp8266-lua/dht22_led/init.lua +++ /dev/null @@ -1,16 +0,0 @@ -print('init.lua ver 1.2') -print('chip: ',node.chipid()) -print('heap: ',node.heap()) - -local config = require('config') - -function go() --- dofile('wificonnect.lua') --- dofile('led22_led.lua') --- https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/onewire-ds18b20.lua --- dofile('onewire-ds18b20.lua') - readDHT() -end - -print('Waiting 10 seconds before continuing...') -tmr.alarm(0, 10000, 0, go) diff --git a/esp8266-lua/dht22_led/onewire-ds18b20.lua b/esp8266-lua/dht22_led/onewire-ds18b20.lua deleted file mode 100644 index 2a9720da1..000000000 --- a/esp8266-lua/dht22_led/onewire-ds18b20.lua +++ /dev/null @@ -1,80 +0,0 @@ ---' --- 18b20 one wire example for NODEMCU --- NODEMCU TEAM --- LICENCE: http://opensource.org/licenses/MIT --- Vowstar ---' - -pin = 8 -ow.setup(pin) -count = 0 -repeat - count = count + 1 - addr = ow.reset_search(pin) - addr = ow.search(pin) - tmr.wdclr() -until((addr ~= nil) or (count > 100)) -if (addr == nil) then - print("No more addresses.") -else - print(addr:byte(1,8)) - crc = ow.crc8(string.sub(addr,1,7)) - if (crc == addr:byte(8)) then - if ((addr:byte(1) == 0x10) or (addr:byte(1) == 0x28)) then - print("Device is a DS18S20 family device.") - repeat - ow.reset(pin) - ow.select(pin, addr) - ow.write(pin, 0x44, 1) - tmr.delay(1000000) - present = ow.reset(pin) - ow.select(pin, addr) - ow.write(pin,0xBE,1) - print("P="..present) - data = nil - data = string.char(ow.read(pin)) - for i = 1, 8 do - data = data .. string.char(ow.read(pin)) - end - print(data:byte(1,9)) - crc = ow.crc8(string.sub(data,1,8)) - print("CRC="..crc) - if (crc == data:byte(9)) then - t = (data:byte(1) + data:byte(2) * 256) * 625 - t1 = t / 10000 - t2 = t % 10000 - print("Temperature= "..t1.."."..t2.." Centigrade") - end - tmr.wdclr() - until false - else - print("Device family is not recognized.") - end - else - print("CRC is not valid!") - end -end - --- -- read temperature with DS18B20 --- -- node.compile("ds18b20.lua") -- run this only once to compile and save to "ds18b20.lc" --- t=require("ds18b20") --- t.setup(9) --- addrs=t.addrs() --- -- Total DS18B20 numbers, assume it is 2 --- print(table.getn(addrs)) --- -- The first DS18B20 --- print(t.read(addrs[1],t.C)) --- print(t.read(addrs[1],t.F)) --- print(t.read(addrs[1],t.K)) --- -- The second DS18B20 --- print(t.read(addrs[2],t.C)) --- print(t.read(addrs[2],t.F)) --- print(t.read(addrs[2],t.K)) --- -- Just read --- print(t.read()) --- -- Just read as centigrade --- print(t.read(nil,t.C)) --- -- Don't forget to release it after use --- t = nil --- ds18b20 = nil --- package.loaded["ds18b20"]=nil diff --git a/esp8266-lua/getchipdid/getchipid.py b/esp8266-lua/getchipdid/getchipid.py deleted file mode 100755 index 1097796a1..000000000 --- a/esp8266-lua/getchipdid/getchipid.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python -import serial - -ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1) -ser.flush() -ser.write('=node.chipid()\n') -ser.flush() - -ser.readline() -print("esp8266-{}".format(ser.readline())), -ser.close() - diff --git a/esp8266-lua/playground/Makefile b/esp8266-lua/playground/Makefile deleted file mode 120000 index d0b0e8e00..000000000 --- a/esp8266-lua/playground/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/esp8266-lua/playground/init.lua b/esp8266-lua/playground/init.lua deleted file mode 100644 index 5c79d0339..000000000 --- a/esp8266-lua/playground/init.lua +++ /dev/null @@ -1 +0,0 @@ --- do nothing on bootup. for now. diff --git a/esp8266-lua/playground/main.lua b/esp8266-lua/playground/main.lua deleted file mode 100644 index fe9b3bc14..000000000 --- a/esp8266-lua/playground/main.lua +++ /dev/null @@ -1,84 +0,0 @@ --- first try - --- hardware: --- esp8266-01 with nodemcu 0.9.5 --- ppd42ns sensor - --- powersource: arduino leonardo for 3.3V and 5V - -local SSID = "stuttgart.freifunk.net" -local SSID_PASSWORD = "" -local TIMEOUT = 10000000 -- 10 seconds - -function connect(timeout) - local time = tmr.now() - wifi.sta.connect() - - -- Wait for IP address; check each 1000ms; timeout - tmr.alarm(1, 1000, 1, - function() - if wifi.sta.status() == 5 then - tmr.stop(1) - print("Station: connected! IP: " .. wifi.sta.getip()) - send_to_api() - else - if tmr.now() - time > timeout then - tmr.stop(1) - print("Timeout!") - return false - end - end - end - ) -end - -function build_post_request(host, uri, data_table) - - local data = "" - - for param,value in pairs(data_table) do - data = data .. param.."="..value.."&" - end - - request = "POST "..uri.." HTTP/1.1\r\n".. - "Host: "..host.."\r\n".. - "Connection: close\r\n".. - "Content-Type: application/x-www-form-urlencoded\r\n".. - "User-Agent: esp8266\r\n".. --- FIXME: add authentication - "Content-Length: "..string.len(data).."\r\n".. - "\r\n".. - data - - print(request) - - return request -end - -function send_to_api() - print("start api connect") - api=net.createConnection(net.TCP, 0) - print("connect") - api:on("receive", function(sck, c) print(c) end ) - api:connect(80, "api.dusti.xyz") - -- FIXME: add read data - local data = { - a = 1 - } - api:on("connection", function(sck) - local post_request = build_post_request("api.dusti.xyz", "/v1/push-sensor-data/", data) - sck:send(post_request) - print("sent") - end) -end - --- configure ESP as a station -wifi.setmode(wifi.STATION) -wifi.sta.config(SSID,SSID_PASSWORD) -wifi.sta.autoconnect(1) - -connect(TIMEOUT) - --- read from gpio2 --- save to file if no wifi found --- push to api if wifi found diff --git a/esp8266-lua/plugin_framework/.gitignore b/esp8266-lua/plugin_framework/.gitignore deleted file mode 100644 index 338c30be2..000000000 --- a/esp8266-lua/plugin_framework/.gitignore +++ /dev/null @@ -1 +0,0 @@ -config.lua diff --git a/esp8266-lua/plugin_framework/README.md b/esp8266-lua/plugin_framework/README.md deleted file mode 100644 index dd8785707..000000000 --- a/esp8266-lua/plugin_framework/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# EPS8266 plugin framework - -## Getting this to work - -Put your wifi credentials in `config.lua` and activate the plugins you want to use by uncommenting them. - -Upload the files `init.lua`, `config.lua`, `wifi_connect.lua` and the plugins (and their dependencies) you activated to your ESP. - -``` -./luatool.py -f init.lua -./luatool.py -f config.lua -./luatool.py -f wifi_connect.lua -``` - -## Troubleshooting - -If you get `Not enough memory` errors compile the lib you want to load (via console on the esp): - -``` -> node.compile('file.lua') -``` -then restart and it should work. - - -# dht_reader.lua - -Push DHT22 data with ESP8266 to api.dusti.xyz - -## Dependencies - -* [dht_lib.lua](https://github.com/nodemcu/nodemcu-firmware/tree/master/lua_modules/dht_lib/dht_lib.lua) -* `drf_api.lua` - -## Instructions - -Connect the DHT22 datapin to GPIO2 diff --git a/esp8266-lua/plugin_framework/dht_reader.lua b/esp8266-lua/plugin_framework/dht_reader.lua deleted file mode 100644 index 66438e603..000000000 --- a/esp8266-lua/plugin_framework/dht_reader.lua +++ /dev/null @@ -1,24 +0,0 @@ -local config = require('config') - -local drf_api = require('drf_api') - -local function timerCB() - status,temp,humi,temp_decimial,humi_decimial = dht.readxx(config.PIN_DHT) - if( status == dht.OK ) then - drf_api.send_dht22_to_api(temp, humi) - elseif( status == dht.ERROR_CHECKSUM ) then - print( "DHT Checksum error." ); - elseif( status == dht.ERROR_TIMEOUT ) then - print( "DHT Time out." ); - end -end - -local function start() - timerCB() - tmr.alarm(1, 60000, 1, timerCB) -end - - -return { - start = start -} diff --git a/esp8266-lua/plugin_framework/dht_test.lua b/esp8266-lua/plugin_framework/dht_test.lua deleted file mode 100644 index 5052a52be..000000000 --- a/esp8266-lua/plugin_framework/dht_test.lua +++ /dev/null @@ -1,11 +0,0 @@ -local config = require('config') - -local function readDHT() - print(dht.read(config.PIN_DHT)) -end - -local function start() - tmr.alarm(2, 1000, 1, readDHT) -end - -return {start = start} diff --git a/esp8266-lua/plugin_framework/door.lua b/esp8266-lua/plugin_framework/door.lua deleted file mode 100644 index e69de29bb..000000000 diff --git a/esp8266-lua/plugin_framework/drf_api.lua b/esp8266-lua/plugin_framework/drf_api.lua deleted file mode 100644 index 0b9665513..000000000 --- a/esp8266-lua/plugin_framework/drf_api.lua +++ /dev/null @@ -1,53 +0,0 @@ -local config = require('config') - -local function build_post_request(host, uri, data) - request = "POST "..uri.." HTTP/1.1\r\n".. - "Host: "..host.."\r\n".. - "Connection: close\r\n".. - "Content-Type: application/json\r\n".. - "User-Agent: esp8266\r\n".. - "Sensor: esp8266-"..node.chipid().."\r\n".. - "Content-Length: "..string.len(data).."\r\n".. - "\r\n".. - data - - return request -end - -local function send_data_to_api(data) - if config.DEBUG then - print("start api connect") - end - api=net.createConnection(net.TCP, 0) - if config.DEBUG then - print("connect") - api:on("receive", function(sck, c) print(c) end ) - end - api:connect(config.API_PORT, config.API_HOST) - api:on("connection", function(sck) - local post_request = build_post_request(config.API_HOST, "/v1/push-sensor-data/", data) - sck:send(post_request) - if config.DEBUG then - print("sent") - end - end) -end - -local function send_ppd42ns_to_api(lowpulseoccupancyP1, lowpulseoccupancyP2, sampletime) - local ratioP1 = lowpulseoccupancyP1 / (sampletime*10.0) - local P1 = 1.1*ratioP1*ratioP1*ratioP1-3.8*ratioP1*ratioP1+520*ratioP1+0.62 - local ratioP2 = lowpulseoccupancyP2 / (sampletime*10.0) - local P2 = 1.1*ratioP2*ratioP2*ratioP2-3.8*ratioP2*ratioP2+520*ratioP2+0.62 - local data = '{"sensordatavalues":[{"value_type":"durP1","value":"'..lowpulseoccupancyP1..'"},{"value_type":"ratioP1","value":"'..ratioP1..'"},{"value_type":"P1","value":"'..P1..'"}' - data = data .. ',{"value_type":"durP2","value":"'..lowpulseoccupancyP2..'"},{"value_type":"ratioP2","value":"'..ratioP2..'"},{"value_type":"P2","value":"'..P2..'"}]}' - send_data_to_api(data) -end - -local function send_dht22_to_api(temperature, humidity) - send_data_to_api('{"sensordatavalues":[{"value_type":"temperature","value":"'..temperature..'"},{"value_type":"humidity","value":"'..humidity..'"}]}') -end - -return { - send_dht22_to_api = send_dht22_to_api, - send_ppd42ns_to_api = send_ppd42ns_to_api -} diff --git a/esp8266-lua/plugin_framework/example_config.lua b/esp8266-lua/plugin_framework/example_config.lua deleted file mode 100644 index dbe12030d..000000000 --- a/esp8266-lua/plugin_framework/example_config.lua +++ /dev/null @@ -1,20 +0,0 @@ -local gpio = {[0]=3,[1]=10,[2]=4,[3]=9,[4]=1,[5]=2,[10]=12,[12]=6,[13]=7,[14]=5,[15]=8,[16]=0} - -return { - DEBUG = false, - SKIP_WIFI_CONNECT = false, - WIFI_SSID = '', - WIFI_KEY = '', - - PLUGINS = { - -- 'dht_reader', - -- 'wsledtest', - 'dht_test', - }, - - PIN_REED_SWITCH = gpio[4], - PIN_GREEN_LED = nil, - PIN_RED_LED = nil, - PIN_RGB_LED = gpio[5], - PIN_DHT = gpio[14], -} diff --git a/esp8266-lua/plugin_framework/flash_initial.sh b/esp8266-lua/plugin_framework/flash_initial.sh deleted file mode 100755 index 998d07083..000000000 --- a/esp8266-lua/plugin_framework/flash_initial.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -set -e - -./luatool.py -f init.lua -./luatool.py -f pluginloader.lua -./luatool.py -f wificonnect.lua -./luatool.py -f config.lua -# ./luatool.py -f wsledtest.lua -# ./luatool.py -c -f drf_api.lua -# ./luatool.py -f dht_reader.lua diff --git a/esp8266-lua/plugin_framework/init.lua b/esp8266-lua/plugin_framework/init.lua deleted file mode 100644 index 6a2b037e5..000000000 --- a/esp8266-lua/plugin_framework/init.lua +++ /dev/null @@ -1,35 +0,0 @@ -print('init.lua ver 1.2') -print('chip: ',node.chipid()) -print('heap: ',node.heap()) - -local config = require('config') - -function go() - gpio.mode(3, gpio.OUTPUT) - ws2812.write(config.PIN_RGB_LED, string.char(0, 0, 0)) - if config.SKIP_WIFI_CONNECT then - local plugin_loader = require('pluginloader') - plugin_loader.start_plugins() - else - dofile('wificonnect.lua') - end - if config.PIN_REED_SWITCH then - dofile('reedswitch.lua') - end -end - -print('Waiting 3 seconds before continuing... Press GPIO 0 to interrupt') -if config.PIN_RGB_LED then - ws2812.write(config.PIN_RGB_LED, string.char(50, 0, 50)) -end -tmr.alarm(0, 3000, 0, go) - -gpio.mode(3, gpio.INT, gpio.PULLUP) -gpio.trig(3, "down", function(level) - print("Stopping timer. Not starting wificonnect") - if config.PIN_RGB_LED then - ws2812.write(config.PIN_RGB_LED, string.char(50, 50, 0)) - end - tmr.stop(0) - gpio.mode(3, gpio.OUTPUT) -end) diff --git a/esp8266-lua/plugin_framework/luatool.py b/esp8266-lua/plugin_framework/luatool.py deleted file mode 100755 index 31cb2c5be..000000000 --- a/esp8266-lua/plugin_framework/luatool.py +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/bin/env python2 -# -# ESP8266 luatool -# Author e-mail: 4ref0nt@gmail.com -# Site: http://esp8266.ru -# Contributions from: https://github.com/sej7278 -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin -# Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import sys -import serial -from time import sleep -import argparse -from os.path import basename - -version="0.6.3" - -def writeln(data, check = 1): - if s.inWaiting() > 0: - s.flushInput() - if len( data ) > 0: - sys.stdout.write("\r\n->") - sys.stdout.write(data.split("\r")[0]) - s.write(data) - sleep(0.3) - if check > 0 : - line = '' - char = '' - while char != chr(62) : # '>' - char = s.read(1) - if char == '' : - raise Exception('No proper answer from MCU') - if char == chr(13) or char == chr(10) : # LF or CR - if line != '': - line = line.strip() - if line+'\r' == data : - sys.stdout.write(" -> ok") - else : - if line[:4] == "lua:" : - sys.stdout.write("\r\n\r\nLua ERROR: %s" % line) - raise Exception('ERROR from Lua interpreter\r\n\r\n') - else : - data = data.split("\r")[0] - sys.stdout.write("\r\n\r\nERROR") - sys.stdout.write("\r\n send string : '%s'" % data) - sys.stdout.write("\r\n expected echo : '%s'" % data) - sys.stdout.write("\r\n but got answer : '%s'" % line) - sys.stdout.write("\r\n\r\n") - raise Exception('Error sending data to MCU\r\n\r\n') - line = '' - else : - line += char - else: - sys.stdout.write(" -> send without check") - -def writer(data): - writeln("file.writeline([==[" + data + "]==])\r") - -def openserial(args): - # Open the selected serial port - try: - s = serial.Serial(args.port, args.baud) - except: - sys.stderr.write("Could not open port %s\n" % (args.port)) - sys.exit(1) - if args.verbose: sys.stderr.write("Set timeout %s\r\n" % s.timeout) - s.timeout = 3 - if args.verbose: sys.stderr.write("Set interCharTimeout %s\r\n" % s.interCharTimeout) - s.interCharTimeout = 3 - return s - -if __name__ == '__main__': - # parse arguments or use defaults - parser = argparse.ArgumentParser(description='ESP8266 Lua script uploader.') - parser.add_argument('-p', '--port', default='/dev/ttyUSB0', help='Device name, default /dev/ttyUSB0') - parser.add_argument('-b', '--baud', default=9600, help='Baudrate, default 9600') - parser.add_argument('-f', '--src', default='main.lua', help='Source file on computer, default main.lua') - parser.add_argument('-t', '--dest', default=None, help='Destination file on MCU, default to source file name') - parser.add_argument('-c', '--compile', action='store_true', help='Compile lua to lc after upload') - parser.add_argument('-r', '--restart', action='store_true', help='Restart MCU after upload') - parser.add_argument('-d', '--dofile', action='store_true', help='Run the Lua script after upload') - parser.add_argument('-v', '--verbose', action='store_true', help="Show progress messages.") - parser.add_argument('-l', '--list', action='store_true', help='List files on device') - args = parser.parse_args() - - if args.list: - s = openserial(args) - writeln("local l = file.list();for k,v in pairs(l) do print('name:'..k..', size:'..v)end\r", 0) - while True : - char = s.read(1) - if char == '' or char == chr(62): break - sys.stdout.write(char) - sys.exit(0) - - if args.dest is None: - args.dest = basename(args.src) - - # open source file for reading - try: - f = open(args.src,"rt") - except: - sys.stderr.write("Could not open input file \"%s\"\n" % args.src) - sys.exit(1) - - # Verify the selected file will not exceed the size of the serial buffer. - # The size of the buffer is 256. This script does not accept files with - # lines longer than 230 characters to have some room for command overhead. - for Ln in f: - if len(Ln) > 230: - sys.stderr.write("File \"%s\" contains a line with more than 240 "\ - "characters. This exceeds the size of the serial buffer.\n" - % args.src) - f.close() - sys.exit(1) - - # Go back to the beginning of the file after verifying it has the correct - # line length - f.seek(0) - - # Open the selected serial port - s = openserial(args) - - # set serial timeout - if args.verbose: sys.stderr.write("Upload starting\r\n") - - # remove existing file on device - if args.verbose: sys.stderr.write("Stage 1. Deleting old file from flash memory") - writeln("file.open(\""+args.dest+"\", \"w\")\r") - writeln("file.close()\r") - writeln("file.remove(\""+args.dest+"\")\r") - - # read source file line by line and write to device - if args.verbose: sys.stderr.write("\r\nStage 2. Creating file in flash memory and write first line") - writeln("file.open(\""+args.dest+"\", \"w+\")\r") - line = f.readline() - if args.verbose: sys.stderr.write("\r\nStage 3. Start writing data to flash memory...") - while line != '': - writer(line.strip()) - line = f.readline() - - # close both files - f.close() - if args.verbose: sys.stderr.write("\r\nStage 4. Flush data and closing file") - writeln("file.flush()\r") - writeln("file.close()\r") - - # compile? - if args.compile: - if args.verbose: sys.stderr.write("\r\nStage 5. Compiling") - writeln("node.compile(\""+args.dest+"\")\r") - writeln("file.remove(\""+args.dest+"\")\r") - - # restart or dofile - if args.restart: - writeln("node.restart()\r") - if args.dofile: # never exec if restart=1 - writeln("dofile(\""+args.dest+"\")\r",0) - - # close serial port - s.flush() - s.close() - - # flush screen - sys.stdout.flush() - sys.stderr.flush() - sys.stderr.write("\r\n--->>> All done <<<---\r\n") diff --git a/esp8266-lua/plugin_framework/pluginloader.lua b/esp8266-lua/plugin_framework/pluginloader.lua deleted file mode 100644 index 0d7107f0e..000000000 --- a/esp8266-lua/plugin_framework/pluginloader.lua +++ /dev/null @@ -1,16 +0,0 @@ -local config = require('config') - -local function start_plugins() - for i, plugin in ipairs(config.PLUGINS) do - print("Starting plugin: "..plugin) - dofile(plugin..".lua") - local plugin_lib = require(plugin) - if plugin_lib == nil then - print("error loading plugin") - else - plugin_lib.start() - end - end -end - -return {start_plugins = start_plugins} diff --git a/esp8266-lua/plugin_framework/reedswitch.lua b/esp8266-lua/plugin_framework/reedswitch.lua deleted file mode 100644 index 9cf48c0f0..000000000 --- a/esp8266-lua/plugin_framework/reedswitch.lua +++ /dev/null @@ -1,28 +0,0 @@ -local config = require('config') - -local last_level = -1 - -local function tmrCb() - local level = gpio.read(config.PIN_REED_SWITCH) - if last_level ~= level then - last_level = level - if level == 0 then - ws2812.write(config.PIN_RGB_LED, string.char(0, 255, 0)) - else - ws2812.write(config.PIN_RGB_LED, string.char(255, 0, 0)) - end - tmr.alarm(3, 1000, 0, function () - ws2812.write(config.PIN_RGB_LED, string.char(0, 0, 0)) - end) - end -end - -local function start() - print('Configuring reedswitch...') - gpio.mode(config.PIN_REED_SWITCH, gpio.INPUT, gpio.PULLUP) - tmr.alarm(2, 1000, 1, tmrCb) -end - -start() - --- return {start = start} diff --git a/esp8266-lua/plugin_framework/wificonnect.lua b/esp8266-lua/plugin_framework/wificonnect.lua deleted file mode 100644 index d6a6fd27c..000000000 --- a/esp8266-lua/plugin_framework/wificonnect.lua +++ /dev/null @@ -1,61 +0,0 @@ -local config = require('config') - --- setup -wifi.setmode(wifi.STATION) -wifi.sta.autoconnect(1) -wifi.sta.config(config.WIFI_SSID, config.WIFI_KEY) - -print('MAC: ',wifi.sta.getmac()) - -if config.PIN_RED_LED and config.PIN_GREEN_LED then - gpio.mode(config.PIN_GREEN_LED, gpio.OUTPUT) - gpio.mode(config.PIN_RED_LED, gpio.OUTPUT) - c = gpio.HIGH -end - --- watch wifi connect state - -tmr.alarm(0, 1000, 1, function() - if wifi.sta.getip() == nil then - local status = wifi.sta.status() - if config.PIN_RGB_LED then - if status == 1 then -- connecting - ws2812.write(config.PIN_RGB_LED, string.char(0, 0, 255)) - elseif status <= 4 then - ws2812.write(config.PIN_RGB_LED, string.char(255, 0, 0)) - elseif status == 5 then - ws2812.write(config.PIN_RGB_LED, string.char(0, 50, 0)) - end - end - if config.PIN_RED_LED and config.PIN_GREEN_LED then - if status == 1 then -- connecting - gpio.write(config.PIN_GREEN_LED, c) - if c == gpio.HIGH then - c = gpio.LOW - else - c = gpio.HIGH - end - gpio.write(config.PIN_RED_LED, c) - elseif status <= 4 then - gpio.write(config.PIN_GREEN_LED, gpio.LOW) - gpio.write(config.PIN_RED_LED, gpio.HIGH) - elseif status == 5 then - gpio.write(config.PIN_GREEN_LED, gpio.HIGH) - gpio.write(config.PIN_RED_LED, gpio.LOW) - end - end - -- print("Connecting to AP...") - else - print('IP: ',wifi.sta.getip()) - if config.PIN_RED_LED and config.PIN_GREEN_LED then - gpio.write(config.PIN_RED_LED, gpio.LOW) - gpio.write(config.PIN_GREEN_LED, gpio.LOW) - end - if config.PIN_RGB_LED then - ws2812.write(config.PIN_RGB_LED, string.char(0, 0, 0)) - end - tmr.stop(0) - local plugin_loader = require('pluginloader') - plugin_loader.start_plugins() - end -end) diff --git a/esp8266-lua/plugin_framework/wsledtest.lua b/esp8266-lua/plugin_framework/wsledtest.lua deleted file mode 100644 index b3e6f531b..000000000 --- a/esp8266-lua/plugin_framework/wsledtest.lua +++ /dev/null @@ -1,11 +0,0 @@ -local config = require('config') - -local function setRandomColor() - ws2812.write(config.PIN_RGB_LED, string.char(math.random(255), math.random(255), math.random(255))) -end - -local function start() - tmr.alarm(2, 500, 1, setRandomColor) -end - -return {start = start} diff --git a/esp8266-lua/ppd42ns+dht22/Makefile b/esp8266-lua/ppd42ns+dht22/Makefile deleted file mode 100644 index 0311040b0..000000000 --- a/esp8266-lua/ppd42ns+dht22/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# for using makefile add luatool.py to your path - -upload: upload_main upload_init - luatool.py -l - -upload_main: - luatool.py -f main.lua - luatool.py -f http.lua - luatool.py -f config.lua - -upload_init: - luatool.py -f init.lua - diff --git a/esp8266-lua/ppd42ns+dht22/config.template b/esp8266-lua/ppd42ns+dht22/config.template deleted file mode 100644 index 5ecbab86f..000000000 --- a/esp8266-lua/ppd42ns+dht22/config.template +++ /dev/null @@ -1,11 +0,0 @@ --- esp8266-12 -pin_P1=6 -- gpio12 black -pin_P2=5 -- gpio14 white --- pin_P2=nil -- to disable sensor -sampletime=30000 -- 30 seconds -filter_time=10000 -- in us --- set to nil (false) to disable DHT -PIN_DHT22=3 -PIN_GREEN_LED = 2 -- GPIO4 -PIN_RED_LED = 1 - diff --git a/esp8266-lua/ppd42ns+dht22/devsnippets.lua b/esp8266-lua/ppd42ns+dht22/devsnippets.lua deleted file mode 100644 index f4fe6aed6..000000000 --- a/esp8266-lua/ppd42ns+dht22/devsnippets.lua +++ /dev/null @@ -1,14 +0,0 @@ - -status,temp,humi,temp_decimial,humi_decimial=dht.readxx(PIN_DHT22) -if( status == dht.OK ) then - print("DHT Temperature: "..temp.." ".."Humidity: "..humi) - print("DHT Temperature_decimial: "..temp_decimial.." ".."Humidity_decimial: "..humi_decimial) - send_to_api_dht22(status,temp,humi,temp_decimial,humi_decimial) -else - --elseif( status ~= dht.OK ) then - print ("DHT error, status="..status.." PIN_DHT22="..PIN_DHT22) -end - - -- from pluginframework: send_data_to_api('{"sensordatavalues":[{"value_type":"temperature","value":"'..temperature..'"},{"value_type":"humidity","value":"'..humidity..'"}]}') - --- =dht.readxx(3) diff --git a/esp8266-lua/ppd42ns+dht22/http.lua b/esp8266-lua/ppd42ns+dht22/http.lua deleted file mode 100644 index a90929910..000000000 --- a/esp8266-lua/ppd42ns+dht22/http.lua +++ /dev/null @@ -1,54 +0,0 @@ - - -function build_post_request(host, uri, data) - - request = "POST "..uri.." HTTP/1.1\r\n".. - "Host: "..host.."\r\n".. - "Connection: close\r\n".. - "Content-Type: application/json\r\n".. - "User-Agent: esp8266\r\n".. - "Sensor: esp8266-"..node.chipid().."\r\n".. - "Content-Length: "..string.len(data).."\r\n".. - "\r\n".. - data - - print(request) - - return request -end - -function send_to_api(lowpulseoccupancyP1, lowpulseoccupancyP2, sampletime) - - local ratioP1 = lowpulseoccupancyP1 / (sampletime*10.0) - local P1 = 1.1*ratioP1*ratioP1*ratioP1-3.8*ratioP1*ratioP1+520*ratioP1+0.62 - local ratioP2 = lowpulseoccupancyP2 / (sampletime*10.0) - local P2 = 1.1*ratioP2*ratioP2*ratioP2-3.8*ratioP2*ratioP2+520*ratioP2+0.62 - local data = '{"sensordatavalues":[{"value_type":"durP1","value":"'..lowpulseoccupancyP1..'"},{"value_type":"ratioP1","value":"'..ratioP1..'"},{"value_type":"P1","value":"'..P1..'"}' - data = data .. ',{"value_type":"durP2","value":"'..lowpulseoccupancyP2..'"},{"value_type":"ratioP2","value":"'..ratioP2..'"},{"value_type":"P2","value":"'..P2..'"}]}' - - print("start api connect") - api=net.createConnection(net.TCP, 0) - print("connect") - api:on("receive", function(sck, c) print(c) end ) - api:connect(80, "api.dusti.xyz") - api:on("connection", function(sck) - local post_request = build_post_request("api.dusti.xyz", "/v1/push-sensor-data/", data) - sck:send(post_request) - print("sent") - end) -end - -function send_to_api_dht(temperature,humidity) - local data='{"sensordatavalues":[{"value_type":"temperature","value":"'..temperature..'"},{"value_type":"humidity","value":"'..humidity..'"}]}' - - print("start api connect (dht22)") - api=net.createConnection(net.TCP, 0) - print("connect (dht22)") - api:on("receive", function(sck, c) print(c) end ) - api:connect(80, "api.dusti.xyz") - api:on("connection", function(sck) - local post_request = build_post_request("api.dusti.xyz", "/v1/push-sensor-data/", data) - sck:send(post_request) - print("sent (dht22)") - end) -end diff --git a/esp8266-lua/ppd42ns+dht22/init.lua b/esp8266-lua/ppd42ns+dht22/init.lua deleted file mode 100644 index 558ca96e8..000000000 --- a/esp8266-lua/ppd42ns+dht22/init.lua +++ /dev/null @@ -1,12 +0,0 @@ -tmr.delay(100000) - -wifi.setmode(wifi.STATION) -wifi.sta.autoconnect(1) -print('set mode=STATION (mode='..wifi.getmode()..')') -print('MAC: ',wifi.sta.getmac()) -print('chip: ',node.chipid()) -print('heap: ',node.heap()) - -wifi.sta.config("Freifunk","") - --- dofile('main.lua') diff --git a/esp8266-lua/ppd42ns+dht22/main.lua b/esp8266-lua/ppd42ns+dht22/main.lua deleted file mode 100644 index fd75e4c30..000000000 --- a/esp8266-lua/ppd42ns+dht22/main.lua +++ /dev/null @@ -1,107 +0,0 @@ --- esp8266-12 -pin_P1=6 -- gpio12 black -pin_P2=5 -- gpio14 white --- pin_P2=nil -- to disable ppd -sampletime=30000 -- 30 seconds -filter_time=10000 -- in us --- set to nil (false) to disable DHT -PIN_DHT22=3 -PIN_GREEN_LED = 2 -- GPIO4 -PIN_RED_LED = 1 --- change any setting in config.lua -dofile('config.lua') - -durationP1=0 -trigOnP1=0 -lastTriggerP1=0 -lowpulseoccupancyP1=0 - -durationP2=0 -trigOnP2=0 -lastTriggerP2=0 -lowpulseoccupancyP2=0 - -temperature=-999 -humidity=-999 -tempdec=99 -humidec=99 - -gpio.mode(PIN_GREEN_LED, gpio.OUTPUT) -gpio.write(PIN_GREEN_LED, gpio.HIGH) -c = gpio.HIGH - -if(pin_P2~=nil) then - gpio.mode(pin_P1, gpio.INT) - function pin4change(level) - if (tmr.now() - lastTriggerP1) > filter_time then - if level == gpio.LOW then - trigOnP1 = tmr.now() - else - durationP1 = tmr.now() - trigOnP1 - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1 - end - lastTriggerP1 = tmr.now() - end - gpio.trig(pin_P1, "both") - end - gpio.trig(pin_P1, "both", pin4change) - - - gpio.mode(pin_P2, gpio.INT) - function pin2change(level) - if (tmr.now() - lastTriggerP2) > filter_time then - if level == gpio.LOW then - trigOnP2 = tmr.now() - else - durationP2 = tmr.now() - trigOnP1 - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2 - end - lastTriggerP2 = tmr.now() - end - gpio.trig(pin_P2, "both") - end - gpio.trig(pin_P2, "both", pin2change) - -end - -function send_it() - if wifi.sta.getip() == nil then - status = wifi.sta.status() - if status == 1 then -- connecting - gpio.write(PIN_GREEN_LED, c) - if c == gpio.HIGH then - c = gpio.LOW - else - c = gpio.HIGH - end - elseif status <= 4 then - gpio.write(PIN_GREEN_LED, gpio.LOW) - elseif status == 5 then - gpio.write(PIN_GREEN_LED, gpio.HIGH) - end - else - print('IP: ',wifi.sta.getip()) - if (pin_P2~=nil) then - send_to_api(lowpulseoccupancyP1, lowpulseoccupancyP2, sampletime) - end - if (PIN_DHT22 and (dht~=nil)) then - status,temperature,humidity,tempdec,humidec=dht.readxx(PIN_DHT22) - if( status == dht.OK ) then - temperature=math.floor(temperature).."."..tempdec - humidity=math.floor(humidity).."."..humidec - print("DHT Temperature: "..temperature.." ".."Humidity: "..humidity) - send_to_api_dht(temperature,humidity) - else - print ("DHT error, status="..status.." PIN_DHT22="..PIN_DHT22) - end - end - end - -- even if the data could not be sent. - -- throw it away and try again after samplingtime - lowpulseoccupancyP1 = 0 - lowpulseoccupancyP2 = 0 - tmr.alarm(0, sampletime, 0, send_it) -end - -tmr.alarm(0, sampletime, 0, send_it) -dofile('http.lua') diff --git a/esp8266-lua/ppd42ns+dht22/readme.md b/esp8266-lua/ppd42ns+dht22/readme.md deleted file mode 100644 index 34ac7b71b..000000000 --- a/esp8266-lua/ppd42ns+dht22/readme.md +++ /dev/null @@ -1,40 +0,0 @@ -# ppd42ns - -this dir derived from ../ppd42ns/, DHT22 added - -## some links for implementation - -- http://esp8266.co.uk/tutorials/introduction-to-the-gpio-api/ -- http://www.nodemcu.com/docs/gpio-module/#gpio-module-gpio-trig -- https://github.com/nodemcu/nodemcu-firmware/issues/179 - - -## other implementations - -### 1 - -https://github.com/marcel12bell/feinstaub-app/blob/master/init.lua - -seems wrong, because no interrupt is used. one value each second via alarm timer. - -### ? - -# DHT22 - - PINS - #### - #### - #### - |||| - 1234 - - PIN connections - 1 3V3 4.6kOhm 4.7muF[+] - 2 GPIO 4.6kOhm - 3 - 4 GND 4.7muF[-] - -* resistor/capacitor are optional, it works without, too -* connect to D3 (nodemcu PIN) resp. GPIO0 - - diff --git a/esp8266-lua/ppd42ns/Makefile b/esp8266-lua/ppd42ns/Makefile deleted file mode 100644 index 9da827118..000000000 --- a/esp8266-lua/ppd42ns/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# for using makefile add luatool.py to your path - -upload: upload_main upload_init - luatool.py -l - -upload_main: - luatool.py -f main.lua - luatool.py -f http.lua - -upload_init: - luatool.py -f init.lua - -noop: - # upload empty init.lua and reboot - luatool.py -r -f noop_init/init.lua - -upload_dev: - luatool.py -f init.lua - luatool.py -f maindev.lua - luatool.py -f http.lua - luatool.py -l diff --git a/esp8266-lua/ppd42ns/http.lua b/esp8266-lua/ppd42ns/http.lua deleted file mode 100644 index 0dbbc4125..000000000 --- a/esp8266-lua/ppd42ns/http.lua +++ /dev/null @@ -1,39 +0,0 @@ - - -function build_post_request(host, uri, data) - - request = "POST "..uri.." HTTP/1.1\r\n".. - "Host: "..host.."\r\n".. - "Connection: close\r\n".. - "Content-Type: application/json\r\n".. - "User-Agent: esp8266\r\n".. - "Sensor: esp8266-"..node.chipid().."\r\n".. - "Content-Length: "..string.len(data).."\r\n".. - "\r\n".. - data - - print(request) - - return request -end - -function send_to_api(lowpulseoccupancyP1, lowpulseoccupancyP2, sampletime) - - local ratioP1 = lowpulseoccupancyP1 / (sampletime*10.0) - local P1 = 1.1*ratioP1*ratioP1*ratioP1-3.8*ratioP1*ratioP1+520*ratioP1+0.62 - local ratioP2 = lowpulseoccupancyP2 / (sampletime*10.0) - local P2 = 1.1*ratioP2*ratioP2*ratioP2-3.8*ratioP2*ratioP2+520*ratioP2+0.62 - local data = '{"sensordatavalues":[{"value_type":"durP1","value":"'..lowpulseoccupancyP1..'"},{"value_type":"ratioP1","value":"'..ratioP1..'"},{"value_type":"P1","value":"'..P1..'"}' - data = data .. ',{"value_type":"durP2","value":"'..lowpulseoccupancyP2..'"},{"value_type":"ratioP2","value":"'..ratioP2..'"},{"value_type":"P2","value":"'..P2..'"}]}' - - print("start api connect") - api=net.createConnection(net.TCP, 0) - print("connect") - api:on("receive", function(sck, c) print(c) end ) - api:connect(80, "api.dusti.xyz") - api:on("connection", function(sck) - local post_request = build_post_request("api.dusti.xyz", "/v1/push-sensor-data/", data) - sck:send(post_request) - print("sent") - end) -end diff --git a/esp8266-lua/ppd42ns/init.lua b/esp8266-lua/ppd42ns/init.lua deleted file mode 100644 index 8cbf000b8..000000000 --- a/esp8266-lua/ppd42ns/init.lua +++ /dev/null @@ -1,13 +0,0 @@ -tmr.delay(100000) - -wifi.setmode(wifi.STATION) -wifi.sta.autoconnect(1) -print('set mode=STATION (mode='..wifi.getmode()..')') -print('MAC: ',wifi.sta.getmac()) -print('chip: ',node.chipid()) -print('heap: ',node.heap()) - -wifi.sta.config("Freifunk","") --- wifi.sta.config("shack","welcome2shack") - -dofile('main.lua') diff --git a/esp8266-lua/ppd42ns/main.lua b/esp8266-lua/ppd42ns/main.lua deleted file mode 100644 index 8ae26c6b2..000000000 --- a/esp8266-lua/ppd42ns/main.lua +++ /dev/null @@ -1,87 +0,0 @@ --- esp8266-12 -pin_P1=6 -- gpio12 black -pin_P2=5 -- gpio14 white - -sampletime=30000 -- 30 seconds -filter_time=10000 -- in us - -durationP1=0 -trigOnP1=0 -lastTriggerP1=0 -lowpulseoccupancyP1=0 - -durationP2=0 -trigOnP2=0 -lastTriggerP2=0 -lowpulseoccupancyP2=0 - - -PIN_GREEN_LED = 2 -PIN_RED_LED = 1 -gpio.mode(PIN_GREEN_LED, gpio.OUTPUT) -gpio.write(PIN_GREEN_LED, gpio.HIGH) -c = gpio.HIGH - - -gpio.mode(pin_P1, gpio.INT) -function pin4change(level) - if (tmr.now() - lastTriggerP1) > filter_time then - if level == gpio.LOW then - trigOnP1 = tmr.now() - else - durationP1 = tmr.now() - trigOnP1 - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1 - end - lastTriggerP1 = tmr.now() - end - gpio.trig(pin_P1, "both") -end -gpio.trig(pin_P1, "both", pin4change) - - -gpio.mode(pin_P2, gpio.INT) -function pin2change(level) - if (tmr.now() - lastTriggerP2) > filter_time then - if level == gpio.LOW then - trigOnP2 = tmr.now() - else - durationP2 = tmr.now() - trigOnP1 - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2 - end - lastTriggerP2 = tmr.now() - end - gpio.trig(pin_P2, "both") -end -gpio.trig(pin_P2, "both", pin2change) - - -function send_it() - if wifi.sta.getip() == nil then - status = wifi.sta.status() - if status == 1 then -- connecting - gpio.write(PIN_GREEN_LED, c) - if c == gpio.HIGH then - c = gpio.LOW - else - c = gpio.HIGH - end - elseif status <= 4 then - gpio.write(PIN_GREEN_LED, gpio.LOW) - elseif status == 5 then - gpio.write(PIN_GREEN_LED, gpio.HIGH) - end - else - print('IP: ',wifi.sta.getip()) - send_to_api(lowpulseoccupancyP1, lowpulseoccupancyP2, sampletime) - end - -- even if the data could not be sent. - -- throw it away and try again after samplingtime - lowpulseoccupancyP1 = 0 - lowpulseoccupancyP2 = 0 - tmr.alarm(0, sampletime, 0, send_it) -end - -tmr.alarm(0, sampletime, 0, send_it) - - -dofile('http.lua') diff --git a/esp8266-lua/ppd42ns/readme.md b/esp8266-lua/ppd42ns/readme.md deleted file mode 100644 index 6d21c815c..000000000 --- a/esp8266-lua/ppd42ns/readme.md +++ /dev/null @@ -1,18 +0,0 @@ -# ppd42ns - -## some links for implementation - -- http://esp8266.co.uk/tutorials/introduction-to-the-gpio-api/ -- http://www.nodemcu.com/docs/gpio-module/#gpio-module-gpio-trig -- https://github.com/nodemcu/nodemcu-firmware/issues/179 - - -## other implementations - -### 1 - -https://github.com/marcel12bell/feinstaub-app/blob/master/init.lua - -seems wrong, because no interrupt is used. one value each second via alarm timer. - -### ? \ No newline at end of file diff --git a/esp8266-lua/ppd42ns_mqtt/Makefile b/esp8266-lua/ppd42ns_mqtt/Makefile deleted file mode 100644 index ff9a5bc27..000000000 --- a/esp8266-lua/ppd42ns_mqtt/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# for using makefile add luatool.py to your path - -upload: upload_main upload_init - luatool.py -p /dev/ttyUSB1 -l - -upload_main: - luatool.py -p /dev/ttyUSB1 -f main.lua - luatool.py -p /dev/ttyUSB1 -f publish.lua - -upload_init: - luatool.py -p /dev/ttyUSB1 -f init.lua - diff --git a/esp8266-lua/ppd42ns_mqtt/init.lua b/esp8266-lua/ppd42ns_mqtt/init.lua deleted file mode 100644 index 1ea756443..000000000 --- a/esp8266-lua/ppd42ns_mqtt/init.lua +++ /dev/null @@ -1,19 +0,0 @@ -SSID = "" -KEY = "" -BROKER = "mqtt.opensensors.io" -- Ip/hostname of MQTT broker -BRPORT = 1883 -- MQTT broker port -BRUSER = "" -- If MQTT authenitcation is used then define the user -BRPWD = "" -- The above user password -CLIENTID = "" -- The MQTT ID. Change to something you like -TOPIC = "/orgs/topic" -SEND_TO_DUSTY = true - --- do not change below this line -sampletime = 30000 -- 30 seconds -filter_time = 10000 -- in us - --- esp8266-12 -pin_P1=6 -- gpio12 black -pin_P2=5 -- gpio14 white - -dofile('main.lua') \ No newline at end of file diff --git a/esp8266-lua/ppd42ns_mqtt/main.lua b/esp8266-lua/ppd42ns_mqtt/main.lua deleted file mode 100644 index bccb80bb7..000000000 --- a/esp8266-lua/ppd42ns_mqtt/main.lua +++ /dev/null @@ -1,103 +0,0 @@ -durationP1=0 -trigOnP1=0 -lastTriggerP1=0 -lowpulseoccupancyP1=0 - -durationP2=0 -trigOnP2=0 -lastTriggerP2=0 -lowpulseoccupancyP2=0 - -PIN_GREEN_LED = 2 -PIN_RED_LED = 1 -gpio.mode(PIN_GREEN_LED, gpio.OUTPUT) -gpio.write(PIN_GREEN_LED, gpio.HIGH) -c = gpio.HIGH - -gpio.mode(pin_P1, gpio.INT) -function pin4change(level) - if (tmr.now() - lastTriggerP1) > filter_time then - if level == gpio.LOW then - trigOnP1 = tmr.now() - else - durationP1 = tmr.now() - trigOnP1 - lowpulseoccupancyP1 = lowpulseoccupancyP1 + durationP1 - end - lastTriggerP1 = tmr.now() - end - gpio.trig(pin_P1, "both") -end -gpio.trig(pin_P1, "both", pin4change) - - -gpio.mode(pin_P2, gpio.INT) -function pin2change(level) - if (tmr.now() - lastTriggerP2) > filter_time then - if level == gpio.LOW then - trigOnP2 = tmr.now() - else - durationP2 = tmr.now() - trigOnP1 - lowpulseoccupancyP2 = lowpulseoccupancyP2 + durationP2 - end - lastTriggerP2 = tmr.now() - end - gpio.trig(pin_P2, "both") -end -gpio.trig(pin_P2, "both", pin2change) - - -function send_it() - if wifi.sta.getip() == nil then - status = wifi.sta.status() - if status == 1 then -- connecting - gpio.write(PIN_GREEN_LED, c) - if c == gpio.HIGH then - c = gpio.LOW - else - c = gpio.HIGH - end - elseif status <= 4 then - gpio.write(PIN_GREEN_LED, gpio.LOW) - elseif status == 5 then - gpio.write(PIN_GREEN_LED, gpio.HIGH) - end - else - print('IP: ',wifi.sta.getip()) - send_to_api(lowpulseoccupancyP1, lowpulseoccupancyP2, sampletime) - end - -- even if the data could not be sent. - -- throw it away and try again after samplingtime - lowpulseoccupancyP1 = 0 - lowpulseoccupancyP2 = 0 - tmr.alarm(0, sampletime, 0, send_it) -end - -dofile('publish.lua') - -function main() - print("wait!") - tmr.delay(100000) - - -- wifi connect - wifi.setmode(wifi.STATION) - wifi.sta.autoconnect(1) - print('set mode=STATION (mode='..wifi.getmode()..')') - print('MAC: ',wifi.sta.getmac()) - print('chip: ',node.chipid()) - print('heap: ',node.heap()) - wifi.sta.config(SSID, KEY) - - -- create mqtt connection - m = mqtt.Client( CLIENTID, 3600, BRUSER, BRPWD) - m:on("offline", function(conn) - print("Disconnected from broker...") - print(node.heap()) - -- reconnect - connect_broker() - end) - connect_broker() - tmr.alarm(0, sampletime, 1, send_it) -end - --- main -main() \ No newline at end of file diff --git a/esp8266-lua/ppd42ns_mqtt/publish.lua b/esp8266-lua/ppd42ns_mqtt/publish.lua deleted file mode 100644 index 34010a359..000000000 --- a/esp8266-lua/ppd42ns_mqtt/publish.lua +++ /dev/null @@ -1,79 +0,0 @@ -function build_post_request(host, uri, data) - local request = "POST "..uri.." HTTP/1.1\r\n".. - "Host: "..host.."\r\n".. - "Connection: close\r\n".. - "Content-Type: application/json\r\n".. - "User-Agent: esp8266\r\n".. - "Sensor: esp8266-"..node.chipid().."\r\n".. - "Content-Length: "..string.len(data).."\r\n".. - "\r\n"..data - return request -end - -function send_to_dusty(ratioP1, P1, ratioP2, P2) - local data = '{"sensordatavalues":[{"value_type":"durP1","value":"'..lowpulseoccupancyP1..'"},{"value_type":"ratioP1","value":"'..ratioP1..'"},{"value_type":"P1","value":"'..P1..'"}' .. - ',{"value_type":"durP2","value":"'..lowpulseoccupancyP2..'"},{"value_type":"ratioP2","value":"'..ratioP2..'"},{"value_type":"P2","value":"'..P2..'"}]}' - - print("start api connect") - local api=net.createConnection(net.TCP, 0) - print("connect") - - api:on("receive", function(sck, c) print(c) end ) - api:connect(80, "api.dusti.xyz") - api:on("connection", function(sck) - local post_request = build_post_request("api.dusti.xyz", "/v1/push-sensor-data/", data) - sck:send(post_request) - print("sent") - end) -end - --- connect -function connect_broker() - print "Connecting to MQTT broker. Please wait..." - m:connect( BROKER , BRPORT, 0, function(conn) - print("Connected to MQTT:" .. BROKER .. ":" .. BRPORT .." as " .. CLIENTID ) - end) -end - --- pub -pub_sem = 0 -function publish_mqtt(msg, cb) - print("Publish to " .. TOPIC .. ":" .. msg) - print('heap: ',node.heap()) - - if pub_sem == 0 then - pub_sem = 1 - m:publish(TOPIC,msg,0,0,function(conn) - print("sent mqtt") - pub_sem = 0 - -- call next when done - if cb ~= nil then - cb() - end - end) - else - print("Semaphore was 1, skip!") - end -end - --- pub to broker -function send_to_broker(ratioP1, P1, ratioP2, P2, cb) - publish_mqtt('{"durP1": "'..lowpulseoccupancyP1..'","ratioP1":"'..ratioP1..'","P1":"'..P1..'","durP2":"'..lowpulseoccupancyP2..'","ratioP2":"'..ratioP2..'","P2":"'..P2..'"}', cb) -end - --- http post -function send_to_api(lowpulseoccupancyP1, lowpulseoccupancyP2, sampletime) - local ratioP1 = lowpulseoccupancyP1 / (sampletime*10.0) - local P1 = 1.1*ratioP1*ratioP1*ratioP1-3.8*ratioP1*ratioP1+520*ratioP1+0.62 - local ratioP2 = lowpulseoccupancyP2 / (sampletime*10.0) - local P2 = 1.1*ratioP2*ratioP2*ratioP2-3.8*ratioP2*ratioP2+520*ratioP2+0.62 - - if SEND_TO_DUSTY == true then - dustyCallback = function() - -- http - send_to_dusty(ratioP1, P1, ratioP2, P2) - end - end - -- mqtt - send_to_broker(ratioP1, P1, ratioP2, P2, dustyCallback) -end diff --git a/esp8266-lua/ppd42ns_mqtt/readme.md b/esp8266-lua/ppd42ns_mqtt/readme.md deleted file mode 100644 index 6d21c815c..000000000 --- a/esp8266-lua/ppd42ns_mqtt/readme.md +++ /dev/null @@ -1,18 +0,0 @@ -# ppd42ns - -## some links for implementation - -- http://esp8266.co.uk/tutorials/introduction-to-the-gpio-api/ -- http://www.nodemcu.com/docs/gpio-module/#gpio-module-gpio-trig -- https://github.com/nodemcu/nodemcu-firmware/issues/179 - - -## other implementations - -### 1 - -https://github.com/marcel12bell/feinstaub-app/blob/master/init.lua - -seems wrong, because no interrupt is used. one value each second via alarm timer. - -### ? \ No newline at end of file diff --git a/esp8266-lua/wifi-freifunk-test/Makefile b/esp8266-lua/wifi-freifunk-test/Makefile deleted file mode 120000 index d0b0e8e00..000000000 --- a/esp8266-lua/wifi-freifunk-test/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/esp8266-lua/wifi-freifunk-test/init.lua b/esp8266-lua/wifi-freifunk-test/init.lua deleted file mode 100644 index d9e043172..000000000 --- a/esp8266-lua/wifi-freifunk-test/init.lua +++ /dev/null @@ -1,37 +0,0 @@ ---[[-------------------------- - test connecting to Freifunk without password. ---------------------------]]-- - ------------ CONFIG ----------- -SSID = "Freifunk" -PASSWORD = "" -TIMEOUT = 10000000 -- 10 seconds ------------------------------- - -function connect(timeout) - local time = tmr.now() - wifi.sta.connect() - - -- Wait for IP address; check each 1000ms; timeout - tmr.alarm(1, 1000, 1, - function() - if wifi.sta.status() == 5 then - tmr.stop(1) - print("Station: connected! IP: " .. wifi.sta.getip()) - return true - else - if tmr.now() - time > timeout then - tmr.stop(1) - print("Timeout!") - return false - end - end - end - ) -end - ---[[ Main loop ]]-- -print("Setting up Wi-Fi connection..") -wifi.setmode(wifi.STATION) -wifi.sta.config(SSID, PASSWORD) -connect(TIMEOUT) diff --git a/esp8266-lua/wifi-freifunk-test/main.lua b/esp8266-lua/wifi-freifunk-test/main.lua deleted file mode 100644 index 0711ed9dd..000000000 --- a/esp8266-lua/wifi-freifunk-test/main.lua +++ /dev/null @@ -1 +0,0 @@ --- empty diff --git a/esp8266/dht22_led/README.md b/esp8266/dht22_led/README.md deleted file mode 100644 index 2ff518d36..000000000 --- a/esp8266/dht22_led/README.md +++ /dev/null @@ -1,99 +0,0 @@ -# dht+LED - -## config.lua - -mapping of gpios -* does not match - -https://github.com/nodemcu/nodemcu-firmware - -from Build 20141219 on: - - 0 [*] GPIO16 - 1 GPIO5 - 2 GPIO4 - 3 GPIO0 - 4 GPIO2 - 5 GPIO14 (SPI CLK) - 6 GPIO12 (SPI MISO) - 7 GPIO13 (SPI MOSI) - 8 GPIO15 (SPI CS) - 9 GPIO3 (UART RX) - 10 GPIO1 (UART TX) - 11 GPIO9 - 12 GPIO10 - -# temperature sensor ds18b20 - -With ds18b20.lua (from nodemcu lib): - -Weird result: - > print(t.read(addrs[1],t.K)) - 277.025 - > print(t.read(addrs[1],t.C)) - 3.8125 - - --- read temperature with DS18B20 --- node.compile("ds18b20.lua") -- run this only once to compile and save to "ds18b20.lc" -t=require("ds18b20") -t.setup(4) -addrs=t.addrs() --- Total DS18B20 numbers, assume it is 2 -print(table.getn(addrs)) --- The first DS18B20 -print(t.read(addrs[1],t.C)) -print(t.read(addrs[1],t.F)) -print(t.read(addrs[1],t.K)) --- The second DS18B20 -print(t.read(addrs[2],t.C)) -print(t.read(addrs[2],t.F)) -print(t.read(addrs[2],t.K)) --- Just read -print(t.read()) --- Just read as centigrade -print(t.read(nil,t.C)) --- Don't forget to release it after use -t = nil -ds18b20 = nil -package.loaded["ds18b20"]=nil - - -# dust sensor - -http://www.sca-shinyei.com/pdf/PPD42NS.pdf - -Model PPD42NS - -This sensor is to create Digital (Lo Pulse) output to Particulate Matters(PM). Lo Pulse Occupancy time (LPO -time) is in proportion to PM concentration. The output from “P1” is for PM whose size is around 1 micro meter -or larger. “P1” Output characteristics is shown in the attached drawing Fig2.,when tested in standard -condition stipulated below. - -Model | PPD42NS -Detectable particle size | approx. 1μm (minimum.) -Detectable range of concentration | 0~28,000 pcs/liter (0~8,000pcs/0.01 CF=283ml) -Supply Voltage | DC5V +/- 10% (CN1:Pin1=GND, Pin3=+5V) Ripple Voltage within 30mV -Operating Temperature Range | 0~45°C -Operating Humidity Range | 95%rh or less (without dew condensation) -Power consumption | 90mA -Storage temperature | -30~60°C -Time for stabilization | 1 minute after power turned on -Dimensions | 59(W) × 45(H) × 22(D) [mm] -Weight | 24g(approx.) -Output Method | Negative Logic, Digital output, Hi : over 4.0V(Rev.2) Lo : under 0.7V (As Input impedance : 200kΩ) OP-Amp output, Pull-up resistor : 10kΩ - - - -PINs - - CN : S5B-EH(JST) - 1 : COMMON(GND) green - 2 : OUTPUT(P2) white - 3 : INPUT(5VDC 90mA) yellow - 4 : OUTPUT(P1) black - 5 : INPUT(T1) white - FOR THRESHOLD FOR [P2] - - - \ No newline at end of file diff --git a/esp8266/ppd42ns+dht22/ppd42ns/readme.md b/esp8266/ppd42ns+dht22/ppd42ns/readme.md deleted file mode 100644 index 5d6cc30a7..000000000 --- a/esp8266/ppd42ns+dht22/ppd42ns/readme.md +++ /dev/null @@ -1,34 +0,0 @@ -# ppd42ns - -## some links for implementation - -- http://esp8266.co.uk/tutorials/introduction-to-the-gpio-api/ -- http://www.nodemcu.com/docs/gpio-module/#gpio-module-gpio-trig -- https://github.com/nodemcu/nodemcu-firmware/issues/179 - - -## other implementations - -1. https://github.com/marcel12bell/feinstaub-app/blob/master/init.lua -(Seems wrong, because no interrupt is used. One value each second via alarm timer.) - -# DHT22 - -Pins and orientation (Front view) - -
-####
-####
-####
-||||
-1234
-
- -How to connect R1 = 4.7kOhm and C1 = 4.7uF/6.3V correctly: - -|PIN | Function | Connections | -| ------------- |:-------------:| -----:| -| 1 | 3V3 | R1 , C1 (+) | -| 2 | Data | R1 , GPIO (Null) | -| 3 | NC | - | -| 4 | GND | C1 (-) | diff --git a/airrohr-firmware/ext_def.h b/ext_def.h similarity index 100% rename from airrohr-firmware/ext_def.h rename to ext_def.h diff --git a/airrohr-firmware/get-platformio.py b/get-platformio.py similarity index 100% rename from airrohr-firmware/get-platformio.py rename to get-platformio.py diff --git a/homeassistant/mqtt2influx.py b/homeassistant/mqtt2influx.py deleted file mode 100755 index 979351a89..000000000 --- a/homeassistant/mqtt2influx.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import argparse -from influxdb import InfluxDBClient -import paho.mqtt.client as mqtt -import sys - -# globals -verbosity_level=3; - -# main -def main(): - args = parse_args() - verbosity_level=args.verbosity - print(args) - try: - userdata={} - iclient = InfluxDBClient(args.influxhost, args.influxport, args.influxuser, args.influxpass, database=args.influxdb) - dbexists=False; - for d in iclient.get_list_database(): - dbexists=args.influxdb in d.values() - if dbexists is True: - continue; - if dbexists is not True: - debug_out("creating database "+args.influxdb,3) - iclient.create_database(args.influxdb) - except InfluxDBClientError: - print("influx client error, exiting...") - sys.exit(1) - - userdata["iclient"]=iclient - userdata["topicroot"]=args.topicroot - - # connect to MQTT - mclient = mqtt.Client(client_id=sys.argv[0], clean_session=True, userdata=userdata)#, protocol=MQTTv31) - # in constructor: mclient.user_data_set(userdata) - if args.mqttuser is not None: - mclient.username_pw_set(args.mqttuser, args.mqttpass) - mclient.on_connect = on_connect - mclient.on_disconnect = on_disconnect - mclient.on_message = on_message - debug_out("connecting to mqtt "+args.influxdb,3) - try: - mclient.connect(args.mqtthost, args.mqttport, 60) - except ConnectionRefusedError as e: - debug_out("connection failed: ") - print(e) - # mclient.subscribe.callback(on_message, args.topicroot+"#", hostname=args.mqtthost) - #mclient.loop_forever(timeout=1.0, max_packets=1, retry_first_connection=False) - mclient.loop_forever() - -def debug_out(msg,verbosity=5): - if verbosity>verbosity_level: - print(msg) - -def on_connect(client, userdata, flags, rc): - debug_out("Connected with result code "+str(rc),3) - # Subscribing in on_connect() means that if we lose the connection and - # reconnect then subscriptions will be renewed. - client.subscribe(userdata["topicroot"]+"#") - debug_out("subscribed to "+userdata["topicroot"]+"#",5) - -def on_disconnect(client, userdata, rc): - debug_out("Disconnected",3) - -# The callback for when a PUBLISH message is received from the server. -def on_message(client, userdata, msg): - debug_out(msg.topic+" "+str(msg.payload),5) - # if topicroot is found at beginning: strip it - ss=msg.topic.lstrip(userdata["topicroot"]).split("/") - slen=len(ss) - json_body={} - if (slen)>=3: - # split contains all parts - json_body = { - "measurement": ss[slen-1], - "fields": { - "value": msg.payload - }, - "tags":{ - "sensortype": ss[slen-2], - "nodeid": ss[slen-3] - }} - userdata["iclient"].write(json_body) - # state_topic: "dusti/esp8266-16058770/PPD42NS/#" - # name: "PPD Sensor" - # qos: 0 - # unit_of_measurement: "%" - # value_template: '{{ value }}' - - -def parse_args(): - parser = argparse.ArgumentParser( - description='Forward MQTT messages to am InfluxDB') - parser.add_argument('-i', '--influxhost', dest='influxhost', type=str, required=False, default='localhost', - help='hostname of InfluxDB http API') - parser.add_argument('-I','--influxport', dest='influxport', type=int, required=False, default=8086, - help='port of InfluxDB http API') - parser.add_argument('-m', '--mqtthost', dest='mqtthost', type=str, required=False, default='localhost', - help='hostname of MQTT server') - parser.add_argument('-M','--mqttport', dest='mqttport', type=int, required=False, default=1883, - help='port of MQTT server') - parser.add_argument('-t', '--topicroot', dest='topicroot', type=str, required=False, default='', - help='only consider topics starting with topicroot') - parser.add_argument('-o', '--omittopic', dest='omittopic', nargs='*', required=False, - help="omit topics matching pattern") - parser.add_argument('-u', '--influxuser', dest='influxuser', type=str, required=False, default=None, - help='username for InfluxDB') - parser.add_argument('-U', '--mqttuser', dest='mqttuser', type=str, required=False, default=None, - help='username for MQTT') - parser.add_argument('-p', '--influxpass', dest='influxpass', type=str, required=False, default=None, - help='password for InfluxDB') - parser.add_argument('-P', '--mqttpass', dest='mqttpass', type=str, required=False, default=None, - help='password for MQTT') - parser.add_argument('-d', '--influxdb', dest='influxdb', type=str, required=False, default='mqtt2influx', - help='name of InfluxDB to store data in') - parser.add_argument('-v', '--verbosity', dest='verbosity', type=int, required=False, default=5, - help='name of InfluxDB to store data in') - return parser.parse_args() - - -if __name__ == '__main__': - #sys.exit( - main() - #) - \ No newline at end of file diff --git a/homeassistant/topic2yaml.py b/homeassistant/topic2yaml.py deleted file mode 100755 index 6fe6471e9..000000000 --- a/homeassistant/topic2yaml.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import paho.mqtt.client as mqtt -import os.path - -mqtthost="mqtt.opendataset.click" -mqttport=1883 -topicroot="dusti/" # topics start with topicroot -# only topics defined here will be used -unitdict={ - "P1":"1/cf", - "P2":"1/cf", - "durP1":"ns", - "durP2":"ns", - "ratioP1":"1", - "ratioP2":"1", - "temperature":"°C", - "humidity":"%" -} - -seentopics={} - -def on_connect(client, userdata, flags, rc): - #print("Connected with result code "+str(rc)) - - # Subscribing in on_connect() means that if we lose the connection and - # reconnect then subscriptions will be renewed. - client.subscribe(topicroot+"#") - -# The callback for when a PUBLISH message is received from the server. -def on_message(client, userdata, msg): - #print(msg.topic+" "+str(msg.payload)) - if seentopics.get(msg.topic) is not None: - return - seentopics[msg.topic]=1 - # if topicroot is found at beginning: strip it - # split the remaining topic - ss=msg.topic.lstrip(topicroot).split("/") - # if topic is in unitdict, output - if unitdict.get(ss[len(ss)-1]) is not None: - configstr =' - platform: mqtt\n' - configstr+=' state_topic: "'+msg.topic+'"\n' - configstr+=' name: "'+msg.topic.lstrip(topicroot)+'"\n' - configstr+=' qos: 0\n' - configstr+=' unit_of_measurement: "'+unitdict.get(ss[len(ss)-1])+'"\n' - configstr+=' value_template: \'{{ value }}\'\n' - print (configstr) - # state_topic: "dusti/esp8266-16058770/PPD42NS/#" - # name: "PPD Sensor" - # qos: 0 - # unit_of_measurement: "%" - # value_template: '{{ value }}' - -client = mqtt.Client() -client.on_connect = on_connect -client.on_message = on_message - -client.connect(mqtthost, mqttport, 60) - -# Blocking call that processes network traffic, dispatches callbacks and -# handles reconnecting. -# Other loop*() functions are available that give a threaded interface and a -# manual interface. -client.loop_forever() diff --git a/airrohr-firmware/html-content.h b/html-content.h similarity index 100% rename from airrohr-firmware/html-content.h rename to html-content.h diff --git a/airrohr-firmware/intl.h b/intl.h similarity index 100% rename from airrohr-firmware/intl.h rename to intl.h diff --git a/airrohr-firmware/intl_bg.h b/intl_bg.h similarity index 100% rename from airrohr-firmware/intl_bg.h rename to intl_bg.h diff --git a/airrohr-firmware/intl_cz.h b/intl_cz.h similarity index 100% rename from airrohr-firmware/intl_cz.h rename to intl_cz.h diff --git a/airrohr-firmware/intl_de.h b/intl_de.h similarity index 100% rename from airrohr-firmware/intl_de.h rename to intl_de.h diff --git a/airrohr-firmware/intl_dk.h b/intl_dk.h similarity index 100% rename from airrohr-firmware/intl_dk.h rename to intl_dk.h diff --git a/airrohr-firmware/intl_en.h b/intl_en.h similarity index 100% rename from airrohr-firmware/intl_en.h rename to intl_en.h diff --git a/airrohr-firmware/intl_es.h b/intl_es.h similarity index 100% rename from airrohr-firmware/intl_es.h rename to intl_es.h diff --git a/airrohr-firmware/intl_fr.h b/intl_fr.h similarity index 100% rename from airrohr-firmware/intl_fr.h rename to intl_fr.h diff --git a/airrohr-firmware/intl_hu.h b/intl_hu.h similarity index 100% rename from airrohr-firmware/intl_hu.h rename to intl_hu.h diff --git a/airrohr-firmware/intl_it.h b/intl_it.h similarity index 100% rename from airrohr-firmware/intl_it.h rename to intl_it.h diff --git a/airrohr-firmware/intl_lu.h b/intl_lu.h similarity index 100% rename from airrohr-firmware/intl_lu.h rename to intl_lu.h diff --git a/airrohr-firmware/intl_nl.h b/intl_nl.h similarity index 100% rename from airrohr-firmware/intl_nl.h rename to intl_nl.h diff --git a/airrohr-firmware/intl_pl.h b/intl_pl.h similarity index 100% rename from airrohr-firmware/intl_pl.h rename to intl_pl.h diff --git a/airrohr-firmware/intl_pt.h b/intl_pt.h similarity index 100% rename from airrohr-firmware/intl_pt.h rename to intl_pt.h diff --git a/airrohr-firmware/intl_rs.h b/intl_rs.h similarity index 100% rename from airrohr-firmware/intl_rs.h rename to intl_rs.h diff --git a/airrohr-firmware/intl_ru.h b/intl_ru.h similarity index 100% rename from airrohr-firmware/intl_ru.h rename to intl_ru.h diff --git a/airrohr-firmware/intl_se.h b/intl_se.h similarity index 100% rename from airrohr-firmware/intl_se.h rename to intl_se.h diff --git a/airrohr-firmware/intl_sk.h b/intl_sk.h similarity index 100% rename from airrohr-firmware/intl_sk.h rename to intl_sk.h diff --git a/airrohr-firmware/intl_template.h b/intl_template.h similarity index 100% rename from airrohr-firmware/intl_template.h rename to intl_template.h diff --git a/airrohr-firmware/intl_tr.h b/intl_tr.h similarity index 100% rename from airrohr-firmware/intl_tr.h rename to intl_tr.h diff --git a/airrohr-firmware/intl_ua.h b/intl_ua.h similarity index 100% rename from airrohr-firmware/intl_ua.h rename to intl_ua.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/.github/stale.yml b/lib/ESP8266_SSD1306/.github/stale.yml similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/.github/stale.yml rename to lib/ESP8266_SSD1306/.github/stale.yml diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/.gitignore b/lib/ESP8266_SSD1306/.gitignore similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/.gitignore rename to lib/ESP8266_SSD1306/.gitignore diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/.piopm b/lib/ESP8266_SSD1306/.piopm similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/.piopm rename to lib/ESP8266_SSD1306/.piopm diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/CMakeLists.txt b/lib/ESP8266_SSD1306/CMakeLists.txt similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/CMakeLists.txt rename to lib/ESP8266_SSD1306/CMakeLists.txt diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/README.md b/lib/ESP8266_SSD1306/README.md similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/README.md rename to lib/ESP8266_SSD1306/README.md diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/UPGRADE-3.0.md b/lib/ESP8266_SSD1306/UPGRADE-3.0.md similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/UPGRADE-3.0.md rename to lib/ESP8266_SSD1306/UPGRADE-3.0.md diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/UPGRADE-4.0.md b/lib/ESP8266_SSD1306/UPGRADE-4.0.md similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/UPGRADE-4.0.md rename to lib/ESP8266_SSD1306/UPGRADE-4.0.md diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/component.mk b/lib/ESP8266_SSD1306/component.mk similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/component.mk rename to lib/ESP8266_SSD1306/component.mk diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/library.properties b/lib/ESP8266_SSD1306/library.properties similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/library.properties rename to lib/ESP8266_SSD1306/library.properties diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/license b/lib/ESP8266_SSD1306/license similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/license rename to lib/ESP8266_SSD1306/license diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/resources/DemoFrame1.jpg b/lib/ESP8266_SSD1306/resources/DemoFrame1.jpg similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/resources/DemoFrame1.jpg rename to lib/ESP8266_SSD1306/resources/DemoFrame1.jpg diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/resources/DemoFrame2.jpg b/lib/ESP8266_SSD1306/resources/DemoFrame2.jpg similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/resources/DemoFrame2.jpg rename to lib/ESP8266_SSD1306/resources/DemoFrame2.jpg diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/resources/DemoFrame3.jpg b/lib/ESP8266_SSD1306/resources/DemoFrame3.jpg similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/resources/DemoFrame3.jpg rename to lib/ESP8266_SSD1306/resources/DemoFrame3.jpg diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/resources/DemoFrame4.jpg b/lib/ESP8266_SSD1306/resources/DemoFrame4.jpg similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/resources/DemoFrame4.jpg rename to lib/ESP8266_SSD1306/resources/DemoFrame4.jpg diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/resources/FontTool.png b/lib/ESP8266_SSD1306/resources/FontTool.png similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/resources/FontTool.png rename to lib/ESP8266_SSD1306/resources/FontTool.png diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/resources/SPI_version.jpg b/lib/ESP8266_SSD1306/resources/SPI_version.jpg similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/resources/SPI_version.jpg rename to lib/ESP8266_SSD1306/resources/SPI_version.jpg diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/resources/glyphEditor.html b/lib/ESP8266_SSD1306/resources/glyphEditor.html similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/resources/glyphEditor.html rename to lib/ESP8266_SSD1306/resources/glyphEditor.html diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/resources/glyphEditor.png b/lib/ESP8266_SSD1306/resources/glyphEditor.png similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/resources/glyphEditor.png rename to lib/ESP8266_SSD1306/resources/glyphEditor.png diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/resources/xbmPreview.png b/lib/ESP8266_SSD1306/resources/xbmPreview.png similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/resources/xbmPreview.png rename to lib/ESP8266_SSD1306/resources/xbmPreview.png diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/OLEDDisplay.cpp b/lib/ESP8266_SSD1306/src/OLEDDisplay.cpp similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/OLEDDisplay.cpp rename to lib/ESP8266_SSD1306/src/OLEDDisplay.cpp diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/OLEDDisplay.h b/lib/ESP8266_SSD1306/src/OLEDDisplay.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/OLEDDisplay.h rename to lib/ESP8266_SSD1306/src/OLEDDisplay.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/OLEDDisplayFonts.h b/lib/ESP8266_SSD1306/src/OLEDDisplayFonts.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/OLEDDisplayFonts.h rename to lib/ESP8266_SSD1306/src/OLEDDisplayFonts.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/OLEDDisplayUi.cpp b/lib/ESP8266_SSD1306/src/OLEDDisplayUi.cpp similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/OLEDDisplayUi.cpp rename to lib/ESP8266_SSD1306/src/OLEDDisplayUi.cpp diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/OLEDDisplayUi.h b/lib/ESP8266_SSD1306/src/OLEDDisplayUi.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/OLEDDisplayUi.h rename to lib/ESP8266_SSD1306/src/OLEDDisplayUi.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/SH1106.h b/lib/ESP8266_SSD1306/src/SH1106.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/SH1106.h rename to lib/ESP8266_SSD1306/src/SH1106.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/SH1106Brzo.h b/lib/ESP8266_SSD1306/src/SH1106Brzo.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/SH1106Brzo.h rename to lib/ESP8266_SSD1306/src/SH1106Brzo.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/SH1106Spi.h b/lib/ESP8266_SSD1306/src/SH1106Spi.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/SH1106Spi.h rename to lib/ESP8266_SSD1306/src/SH1106Spi.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/SH1106Wire.h b/lib/ESP8266_SSD1306/src/SH1106Wire.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/SH1106Wire.h rename to lib/ESP8266_SSD1306/src/SH1106Wire.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/SSD1306.h b/lib/ESP8266_SSD1306/src/SSD1306.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/SSD1306.h rename to lib/ESP8266_SSD1306/src/SSD1306.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/SSD1306Brzo.h b/lib/ESP8266_SSD1306/src/SSD1306Brzo.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/SSD1306Brzo.h rename to lib/ESP8266_SSD1306/src/SSD1306Brzo.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/SSD1306I2C.h b/lib/ESP8266_SSD1306/src/SSD1306I2C.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/SSD1306I2C.h rename to lib/ESP8266_SSD1306/src/SSD1306I2C.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/SSD1306Spi.h b/lib/ESP8266_SSD1306/src/SSD1306Spi.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/SSD1306Spi.h rename to lib/ESP8266_SSD1306/src/SSD1306Spi.h diff --git a/airrohr-firmware/lib/ESP8266_SSD1306/src/SSD1306Wire.h b/lib/ESP8266_SSD1306/src/SSD1306Wire.h similarity index 100% rename from airrohr-firmware/lib/ESP8266_SSD1306/src/SSD1306Wire.h rename to lib/ESP8266_SSD1306/src/SSD1306Wire.h diff --git a/lib/TinyGSM/examples/AllFunctions/AllFunctions.ino b/lib/TinyGSM/examples/AllFunctions/AllFunctions.ino new file mode 100644 index 000000000..b3e6ff6bb --- /dev/null +++ b/lib/TinyGSM/examples/AllFunctions/AllFunctions.ino @@ -0,0 +1,488 @@ +/************************************************************** + * + * TinyGSM Getting Started guide: + * https://tiny.cc/tinygsm-readme + * + * NOTE: + * Some of the functions may be unavailable for your modem. + * Just comment them out. + * + **************************************************************/ + +// Select your modem: +#define TINY_GSM_MODEM_SIM800 +// #define TINY_GSM_MODEM_SIM808 +// #define TINY_GSM_MODEM_SIM868 +// #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_SIM7000 +// #define TINY_GSM_MODEM_SIM7000SSL +// #define TINY_GSM_MODEM_SIM7080 +// #define TINY_GSM_MODEM_SIM5360 +// #define TINY_GSM_MODEM_SIM7600 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_SARAR4 +// #define TINY_GSM_MODEM_M95 +// #define TINY_GSM_MODEM_BG96 +// #define TINY_GSM_MODEM_A6 +// #define TINY_GSM_MODEM_A7 +// #define TINY_GSM_MODEM_M590 +// #define TINY_GSM_MODEM_MC60 +// #define TINY_GSM_MODEM_MC60E +// #define TINY_GSM_MODEM_ESP8266 +// #define TINY_GSM_MODEM_XBEE +// #define TINY_GSM_MODEM_SEQUANS_MONARCH + +// Set serial for debug console (to the Serial Monitor, default speed 115200) +#define SerialMon Serial + +// Set serial for AT commands (to the module) +// Use Hardware Serial on Mega, Leonardo, Micro +#ifndef __AVR_ATmega328P__ +#define SerialAT Serial1 + +// or Software Serial on Uno, Nano +#else +#include +SoftwareSerial SerialAT(2, 3); // RX, TX +#endif + +// See all AT commands, if wanted +// #define DUMP_AT_COMMANDS + +// Define the serial console for debug prints, if needed +#define TINY_GSM_DEBUG SerialMon + +// Range to attempt to autobaud +// NOTE: DO NOT AUTOBAUD in production code. Once you've established +// communication, set a fixed baud rate using modem.setBaud(#). +#define GSM_AUTOBAUD_MIN 9600 +#define GSM_AUTOBAUD_MAX 57600 + +// Add a reception delay, if needed. +// This may be needed for a fast processor at a slow baud rate. +// #define TINY_GSM_YIELD() { delay(2); } + +/* + * Tests enabled + */ +#define TINY_GSM_TEST_GPRS true +#define TINY_GSM_TEST_WIFI false +#define TINY_GSM_TEST_TCP true +#define TINY_GSM_TEST_SSL true +#define TINY_GSM_TEST_CALL false +#define TINY_GSM_TEST_SMS false +#define TINY_GSM_TEST_USSD false +#define TINY_GSM_TEST_BATTERY true +#define TINY_GSM_TEST_TEMPERATURE true +#define TINY_GSM_TEST_GSM_LOCATION false +#define TINY_GSM_TEST_NTP false +#define TINY_GSM_TEST_TIME false +#define TINY_GSM_TEST_GPS false +// disconnect and power down modem after tests +#define TINY_GSM_POWERDOWN false + +// set GSM PIN, if any +#define GSM_PIN "" + +// Set phone numbers, if you want to test SMS and Calls +// #define SMS_TARGET "+380xxxxxxxxx" +// #define CALL_TARGET "+380xxxxxxxxx" + +// Your GPRS credentials, if any +const char apn[] = "YourAPN"; +// const char apn[] = "ibasis.iot"; +const char gprsUser[] = ""; +const char gprsPass[] = ""; + +// Your WiFi connection credentials, if applicable +const char wifiSSID[] = "YourSSID"; +const char wifiPass[] = "YourWiFiPass"; + +// Server details to test TCP/SSL +const char server[] = "vsh.pp.ua"; +const char resource[] = "/TinyGSM/logo.txt"; + +#include + +#if TINY_GSM_TEST_GPRS && not defined TINY_GSM_MODEM_HAS_GPRS +#undef TINY_GSM_TEST_GPRS +#undef TINY_GSM_TEST_WIFI +#define TINY_GSM_TEST_GPRS false +#define TINY_GSM_TEST_WIFI true +#endif +#if TINY_GSM_TEST_WIFI && not defined TINY_GSM_MODEM_HAS_WIFI +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false +#endif + +#ifdef DUMP_AT_COMMANDS +#include +StreamDebugger debugger(SerialAT, SerialMon); +TinyGsm modem(debugger); +#else +TinyGsm modem(SerialAT); +#endif + +void setup() { + // Set console baud rate + SerialMon.begin(115200); + delay(10); + + // !!!!!!!!!!! + // Set your reset, enable, power pins here + // !!!!!!!!!!! + + DBG("Wait..."); + delay(6000); + + // Set GSM module baud rate + TinyGsmAutoBaud(SerialAT, GSM_AUTOBAUD_MIN, GSM_AUTOBAUD_MAX); + // SerialAT.begin(9600); +} + +void loop() { + // Restart takes quite some time + // To skip it, call init() instead of restart() + DBG("Initializing modem..."); + if (!modem.restart()) { + // if (!modem.init()) { + DBG("Failed to restart modem, delaying 10s and retrying"); + // restart autobaud in case GSM just rebooted + // TinyGsmAutoBaud(SerialAT, GSM_AUTOBAUD_MIN, GSM_AUTOBAUD_MAX); + return; + } + + String name = modem.getModemName(); + DBG("Modem Name:", name); + + String modemInfo = modem.getModemInfo(); + DBG("Modem Info:", modemInfo); + +#if TINY_GSM_TEST_GPRS + // Unlock your SIM card with a PIN if needed + if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); } +#endif + +#if TINY_GSM_TEST_WIFI + DBG("Setting SSID/password..."); + if (!modem.networkConnect(wifiSSID, wifiPass)) { + DBG(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); +#endif + +#if TINY_GSM_TEST_GPRS && defined TINY_GSM_MODEM_XBEE + // The XBee must run the gprsConnect function BEFORE waiting for network! + modem.gprsConnect(apn, gprsUser, gprsPass); +#endif + + DBG("Waiting for network..."); + if (!modem.waitForNetwork(600000L, true)) { + delay(10000); + return; + } + + if (modem.isNetworkConnected()) { DBG("Network connected"); } + +#if TINY_GSM_TEST_GPRS + DBG("Connecting to", apn); + if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { + delay(10000); + return; + } + + bool res = modem.isGprsConnected(); + DBG("GPRS status:", res ? "connected" : "not connected"); + + String ccid = modem.getSimCCID(); + DBG("CCID:", ccid); + + String imei = modem.getIMEI(); + DBG("IMEI:", imei); + + String imsi = modem.getIMSI(); + DBG("IMSI:", imsi); + + String cop = modem.getOperator(); + DBG("Operator:", cop); + + IPAddress local = modem.localIP(); + DBG("Local IP:", local); + + int csq = modem.getSignalQuality(); + DBG("Signal quality:", csq); +#endif + +#if TINY_GSM_TEST_USSD && defined TINY_GSM_MODEM_HAS_SMS + String ussd_balance = modem.sendUSSD("*111#"); + DBG("Balance (USSD):", ussd_balance); + + String ussd_phone_num = modem.sendUSSD("*161#"); + DBG("Phone number (USSD):", ussd_phone_num); +#endif + +#if TINY_GSM_TEST_TCP && defined TINY_GSM_MODEM_HAS_TCP + TinyGsmClient client(modem, 0); + const int port = 80; + DBG("Connecting to", server); + if (!client.connect(server, port)) { + DBG("... failed"); + } else { + // Make a HTTP GET request: + client.print(String("GET ") + resource + " HTTP/1.0\r\n"); + client.print(String("Host: ") + server + "\r\n"); + client.print("Connection: close\r\n\r\n"); + + // Wait for data to arrive + uint32_t start = millis(); + while (client.connected() && !client.available() && + millis() - start < 30000L) { + delay(100); + }; + + // Read data + start = millis(); + char logo[640] = { + '\0', + }; + int read_chars = 0; + while (client.connected() && millis() - start < 10000L) { + while (client.available()) { + logo[read_chars] = client.read(); + logo[read_chars + 1] = '\0'; + read_chars++; + start = millis(); + } + } + SerialMon.println(logo); + DBG("##### RECEIVED:", strlen(logo), "CHARACTERS"); + client.stop(); + } +#endif + +#if TINY_GSM_TEST_SSL && defined TINY_GSM_MODEM_HAS_SSL + TinyGsmClientSecure secureClient(modem, 1); + const int securePort = 443; + DBG("Connecting securely to", server); + if (!secureClient.connect(server, securePort)) { + DBG("... failed"); + } else { + // Make a HTTP GET request: + secureClient.print(String("GET ") + resource + " HTTP/1.0\r\n"); + secureClient.print(String("Host: ") + server + "\r\n"); + secureClient.print("Connection: close\r\n\r\n"); + + // Wait for data to arrive + uint32_t startS = millis(); + while (secureClient.connected() && !secureClient.available() && + millis() - startS < 30000L) { + delay(100); + }; + + // Read data + startS = millis(); + char logoS[640] = { + '\0', + }; + int read_charsS = 0; + while (secureClient.connected() && millis() - startS < 10000L) { + while (secureClient.available()) { + logoS[read_charsS] = secureClient.read(); + logoS[read_charsS + 1] = '\0'; + read_charsS++; + startS = millis(); + } + } + SerialMon.println(logoS); + DBG("##### RECEIVED:", strlen(logoS), "CHARACTERS"); + secureClient.stop(); + } +#endif + +#if TINY_GSM_TEST_CALL && defined TINY_GSM_MODEM_HAS_CALLING && \ + defined CALL_TARGET + DBG("Calling:", CALL_TARGET); + + // This is NOT supported on M590 + res = modem.callNumber(CALL_TARGET); + DBG("Call:", res ? "OK" : "fail"); + + if (res) { + delay(1000L); + + // Play DTMF A, duration 1000ms + modem.dtmfSend('A', 1000); + + // Play DTMF 0..4, default duration (100ms) + for (char tone = '0'; tone <= '4'; tone++) { modem.dtmfSend(tone); } + + delay(5000); + + res = modem.callHangup(); + DBG("Hang up:", res ? "OK" : "fail"); + } +#endif + +#if TINY_GSM_TEST_SMS && defined TINY_GSM_MODEM_HAS_SMS && defined SMS_TARGET + res = modem.sendSMS(SMS_TARGET, String("Hello from ") + imei); + DBG("SMS:", res ? "OK" : "fail"); + + // This is only supported on SIMxxx series + res = modem.sendSMS_UTF8_begin(SMS_TARGET); + if (res) { + auto stream = modem.sendSMS_UTF8_stream(); + stream.print(F("Привіііт! Print number: ")); + stream.print(595); + res = modem.sendSMS_UTF8_end(); + } + DBG("UTF8 SMS:", res ? "OK" : "fail"); + +#endif + +#if TINY_GSM_TEST_GSM_LOCATION && defined TINY_GSM_MODEM_HAS_GSM_LOCATION + float lat = 0; + float lon = 0; + float accuracy = 0; + int year = 0; + int month = 0; + int day = 0; + int hour = 0; + int min = 0; + int sec = 0; + for (int8_t i = 15; i; i--) { + DBG("Requesting current GSM location"); + if (modem.getGsmLocation(&lat, &lon, &accuracy, &year, &month, &day, &hour, + &min, &sec)) { + DBG("Latitude:", String(lat, 8), "\tLongitude:", String(lon, 8)); + DBG("Accuracy:", accuracy); + DBG("Year:", year, "\tMonth:", month, "\tDay:", day); + DBG("Hour:", hour, "\tMinute:", min, "\tSecond:", sec); + break; + } else { + DBG("Couldn't get GSM location, retrying in 15s."); + delay(15000L); + } + } + DBG("Retrieving GSM location again as a string"); + String location = modem.getGsmLocation(); + DBG("GSM Based Location String:", location); +#endif + +#if TINY_GSM_TEST_GPS && defined TINY_GSM_MODEM_HAS_GPS + DBG("Enabling GPS/GNSS/GLONASS and waiting 15s for warm-up"); + modem.enableGPS(); + delay(15000L); + float lat2 = 0; + float lon2 = 0; + float speed2 = 0; + float alt2 = 0; + int vsat2 = 0; + int usat2 = 0; + float accuracy2 = 0; + int year2 = 0; + int month2 = 0; + int day2 = 0; + int hour2 = 0; + int min2 = 0; + int sec2 = 0; + for (int8_t i = 15; i; i--) { + DBG("Requesting current GPS/GNSS/GLONASS location"); + if (modem.getGPS(&lat2, &lon2, &speed2, &alt2, &vsat2, &usat2, &accuracy2, + &year2, &month2, &day2, &hour2, &min2, &sec2)) { + DBG("Latitude:", String(lat2, 8), "\tLongitude:", String(lon2, 8)); + DBG("Speed:", speed2, "\tAltitude:", alt2); + DBG("Visible Satellites:", vsat2, "\tUsed Satellites:", usat2); + DBG("Accuracy:", accuracy2); + DBG("Year:", year2, "\tMonth:", month2, "\tDay:", day2); + DBG("Hour:", hour2, "\tMinute:", min2, "\tSecond:", sec2); + break; + } else { + DBG("Couldn't get GPS/GNSS/GLONASS location, retrying in 15s."); + delay(15000L); + } + } + DBG("Retrieving GPS/GNSS/GLONASS location again as a string"); + String gps_raw = modem.getGPSraw(); + DBG("GPS/GNSS Based Location String:", gps_raw); + DBG("Disabling GPS"); + modem.disableGPS(); +#endif + +#if TINY_GSM_TEST_NTP && defined TINY_GSM_MODEM_HAS_NTP + DBG("Asking modem to sync with NTP"); + modem.NTPServerSync("132.163.96.5", 20); +#endif + +#if TINY_GSM_TEST_TIME && defined TINY_GSM_MODEM_HAS_TIME + int year3 = 0; + int month3 = 0; + int day3 = 0; + int hour3 = 0; + int min3 = 0; + int sec3 = 0; + float timezone = 0; + for (int8_t i = 5; i; i--) { + DBG("Requesting current network time"); + if (modem.getNetworkTime(&year3, &month3, &day3, &hour3, &min3, &sec3, + &timezone)) { + DBG("Year:", year3, "\tMonth:", month3, "\tDay:", day3); + DBG("Hour:", hour3, "\tMinute:", min3, "\tSecond:", sec3); + DBG("Timezone:", timezone); + break; + } else { + DBG("Couldn't get network time, retrying in 15s."); + delay(15000L); + } + } + DBG("Retrieving time again as a string"); + String time = modem.getGSMDateTime(DATE_FULL); + DBG("Current Network Time:", time); +#endif + +#if TINY_GSM_TEST_BATTERY && defined TINY_GSM_MODEM_HAS_BATTERY + uint8_t chargeState = -99; + int8_t percent = -99; + uint16_t milliVolts = -9999; + modem.getBattStats(chargeState, percent, milliVolts); + DBG("Battery charge state:", chargeState); + DBG("Battery charge 'percent':", percent); + DBG("Battery voltage:", milliVolts / 1000.0F); +#endif + +#if TINY_GSM_TEST_TEMPERATURE && defined TINY_GSM_MODEM_HAS_TEMPERATURE + float temp = modem.getTemperature(); + DBG("Chip temperature:", temp); +#endif + +#if TINY_GSM_POWERDOWN + +#if TINY_GSM_TEST_GPRS + modem.gprsDisconnect(); + delay(5000L); + if (!modem.isGprsConnected()) { + DBG("GPRS disconnected"); + } else { + DBG("GPRS disconnect: Failed."); + } +#endif + +#if TINY_GSM_TEST_WIFI + modem.networkDisconnect(); + DBG("WiFi disconnected"); +#endif + + // Try to power-off (modem may decide to restart automatically) + // To turn off modem completely, please use Reset/Enable pins + modem.poweroff(); + DBG("Poweroff."); +#endif + + DBG("End of tests."); + + // Do nothing forevermore + while (true) { modem.maintain(); } +} diff --git a/lib/TinyGSM/examples/BlynkClient/BlynkClient.ino b/lib/TinyGSM/examples/BlynkClient/BlynkClient.ino new file mode 100644 index 000000000..2ab7f3d9c --- /dev/null +++ b/lib/TinyGSM/examples/BlynkClient/BlynkClient.ino @@ -0,0 +1,115 @@ +/************************************************************** + * + * For this example, you need to install Blynk library: + * https://github.com/blynkkk/blynk-library/releases/latest + * + * TinyGSM Getting Started guide: + * https://tiny.cc/tinygsm-readme + * + ************************************************************** + * + * Blynk is a platform with iOS and Android apps to control + * Arduino, Raspberry Pi and the likes over the Internet. + * You can easily build graphic interfaces for all your + * projects by simply dragging and dropping widgets. + * + * Blynk supports many development boards with WiFi, Ethernet, + * GSM, Bluetooth, BLE, USB/Serial connection methods. + * See more in Blynk library examples and community forum. + * + * http://www.blynk.io/ + * + * Change GPRS apm, user, pass, and Blynk auth token to run :) + **************************************************************/ + +/* Fill in information from Blynk Device Info here */ +#define BLYNK_TEMPLATE_ID "TMPxxxxxx" +#define BLYNK_TEMPLATE_NAME "Device" +#define BLYNK_AUTH_TOKEN "YourAuthToken" + +#define BLYNK_PRINT Serial // Comment this out to disable prints and save space + +// Default heartbeat interval for GSM is 60 +// If you want override this value, uncomment and set this option: +// #define BLYNK_HEARTBEAT 30 + +// Select your modem: +#define TINY_GSM_MODEM_SIM800 +// #define TINY_GSM_MODEM_SIM808 +// #define TINY_GSM_MODEM_SIM868 +// #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_SIM7000 +// #define TINY_GSM_MODEM_SIM7000SSL +// #define TINY_GSM_MODEM_SIM7080 +// #define TINY_GSM_MODEM_SIM5360 +// #define TINY_GSM_MODEM_SIM7600 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_SARAR4 +// #define TINY_GSM_MODEM_M95 +// #define TINY_GSM_MODEM_BG96 +// #define TINY_GSM_MODEM_A6 +// #define TINY_GSM_MODEM_A7 +// #define TINY_GSM_MODEM_M590 +// #define TINY_GSM_MODEM_MC60 +// #define TINY_GSM_MODEM_MC60E +// #define TINY_GSM_MODEM_ESP8266 +// #define TINY_GSM_MODEM_XBEE +// #define TINY_GSM_MODEM_SEQUANS_MONARCH + +#include +#include + +// Set serial for debug console (to the Serial Monitor, default speed 115200) +#define SerialMon Serial + +// Hardware Serial on Mega, Leonardo, Micro +#ifndef __AVR_ATmega328P__ +#define SerialAT Serial1 + +// or Software Serial on Uno, Nano +#else +#include +SoftwareSerial SerialAT(2, 3); // RX, TX +#endif + + +// Your GPRS credentials, if any +const char apn[] = "YourAPN"; +const char user[] = ""; +const char pass[] = ""; + +// You should get Auth Token in the Blynk App. +// Go to the Project Settings (nut icon). +const char auth[] = "YourAuthToken"; + +TinyGsm modem(SerialAT); + +void setup() +{ + // Set console baud rate + SerialMon.begin(115200); + delay(10); + + // Set GSM module baud rate + SerialAT.begin(115200); + delay(6000); + + // Restart takes quite some time + // To skip it, call init() instead of restart() + SerialMon.println("Initializing modem..."); + modem.restart(); + + String modemInfo = modem.getModemInfo(); + SerialMon.print("Modem Info: "); + SerialMon.println(modemInfo); + + // Unlock your SIM card with a PIN + //modem.simUnlock("1234"); + + Blynk.begin(auth, modem, apn, user, pass); +} + +void loop() +{ + Blynk.run(); +} diff --git a/lib/TinyGSM/examples/FileDownload/FileDownload.ino b/lib/TinyGSM/examples/FileDownload/FileDownload.ino new file mode 100644 index 000000000..d66e4b7df --- /dev/null +++ b/lib/TinyGSM/examples/FileDownload/FileDownload.ino @@ -0,0 +1,356 @@ +/************************************************************** + * + * For this example, you need to install CRC32 library: + * https://github.com/bakercp/CRC32 + * or from http://librarymanager/all#CRC32+checksum + * + * TinyGSM Getting Started guide: + * https://tiny.cc/tinygsm-readme + * + * ATTENTION! Downloading big files requires of knowledge of + * the TinyGSM internals and some modem specifics, + * so this is for more experienced developers. + * + **************************************************************/ + +// Select your modem: +#define TINY_GSM_MODEM_SIM800 +// #define TINY_GSM_MODEM_SIM808 +// #define TINY_GSM_MODEM_SIM868 +// #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_SIM7000 +// #define TINY_GSM_MODEM_SIM7000SSL +// #define TINY_GSM_MODEM_SIM7080 +// #define TINY_GSM_MODEM_SIM5360 +// #define TINY_GSM_MODEM_SIM7600 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_SARAR4 +// #define TINY_GSM_MODEM_M95 +// #define TINY_GSM_MODEM_BG96 +// #define TINY_GSM_MODEM_A6 +// #define TINY_GSM_MODEM_A7 +// #define TINY_GSM_MODEM_M590 +// #define TINY_GSM_MODEM_MC60 +// #define TINY_GSM_MODEM_MC60E +// #define TINY_GSM_MODEM_ESP8266 +// #define TINY_GSM_MODEM_XBEE +// #define TINY_GSM_MODEM_SEQUANS_MONARCH + +// Set serial for debug console (to the Serial Monitor, default speed 115200) +#define SerialMon Serial + +// Set serial for AT commands (to the module) +// Use Hardware Serial on Mega, Leonardo, Micro +#ifndef __AVR_ATmega328P__ +#define SerialAT Serial1 + +// or Software Serial on Uno, Nano +#else +#include +SoftwareSerial SerialAT(2, 3); // RX, TX +#endif + +// Increase RX buffer to capture the entire response +// Chips without internal buffering (A6/A7, ESP8266, M590) +// need enough space in the buffer for the entire response +// else data will be lost (and the http library will fail). +#if !defined(TINY_GSM_RX_BUFFER) +#define TINY_GSM_RX_BUFFER 1024 +#endif + +// See all AT commands, if wanted +// #define DUMP_AT_COMMANDS + +// Define the serial console for debug prints, if needed +#define TINY_GSM_DEBUG SerialMon +// #define LOGGING // <- Logging is for the HTTP library + +// Add a reception delay, if needed. +// This may be needed for a fast processor at a slow baud rate. +// #define TINY_GSM_YIELD() { delay(2); } + +// Define how you're planning to connect to the internet. +// This is only needed for this example, not in other code. +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false + +// set GSM PIN, if any +#define GSM_PIN "" + +// Your GPRS credentials, if any +const char apn[] = "YourAPN"; +const char gprsUser[] = ""; +const char gprsPass[] = ""; + +// Your WiFi connection credentials, if applicable +const char wifiSSID[] = "YourSSID"; +const char wifiPass[] = "YourWiFiPass"; + +// Server details +const char server[] = "vsh.pp.ua"; +const int port = 80; + +#include +#include + +// Just in case someone defined the wrong thing.. +#if TINY_GSM_USE_GPRS && not defined TINY_GSM_MODEM_HAS_GPRS +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS false +#define TINY_GSM_USE_WIFI true +#endif +#if TINY_GSM_USE_WIFI && not defined TINY_GSM_MODEM_HAS_WIFI +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false +#endif + +const char resource[] = "/TinyGSM/test_1k.bin"; +uint32_t knownCRC32 = 0x6f50d767; +uint32_t knownFileSize = 1024; // In case server does not send it + +#ifdef DUMP_AT_COMMANDS +#include +StreamDebugger debugger(SerialAT, SerialMon); +TinyGsm modem(debugger); +#else +TinyGsm modem(SerialAT); +#endif + +TinyGsmClient client(modem); + +void setup() { + // Set console baud rate + SerialMon.begin(115200); + delay(10); + + // !!!!!!!!!!! + // Set your reset, enable, power pins here + // !!!!!!!!!!! + + SerialMon.println("Wait..."); + + // Set GSM module baud rate + SerialAT.begin(115200); + delay(6000); + + // Restart takes quite some time + // To skip it, call init() instead of restart() + SerialMon.println("Initializing modem..."); + modem.restart(); + // modem.init(); + + String modemInfo = modem.getModemInfo(); + SerialMon.print("Modem Info: "); + SerialMon.println(modemInfo); + +#if TINY_GSM_USE_GPRS + // Unlock your SIM card with a PIN if needed + if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); } +#endif +} + +void printPercent(uint32_t readLength, uint32_t contentLength) { + // If we know the total length + if (contentLength != (uint32_t)-1) { + SerialMon.print("\r "); + SerialMon.print((100.0 * readLength) / contentLength); + SerialMon.print('%'); + } else { + SerialMon.println(readLength); + } +} + +void loop() { +#if TINY_GSM_USE_WIFI + // Wifi connection parameters must be set before waiting for the network + SerialMon.print(F("Setting SSID/password...")); + if (!modem.networkConnect(wifiSSID, wifiPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); +#endif + +#if TINY_GSM_USE_GPRS && defined TINY_GSM_MODEM_XBEE + // The XBee must run the gprsConnect function BEFORE waiting for network! + modem.gprsConnect(apn, gprsUser, gprsPass); +#endif + + SerialMon.print("Waiting for network..."); + if (!modem.waitForNetwork()) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); } + +#if TINY_GSM_USE_GPRS + // GPRS connection parameters are usually set after network registration + SerialMon.print(F("Connecting to ")); + SerialMon.print(apn); + if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + if (modem.isGprsConnected()) { SerialMon.println("GPRS connected"); } +#endif + + SerialMon.print(F("Connecting to ")); + SerialMon.print(server); + if (!client.connect(server, port)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + // Make a HTTP GET request: + client.print(String("GET ") + resource + " HTTP/1.0\r\n"); + client.print(String("Host: ") + server + "\r\n"); + client.print("Connection: close\r\n\r\n"); + + // Let's see what the entire elapsed time is, from after we send the request. + uint32_t timeElapsed = millis(); + + SerialMon.println(F("Waiting for response header")); + + // While we are still looking for the end of the header (i.e. empty line + // FOLLOWED by a newline), continue to read data into the buffer, parsing each + // line (data FOLLOWED by a newline). If it takes too long to get data from + // the client, we need to exit. + + const uint32_t clientReadTimeout = 5000; + uint32_t clientReadStartTime = millis(); + String headerBuffer; + bool finishedHeader = false; + uint32_t contentLength = 0; + + while (!finishedHeader) { + int nlPos; + + if (client.available()) { + clientReadStartTime = millis(); + while (client.available()) { + char c = client.read(); + headerBuffer += c; + + // Uncomment the lines below to see the data coming into the buffer + // if (c < 16) + // SerialMon.print('0'); + // SerialMon.print(c, HEX); + // SerialMon.print(' '); + // if (isprint(c)) + // SerialMon.print(reinterpret_cast c); + // else + // SerialMon.print('*'); + // SerialMon.print(' '); + + // Let's exit and process if we find a new line + if (headerBuffer.indexOf(F("\r\n")) >= 0) break; + } + } else { + if (millis() - clientReadStartTime > clientReadTimeout) { + // Time-out waiting for data from client + SerialMon.println(F(">>> Client Timeout !")); + break; + } + } + + // See if we have a new line. + nlPos = headerBuffer.indexOf(F("\r\n")); + + if (nlPos > 0) { + headerBuffer.toLowerCase(); + // Check if line contains content-length + if (headerBuffer.startsWith(F("content-length:"))) { + contentLength = + headerBuffer.substring(headerBuffer.indexOf(':') + 1).toInt(); + // SerialMon.print(F("Got Content Length: ")); // uncomment for + // SerialMon.println(contentLength); // confirmation + } + + headerBuffer.remove(0, nlPos + 2); // remove the line + } else if (nlPos == 0) { + // if the new line is empty (i.e. "\r\n" is at the beginning of the line), + // we are done with the header. + finishedHeader = true; + } + } + + // The two cases which are not managed properly are as follows: + // 1. The client doesn't provide data quickly enough to keep up with this + // loop. + // 2. If the client data is segmented in the middle of the 'Content-Length: ' + // header, + // then that header may be missed/damaged. + // + + uint32_t readLength = 0; + CRC32 crc; + + if (finishedHeader && contentLength == knownFileSize) { + SerialMon.println(F("Reading response data")); + clientReadStartTime = millis(); + + printPercent(readLength, contentLength); + while (readLength < contentLength && client.connected() && + millis() - clientReadStartTime < clientReadTimeout) { + while (client.available()) { + uint8_t c = client.read(); + // SerialMon.print(reinterpret_castc); // Uncomment this to show + // data + crc.update(c); + readLength++; + if (readLength % (contentLength / 13) == 0) { + printPercent(readLength, contentLength); + } + clientReadStartTime = millis(); + } + } + printPercent(readLength, contentLength); + } + + timeElapsed = millis() - timeElapsed; + SerialMon.println(); + + // Shutdown + + client.stop(); + SerialMon.println(F("Server disconnected")); + +#if TINY_GSM_USE_WIFI + modem.networkDisconnect(); + SerialMon.println(F("WiFi disconnected")); +#endif +#if TINY_GSM_USE_GPRS + modem.gprsDisconnect(); + SerialMon.println(F("GPRS disconnected")); +#endif + + float duration = float(timeElapsed) / 1000; + + SerialMon.println(); + SerialMon.print("Content-Length: "); + SerialMon.println(contentLength); + SerialMon.print("Actually read: "); + SerialMon.println(readLength); + SerialMon.print("Calc. CRC32: 0x"); + SerialMon.println(crc.finalize(), HEX); + SerialMon.print("Known CRC32: 0x"); + SerialMon.println(knownCRC32, HEX); + SerialMon.print("Duration: "); + SerialMon.print(duration); + SerialMon.println("s"); + + // Do nothing forevermore + while (true) { delay(1000); } +} diff --git a/lib/TinyGSM/examples/HttpClient/HttpClient.ino b/lib/TinyGSM/examples/HttpClient/HttpClient.ino new file mode 100644 index 000000000..3e4659bfd --- /dev/null +++ b/lib/TinyGSM/examples/HttpClient/HttpClient.ino @@ -0,0 +1,261 @@ +/************************************************************** + * + * This sketch connects to a website and downloads a page. + * It can be used to perform HTTP/RESTful API calls. + * + * For this example, you need to install ArduinoHttpClient library: + * https://github.com/arduino-libraries/ArduinoHttpClient + * or from http://librarymanager/all#ArduinoHttpClient + * + * TinyGSM Getting Started guide: + * https://tiny.cc/tinygsm-readme + * + * For more HTTP API examples, see ArduinoHttpClient library + * + * NOTE: This example may NOT work with the XBee because the + * HttpClient library does not empty to serial buffer fast enough + * and the buffer overflow causes the HttpClient library to stall. + * Boards with faster processors may work, 8MHz boards will not. + **************************************************************/ + +// Select your modem: +#define TINY_GSM_MODEM_SIM800 +// #define TINY_GSM_MODEM_SIM808 +// #define TINY_GSM_MODEM_SIM868 +// #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_SIM7000 +// #define TINY_GSM_MODEM_SIM7000SSL +// #define TINY_GSM_MODEM_SIM7080 +// #define TINY_GSM_MODEM_SIM5360 +// #define TINY_GSM_MODEM_SIM7600 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_SARAR4 +// #define TINY_GSM_MODEM_M95 +// #define TINY_GSM_MODEM_BG96 +// #define TINY_GSM_MODEM_A6 +// #define TINY_GSM_MODEM_A7 +// #define TINY_GSM_MODEM_M590 +// #define TINY_GSM_MODEM_MC60 +// #define TINY_GSM_MODEM_MC60E +// #define TINY_GSM_MODEM_ESP8266 +// #define TINY_GSM_MODEM_XBEE +// #define TINY_GSM_MODEM_SEQUANS_MONARCH + +// Set serial for debug console (to the Serial Monitor, default speed 115200) +#define SerialMon Serial + +// Set serial for AT commands (to the module) +// Use Hardware Serial on Mega, Leonardo, Micro +#ifndef __AVR_ATmega328P__ +#define SerialAT Serial1 + +// or Software Serial on Uno, Nano +#else +#include +SoftwareSerial SerialAT(2, 3); // RX, TX +#endif + +// Increase RX buffer to capture the entire response +// Chips without internal buffering (A6/A7, ESP8266, M590) +// need enough space in the buffer for the entire response +// else data will be lost (and the http library will fail). +#if !defined(TINY_GSM_RX_BUFFER) +#define TINY_GSM_RX_BUFFER 650 +#endif + +// See all AT commands, if wanted +// #define DUMP_AT_COMMANDS + +// Define the serial console for debug prints, if needed +#define TINY_GSM_DEBUG SerialMon +// #define LOGGING // <- Logging is for the HTTP library + +// Range to attempt to autobaud +// NOTE: DO NOT AUTOBAUD in production code. Once you've established +// communication, set a fixed baud rate using modem.setBaud(#). +#define GSM_AUTOBAUD_MIN 9600 +#define GSM_AUTOBAUD_MAX 115200 + +// Add a reception delay, if needed. +// This may be needed for a fast processor at a slow baud rate. +// #define TINY_GSM_YIELD() { delay(2); } + +// Define how you're planning to connect to the internet +// These defines are only for this example; they are not needed in other code. +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false + +// set GSM PIN, if any +#define GSM_PIN "" + +// Your GPRS credentials, if any +const char apn[] = "YourAPN"; +const char gprsUser[] = ""; +const char gprsPass[] = ""; + +// Your WiFi connection credentials, if applicable +const char wifiSSID[] = "YourSSID"; +const char wifiPass[] = "YourWiFiPass"; + +// Server details +const char server[] = "vsh.pp.ua"; +const char resource[] = "/TinyGSM/logo.txt"; +const int port = 80; + +#include +#include + +// Just in case someone defined the wrong thing.. +#if TINY_GSM_USE_GPRS && not defined TINY_GSM_MODEM_HAS_GPRS +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS false +#define TINY_GSM_USE_WIFI true +#endif +#if TINY_GSM_USE_WIFI && not defined TINY_GSM_MODEM_HAS_WIFI +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false +#endif + +#ifdef DUMP_AT_COMMANDS +#include +StreamDebugger debugger(SerialAT, SerialMon); +TinyGsm modem(debugger); +#else +TinyGsm modem(SerialAT); +#endif + +TinyGsmClient client(modem); +HttpClient http(client, server, port); + +void setup() { + // Set console baud rate + SerialMon.begin(115200); + delay(10); + + // !!!!!!!!!!! + // Set your reset, enable, power pins here + // !!!!!!!!!!! + + SerialMon.println("Wait..."); + + // Set GSM module baud rate + TinyGsmAutoBaud(SerialAT, GSM_AUTOBAUD_MIN, GSM_AUTOBAUD_MAX); + // SerialAT.begin(9600); + delay(6000); + + // Restart takes quite some time + // To skip it, call init() instead of restart() + SerialMon.println("Initializing modem..."); + modem.restart(); + // modem.init(); + + String modemInfo = modem.getModemInfo(); + SerialMon.print("Modem Info: "); + SerialMon.println(modemInfo); + +#if TINY_GSM_USE_GPRS + // Unlock your SIM card with a PIN if needed + if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); } +#endif +} + +void loop() { +#if TINY_GSM_USE_WIFI + // Wifi connection parameters must be set before waiting for the network + SerialMon.print(F("Setting SSID/password...")); + if (!modem.networkConnect(wifiSSID, wifiPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); +#endif + +#if TINY_GSM_USE_GPRS && defined TINY_GSM_MODEM_XBEE + // The XBee must run the gprsConnect function BEFORE waiting for network! + modem.gprsConnect(apn, gprsUser, gprsPass); +#endif + + SerialMon.print("Waiting for network..."); + if (!modem.waitForNetwork()) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); } + +#if TINY_GSM_USE_GPRS + // GPRS connection parameters are usually set after network registration + SerialMon.print(F("Connecting to ")); + SerialMon.print(apn); + if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + if (modem.isGprsConnected()) { SerialMon.println("GPRS connected"); } +#endif + + SerialMon.print(F("Performing HTTP GET request... ")); + int err = http.get(resource); + if (err != 0) { + SerialMon.println(F("failed to connect")); + delay(10000); + return; + } + + int status = http.responseStatusCode(); + SerialMon.print(F("Response status code: ")); + SerialMon.println(status); + if (!status) { + delay(10000); + return; + } + + SerialMon.println(F("Response Headers:")); + while (http.headerAvailable()) { + String headerName = http.readHeaderName(); + String headerValue = http.readHeaderValue(); + SerialMon.println(" " + headerName + " : " + headerValue); + } + + int length = http.contentLength(); + if (length >= 0) { + SerialMon.print(F("Content length is: ")); + SerialMon.println(length); + } + if (http.isResponseChunked()) { + SerialMon.println(F("The response is chunked")); + } + + String body = http.responseBody(); + SerialMon.println(F("Response:")); + SerialMon.println(body); + + SerialMon.print(F("Body length is: ")); + SerialMon.println(body.length()); + + // Shutdown + + http.stop(); + SerialMon.println(F("Server disconnected")); + +#if TINY_GSM_USE_WIFI + modem.networkDisconnect(); + SerialMon.println(F("WiFi disconnected")); +#endif +#if TINY_GSM_USE_GPRS + modem.gprsDisconnect(); + SerialMon.println(F("GPRS disconnected")); +#endif + + // Do nothing forevermore + while (true) { delay(1000); } +} diff --git a/lib/TinyGSM/examples/HttpsClient/HttpsClient.ino b/lib/TinyGSM/examples/HttpsClient/HttpsClient.ino new file mode 100644 index 000000000..33092f206 --- /dev/null +++ b/lib/TinyGSM/examples/HttpsClient/HttpsClient.ino @@ -0,0 +1,257 @@ +/************************************************************** + * + * This sketch connects to a website and downloads a page. + * It can be used to perform HTTP/RESTful API calls. + * + * For this example, you need to install ArduinoHttpClient library: + * https://github.com/arduino-libraries/ArduinoHttpClient + * or from http://librarymanager/all#ArduinoHttpClient + * + * TinyGSM Getting Started guide: + * https://tiny.cc/tinygsm-readme + * + * SSL/TLS is not yet supported on the Quectel modems + * The A6/A7/A20 and M590 are not capable of SSL/TLS + * + * For more HTTP API examples, see ArduinoHttpClient library + * + * NOTE: This example may NOT work with the XBee because the + * HttpClient library does not empty to serial buffer fast enough + * and the buffer overflow causes the HttpClient library to stall. + * Boards with faster processors may work, 8MHz boards will not. + **************************************************************/ + +// Select your modem: +#define TINY_GSM_MODEM_SIM800 +// #define TINY_GSM_MODEM_SIM808 +// #define TINY_GSM_MODEM_SIM868 +// #define TINY_GSM_MODEM_SIM7000SSL +// #define TINY_GSM_MODEM_SIM7080 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_SARAR4 +// #define TINY_GSM_MODEM_ESP8266 +// #define TINY_GSM_MODEM_XBEE +// #define TINY_GSM_MODEM_SEQUANS_MONARCH + +// Set serial for debug console (to the Serial Monitor, default speed 115200) +#define SerialMon Serial + +// Set serial for AT commands (to the module) +// Use Hardware Serial on Mega, Leonardo, Micro +#ifndef __AVR_ATmega328P__ +#define SerialAT Serial1 + +// or Software Serial on Uno, Nano +#else +#include +SoftwareSerial SerialAT(2, 3); // RX, TX +#endif + +// Increase RX buffer to capture the entire response +// Chips without internal buffering (A6/A7, ESP8266, M590) +// need enough space in the buffer for the entire response +// else data will be lost (and the http library will fail). +#if !defined(TINY_GSM_RX_BUFFER) +#define TINY_GSM_RX_BUFFER 650 +#endif + +// See all AT commands, if wanted +// #define DUMP_AT_COMMANDS + +// Define the serial console for debug prints, if needed +#define TINY_GSM_DEBUG SerialMon +// #define LOGGING // <- Logging is for the HTTP library + +// Range to attempt to autobaud +// NOTE: DO NOT AUTOBAUD in production code. Once you've established +// communication, set a fixed baud rate using modem.setBaud(#). +#define GSM_AUTOBAUD_MIN 9600 +#define GSM_AUTOBAUD_MAX 115200 + +// Add a reception delay, if needed. +// This may be needed for a fast processor at a slow baud rate. +// #define TINY_GSM_YIELD() { delay(2); } + +// Define how you're planning to connect to the internet. +// This is only needed for this example, not in other code. +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false + +// set GSM PIN, if any +#define GSM_PIN "" + +// flag to force SSL client authentication, if needed +// #define TINY_GSM_SSL_CLIENT_AUTHENTICATION + +// Your GPRS credentials, if any +const char apn[] = "YourAPN"; +const char gprsUser[] = ""; +const char gprsPass[] = ""; + +// Your WiFi connection credentials, if applicable +const char wifiSSID[] = "YourSSID"; +const char wifiPass[] = "YourWiFiPass"; + +// Server details +const char server[] = "vsh.pp.ua"; +const char resource[] = "/TinyGSM/logo.txt"; +const int port = 443; + +#include +#include + +// Just in case someone defined the wrong thing.. +#if TINY_GSM_USE_GPRS && not defined TINY_GSM_MODEM_HAS_GPRS +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS false +#define TINY_GSM_USE_WIFI true +#endif +#if TINY_GSM_USE_WIFI && not defined TINY_GSM_MODEM_HAS_WIFI +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false +#endif + +#ifdef DUMP_AT_COMMANDS +#include +StreamDebugger debugger(SerialAT, SerialMon); +TinyGsm modem(debugger); +#else +TinyGsm modem(SerialAT); +#endif + +TinyGsmClientSecure client(modem); +HttpClient http(client, server, port); + +void setup() { + // Set console baud rate + SerialMon.begin(115200); + delay(10); + + // !!!!!!!!!!! + // Set your reset, enable, power pins here + // !!!!!!!!!!! + + SerialMon.println("Wait..."); + + // Set GSM module baud rate + TinyGsmAutoBaud(SerialAT, GSM_AUTOBAUD_MIN, GSM_AUTOBAUD_MAX); + // SerialAT.begin(9600); + delay(6000); + + // Restart takes quite some time + // To skip it, call init() instead of restart() + SerialMon.println("Initializing modem..."); + modem.restart(); + // modem.init(); + + String modemInfo = modem.getModemInfo(); + SerialMon.print("Modem Info: "); + SerialMon.println(modemInfo); + +#if TINY_GSM_USE_GPRS + // Unlock your SIM card with a PIN if needed + if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); } +#endif +} + +void loop() { +#if TINY_GSM_USE_WIFI + // Wifi connection parameters must be set before waiting for the network + SerialMon.print(F("Setting SSID/password...")); + if (!modem.networkConnect(wifiSSID, wifiPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); +#endif + +#if TINY_GSM_USE_GPRS && defined TINY_GSM_MODEM_XBEE + // The XBee must run the gprsConnect function BEFORE waiting for network! + modem.gprsConnect(apn, gprsUser, gprsPass); +#endif + + SerialMon.print("Waiting for network..."); + if (!modem.waitForNetwork()) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); } + +#if TINY_GSM_USE_GPRS + // GPRS connection parameters are usually set after network registration + SerialMon.print(F("Connecting to ")); + SerialMon.print(apn); + if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + if (modem.isGprsConnected()) { SerialMon.println("GPRS connected"); } +#endif + + SerialMon.print(F("Performing HTTPS GET request... ")); + http.connectionKeepAlive(); // Currently, this is needed for HTTPS + int err = http.get(resource); + if (err != 0) { + SerialMon.println(F("failed to connect")); + delay(10000); + return; + } + + int status = http.responseStatusCode(); + SerialMon.print(F("Response status code: ")); + SerialMon.println(status); + if (!status) { + delay(10000); + return; + } + + SerialMon.println(F("Response Headers:")); + while (http.headerAvailable()) { + String headerName = http.readHeaderName(); + String headerValue = http.readHeaderValue(); + SerialMon.println(" " + headerName + " : " + headerValue); + } + + int length = http.contentLength(); + if (length >= 0) { + SerialMon.print(F("Content length is: ")); + SerialMon.println(length); + } + if (http.isResponseChunked()) { + SerialMon.println(F("The response is chunked")); + } + + String body = http.responseBody(); + SerialMon.println(F("Response:")); + SerialMon.println(body); + + SerialMon.print(F("Body length is: ")); + SerialMon.println(body.length()); + + // Shutdown + + http.stop(); + SerialMon.println(F("Server disconnected")); + +#if TINY_GSM_USE_WIFI + modem.networkDisconnect(); + SerialMon.println(F("WiFi disconnected")); +#endif +#if TINY_GSM_USE_GPRS + modem.gprsDisconnect(); + SerialMon.println(F("GPRS disconnected")); +#endif + + // Do nothing forevermore + while (true) { delay(1000); } +} diff --git a/lib/TinyGSM/examples/MqttClient/MqttClient.ino b/lib/TinyGSM/examples/MqttClient/MqttClient.ino new file mode 100644 index 000000000..77a850083 --- /dev/null +++ b/lib/TinyGSM/examples/MqttClient/MqttClient.ino @@ -0,0 +1,290 @@ +/************************************************************** + * + * For this example, you need to install PubSubClient library: + * https://github.com/knolleary/pubsubclient + * or from http://librarymanager/all#PubSubClient + * + * TinyGSM Getting Started guide: + * https://tiny.cc/tinygsm-readme + * + * For more MQTT examples, see PubSubClient library + * + ************************************************************** + * This example connects to HiveMQ's showcase broker. + * + * You can quickly test sending and receiving messages from the HiveMQ webclient + * available at http://www.hivemq.com/demos/websocket-client/. + * + * Subscribe to the topic GsmClientTest/ledStatus + * Publish "toggle" to the topic GsmClientTest/led and the LED on your board + * should toggle and you should see a new message published to + * GsmClientTest/ledStatus with the newest LED status. + * + **************************************************************/ + +// Select your modem: +#define TINY_GSM_MODEM_SIM800 +// #define TINY_GSM_MODEM_SIM808 +// #define TINY_GSM_MODEM_SIM868 +// #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_SIM7000 +// #define TINY_GSM_MODEM_SIM7000SSL +// #define TINY_GSM_MODEM_SIM7080 +// #define TINY_GSM_MODEM_SIM5360 +// #define TINY_GSM_MODEM_SIM7600 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_SARAR4 +// #define TINY_GSM_MODEM_M95 +// #define TINY_GSM_MODEM_BG96 +// #define TINY_GSM_MODEM_A6 +// #define TINY_GSM_MODEM_A7 +// #define TINY_GSM_MODEM_M590 +// #define TINY_GSM_MODEM_MC60 +// #define TINY_GSM_MODEM_MC60E +// #define TINY_GSM_MODEM_ESP8266 +// #define TINY_GSM_MODEM_XBEE +// #define TINY_GSM_MODEM_SEQUANS_MONARCH + +// Set serial for debug console (to the Serial Monitor, default speed 115200) +#define SerialMon Serial + +// Set serial for AT commands (to the module) +// Use Hardware Serial on Mega, Leonardo, Micro +#ifndef __AVR_ATmega328P__ +#define SerialAT Serial1 + +// or Software Serial on Uno, Nano +#else +#include +SoftwareSerial SerialAT(2, 3); // RX, TX +#endif + +// See all AT commands, if wanted +// #define DUMP_AT_COMMANDS + +// Define the serial console for debug prints, if needed +#define TINY_GSM_DEBUG SerialMon + +// Range to attempt to autobaud +// NOTE: DO NOT AUTOBAUD in production code. Once you've established +// communication, set a fixed baud rate using modem.setBaud(#). +#define GSM_AUTOBAUD_MIN 9600 +#define GSM_AUTOBAUD_MAX 115200 + +// Add a reception delay, if needed. +// This may be needed for a fast processor at a slow baud rate. +// #define TINY_GSM_YIELD() { delay(2); } + +// Define how you're planning to connect to the internet. +// This is only needed for this example, not in other code. +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false + +// set GSM PIN, if any +#define GSM_PIN "" + +// Your GPRS credentials, if any +const char apn[] = "YourAPN"; +const char gprsUser[] = ""; +const char gprsPass[] = ""; + +// Your WiFi connection credentials, if applicable +const char wifiSSID[] = "YourSSID"; +const char wifiPass[] = "YourWiFiPass"; + +// MQTT details +const char* broker = "broker.hivemq.com"; + +const char* topicLed = "GsmClientTest/led"; +const char* topicInit = "GsmClientTest/init"; +const char* topicLedStatus = "GsmClientTest/ledStatus"; + +#include +#include + +// Just in case someone defined the wrong thing.. +#if TINY_GSM_USE_GPRS && not defined TINY_GSM_MODEM_HAS_GPRS +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS false +#define TINY_GSM_USE_WIFI true +#endif +#if TINY_GSM_USE_WIFI && not defined TINY_GSM_MODEM_HAS_WIFI +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false +#endif + +#ifdef DUMP_AT_COMMANDS +#include +StreamDebugger debugger(SerialAT, SerialMon); +TinyGsm modem(debugger); +#else +TinyGsm modem(SerialAT); +#endif +TinyGsmClient client(modem); +PubSubClient mqtt(client); + +#define LED_PIN 13 +int ledStatus = LOW; + +uint32_t lastReconnectAttempt = 0; + +void mqttCallback(char* topic, byte* payload, unsigned int len) { + SerialMon.print("Message arrived ["); + SerialMon.print(topic); + SerialMon.print("]: "); + SerialMon.write(payload, len); + SerialMon.println(); + + // Only proceed if incoming message's topic matches + if (String(topic) == topicLed) { + ledStatus = !ledStatus; + digitalWrite(LED_PIN, ledStatus); + mqtt.publish(topicLedStatus, ledStatus ? "1" : "0"); + } +} + +boolean mqttConnect() { + SerialMon.print("Connecting to "); + SerialMon.print(broker); + + // Connect to MQTT Broker + boolean status = mqtt.connect("GsmClientTest"); + + // Or, if you want to authenticate MQTT: + // boolean status = mqtt.connect("GsmClientName", "mqtt_user", "mqtt_pass"); + + if (status == false) { + SerialMon.println(" fail"); + return false; + } + SerialMon.println(" success"); + mqtt.publish(topicInit, "GsmClientTest started"); + mqtt.subscribe(topicLed); + return mqtt.connected(); +} + + +void setup() { + // Set console baud rate + SerialMon.begin(115200); + delay(10); + + pinMode(LED_PIN, OUTPUT); + + // !!!!!!!!!!! + // Set your reset, enable, power pins here + // !!!!!!!!!!! + + SerialMon.println("Wait..."); + + // Set GSM module baud rate + TinyGsmAutoBaud(SerialAT, GSM_AUTOBAUD_MIN, GSM_AUTOBAUD_MAX); + // SerialAT.begin(9600); + delay(6000); + + // Restart takes quite some time + // To skip it, call init() instead of restart() + SerialMon.println("Initializing modem..."); + modem.restart(); + // modem.init(); + + String modemInfo = modem.getModemInfo(); + SerialMon.print("Modem Info: "); + SerialMon.println(modemInfo); + +#if TINY_GSM_USE_GPRS + // Unlock your SIM card with a PIN if needed + if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); } +#endif + +#if TINY_GSM_USE_WIFI + // Wifi connection parameters must be set before waiting for the network + SerialMon.print(F("Setting SSID/password...")); + if (!modem.networkConnect(wifiSSID, wifiPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); +#endif + +#if TINY_GSM_USE_GPRS && defined TINY_GSM_MODEM_XBEE + // The XBee must run the gprsConnect function BEFORE waiting for network! + modem.gprsConnect(apn, gprsUser, gprsPass); +#endif + + SerialMon.print("Waiting for network..."); + if (!modem.waitForNetwork()) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); } + +#if TINY_GSM_USE_GPRS + // GPRS connection parameters are usually set after network registration + SerialMon.print(F("Connecting to ")); + SerialMon.print(apn); + if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + if (modem.isGprsConnected()) { SerialMon.println("GPRS connected"); } +#endif + + // MQTT Broker setup + mqtt.setServer(broker, 1883); + mqtt.setCallback(mqttCallback); +} + +void loop() { + // Make sure we're still registered on the network + if (!modem.isNetworkConnected()) { + SerialMon.println("Network disconnected"); + if (!modem.waitForNetwork(180000L, true)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + if (modem.isNetworkConnected()) { + SerialMon.println("Network re-connected"); + } + +#if TINY_GSM_USE_GPRS + // and make sure GPRS/EPS is still connected + if (!modem.isGprsConnected()) { + SerialMon.println("GPRS disconnected!"); + SerialMon.print(F("Connecting to ")); + SerialMon.print(apn); + if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + if (modem.isGprsConnected()) { SerialMon.println("GPRS reconnected"); } + } +#endif + } + + if (!mqtt.connected()) { + SerialMon.println("=== MQTT NOT CONNECTED ==="); + // Reconnect every 10 seconds + uint32_t t = millis(); + if (t - lastReconnectAttempt > 10000L) { + lastReconnectAttempt = t; + if (mqttConnect()) { lastReconnectAttempt = 0; } + } + delay(100); + return; + } + + mqtt.loop(); +} diff --git a/lib/TinyGSM/examples/WebClient/WebClient.ino b/lib/TinyGSM/examples/WebClient/WebClient.ino new file mode 100644 index 000000000..74ffa0a8d --- /dev/null +++ b/lib/TinyGSM/examples/WebClient/WebClient.ino @@ -0,0 +1,244 @@ +/************************************************************** + * + * This sketch connects to a website and downloads a page. + * It can be used to perform HTTP/RESTful API calls. + * + * TinyGSM Getting Started guide: + * https://tiny.cc/tinygsm-readme + * + **************************************************************/ + +// Select your modem: +#define TINY_GSM_MODEM_SIM800 +// #define TINY_GSM_MODEM_SIM808 +// #define TINY_GSM_MODEM_SIM868 +// #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_SIM7000 +// #define TINY_GSM_MODEM_SIM7000SSL +// #define TINY_GSM_MODEM_SIM7080 +// #define TINY_GSM_MODEM_SIM5360 +// #define TINY_GSM_MODEM_SIM7600 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_SARAR4 +// #define TINY_GSM_MODEM_M95 +// #define TINY_GSM_MODEM_BG96 +// #define TINY_GSM_MODEM_A6 +// #define TINY_GSM_MODEM_A7 +// #define TINY_GSM_MODEM_M590 +// #define TINY_GSM_MODEM_MC60 +// #define TINY_GSM_MODEM_MC60E +// #define TINY_GSM_MODEM_ESP8266 +// #define TINY_GSM_MODEM_XBEE +// #define TINY_GSM_MODEM_SEQUANS_MONARCH + +// Set serial for debug console (to the Serial Monitor, default speed 115200) +#define SerialMon Serial + +// Set serial for AT commands (to the module) +// Use Hardware Serial on Mega, Leonardo, Micro +#ifndef __AVR_ATmega328P__ +#define SerialAT Serial1 + +// or Software Serial on Uno, Nano +#else +#include +SoftwareSerial SerialAT(2, 3); // RX, TX +#endif + +// Increase RX buffer to capture the entire response +// Chips without internal buffering (A6/A7, ESP8266, M590) +// need enough space in the buffer for the entire response +// else data will be lost (and the http library will fail). +#if !defined(TINY_GSM_RX_BUFFER) +#define TINY_GSM_RX_BUFFER 650 +#endif + +// See all AT commands, if wanted +// #define DUMP_AT_COMMANDS + +// Define the serial console for debug prints, if needed +#define TINY_GSM_DEBUG SerialMon + +// Range to attempt to autobaud +// NOTE: DO NOT AUTOBAUD in production code. Once you've established +// communication, set a fixed baud rate using modem.setBaud(#). +#define GSM_AUTOBAUD_MIN 9600 +#define GSM_AUTOBAUD_MAX 115200 + +// Add a reception delay, if needed. +// This may be needed for a fast processor at a slow baud rate. +// #define TINY_GSM_YIELD() { delay(2); } + +// Uncomment this if you want to use SSL +// #define USE_SSL + +// Define how you're planning to connect to the internet. +// This is only needed for this example, not in other code. +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false + +// set GSM PIN, if any +#define GSM_PIN "" + +// Your GPRS credentials, if any +const char apn[] = "YourAPN"; +const char gprsUser[] = ""; +const char gprsPass[] = ""; + +// Your WiFi connection credentials, if applicable +const char wifiSSID[] = "YourSSID"; +const char wifiPass[] = "YourWiFiPass"; + +// Server details +const char server[] = "vsh.pp.ua"; +const char resource[] = "/TinyGSM/logo.txt"; + +#include + +// Just in case someone defined the wrong thing.. +#if TINY_GSM_USE_GPRS && not defined TINY_GSM_MODEM_HAS_GPRS +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS false +#define TINY_GSM_USE_WIFI true +#endif +#if TINY_GSM_USE_WIFI && not defined TINY_GSM_MODEM_HAS_WIFI +#undef TINY_GSM_USE_GPRS +#undef TINY_GSM_USE_WIFI +#define TINY_GSM_USE_GPRS true +#define TINY_GSM_USE_WIFI false +#endif + +#ifdef DUMP_AT_COMMANDS +#include +StreamDebugger debugger(SerialAT, SerialMon); +TinyGsm modem(debugger); +#else +TinyGsm modem(SerialAT); +#endif + +#ifdef USE_SSL +TinyGsmClientSecure client(modem); +const int port = 443; +#else +TinyGsmClient client(modem); +const int port = 80; +#endif + +void setup() { + // Set console baud rate + SerialMon.begin(115200); + delay(10); + + // !!!!!!!!!!! + // Set your reset, enable, power pins here + // !!!!!!!!!!! + + SerialMon.println("Wait..."); + + // Set GSM module baud rate + TinyGsmAutoBaud(SerialAT, GSM_AUTOBAUD_MIN, GSM_AUTOBAUD_MAX); + // SerialAT.begin(9600); + delay(6000); + + // Restart takes quite some time + // To skip it, call init() instead of restart() + SerialMon.println("Initializing modem..."); + modem.restart(); + // modem.init(); + + String modemInfo = modem.getModemInfo(); + SerialMon.print("Modem Info: "); + SerialMon.println(modemInfo); + +#if TINY_GSM_USE_GPRS + // Unlock your SIM card with a PIN if needed + if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); } +#endif +} + +void loop() { +#if TINY_GSM_USE_WIFI + // Wifi connection parameters must be set before waiting for the network + SerialMon.print(F("Setting SSID/password...")); + if (!modem.networkConnect(wifiSSID, wifiPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); +#endif + +#if TINY_GSM_USE_GPRS && defined TINY_GSM_MODEM_XBEE + // The XBee must run the gprsConnect function BEFORE waiting for network! + modem.gprsConnect(apn, gprsUser, gprsPass); +#endif + + SerialMon.print("Waiting for network..."); + if (!modem.waitForNetwork()) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); } + +#if TINY_GSM_USE_GPRS + // GPRS connection parameters are usually set after network registration + SerialMon.print(F("Connecting to ")); + SerialMon.print(apn); + if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + if (modem.isGprsConnected()) { SerialMon.println("GPRS connected"); } +#endif + + SerialMon.print("Connecting to "); + SerialMon.println(server); + if (!client.connect(server, port)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + // Make a HTTP GET request: + SerialMon.println("Performing HTTP GET request..."); + client.print(String("GET ") + resource + " HTTP/1.1\r\n"); + client.print(String("Host: ") + server + "\r\n"); + client.print("Connection: close\r\n\r\n"); + client.println(); + + uint32_t timeout = millis(); + while (client.connected() && millis() - timeout < 10000L) { + // Print available data + while (client.available()) { + char c = client.read(); + SerialMon.print(c); + timeout = millis(); + } + } + SerialMon.println(); + + // Shutdown + + client.stop(); + SerialMon.println(F("Server disconnected")); + +#if TINY_GSM_USE_WIFI + modem.networkDisconnect(); + SerialMon.println(F("WiFi disconnected")); +#endif +#if TINY_GSM_USE_GPRS + modem.gprsDisconnect(); + SerialMon.println(F("GPRS disconnected")); +#endif + + // Do nothing forevermore + while (true) { delay(1000); } +} diff --git a/lib/TinyGSM/examples/example_dependencies.json b/lib/TinyGSM/examples/example_dependencies.json new file mode 100644 index 000000000..76d7297f8 --- /dev/null +++ b/lib/TinyGSM/examples/example_dependencies.json @@ -0,0 +1,41 @@ +[ + { + "name": "PubSubClient", + "owner": "knolleary", + "library id": "89", + "url": "https://github.com/knolleary/pubsubclient.git", + "version": "~2.8", + "note": "A client library for MQTT messaging.", + "authors": ["Nick O'Leary"] + }, + { + "name": "Blynk", + "owner": "blynkkk", + "library id": "415", + "url": "https://github.com/blynkkk/blynk-library.git", + "version": "~0.6.7", + "authors": ["Volodymyr Shymanskyy"], + "frameworks": "*", + "platforms": "*" + }, + { + "name": "AceCRC", + "owner": "bxparks", + "library id": "1202", + "url": "https://github.com/bxparks/AceCRC.git", + "version": "~1.0.1", + "authors": ["Brian T. Park"], + "frameworks": "*", + "platforms": "*" + }, + { + "name": "StreamDebugger", + "owner": "vshymanskyy", + "library id": "1286", + "url": "https://github.com/vshymanskyy/StreamDebugger.git", + "version": "~1.0.1", + "authors": ["Volodymyr Shymanskyy"], + "frameworks": "*", + "platforms": "*" + } +] diff --git a/lib/TinyGSM/examples/more/Hologram_Dash/Hologram_Dash.ino b/lib/TinyGSM/examples/more/Hologram_Dash/Hologram_Dash.ino new file mode 100644 index 000000000..5578fc40d --- /dev/null +++ b/lib/TinyGSM/examples/more/Hologram_Dash/Hologram_Dash.ino @@ -0,0 +1,136 @@ +/************************************************************** + * + * This sketch connects to a website and downloads a page. + * It can be used to perform HTTP/RESTful API calls. + * + * TinyGSM Getting Started guide: + * https://tiny.cc/tinygsm-readme + * + **************************************************************/ + +// Hologram Dash uses UBLOX U2 modems +#define TINY_GSM_MODEM_UBLOX + +// Increase RX buffer if needed +#if !defined(TINY_GSM_RX_BUFFER) +#define TINY_GSM_RX_BUFFER 512 +#endif + +#include + +// Uncomment this if you want to see all AT commands +// #define DUMP_AT_COMMANDS + +// Uncomment this if you want to use SSL +// #define USE_SSL + +// Set serial for debug console (to the Serial Monitor, speed 115200) +#define SerialMon Serial + +// We'll be using SerialSystem in Passthrough mode +#define SerialAT SerialSystem + +// Your GPRS credentials +// Leave empty, if missing user or pass +const char apn[] = "YourAPN"; +const char user[] = ""; +const char pass[] = ""; + +// Server details +const char server[] = "vsh.pp.ua"; +const char resource[] = "/TinyGSM/logo.txt"; + +#ifdef DUMP_AT_COMMANDS + #include + StreamDebugger debugger(SerialAT, SerialMon); + TinyGsm mdm(debugger); +#else + TinyGsm mdm(SerialAT); +#endif + +#ifdef USE_SSL + TinyGsmClientSecure client(mdm); + const int port = 443; +#else + TinyGsmClient client(mdm); + const int port = 80; +#endif + +void setup() { + // Set console baud rate + SerialMon.begin(115200); + delay(10); + + // Set up Passthrough + HologramCloud.enterPassthrough(); + delay(6000); + + // Restart takes quite some time + // To skip it, call init() instead of restart() + SerialMon.println(F("Initializing modem...")); + mdm.restart(); + + String modemInfo = mdm.getModemInfo(); + SerialMon.print(F("Modem: ")); + SerialMon.println(modemInfo); + + // Unlock your SIM card with a PIN + //mdm.simUnlock("1234"); +} + +void loop() { + SerialMon.print(F("Waiting for network...")); + if (!mdm.waitForNetwork()) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + SerialMon.print(F("Connecting to ")); + SerialMon.print(apn); + if (!mdm.gprsConnect(apn, user, pass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + SerialMon.print(F("Connecting to ")); + SerialMon.print(server); + if (!client.connect(server, port)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + // Make a HTTP GET request: + client.print(String("GET ") + resource + " HTTP/1.0\r\n"); + client.print(String("Host: ") + server + "\r\n"); + client.print("Connection: close\r\n\r\n"); + + uint32_t timeout = millis(); + while (client.connected() && millis() - timeout < 10000L) { + // Print available data + while (client.available()) { + char c = client.read(); + SerialMon.print(c); + timeout = millis(); + } + } + SerialMon.println(); + + // Shutdown + + client.stop(); + SerialMon.println(F("Server disconnected")); + + mdm.gprsDisconnect(); + SerialMon.println(F("GPRS disconnected")); + + // Do nothing forevermore + while (true) { + delay(1000); + } +} diff --git a/lib/TinyGSM/examples/more/Industruino/Industruino.ino b/lib/TinyGSM/examples/more/Industruino/Industruino.ino new file mode 100644 index 000000000..cd2b747e8 --- /dev/null +++ b/lib/TinyGSM/examples/more/Industruino/Industruino.ino @@ -0,0 +1,161 @@ +/************************************************************** + * + * This sketch connects to a website and downloads a page. + * It can be used to perform HTTP/RESTful API calls. + * + * For this example, you need to install ArduinoHttpClient library: + * https://github.com/arduino-libraries/ArduinoHttpClient + * or from http://librarymanager/all#ArduinoHttpClient + * + * TinyGSM Getting Started guide: + * https://tiny.cc/tinygsm-readme + * + * For more HTTP API examples, see ArduinoHttpClient library + * + **************************************************************/ + +// Industruino uses SIM800H +#define TINY_GSM_MODEM_SIM800 + +// Increase RX buffer if needed +#if !defined(TINY_GSM_RX_BUFFER) +#define TINY_GSM_RX_BUFFER 512 +#endif + +#include +#include + +// Uncomment this if you want to see all AT commands +// #define DUMP_AT_COMMANDS + +// Uncomment this if you want to use SSL +// #define USE_SSL + +// Set serial for debug console (to the Serial Monitor, speed 115200) +#define SerialMon SerialUSB + +// Select Serial1 or Serial depending on your module configuration +#define SerialAT Serial1 + +// Your GPRS credentials +// Leave empty, if missing user or pass +const char apn[] = "YourAPN"; +const char user[] = ""; +const char pass[] = ""; + +// Server details +const char server[] = "vsh.pp.ua"; +const char resource[] = "/TinyGSM/logo.txt"; + +#ifdef DUMP_AT_COMMANDS + #include + StreamDebugger debugger(SerialAT, SerialMon); + TinyGsm modem(debugger); +#else + TinyGsm modem(SerialAT); +#endif + +#ifdef USE_SSL + TinyGsmClientSecure client(modem); + HttpClient http(client, server, 443); +#else + TinyGsmClient client(modem); + HttpClient http(client, server, 80); +#endif + +void setup() { + // Turn on modem with 1 second pulse on D6 + pinMode(6, OUTPUT); + digitalWrite(6, HIGH); + delay(1000); + digitalWrite(6, LOW); + + // Set console baud rate + SerialMon.begin(115200); + delay(10); + + // Set GSM module baud rate + SerialAT.begin(115200); + delay(6000); + + // Restart takes quite some time + // To skip it, call init() instead of restart() + SerialMon.println(F("Initializing modem...")); + modem.restart(); + + String modemInfo = modem.getModemInfo(); + SerialMon.print(F("Modem: ")); + SerialMon.println(modemInfo); + + // Unlock your SIM card with a PIN + //modem.simUnlock("1234"); +} + +void loop() { + SerialMon.print(F("Waiting for network...")); + if (!modem.waitForNetwork()) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + SerialMon.print(F("Connecting to ")); + SerialMon.print(apn); + if (!modem.gprsConnect(apn, user, pass)) { + SerialMon.println(" fail"); + delay(10000); + return; + } + SerialMon.println(" success"); + + SerialMon.print(F("Performing HTTP GET request... ")); + int err = http.get(resource); + if (err != 0) { + SerialMon.println(F("failed to connect")); + delay(10000); + return; + } + + int status = http.responseStatusCode(); + SerialMon.println(status); + if (!status) { + delay(10000); + return; + } + + while (http.headerAvailable()) { + String headerName = http.readHeaderName(); + String headerValue = http.readHeaderValue(); + //SerialMon.println(headerName + " : " + headerValue); + } + + int length = http.contentLength(); + if (length >= 0) { + SerialMon.print(F("Content length is: ")); + SerialMon.println(length); + } + if (http.isResponseChunked()) { + SerialMon.println(F("The response is chunked")); + } + + String body = http.responseBody(); + SerialMon.println(F("Response:")); + SerialMon.println(body); + + SerialMon.print(F("Body length is: ")); + SerialMon.println(body.length()); + + // Shutdown + + http.stop(); + SerialMon.println(F("Server disconnected")); + + modem.gprsDisconnect(); + SerialMon.println(F("GPRS disconnected")); + + // Do nothing forevermore + while (true) { + delay(1000); + } +} diff --git a/lib/TinyGSM/examples/more/SIM800_SslSetCert/COMODORSACertificationAuthority.h b/lib/TinyGSM/examples/more/SIM800_SslSetCert/COMODORSACertificationAuthority.h new file mode 100644 index 000000000..514db99a1 --- /dev/null +++ b/lib/TinyGSM/examples/more/SIM800_SslSetCert/COMODORSACertificationAuthority.h @@ -0,0 +1,36 @@ +const char cert[] PROGMEM = +"-----BEGIN CERTIFICATE-----\n" +"MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB\n" +"hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" +"A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV\n" +"BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5\n" +"MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgT\n" +"EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR\n" +"Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNh\n" +"dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR\n" +"6FSS0gpWsawNJN3Fz0RndJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8X\n" +"pz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZFGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC\n" +"9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+5eNu/Nio5JIk2kNrYrhV\n" +"/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pGx8cgoLEf\n" +"Zd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z\n" +"+pUX2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7w\n" +"qP/0uK3pN/u6uPQLOvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZah\n" +"SL0896+1DSJMwBGB7FY79tOi4lu3sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVIC\n" +"u9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+CGCe01a60y1Dma/RMhnEw6abf\n" +"Fobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5WdYgGq/yapiq\n" +"crxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E\n" +"FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB\n" +"/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvl\n" +"wFTPoCWOAvn9sKIN9SCYPBMtrFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM\n" +"4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV\n" +"2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSgtZx8jb8uk2Intzna\n" +"FxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwWsRqZ\n" +"CuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiK\n" +"boHGhfKppC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmcke\n" +"jkk9u+UJueBPSZI9FoJAzMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yL\n" +"S0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb\n" +"QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl\n" +"0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB\n" +"NVOFBkpdn627G190\n" +"-----END CERTIFICATE-----\n"; + diff --git a/lib/TinyGSM/examples/more/SIM800_SslSetCert/DSTRootCAX3.der.h b/lib/TinyGSM/examples/more/SIM800_SslSetCert/DSTRootCAX3.der.h new file mode 100644 index 000000000..15063a3e2 --- /dev/null +++ b/lib/TinyGSM/examples/more/SIM800_SslSetCert/DSTRootCAX3.der.h @@ -0,0 +1,74 @@ +const char cert[] PROGMEM = +{ + 0x30, 0x82, 0x03, 0x4a, 0x30, 0x82, 0x02, 0x32, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x10, 0x44, 0xaf, 0xb0, 0x80, 0xd6, 0xa3, 0x27, 0xba, 0x89, + 0x30, 0x39, 0x86, 0x2e, 0xf8, 0x40, 0x6b, 0x30, 0x0d, 0x06, 0x09, 0x2a, + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x3f, + 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x1b, 0x44, + 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x20, 0x54, 0x72, 0x75, 0x73, 0x74, 0x20, 0x43, + 0x6f, 0x2e, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, + 0x0e, 0x44, 0x53, 0x54, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, + 0x20, 0x58, 0x33, 0x30, 0x1e, 0x17, 0x0d, 0x30, 0x30, 0x30, 0x39, 0x33, + 0x30, 0x32, 0x31, 0x31, 0x32, 0x31, 0x39, 0x5a, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x39, 0x33, 0x30, 0x31, 0x34, 0x30, 0x31, 0x31, 0x35, 0x5a, 0x30, + 0x3f, 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x1b, + 0x44, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x20, 0x53, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x20, 0x54, 0x72, 0x75, 0x73, 0x74, 0x20, + 0x43, 0x6f, 0x2e, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, 0x03, + 0x13, 0x0e, 0x44, 0x53, 0x54, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, + 0x41, 0x20, 0x58, 0x33, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, + 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, + 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, + 0x00, 0xdf, 0xaf, 0xe9, 0x97, 0x50, 0x08, 0x83, 0x57, 0xb4, 0xcc, 0x62, + 0x65, 0xf6, 0x90, 0x82, 0xec, 0xc7, 0xd3, 0x2c, 0x6b, 0x30, 0xca, 0x5b, + 0xec, 0xd9, 0xc3, 0x7d, 0xc7, 0x40, 0xc1, 0x18, 0x14, 0x8b, 0xe0, 0xe8, + 0x33, 0x76, 0x49, 0x2a, 0xe3, 0x3f, 0x21, 0x49, 0x93, 0xac, 0x4e, 0x0e, + 0xaf, 0x3e, 0x48, 0xcb, 0x65, 0xee, 0xfc, 0xd3, 0x21, 0x0f, 0x65, 0xd2, + 0x2a, 0xd9, 0x32, 0x8f, 0x8c, 0xe5, 0xf7, 0x77, 0xb0, 0x12, 0x7b, 0xb5, + 0x95, 0xc0, 0x89, 0xa3, 0xa9, 0xba, 0xed, 0x73, 0x2e, 0x7a, 0x0c, 0x06, + 0x32, 0x83, 0xa2, 0x7e, 0x8a, 0x14, 0x30, 0xcd, 0x11, 0xa0, 0xe1, 0x2a, + 0x38, 0xb9, 0x79, 0x0a, 0x31, 0xfd, 0x50, 0xbd, 0x80, 0x65, 0xdf, 0xb7, + 0x51, 0x63, 0x83, 0xc8, 0xe2, 0x88, 0x61, 0xea, 0x4b, 0x61, 0x81, 0xec, + 0x52, 0x6b, 0xb9, 0xa2, 0xe2, 0x4b, 0x1a, 0x28, 0x9f, 0x48, 0xa3, 0x9e, + 0x0c, 0xda, 0x09, 0x8e, 0x3e, 0x17, 0x2e, 0x1e, 0xdd, 0x20, 0xdf, 0x5b, + 0xc6, 0x2a, 0x8a, 0xab, 0x2e, 0xbd, 0x70, 0xad, 0xc5, 0x0b, 0x1a, 0x25, + 0x90, 0x74, 0x72, 0xc5, 0x7b, 0x6a, 0xab, 0x34, 0xd6, 0x30, 0x89, 0xff, + 0xe5, 0x68, 0x13, 0x7b, 0x54, 0x0b, 0xc8, 0xd6, 0xae, 0xec, 0x5a, 0x9c, + 0x92, 0x1e, 0x3d, 0x64, 0xb3, 0x8c, 0xc6, 0xdf, 0xbf, 0xc9, 0x41, 0x70, + 0xec, 0x16, 0x72, 0xd5, 0x26, 0xec, 0x38, 0x55, 0x39, 0x43, 0xd0, 0xfc, + 0xfd, 0x18, 0x5c, 0x40, 0xf1, 0x97, 0xeb, 0xd5, 0x9a, 0x9b, 0x8d, 0x1d, + 0xba, 0xda, 0x25, 0xb9, 0xc6, 0xd8, 0xdf, 0xc1, 0x15, 0x02, 0x3a, 0xab, + 0xda, 0x6e, 0xf1, 0x3e, 0x2e, 0xf5, 0x5c, 0x08, 0x9c, 0x3c, 0xd6, 0x83, + 0x69, 0xe4, 0x10, 0x9b, 0x19, 0x2a, 0xb6, 0x29, 0x57, 0xe3, 0xe5, 0x3d, + 0x9b, 0x9f, 0xf0, 0x02, 0x5d, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x42, + 0x30, 0x40, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, + 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0e, 0x06, 0x03, 0x55, + 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, + 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xc4, 0xa7, + 0xb1, 0xa4, 0x7b, 0x2c, 0x71, 0xfa, 0xdb, 0xe1, 0x4b, 0x90, 0x75, 0xff, + 0xc4, 0x15, 0x60, 0x85, 0x89, 0x10, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, + 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, + 0x01, 0x00, 0xa3, 0x1a, 0x2c, 0x9b, 0x17, 0x00, 0x5c, 0xa9, 0x1e, 0xee, + 0x28, 0x66, 0x37, 0x3a, 0xbf, 0x83, 0xc7, 0x3f, 0x4b, 0xc3, 0x09, 0xa0, + 0x95, 0x20, 0x5d, 0xe3, 0xd9, 0x59, 0x44, 0xd2, 0x3e, 0x0d, 0x3e, 0xbd, + 0x8a, 0x4b, 0xa0, 0x74, 0x1f, 0xce, 0x10, 0x82, 0x9c, 0x74, 0x1a, 0x1d, + 0x7e, 0x98, 0x1a, 0xdd, 0xcb, 0x13, 0x4b, 0xb3, 0x20, 0x44, 0xe4, 0x91, + 0xe9, 0xcc, 0xfc, 0x7d, 0xa5, 0xdb, 0x6a, 0xe5, 0xfe, 0xe6, 0xfd, 0xe0, + 0x4e, 0xdd, 0xb7, 0x00, 0x3a, 0xb5, 0x70, 0x49, 0xaf, 0xf2, 0xe5, 0xeb, + 0x02, 0xf1, 0xd1, 0x02, 0x8b, 0x19, 0xcb, 0x94, 0x3a, 0x5e, 0x48, 0xc4, + 0x18, 0x1e, 0x58, 0x19, 0x5f, 0x1e, 0x02, 0x5a, 0xf0, 0x0c, 0xf1, 0xb1, + 0xad, 0xa9, 0xdc, 0x59, 0x86, 0x8b, 0x6e, 0xe9, 0x91, 0xf5, 0x86, 0xca, + 0xfa, 0xb9, 0x66, 0x33, 0xaa, 0x59, 0x5b, 0xce, 0xe2, 0xa7, 0x16, 0x73, + 0x47, 0xcb, 0x2b, 0xcc, 0x99, 0xb0, 0x37, 0x48, 0xcf, 0xe3, 0x56, 0x4b, + 0xf5, 0xcf, 0x0f, 0x0c, 0x72, 0x32, 0x87, 0xc6, 0xf0, 0x44, 0xbb, 0x53, + 0x72, 0x6d, 0x43, 0xf5, 0x26, 0x48, 0x9a, 0x52, 0x67, 0xb7, 0x58, 0xab, + 0xfe, 0x67, 0x76, 0x71, 0x78, 0xdb, 0x0d, 0xa2, 0x56, 0x14, 0x13, 0x39, + 0x24, 0x31, 0x85, 0xa2, 0xa8, 0x02, 0x5a, 0x30, 0x47, 0xe1, 0xdd, 0x50, + 0x07, 0xbc, 0x02, 0x09, 0x90, 0x00, 0xeb, 0x64, 0x63, 0x60, 0x9b, 0x16, + 0xbc, 0x88, 0xc9, 0x12, 0xe6, 0xd2, 0x7d, 0x91, 0x8b, 0xf9, 0x3d, 0x32, + 0x8d, 0x65, 0xb4, 0xe9, 0x7c, 0xb1, 0x57, 0x76, 0xea, 0xc5, 0xb6, 0x28, + 0x39, 0xbf, 0x15, 0x65, 0x1c, 0xc8, 0xf6, 0x77, 0x96, 0x6a, 0x0a, 0x8d, + 0x77, 0x0b, 0xd8, 0x91, 0x0b, 0x04, 0x8e, 0x07, 0xdb, 0x29, 0xb6, 0x0a, + 0xee, 0x9d, 0x82, 0x35, 0x35, 0x10 +}; diff --git a/lib/TinyGSM/examples/more/SIM800_SslSetCert/DSTRootCAX3.h b/lib/TinyGSM/examples/more/SIM800_SslSetCert/DSTRootCAX3.h new file mode 100644 index 000000000..55e79d96c --- /dev/null +++ b/lib/TinyGSM/examples/more/SIM800_SslSetCert/DSTRootCAX3.h @@ -0,0 +1,22 @@ +const char cert[] PROGMEM = +"-----BEGIN CERTIFICATE-----\n" +"MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\n" +"MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" +"DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow\n" +"PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\n" +"Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" +"AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\n" +"rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\n" +"OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b\n" +"xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw\n" +"7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD\n" +"aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\n" +"HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG\n" +"SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69\n" +"ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr\n" +"AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz\n" +"R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5\n" +"JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\n" +"Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n" +"-----END CERTIFICATE-----\n"; + diff --git a/lib/TinyGSM/examples/more/SIM800_SslSetCert/SIM800_SslSetCert.ino b/lib/TinyGSM/examples/more/SIM800_SslSetCert/SIM800_SslSetCert.ino new file mode 100644 index 000000000..eef420761 --- /dev/null +++ b/lib/TinyGSM/examples/more/SIM800_SslSetCert/SIM800_SslSetCert.ino @@ -0,0 +1,96 @@ +/************************************************************** + * + * This sketch uploads SSL certificates to the SIM8xx + * + * TinyGSM Getting Started guide: + * https://tiny.cc/tinygsm-readme + * + **************************************************************/ + +// This example is specific to SIM8xx +#define TINY_GSM_MODEM_SIM800 + +// Select your certificate: +#include "DSTRootCAX3.h" +//#include "DSTRootCAX3.der.h" +//#include "COMODORSACertificationAuthority.h" + +// Select the file you want to write into +// (the file is stored on the modem) +#define CERT_FILE "C:\\USER\\CERT.CRT" + +#include + +// Set serial for debug console (to the Serial Monitor, speed 115200) +#define SerialMon Serial + +// Use Hardware Serial for AT commands +#define SerialAT Serial1 + +// Uncomment this if you want to see all AT commands +// #define DUMP_AT_COMMANDS + + +#ifdef DUMP_AT_COMMANDS + #include + StreamDebugger debugger(SerialAT, SerialMon); + TinyGsm modem(debugger); +#else + TinyGsm modem(SerialAT); +#endif + +void setup() { + // Set console baud rate + SerialMon.begin(115200); + delay(10); + + // Set GSM module baud rate + SerialAT.begin(115200); + delay(6000); + + SerialMon.println(F("Initializing modem...")); + modem.init(); + + modem.sendAT(GF("+FSCREATE=" CERT_FILE)); + if (modem.waitResponse() != 1) return; + + const int cert_size = sizeof(cert); + + modem.sendAT(GF("+FSWRITE=" CERT_FILE ",0,"), cert_size, GF(",10")); + if (modem.waitResponse(GF(">")) != 1) { + return; + } + + for (int i = 0; i < cert_size; i++) { + char c = pgm_read_byte(&cert[i]); + modem.stream.write(c); + } + + modem.stream.write(GSM_NL); + modem.stream.flush(); + + if (modem.waitResponse(2000) != 1) return; + + modem.sendAT(GF("+SSLSETCERT=\"" CERT_FILE "\"")); + if (modem.waitResponse() != 1) return; + if (modem.waitResponse(5000L, GF(GSM_NL "+SSLSETCERT:")) != 1) return; + const int retCode = modem.stream.readStringUntil('\n').toInt(); + + + SerialMon.println(); + SerialMon.println(); + SerialMon.println(F("****************************")); + SerialMon.print(F("Setting Certificate: ")); + SerialMon.println((0 == retCode) ? "OK" : "FAILED"); + SerialMon.println(F("****************************")); +} + +void loop() { + if (SerialAT.available()) { + SerialMon.write(SerialAT.read()); + } + if (SerialMon.available()) { + SerialAT.write(SerialMon.read()); + } + delay(0); +} diff --git a/lib/TinyGSM/keywords.txt b/lib/TinyGSM/keywords.txt new file mode 100644 index 000000000..b6b4b105f --- /dev/null +++ b/lib/TinyGSM/keywords.txt @@ -0,0 +1,29 @@ +####################################### +# Data types (KEYWORD1) +####################################### +TinyGsm KEYWORD1 +TinyGsmClient KEYWORD1 +TinyGsmClientSecure KEYWORD1 + +SerialAT KEYWORD1 +SerialMon KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +begin KEYWORD2 +restart KEYWORD2 +waitForNetwork KEYWORD2 +getSimStatus KEYWORD2 +gprsConnect KEYWORD2 +gprsDisconnect KEYWORD2 +isGprsConnected KEYWORD2 +isNetworkConnected KEYWORD2 +factoryReset KEYWORD2 + +####################################### +# Literals (LITERAL1) +####################################### +DATE_FULL LITERAL1 +DATE_TIME LITERAL1 +DATE_DATE LITERAL1 diff --git a/lib/TinyGSM/library.json b/lib/TinyGSM/library.json new file mode 100644 index 000000000..a4d18275d --- /dev/null +++ b/lib/TinyGSM/library.json @@ -0,0 +1,32 @@ +{ + "name": "TinyGSM", + "version": "0.11.7", + "description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM, LTE, and WiFi modules with AT command interfaces.", + "keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM7000, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95, MC60, MC60E, BG96, ublox, Quectel, SIMCOM, AI Thinker, LTE, LTE-M", + "authors": [ + { + "name": "Volodymyr Shymanskyy", + "url": "https://github.com/vshymanskyy", + "maintainer": true + } + ], + "repository": { + "type": "git", + "url": "https://github.com/vshymanskyy/TinyGSM.git" + }, + "homepage": "https://github.com/vshymanskyy/TinyGSM", + "export": { + "include": [ + "LICENSE", + "library.json", + "library.properties", + "README.md", + "keywords.txt", + "src/*", + "examples/*" + ] + }, + "frameworks": ["arduino", "energia", "wiringpi"], + "platforms": "*", + "headers": "TinyGsmClient.h" +} diff --git a/airrohr-firmware/lib/readme.txt b/lib/readme.txt similarity index 100% rename from airrohr-firmware/lib/readme.txt rename to lib/readme.txt diff --git a/airrohr-firmware/oledfont.h b/oledfont.h similarity index 100% rename from airrohr-firmware/oledfont.h rename to oledfont.h diff --git a/perl-scripts/honey_pms.pl b/perl-scripts/honey_pms.pl deleted file mode 100755 index 51d947f11..000000000 --- a/perl-scripts/honey_pms.pl +++ /dev/null @@ -1,84 +0,0 @@ -#! /usr/bin/perl - -# decoding data from Honeywell PM sensor - -use strict; - -my $data_file = shift or die "Usage: $0 \n"; - -open (FILE, $data_file) or die ("Could not open file!"); - -my $len=0; -my $framelength = 0; -my $PM1cf = 0; -my $PM10cf = 0; -my $PM25cf = 0; -my $PM1 = 0; -my $PM10 = 0; -my $PM25 = 0; -my $PM03cnt = 0; -my $PM05cnt = 0; -my $PM1cnt = 0; -my $PM10cnt = 0; -my $PM25cnt = 0; -my $checksum_is = 0; -my $checksum_should = 0; -my $buffer = 0; - -while (1) { - $len = 0; - $PM1 = 0; - $PM10 = 0; - $PM25 = 0; - $checksum_is = 0; - $checksum_should = 0; - while($len!=32){ - read (FILE, $buffer, 1); - printf ("%d Hex Format: %02lX - Dec Format: %d\n",$len,ord($buffer),ord($buffer)); - if ($len==0) { if (ord($buffer) != 66) { $len = -1 }; }; - if ($len==1) { if (ord($buffer) != 77) { $len = -1 }; }; - if ($len==2) { $checksum_is =ord($buffer);$framelength = 256*ord($buffer); }; - if ($len==3) { $checksum_is+=ord($buffer);$framelength += ord($buffer); }; - if ($len==4) { $checksum_is+=ord($buffer); }; - if ($len==5) { $checksum_is+=ord($buffer); }; - if ($len==6) { $checksum_is+=ord($buffer);$PM25 = 256*ord($buffer); }; - if ($len==7) { $checksum_is+=ord($buffer);$PM25 += ord($buffer); }; - if ($len==8) { $checksum_is+=ord($buffer);$PM10 = 256*ord($buffer); }; - if ($len==9) { $checksum_is+=ord($buffer);$PM10 += ord($buffer); }; - if ($len==10) { $checksum_is+=ord($buffer); } - if ($len==11) { $checksum_is+=ord($buffer); } - if ($len==12) { $checksum_is+=ord($buffer); } - if ($len==13) { $checksum_is+=ord($buffer); } - if ($len==14) { $checksum_is+=ord($buffer); } - if ($len==15) { $checksum_is+=ord($buffer); } - if ($len==16) { $checksum_is+=ord($buffer); } - if ($len==17) { $checksum_is+=ord($buffer); } - if ($len==18) { $checksum_is+=ord($buffer); } - if ($len==19) { $checksum_is+=ord($buffer); } - if ($len==20) { $checksum_is+=ord($buffer); } - if ($len==21) { $checksum_is+=ord($buffer); } - if ($len==22) { $checksum_is+=ord($buffer); } - if ($len==23) { $checksum_is+=ord($buffer); } - if ($len==24) { $checksum_is+=ord($buffer); } - if ($len==25) { $checksum_is+=ord($buffer); } - if ($len==26) { $checksum_is+=ord($buffer); } - if ($len==27) { $checksum_is+=ord($buffer); } - if ($len==28) { $checksum_is+=ord($buffer); } - if ($len==29) { $checksum_is+=ord($buffer); } - if ($len==30) { $checksum_should = 256*ord($buffer); } - if ($len==31) { $checksum_should += ord($buffer); } - $len++; - } - - $checksum_is += 143; - - print "PM1: $PM1\n"; - print "PM2.5: $PM25\n"; - print "PM10: $PM10\n"; - print "Checksum is: $checksum_is - Checksum_should: $checksum_should\n"; - -} - -print "\n=====End of Script====="; - -close(FILE); diff --git a/perl-scripts/test_pms1003.pl b/perl-scripts/test_pms1003.pl deleted file mode 100755 index 5953a0dfb..000000000 --- a/perl-scripts/test_pms1003.pl +++ /dev/null @@ -1,84 +0,0 @@ -#! /usr/bin/perl - -# decoding data from Plantronics PMS 1003, PMS 7003 - -use strict; - -my $data_file = shift or die "Usage: $0 \n"; - -open (FILE, $data_file) or die ("Could not open file!"); - -my $len=0; -my $framelength = 0; -my $PM1cf = 0; -my $PM10cf = 0; -my $PM25cf = 0; -my $PM1 = 0; -my $PM10 = 0; -my $PM25 = 0; -my $PM03cnt = 0; -my $PM05cnt = 0; -my $PM1cnt = 0; -my $PM10cnt = 0; -my $PM25cnt = 0; -my $checksum_is = 0; -my $checksum_should = 0; -my $buffer = 0; - -while (1) { - $len = 0; - $PM1 = 0; - $PM10 = 0; - $PM25 = 0; - $checksum_is = 0; - $checksum_should = 0; - while($len!=32){ - read (FILE, $buffer, 1); - printf ("%d Hex Format: %02lX - Dec Format: %d\n",$len,ord($buffer),ord($buffer)); - if ($len==0) { if (ord($buffer) != 66) { $len = -1 }; }; - if ($len==1) { if (ord($buffer) != 77) { $len = -1 }; }; - if ($len==2) { $checksum_is =ord($buffer);$framelength = 256*ord($buffer); }; - if ($len==3) { $checksum_is+=ord($buffer);$framelength += ord($buffer); }; - if ($len==4) { $checksum_is+=ord($buffer);$PM1cf = 256*ord($buffer); }; - if ($len==5) { $checksum_is+=ord($buffer);$PM1cf += ord($buffer); }; - if ($len==6) { $checksum_is+=ord($buffer);$PM25cf = 256*ord($buffer); }; - if ($len==7) { $checksum_is+=ord($buffer);$PM25cf += ord($buffer); }; - if ($len==8) { $checksum_is+=ord($buffer);$PM10cf = 256*ord($buffer); }; - if ($len==9) { $checksum_is+=ord($buffer);$PM10cf += ord($buffer); }; - if ($len==10) { $checksum_is+=ord($buffer);$PM1 = 256*ord($buffer); }; - if ($len==11) { $checksum_is+=ord($buffer);$PM1 += ord($buffer); }; - if ($len==12) { $checksum_is+=ord($buffer);$PM25 = 256*ord($buffer); }; - if ($len==13) { $checksum_is+=ord($buffer);$PM25 += ord($buffer); }; - if ($len==14) { $checksum_is+=ord($buffer);$PM10 = 256*ord($buffer); }; - if ($len==15) { $checksum_is+=ord($buffer);$PM10 += ord($buffer); }; - if ($len==16) { $checksum_is+=ord($buffer);$PM03cnt = 256*ord($buffer); }; - if ($len==17) { $checksum_is+=ord($buffer);$PM03cnt += ord($buffer); }; - if ($len==18) { $checksum_is+=ord($buffer);$PM05cnt = 256*ord($buffer); }; - if ($len==19) { $checksum_is+=ord($buffer);$PM05cnt += ord($buffer); }; - if ($len==20) { $checksum_is+=ord($buffer); } - if ($len==21) { $checksum_is+=ord($buffer); } - if ($len==22) { $checksum_is+=ord($buffer); } - if ($len==23) { $checksum_is+=ord($buffer); } - if ($len==24) { $checksum_is+=ord($buffer); } - if ($len==25) { $checksum_is+=ord($buffer); } - if ($len==26) { $checksum_is+=ord($buffer); } - if ($len==27) { $checksum_is+=ord($buffer); } - if ($len==28) { $checksum_is+=ord($buffer); } - if ($len==29) { $checksum_is+=ord($buffer); } - if ($len==30) { $checksum_should = 256*ord($buffer); } - if ($len==31) { $checksum_should += ord($buffer); } - $len++; - } - - $checksum_is += 143; - - print "PM1: $PM1\n"; - print "PM2.5: $PM25\n"; - print "PM10: $PM10\n"; - print "Checksum is: $checksum_is - Checksum_should: $checksum_should\n"; - -} - -print "\n=====End of Script====="; - -close(FILE); diff --git a/perl-scripts/test_pms3003.pl b/perl-scripts/test_pms3003.pl deleted file mode 100755 index 18bf0603e..000000000 --- a/perl-scripts/test_pms3003.pl +++ /dev/null @@ -1,73 +0,0 @@ -#! /usr/bin/perl -use strict; - -my $data_file = shift or die "Usage: $0 \n"; - -open (FILE, $data_file) or die ("Could not open file!"); - -my $len=0; -my $framelength = 0; -my $PM1cf = 0; -my $PM10cf = 0; -my $PM25cf = 0; -my $PM1 = 0; -my $PM10 = 0; -my $PM25 = 0; -my $PM03cnt = 0; -my $PM05cnt = 0; -my $PM1cnt = 0; -my $PM10cnt = 0; -my $PM25cnt = 0; -my $checksum_is = 0; -my $checksum_should = 0; -my $buffer = 0; - -while (1) { - $len = 0; - $PM1 = 0; - $PM10 = 0; - $PM25 = 0; - $checksum_is = 0; - $checksum_should = 0; - while($len!=24){ - read (FILE, $buffer, 1); - printf ("%d Hex Format: %02lX - Dec Format: %d\n",$len,ord($buffer),ord($buffer)); - if ($len==0) { if (ord($buffer) != 66) { $len = -1 }; }; - if ($len==1) { if (ord($buffer) != 77) { $len = -1 }; }; - if ($len==2) { $checksum_is =ord($buffer);$framelength = 256*ord($buffer); }; - if ($len==3) { $checksum_is+=ord($buffer);$framelength += ord($buffer); }; - if ($len==4) { $checksum_is+=ord($buffer);$PM1cf = 256*ord($buffer); }; - if ($len==5) { $checksum_is+=ord($buffer);$PM1cf += ord($buffer); }; - if ($len==6) { $checksum_is+=ord($buffer);$PM25cf = 256*ord($buffer); }; - if ($len==7) { $checksum_is+=ord($buffer);$PM25cf += ord($buffer); }; - if ($len==8) { $checksum_is+=ord($buffer);$PM10cf = 256*ord($buffer); }; - if ($len==9) { $checksum_is+=ord($buffer);$PM10cf += ord($buffer); }; - if ($len==10) { $checksum_is+=ord($buffer);$PM1 = 256*ord($buffer); }; - if ($len==11) { $checksum_is+=ord($buffer);$PM1 += ord($buffer); }; - if ($len==12) { $checksum_is+=ord($buffer);$PM25 = 256*ord($buffer); }; - if ($len==13) { $checksum_is+=ord($buffer);$PM25 += ord($buffer); }; - if ($len==14) { $checksum_is+=ord($buffer);$PM10 = 256*ord($buffer); }; - if ($len==15) { $checksum_is+=ord($buffer);$PM10 += ord($buffer); }; - if ($len==16) { $checksum_is+=ord($buffer);$PM03cnt = 256*ord($buffer); }; - if ($len==17) { $checksum_is+=ord($buffer);$PM03cnt += ord($buffer); }; - if ($len==18) { $checksum_is+=ord($buffer);$PM05cnt = 256*ord($buffer); }; - if ($len==19) { $checksum_is+=ord($buffer);$PM05cnt += ord($buffer); }; - if ($len==20) { $checksum_is+=ord($buffer); } - if ($len==21) { $checksum_is+=ord($buffer); } - if ($len==22) { $checksum_should = 256*ord($buffer); } - if ($len==23) { $checksum_should += ord($buffer); } - $len++; - } - - $checksum_is += 143; - - print "PM1: $PM1\n"; - print "PM2.5: $PM25\n"; - print "PM10: $PM10\n"; - print "Checksum is: $checksum_is - Checksum_should: $checksum_should\n"; - -} - -print "\n=====End of Script====="; - -close(FILE); diff --git a/perl-scripts/test_sds011.pl b/perl-scripts/test_sds011.pl deleted file mode 100755 index 6d255eb7b..000000000 --- a/perl-scripts/test_sds011.pl +++ /dev/null @@ -1,46 +0,0 @@ -#! /usr/bin/perl -use strict; - -#$data_file="/dev/cu.wchusbserial1410"; - -my $data_file = shift or die "Usage: $0 \n"; - -open (FILE, $data_file) or die ("Could not open file!"); - -my $len=0; -my $PM10 = 0; -my $PM25 = 0; -my $checksum_is = 0; -my $checksum_should = 0; -my $buffer = 0; - -while (1) { - $len = 0; - $PM10 = 0; - $PM25 = 0; - $checksum_is = 0; - $checksum_should = 0; - while($len!=10){ - read (FILE, $buffer, 1); - printf ("%d Hex Format: %02lX - Dec Format: %d\n",$len,ord($buffer),ord($buffer)); - if ($len==0) { if (ord($buffer) != 170) { $len = -1; }; }; - if ($len==1) { if (ord($buffer) != 192) { $len = -1; }; }; - if ($len==2) { $checksum_is+=ord($buffer);$PM25 += ord($buffer); }; - if ($len==3) { $checksum_is+=ord($buffer);$PM25 += 256*ord($buffer); $PM25=$PM25; }; - if ($len==4) { $checksum_is+=ord($buffer);$PM10 += ord($buffer); }; - if ($len==5) { $checksum_is+=ord($buffer);$PM10 += 256*ord($buffer); $PM10=$PM10; }; - if ($len==6) { $checksum_is+=ord($buffer); } - if ($len==7) { $checksum_is+=ord($buffer); } - if ($len==8) { $checksum_should+=ord($buffer); } - $len++; - } - - print "PM2.5: ".($PM25/10)."\n"; - print "PM10: ".($PM10/10)."\n"; - print "Checksum is: $checksum_is - Checksum_should: $checksum_should\n"; - -} - -print "\n=====End of Script====="; - -close(FILE); diff --git a/airrohr-firmware/platformio.ini b/platformio.ini similarity index 100% rename from airrohr-firmware/platformio.ini rename to platformio.ini diff --git a/airrohr-firmware/platformio_script.py b/platformio_script.py similarity index 100% rename from airrohr-firmware/platformio_script.py rename to platformio_script.py diff --git a/airrohr-firmware/ppd42ns-wificonfig-ppd-sds-dht.spiffs.bin b/ppd42ns-wificonfig-ppd-sds-dht.spiffs.bin similarity index 100% rename from airrohr-firmware/ppd42ns-wificonfig-ppd-sds-dht.spiffs.bin rename to ppd42ns-wificonfig-ppd-sds-dht.spiffs.bin diff --git a/r-scripts/.Renviron b/r-scripts/.Renviron deleted file mode 100644 index ad9a609e6..000000000 --- a/r-scripts/.Renviron +++ /dev/null @@ -1,3 +0,0 @@ -#oldpkg <- getOption("defaultPackages"); -#options(defaultPackages = c(oldpkg, "ggplot2","dplyr","timeSeries","forecast","plotly")) -R_DEFAULT_PACKAGES='ggplot2,dplyr,timeSeries,forecast,plotly' diff --git a/r-scripts/Makefile b/r-scripts/Makefile deleted file mode 100644 index c4ddf4062..000000000 --- a/r-scripts/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -R_OPTS=--no-save --no-restore --no-init-file --no-site-file # vanilla, but with --environ - -# TODO: define all targets from source files, if possible - -all: readdata.RData luft.RData readdata_s_mitte.R - -run-scripts: - # run these scripts - -%.pdf: %.Rmd - R ${R_OPTS} -e "library(knitr); knit2pdf('$<')" - -%.pdf: %.rmd - R ${R_OPTS} -e "library(knitr); knit2pdf('$<')" - -%.html: %.rmd - R ${R_OPTS} -e "rmarkdown::render('$<')" - -%.html: %.Rmd - R ${R_OPTS} -e "rmarkdown::render('$<')" - -# Note that you could also use -# R ${R_OPTS} -e "markdown::markdownToHTML('markdown_example.md', 'markdown_example.html')" - -%.R: %.Rmd - R ${R_OPTS} -e "library(knitr);knit('$<',tangle=TRUE)" - -# run R script and save workspace, e.g. -# make gendataexample.RData -%.RData: %.R - R ${R_OPTS} -e 'source("$<"); save(list=ls(),file="$@")' - -# TODO -# clean: -# rm - diff --git a/r-scripts/README.md b/r-scripts/README.md deleted file mode 100644 index 1494ccbb3..000000000 --- a/r-scripts/README.md +++ /dev/null @@ -1,3 +0,0 @@ - -currently working on plots from csv data, which can be fetched with this wget script: [../apiclients/getarchive.sh](../apiclients/getarchive.sh). - diff --git a/r-scripts/TODO.md b/r-scripts/TODO.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/r-scripts/archive.luftdaten.info/00disclamer.md b/r-scripts/archive.luftdaten.info/00disclamer.md deleted file mode 100644 index fb1295adc..000000000 --- a/r-scripts/archive.luftdaten.info/00disclamer.md +++ /dev/null @@ -1,14 +0,0 @@ -# Archive of luftdaten.info / api.dusti.xyz - -## about - -This archive consists of CSV dumps of all outdoor PPD42NS sensor that seem to have valid data. - -## Problems - -Please report problems in our opendata-stuttgart issuetracker: https://github.com/opendata-stuttgart/meta/issues - -## Future improvements - -- description of position of sensor on location -- image of sensor at location diff --git a/r-scripts/data/sampledata.csv b/r-scripts/data/sampledata.csv deleted file mode 100644 index e45d00027..000000000 --- a/r-scripts/data/sampledata.csv +++ /dev/null @@ -1,300 +0,0 @@ -timestamp,type,indoor,location_id,sampling_rate,P1,P2,durP1,durP2,ratioP1,ratioP2,temperature,humidity,pressure,altitude,pressure_sealevel,brightness,dust_density,vo_raw,voltage,P10,P25,durP10,durP25,ratioP10,ratioP25 -2015-05-05 08:15:59.847276+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,16655.81,3513.72,2906824,972924,19.38,6.49 -2015-05-05 08:15:44.635833+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,28522.88,4473.86,3794072,1198488,25.29,7.99 -2015-05-05 08:15:29.426569+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15669.34,3569.94,2812860,986724,18.75,6.58 -2015-05-05 08:15:14.215062+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12730.82,3104.04,2503032,870160,16.69,5.80 -2015-05-05 08:14:59.003782+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14017.50,3551.84,2644788,982288,17.63,6.55 -2015-05-05 08:14:43.795172+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14654.00,3499.72,2711264,969476,18.08,6.46 -2015-05-05 08:14:28.587472+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,11382.61,3232.02,2342328,902680,15.62,6.02 -2015-05-05 08:14:13.374861+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,11994.71,3027.35,2416972,850496,16.11,5.67 -2015-05-05 08:13:58.163716+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13236.80,3318.26,2560024,924380,17.07,6.16 -2015-05-05 08:13:42.955626+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13134.64,3496.96,2548652,968796,16.99,6.46 -2015-05-05 08:13:27.747796+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12080.13,3061.42,2427160,859248,16.18,5.73 -2015-05-05 08:13:12.536725+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13187.93,3960.95,2554592,1080648,17.03,7.20 -2015-05-05 08:12:57.323005+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12409.39,3058.44,2465928,858484,16.44,5.72 -2015-05-05 08:12:42.111640+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14310.75,3640.22,2675696,1003868,17.84,6.69 -2015-05-05 08:12:26.906133+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12022.30,2602.99,2420268,739320,16.14,4.93 -2015-05-05 08:12:11.691216+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,11961.63,3174.79,2413012,888184,16.09,5.92 -2015-05-05 08:11:56.480045+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,11904.76,3318.15,2406184,924352,16.04,6.16 -2015-05-05 08:11:41.272567+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14927.72,3440.10,2739172,954744,18.26,6.36 -2015-05-05 08:11:26.061052+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14494.91,3539.82,2694860,979340,17.97,6.53 -2015-05-05 08:11:10.852364+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14609.72,3515.38,2706712,973332,18.04,6.49 -2015-05-05 08:10:55.641010+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13690.81,3717.87,2609768,1022676,17.40,6.82 -2015-05-05 08:10:40.432068+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12981.51,2931.16,2531480,825644,16.88,5.50 -2015-05-05 08:10:25.220743+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14127.96,3689.97,2656488,1015936,17.71,6.77 -2015-05-05 08:10:10.008948+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,18351.57,3648.68,3058768,1005924,20.39,6.71 -2015-05-05 08:09:54.800091+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14787.64,3492.74,2724940,967756,18.17,6.45 -2015-05-05 08:09:39.588713+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,18775.34,3154.54,3095036,883036,20.63,5.89 -2015-05-05 08:09:24.376809+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14704.39,3061.89,2716432,859368,18.11,5.73 -2015-05-05 08:09:09.168473+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,16089.01,3549.93,2853376,981820,19.02,6.55 -2015-05-05 08:08:53.956821+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12374.49,3008.88,2461856,845740,16.41,5.64 -2015-05-05 08:08:38.749043+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13621.06,3702.63,2602208,1018996,17.35,6.79 -2015-05-05 08:08:23.537203+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,18304.13,3576.32,3054668,988284,20.36,6.59 -2015-05-05 08:08:08.325756+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15531.32,3346.84,2799352,931532,18.66,6.21 -2015-05-05 08:07:53.116754+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15054.28,3810.12,2751944,1044840,18.35,6.97 -2015-05-05 08:07:37.905465+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15110.48,3527.66,2757588,976352,18.38,6.51 -2015-05-05 08:07:22.696484+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15372.52,3713.97,2783696,1021736,18.56,6.81 -2015-05-05 08:07:07.484829+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,16432.97,3744.92,2885980,1029196,19.24,6.86 -2015-05-05 08:06:52.273033+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13254.14,3027.24,2561948,850468,17.08,5.67 -2015-05-05 08:06:37.065732+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15125.64,3841.90,2759108,1052428,18.39,7.02 -2015-05-05 08:06:21.853667+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14873.51,3548.74,2733676,981528,18.22,6.54 -2015-05-05 08:06:06.641623+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14070.73,3623.70,2650436,999848,17.67,6.67 -2015-05-05 08:05:51.432748+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15095.25,3559.95,2756060,984276,18.37,6.56 -2015-05-05 08:05:36.221536+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15685.02,4060.55,2814388,1104004,18.76,7.36 -2015-05-05 08:05:21.009751+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14922.47,3699.48,2738640,1018236,18.26,6.79 -2015-05-05 08:05:05.801315+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15526.55,3226.29,2798884,901232,18.66,6.01 -2015-05-05 08:04:50.589918+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13359.51,3510.53,2573596,972140,17.16,6.48 -2015-05-05 08:04:35.381014+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14610.66,3478.12,2706808,964148,18.05,6.43 -2015-05-05 08:04:20.170226+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13949.51,3526.63,2637552,976100,17.58,6.51 -2015-05-05 08:04:04.961268+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15230.74,3748.08,2769612,1029956,18.46,6.87 -2015-05-05 08:03:49.750359+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13943.58,3410.71,2636920,947452,17.58,6.32 -2015-05-05 08:03:34.539083+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12246.37,3315.33,2446832,923644,16.31,6.16 -2015-05-05 08:03:19.327196+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14976.42,3213.73,2744096,898056,18.29,5.99 -2015-05-05 08:03:04.119030+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13604.49,3406.35,2600408,946368,17.34,6.31 -2015-05-05 08:02:48.910494+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14185.81,3336.36,2662588,928912,17.75,6.19 -2015-05-05 08:02:33.698878+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15685.60,3519.73,2814444,974404,18.76,6.50 -2015-05-05 08:02:18.490477+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,17986.16,3695.50,3026972,1017272,20.18,6.78 -2015-05-05 08:02:03.278640+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,16636.57,3602.63,2905032,994712,19.37,6.63 -2015-05-05 08:01:48.066729+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,19128.39,3189.17,3124772,891832,20.83,5.95 -2015-05-05 08:01:32.859209+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12524.79,3162.16,2479332,884976,16.53,5.90 -2015-05-05 08:01:17.648030+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,16854.28,3285.51,2925208,916160,19.50,6.11 -2015-05-05 08:01:02.439924+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,19356.69,5143.81,3143776,1343540,20.96,8.96 -2015-05-05 08:00:47.227051+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,17122.36,3986.78,2949776,1086728,19.67,7.24 -2015-05-05 08:00:32.016398+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,16495.93,4539.66,2891892,1213172,19.28,8.09 -2015-05-05 08:00:16.806951+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,16220.05,4216.82,2865860,1140188,19.11,7.60 -2015-05-05 08:00:01.595814+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,16018.60,3192.15,2846636,892588,18.98,5.95 -2015-05-05 07:59:46.384304+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,11194.17,2969.04,2318744,835456,15.46,5.57 -2015-05-05 07:59:31.175586+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13549.38,3581.16,2594408,989468,17.30,6.60 -2015-05-05 07:59:15.963926+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12427.38,3221.18,2468024,899940,16.45,6.00 -2015-05-05 07:59:00.755554+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13377.93,3055.74,2575624,857792,17.17,5.72 -2015-05-05 07:58:45.544093+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12639.05,3061.75,2492512,859332,16.62,5.73 -2015-05-05 07:58:30.335997+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14323.72,3153.91,2677052,882876,17.85,5.89 -2015-05-05 07:58:15.124818+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12574.56,3420.39,2485084,949856,16.57,6.33 -2015-05-05 07:57:59.916087+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13655.39,3480.45,2605932,964724,17.37,6.43 -2015-05-05 07:57:44.704924+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,10690.80,2820.04,2254264,796676,15.03,5.31 -2015-05-05 07:57:29.496228+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14805.90,3355.83,2726800,933780,18.18,6.23 -2015-05-05 07:57:14.284746+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14724.64,3159.52,2718504,884304,18.12,5.90 -2015-05-05 07:56:59.075649+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,11651.57,3744.80,2375488,1029168,15.84,6.86 -2015-05-05 07:56:43.864866+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14400.01,3241.13,2685008,904980,17.90,6.03 -2015-05-05 07:56:28.652978+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14084.52,3379.00,2651896,939560,17.68,6.26 -2015-05-05 07:56:13.444290+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13403.85,3290.78,2578476,917484,17.19,6.12 -2015-05-05 07:55:58.232980+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12560.22,2957.03,2483428,832348,16.56,5.55 -2015-05-05 07:55:43.024697+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12842.28,3762.37,2515732,1033392,16.77,6.89 -2015-05-05 07:55:27.812758+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12857.29,3052.16,2517436,856872,16.78,5.71 -2015-05-05 07:55:12.601291+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14628.15,3181.49,2708608,889884,18.06,5.93 -2015-05-05 07:54:57.392805+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14022.88,3575.14,2645360,987996,17.64,6.59 -2015-05-05 07:54:42.185576+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12365.04,3235.06,2460752,903448,16.41,6.02 -2015-05-05 07:54:26.972862+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14627.41,2861.19,2708532,807436,18.06,5.38 -2015-05-05 07:54:11.761278+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,10341.65,2757.68,2208208,780300,14.72,5.20 -2015-05-05 07:53:56.552581+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,10366.51,2964.73,2211524,834340,14.74,5.56 -2015-05-05 07:53:41.342085+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,12747.94,3604.30,2504988,995120,16.70,6.63 -2015-05-05 07:53:26.133667+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15351.96,3365.56,2781660,936208,18.54,6.24 -2015-05-05 07:53:10.921923+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13824.09,3430.26,2624132,952304,17.49,6.35 -2015-05-05 07:52:55.710395+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13052.93,3318.87,2539508,924532,16.93,6.16 -2015-05-05 07:52:40.502163+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,14690.84,3466.67,2715044,961320,18.10,6.41 -2015-05-05 07:52:25.289371+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,13686.16,3304.69,2609264,920976,17.40,6.14 -2015-05-05 07:52:10.081880+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,11051.58,3198.49,2300700,894196,15.34,5.96 -2015-05-05 07:51:54.870408+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,17526.92,3821.90,2986296,1047656,19.91,6.98 -2015-05-05 07:51:39.661422+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15608.33,3319.62,2806900,924720,18.71,6.16 -2015-05-05 07:51:24.449844+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15258.72,3900.04,2772400,1066252,18.48,7.11 -2015-05-05 07:51:09.238313+00:00,dsm501a,True,4,15000,,,,,,,,,,,,,,,,15131.79,3671.43,2759724,1011444,18.40,6.74 -2015-05-05 08:16:08.785643+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.06,197.00,0.96,,,,,, -2015-05-05 08:16:07.787974+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,163.00,0.80,,,,,, -2015-05-05 08:16:06.891019+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,148.00,0.72,,,,,, -2015-05-05 08:16:05.747148+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,160.00,0.78,,,,,, -2015-05-05 08:16:04.732423+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,146.00,0.71,,,,,, -2015-05-05 08:16:03.749072+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,169.00,0.83,,,,,, -2015-05-05 08:16:02.769387+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,156.00,0.76,,,,,, -2015-05-05 08:16:02.281653+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,172.00,0.84,,,,,, -2015-05-05 08:16:00.680902+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.01,138.00,0.67,,,,,, -2015-05-05 08:15:59.683073+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,166.00,0.81,,,,,, -2015-05-05 08:15:58.654590+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,146.00,0.71,,,,,, -2015-05-05 08:15:57.641166+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,146.00,0.71,,,,,, -2015-05-05 08:15:56.628379+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,156.00,0.76,,,,,, -2015-05-05 08:15:55.615663+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,156.00,0.76,,,,,, -2015-05-05 08:15:54.601595+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,160.00,0.78,,,,,, -2015-05-05 08:15:53.588816+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,165.00,0.81,,,,,, -2015-05-05 08:15:52.576731+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,154.00,0.75,,,,,, -2015-05-05 08:15:51.562752+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,167.00,0.82,,,,,, -2015-05-05 08:15:50.551588+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,161.00,0.79,,,,,, -2015-05-05 08:15:49.536798+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,155.00,0.76,,,,,, -2015-05-05 08:15:48.525155+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.05,175.00,0.85,,,,,, -2015-05-05 08:15:47.511771+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,157.00,0.77,,,,,, -2015-05-05 08:15:46.497825+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,157.00,0.77,,,,,, -2015-05-05 08:15:45.486474+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,153.00,0.75,,,,,, -2015-05-05 08:15:44.488568+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,155.00,0.76,,,,,, -2015-05-05 08:15:43.458616+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,148.00,0.72,,,,,, -2015-05-05 08:15:42.446907+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,153.00,0.75,,,,,, -2015-05-05 08:15:41.432080+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.05,180.00,0.88,,,,,, -2015-05-05 08:15:40.420297+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,166.00,0.81,,,,,, -2015-05-05 08:15:39.407606+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,147.00,0.72,,,,,, -2015-05-05 08:15:38.393640+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,163.00,0.80,,,,,, -2015-05-05 08:15:37.381668+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,157.00,0.77,,,,,, -2015-05-05 08:15:36.368651+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,142.00,0.69,,,,,, -2015-05-05 08:15:35.354812+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,144.00,0.70,,,,,, -2015-05-05 08:15:34.374228+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,140.00,0.68,,,,,, -2015-05-05 08:15:33.348950+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,160.00,0.78,,,,,, -2015-05-05 08:15:32.338170+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,146.00,0.71,,,,,, -2015-05-05 08:15:31.302274+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,162.00,0.79,,,,,, -2015-05-05 08:15:30.289726+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,165.00,0.81,,,,,, -2015-05-05 08:15:29.292581+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,169.00,0.83,,,,,, -2015-05-05 08:15:28.264352+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,158.00,0.77,,,,,, -2015-05-05 08:15:27.250873+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,152.00,0.74,,,,,, -2015-05-05 08:15:26.236420+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,157.00,0.77,,,,,, -2015-05-05 08:15:25.224620+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,173.00,0.84,,,,,, -2015-05-05 08:15:24.210639+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,147.00,0.72,,,,,, -2015-05-05 08:15:23.197032+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,158.00,0.77,,,,,, -2015-05-05 08:15:22.184634+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,158.00,0.77,,,,,, -2015-05-05 08:15:21.170095+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,166.00,0.81,,,,,, -2015-05-05 08:15:20.158473+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,158.00,0.77,,,,,, -2015-05-05 08:15:19.145092+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,157.00,0.77,,,,,, -2015-05-05 08:15:18.130389+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,160.00,0.78,,,,,, -2015-05-05 08:15:17.118895+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,159.00,0.78,,,,,, -2015-05-05 08:15:16.105094+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.01,135.00,0.66,,,,,, -2015-05-05 08:15:15.092544+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,156.00,0.76,,,,,, -2015-05-05 08:15:14.096413+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,158.00,0.77,,,,,, -2015-05-05 08:15:13.065606+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,161.00,0.79,,,,,, -2015-05-05 08:15:12.053550+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,158.00,0.77,,,,,, -2015-05-05 08:15:11.041549+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,173.00,0.84,,,,,, -2015-05-05 08:15:10.028215+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,149.00,0.73,,,,,, -2015-05-05 08:15:09.013499+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,160.00,0.78,,,,,, -2015-05-05 08:15:08.001414+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,159.00,0.78,,,,,, -2015-05-05 08:15:06.986781+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,148.00,0.72,,,,,, -2015-05-05 08:15:05.975465+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,153.00,0.75,,,,,, -2015-05-05 08:15:04.961467+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,150.00,0.73,,,,,, -2015-05-05 08:15:03.949245+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,157.00,0.77,,,,,, -2015-05-05 08:15:02.935633+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,155.00,0.76,,,,,, -2015-05-05 08:15:01.922654+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,158.00,0.77,,,,,, -2015-05-05 08:15:00.909451+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,167.00,0.82,,,,,, -2015-05-05 08:14:59.896781+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,171.00,0.83,,,,,, -2015-05-05 08:14:58.897169+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,167.00,0.82,,,,,, -2015-05-05 08:14:57.870485+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,155.00,0.76,,,,,, -2015-05-05 08:14:56.858041+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,162.00,0.79,,,,,, -2015-05-05 08:14:55.844151+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,169.00,0.83,,,,,, -2015-05-05 08:14:54.830009+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,170.00,0.83,,,,,, -2015-05-05 08:14:53.818305+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,164.00,0.80,,,,,, -2015-05-05 08:14:52.804291+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,159.00,0.78,,,,,, -2015-05-05 08:14:51.790312+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,170.00,0.83,,,,,, -2015-05-05 08:14:50.778523+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,162.00,0.79,,,,,, -2015-05-05 08:14:49.765706+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,165.00,0.81,,,,,, -2015-05-05 08:14:48.751935+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,162.00,0.79,,,,,, -2015-05-05 08:14:47.739428+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,165.00,0.81,,,,,, -2015-05-05 08:14:46.725544+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,165.00,0.81,,,,,, -2015-05-05 08:14:45.713473+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,162.00,0.79,,,,,, -2015-05-05 08:14:44.700650+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,145.00,0.71,,,,,, -2015-05-05 08:14:43.705650+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.01,134.00,0.65,,,,,, -2015-05-05 08:14:42.672647+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,153.00,0.75,,,,,, -2015-05-05 08:14:41.660431+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,165.00,0.81,,,,,, -2015-05-05 08:14:40.647329+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,164.00,0.80,,,,,, -2015-05-05 08:14:39.633216+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,158.00,0.77,,,,,, -2015-05-05 08:14:38.621741+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,166.00,0.81,,,,,, -2015-05-05 08:14:37.607283+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,158.00,0.77,,,,,, -2015-05-05 08:14:36.595630+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,144.00,0.70,,,,,, -2015-05-05 08:14:35.582094+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,163.00,0.80,,,,,, -2015-05-05 08:14:34.567227+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,173.00,0.84,,,,,, -2015-05-05 08:14:33.556477+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,166.00,0.81,,,,,, -2015-05-05 08:14:32.542560+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,161.00,0.79,,,,,, -2015-05-05 08:14:31.527978+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.03,158.00,0.77,,,,,, -2015-05-05 08:14:30.516397+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,145.00,0.71,,,,,, -2015-05-05 08:14:29.502226+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.04,165.00,0.81,,,,,, -2015-05-05 08:14:28.505479+00:00,GP2Y1010AU0F,True,4,40,,,,,,,,,,,,,0.02,147.00,0.72,,,,,, -2015-05-05 08:15:53.652791+00:00,PPD42NS,True,4,15000,18060.31,472.75,3033464,136864,20.22,0.91,,,,,,,,,,,,,,, -2015-05-05 08:15:37.591676+00:00,PPD42NS,True,4,15000,10973.20,1140.35,2290708,330696,15.27,2.20,,,,,,,,,,,,,,, -2015-05-05 08:15:21.531012+00:00,PPD42NS,True,4,15000,9031.82,694.32,2024608,201312,13.50,1.34,,,,,,,,,,,,,,, -2015-05-05 08:15:05.471808+00:00,PPD42NS,True,4,15000,6748.41,709.72,1654212,205792,11.03,1.37,,,,,,,,,,,,,,, -2015-05-05 08:14:49.408673+00:00,PPD42NS,True,4,15000,9180.91,861.82,2046436,250000,13.64,1.67,,,,,,,,,,,,,,, -2015-05-05 08:14:33.347157+00:00,PPD42NS,True,4,15000,6627.27,212.59,1632392,61308,10.88,0.41,,,,,,,,,,,,,,, -2015-05-05 08:14:17.284144+00:00,PPD42NS,True,4,15000,8683.26,481.20,1972564,139320,13.15,0.93,,,,,,,,,,,,,,, -2015-05-05 08:14:01.223079+00:00,PPD42NS,True,4,15000,16169.20,265.25,2861024,76580,19.07,0.51,,,,,,,,,,,,,,, -2015-05-05 08:13:45.160235+00:00,PPD42NS,True,4,15000,7369.07,1025.75,1762268,297548,11.75,1.98,,,,,,,,,,,,,,, -2015-05-05 08:13:29.099202+00:00,PPD42NS,True,4,15000,6334.35,443.15,1578596,128256,10.52,0.86,,,,,,,,,,,,,,, -2015-05-05 08:13:13.037600+00:00,PPD42NS,True,4,15000,8243.71,648.26,1904808,187916,12.70,1.25,,,,,,,,,,,,,,, -2015-05-05 08:12:56.977150+00:00,PPD42NS,True,4,15000,7835.02,180.38,1839540,51972,12.26,0.35,,,,,,,,,,,,,,, -2015-05-05 08:12:40.916799+00:00,PPD42NS,True,4,15000,7172.74,813.48,1728744,235956,11.52,1.57,,,,,,,,,,,,,,, -2015-05-05 08:12:24.856448+00:00,PPD42NS,True,4,15000,6508.96,74.62,1610844,21368,10.74,0.14,,,,,,,,,,,,,,, -2015-05-05 08:12:08.795162+00:00,PPD42NS,True,4,15000,6610.50,324.40,1629352,93748,10.86,0.62,,,,,,,,,,,,,,, -2015-05-05 08:11:52.732573+00:00,PPD42NS,True,4,15000,6744.61,851.18,1653532,246908,11.02,1.65,,,,,,,,,,,,,,, -2015-05-05 08:11:36.672057+00:00,PPD42NS,True,4,15000,7085.21,332.79,1713604,,11.42,0.64,,,,,,,,,,,,,,, -2015-05-05 08:11:20.609985+00:00,PPD42NS,True,4,15000,6655.72,633.59,1637540,183648,10.92,1.22,,,,,,,,,,,,,,, -2015-05-05 08:11:04.548396+00:00,PPD42NS,True,4,15000,7434.96,762.11,1773388,221024,11.82,1.47,,,,,,,,,,,,,,, -2015-05-05 08:10:48.487666+00:00,PPD42NS,True,4,15000,6322.95,,1576472,93312,10.51,0.62,,,,,,,,,,,,,,, -2015-05-05 08:10:32.425754+00:00,PPD42NS,True,4,15000,15485.83,0.62,2794880,0,18.63,0.00,,,,,,,,,,,,,,, -2015-05-05 08:10:16.366296+00:00,PPD42NS,True,4,15000,6240.18,291.73,1560980,84264,10.41,0.56,,,,,,,,,,,,,,, -2015-05-05 08:10:00.304462+00:00,PPD42NS,True,4,15000,6613.63,0.62,1629920,0,10.87,0.00,,,,,,,,,,,,,,, -2015-05-05 08:09:44.245072+00:00,PPD42NS,True,4,15000,7288.21,544.46,1748532,157720,11.66,1.05,,,,,,,,,,,,,,, -2015-05-05 08:09:28.182253+00:00,PPD42NS,True,4,15000,,0.62,1768704,0,11.79,0.00,,,,,,,,,,,,,,, -2015-05-05 08:09:12.121973+00:00,PPD42NS,True,4,15000,6598.57,359.28,1627188,103880,10.85,0.69,,,,,,,,,,,,,,, -2015-05-05 08:08:56.060432+00:00,PPD42NS,True,4,15000,14372.74,0.62,2682168,0,17.88,0.00,,,,,,,,,,,,,,, -2015-05-05 08:08:40.001146+00:00,PPD42NS,True,4,15000,14841.77,644.33,2730452,186772,18.20,1.25,,,,,,,,,,,,,,, -2015-05-05 08:08:23.938119+00:00,PPD42NS,True,4,15000,7090.27,580.28,1714484,168140,11.43,1.12,,,,,,,,,,,,,,, -2015-05-05 08:08:07.875470+00:00,PPD42NS,True,4,15000,7339.64,0.62,1757280,0,11.72,0.00,,,,,,,,,,,,,,, -2015-05-05 08:07:51.815667+00:00,PPD42NS,True,4,15000,8189.86,952.50,1896336,276316,12.64,1.84,,,,,,,,,,,,,,, -2015-05-05 08:07:35.755389+00:00,PPD42NS,True,4,15000,7561.87,429.94,1794624,124416,11.96,0.83,,,,,,,,,,,,,,, -2015-05-05 08:07:19.693213+00:00,PPD42NS,True,4,15000,7547.04,518.58,1792156,150192,11.95,1.00,,,,,,,,,,,,,,, -2015-05-05 08:07:03.631448+00:00,PPD42NS,True,4,15000,7365.93,821.77,1761736,238364,11.74,1.59,,,,,,,,,,,,,,, -2015-05-05 08:06:47.573833+00:00,PPD42NS,True,4,15000,6951.45,178.06,1690236,51300,11.27,0.34,,,,,,,,,,,,,,, -2015-05-05 08:06:31.508709+00:00,PPD42NS,True,4,15000,8791.90,1052.69,1988940,305348,13.26,2.04,,,,,,,,,,,,,,, -2015-05-05 08:06:15.445496+00:00,PPD42NS,True,4,15000,5967.60,321.06,1509084,92780,10.06,0.62,,,,,,,,,,,,,,, -2015-05-05 08:05:59.385219+00:00,PPD42NS,True,4,15000,6992.30,243.54,1697404,70280,11.32,0.47,,,,,,,,,,,,,,, -2015-05-05 08:05:43.323202+00:00,PPD42NS,True,4,15000,6991.09,450.90,1697192,130508,11.31,0.87,,,,,,,,,,,,,,, -2015-05-05 08:05:27.263351+00:00,PPD42NS,True,4,15000,7176.04,237.85,1729312,68632,11.53,0.46,,,,,,,,,,,,,,, -2015-05-05 08:05:11.200326+00:00,PPD42NS,True,4,15000,7148.58,,1724576,71072,11.50,0.47,,,,,,,,,,,,,,, -2015-05-05 08:04:55.139757+00:00,PPD42NS,True,4,15000,16401.21,519.21,2882992,150376,19.22,1.00,,,,,,,,,,,,,,, -2015-05-05 08:04:39.077065+00:00,PPD42NS,True,4,15000,6161.22,262.91,1546088,75900,10.31,0.51,,,,,,,,,,,,,,, -2015-05-05 08:04:23.016566+00:00,PPD42NS,True,4,15000,7017.73,292.31,1701852,84432,11.35,0.56,,,,,,,,,,,,,,, -2015-05-05 08:04:06.956241+00:00,PPD42NS,True,4,15000,14762.59,304.23,2722384,87892,18.15,0.59,,,,,,,,,,,,,,, -2015-05-05 08:03:50.896043+00:00,PPD42NS,True,4,15000,6074.75,314.88,1529648,90984,10.20,0.61,,,,,,,,,,,,,,, -2015-05-05 08:03:34.832675+00:00,PPD42NS,True,4,15000,7754.34,263.92,1826384,76192,12.18,0.51,,,,,,,,,,,,,,, -2015-05-05 08:03:18.769698+00:00,PPD42NS,True,4,15000,5294.12,502.19,1374764,145424,9.17,0.97,,,,,,,,,,,,,,, -2015-05-05 08:03:02.708364+00:00,PPD42NS,True,4,15000,7328.14,396.89,1755328,114808,11.70,0.77,,,,,,,,,,,,,,, -2015-05-05 08:02:46.646314+00:00,PPD42NS,True,4,15000,6748.95,237.30,1654308,68472,11.03,0.46,,,,,,,,,,,,,,, -2015-05-05 08:02:30.583076+00:00,PPD42NS,True,4,15000,7012.40,234.56,1700920,67676,11.34,0.45,,,,,,,,,,,,,,, -2015-05-05 08:02:14.521072+00:00,PPD42NS,True,4,15000,7434.46,301.47,1773304,87092,11.82,0.58,,,,,,,,,,,,,,, -2015-05-05 08:01:58.459735+00:00,PPD42NS,True,4,15000,7321.36,300.32,1754176,86756,11.69,0.58,,,,,,,,,,,,,,, -2015-05-05 08:01:42.399430+00:00,PPD42NS,True,4,15000,7146.14,288.92,1724156,83448,11.49,0.56,,,,,,,,,,,,,,, -2015-05-05 08:01:26.337841+00:00,PPD42NS,True,4,15000,6473.19,548.64,1604280,158936,10.70,1.06,,,,,,,,,,,,,,, -2015-05-05 08:01:10.277576+00:00,PPD42NS,True,4,15000,14030.23,212.88,2646140,61392,17.64,0.41,,,,,,,,,,,,,,, -2015-05-05 08:00:54.217136+00:00,PPD42NS,True,4,15000,6729.33,300.85,1650792,86912,11.01,0.58,,,,,,,,,,,,,,, -2015-05-05 08:00:38.154787+00:00,PPD42NS,True,4,15000,6620.07,329.58,1631088,95252,10.87,0.64,,,,,,,,,,,,,,, -2015-05-05 08:00:22.092329+00:00,PPD42NS,True,4,15000,8049.99,949.21,1874152,275364,12.49,1.84,,,,,,,,,,,,,,, -2015-05-05 08:00:06.030593+00:00,PPD42NS,True,4,15000,5996.88,313.83,1514724,90680,10.10,0.60,,,,,,,,,,,,,,, -2015-05-05 07:59:49.968737+00:00,PPD42NS,True,4,15000,6221.91,91.07,1557544,26124,10.38,0.17,,,,,,,,,,,,,,, -2015-05-05 07:59:33.918544+00:00,PPD42NS,True,4,15000,16144.50,753.73,2858672,218588,19.06,1.46,,,,,,,,,,,,,,, -2015-05-05 07:59:17.846155+00:00,PPD42NS,True,4,15000,6196.08,381.87,1552676,110444,10.35,0.74,,,,,,,,,,,,,,, -2015-05-05 07:59:01.784061+00:00,PPD42NS,True,4,15000,6750.42,264.89,1654572,76476,11.03,0.51,,,,,,,,,,,,,,, -2015-05-05 07:58:45.723962+00:00,PPD42NS,True,4,15000,6624.26,70.73,1631848,20244,10.88,0.13,,,,,,,,,,,,,,, -2015-05-05 07:58:29.662149+00:00,PPD42NS,True,4,15000,5878.15,107.78,1491752,30956,9.95,0.21,,,,,,,,,,,,,,, -2015-05-05 07:58:13.601690+00:00,PPD42NS,True,4,15000,6637.74,944.21,1634288,273912,10.90,1.83,,,,,,,,,,,,,,, -2015-05-05 07:57:57.541107+00:00,PPD42NS,True,4,15000,5975.25,132.85,1510560,38208,10.07,0.25,,,,,,,,,,,,,,, -2015-05-05 07:57:41.480988+00:00,PPD42NS,True,4,15000,15823.56,845.16,2827844,245160,18.85,1.63,,,,,,,,,,,,,,, -2015-05-05 07:57:25.419501+00:00,PPD42NS,True,4,15000,6943.85,494.25,1688900,143116,11.26,0.95,,,,,,,,,,,,,,, -2015-05-05 07:57:09.357375+00:00,PPD42NS,True,4,15000,5914.70,133.47,1498852,38388,9.99,0.26,,,,,,,,,,,,,,, -2015-05-05 07:56:53.295739+00:00,PPD42NS,True,4,15000,6631.04,433.62,1633076,125484,10.89,0.84,,,,,,,,,,,,,,, -2015-05-05 07:56:37.233668+00:00,PPD42NS,True,4,15000,7041.73,543.28,1706040,157376,11.37,1.05,,,,,,,,,,,,,,, -2015-05-05 07:56:21.171581+00:00,PPD42NS,True,4,15000,6285.36,704.37,1569452,204236,10.46,1.36,,,,,,,,,,,,,,, -2015-05-05 07:56:05.109987+00:00,PPD42NS,True,4,15000,6583.94,0.62,1624528,0,10.83,0.00,,,,,,,,,,,,,,, -2015-05-05 07:55:49.050888+00:00,PPD42NS,True,4,15000,15659.83,171.31,2811932,49344,18.75,0.33,,,,,,,,,,,,,,, -2015-05-05 07:55:32.990231+00:00,PPD42NS,True,4,15000,6434.43,114.96,1597144,33032,10.65,0.22,,,,,,,,,,,,,,, -2015-05-05 07:55:16.930056+00:00,PPD42NS,True,4,15000,,344.04,1764440,99452,11.76,0.66,,,,,,,,,,,,,,, -2015-05-05 07:55:00.867301+00:00,PPD42NS,True,4,15000,6918.61,928.67,1684456,269404,11.23,1.80,,,,,,,,,,,,,,, -2015-05-05 07:54:44.804600+00:00,PPD42NS,True,4,15000,6329.54,155.37,1577700,44728,10.52,0.30,,,,,,,,,,,,,,, -2015-05-05 07:54:28.742713+00:00,PPD42NS,True,4,15000,6440.02,651.79,1598176,188944,10.65,1.26,,,,,,,,,,,,,,, -2015-05-05 07:54:12.680415+00:00,PPD42NS,True,4,15000,5768.14,153.61,1470228,44220,9.80,0.29,,,,,,,,,,,,,,, -2015-05-05 07:53:56.621355+00:00,PPD42NS,True,4,15000,15464.55,474.80,2792784,137460,18.62,0.92,,,,,,,,,,,,,,, -2015-05-05 07:53:40.558344+00:00,PPD42NS,True,4,15000,6740.11,702.16,1652724,203592,11.02,1.36,,,,,,,,,,,,,,, -2015-05-05 07:53:24.496260+00:00,PPD42NS,True,4,15000,6398.04,294.21,1590420,84984,10.60,0.57,,,,,,,,,,,,,,, -2015-05-05 07:53:08.435849+00:00,PPD42NS,True,4,15000,7928.32,550.84,1854640,159576,12.36,1.06,,,,,,,,,,,,,,, -2015-05-05 07:52:52.374188+00:00,PPD42NS,True,4,15000,7157.45,626.48,1726108,181580,11.51,,,,,,,,,,,,,,,, -2015-05-05 07:52:36.313871+00:00,PPD42NS,True,4,15000,6812.70,479.60,1665692,138856,11.10,0.93,,,,,,,,,,,,,,, -2015-05-05 07:52:20.251114+00:00,PPD42NS,True,4,15000,6910.72,0.62,1683064,0,11.22,0.00,,,,,,,,,,,,,,, -2015-05-05 07:52:04.190615+00:00,PPD42NS,True,4,15000,7221.89,604.41,1737192,175160,11.58,1.17,,,,,,,,,,,,,,, -2015-05-05 07:51:48.128391+00:00,PPD42NS,True,4,15000,7518.92,531.48,1787464,153944,11.92,1.03,,,,,,,,,,,,,,, -2015-05-05 07:51:32.068226+00:00,PPD42NS,True,4,15000,7886.83,124.53,1847940,35800,12.32,0.24,,,,,,,,,,,,,,, -2015-05-05 07:51:16.005486+00:00,PPD42NS,True,4,15000,8371.56,632.61,1924768,183364,12.83,1.22,,,,,,,,,,,,,,, -2015-05-05 07:50:59.944938+00:00,PPD42NS,True,4,15000,7660.68,201.53,1810996,58100,12.07,0.39,,,,,,,,,,,,,,, -2015-05-05 07:50:43.883950+00:00,PPD42NS,True,4,15000,7934.05,781.96,1855564,226796,12.37,1.51,,,,,,,,,,,,,,, -2015-05-05 07:50:27.822111+00:00,PPD42NS,True,4,15000,8512.43,157.14,1946520,45240,12.98,0.30,,,,,,,,,,,,,,, -2015-05-05 07:50:11.762732+00:00,PPD42NS,True,4,15000,15413.34,290.17,2787732,83812,18.58,0.56,,,,,,,,,,,,,,, -2015-05-05 07:49:55.699597+00:00,PPD42NS,True,4,15000,7703.73,558.55,1818084,161820,12.12,1.08,,,,,,,,,,,,,,, -2015-05-05 07:49:39.639496+00:00,PPD42NS,True,4,15000,6874.58,0.62,1676676,0,11.18,0.00,,,,,,,,,,,,,,, -2015-05-05 07:49:23.578835+00:00,PPD42NS,True,4,15000,7250.78,811.47,1742140,235372,11.61,1.57,,,,,,,,,,,,,,, diff --git a/r-scripts/installrequire.R b/r-scripts/installrequire.R deleted file mode 100644 index ba37eb022..000000000 --- a/r-scripts/installrequire.R +++ /dev/null @@ -1,10 +0,0 @@ -# function to require packages. Installs them, if necessary -# @parameter packagelist a vector of character strings with the package names -installrequire<-function(packagelist=c(),...){ - for (packagename in packagelist){ - if(! packagename %in% installed.packages()[,1]){ - install.packages(packagename,...) - } - require(packagename, character.only=TRUE) - } -} diff --git a/r-scripts/luft.R b/r-scripts/luft.R deleted file mode 100644 index 3fdc3ec61..000000000 --- a/r-scripts/luft.R +++ /dev/null @@ -1,195 +0,0 @@ -source("installrequire.R") -installrequire(c("lubridate","dplyr","ggplot2")) -# library(xlsx) -# library(lubridate) -# library(dplyr) -# library(ggplot2) - - -########################################################################### -#####Preparation(only once)################################################ -########################################################################### -#roh <- read.xlsx(file="table23032015135021029.xlsx", sheetIndex=1) -#names(roh) <- c("Messstelle", "Datetime", "Agg_Zeitraum", "Agg_Art", "NO2") -#roh$NO2 <- as.numeric(as.character(roh$NO2)) -#roh$Datetime <- ymd_hm(roh$Datetime) -#roh <- roh %>% mutate(Woche=week(Datetime)) %>% mutate(Monat=month(Datetime)) %>% mutate(Date=as.Date(Datetime)) - -# script to read+preprocess (Makefile friendly) -# loads dataframe dat -source("readdata.R") -stop("readddata.R dysfct/not existent/moved to readairdat, stopping here...") - - -## Plots, to pdf -# pdf("plots.pdf") -png(width=1200,height=1000) - -#Werte fuer PM2.5 im Zeitverlauf -p1 <- ggplot(filter(dat, type=="PPD42NS"), aes(timestamp2, P2, color=type)) + geom_point() + theme(axis.text.x = element_text(angle=90)) + geom_point(data=filter(dat, type == "GP2Y1010AU0F"), aes(timestamp2, P25, color=type)) + scale_y_log10() -#+ geom_point(data=filter(dat, type=="GP2Y1010AU0F"), aes(timestamp2, vo_raw, color=type)) -print(p1) - -# density plots -p1<-ggplot(dat, aes(x = P2)) + stat_density() + scale_x_log10()+ labs(title="P2 density (log scaled)") -print(p1) - -p1<-ggplot(dat, aes(x = P1)) + stat_density() + scale_x_log10() + labs(title="P1 density (log scaled)") -print(p1) - -p1<-ggplot(dat, aes(x = P1)) + stat_density() + scale_x_log10() + labs(title="P1 density (log scaled) by location_id")+ facet_wrap(~location_id); print(p1) - -p1<-ggplot(dat, aes(x = P1)) + stat_density() + xlim(c(-1000,15645))+ labs(title="P1 density") -print(p1) - -p1<-ggplot(dat, aes(x = P1)) + stat_density() + xlim(c(-1000,15645))+ labs(title="P1 density per location_id")+ facet_wrap(~location_id); print(p1) - -p1<-ggplot(dat, aes(x = ratioP1)) + stat_density() + labs(title="ratioP1 density") + xlim(c(0,15)) -print(p1) -p1<-ggplot(dat, aes(x = ratioP1)) + stat_density() + labs(title="ratioP1 density by location_id") + xlim(c(0,15)) + facet_wrap(~location_id) -print(p1) - -p1<-ggplot(dat, aes(x = ratioP2)) + stat_density() + labs(title="ratioP2 density") + xlim(c(0,2)) -print(p1) -p1<-ggplot(dat, aes(x = ratioP2)) + stat_density() + labs(title="ratioP2 density by location_id") + xlim(c(0,2)) + facet_wrap(~location_id) -print(p1) - -p1<-ggplot(dat, aes(x = ratioP2)) + stat_density() + labs(title="ratioP2 density") + xlim(c(0,15)) -#+ scale_x_log10() -print(p1) - -p1<-ggplot(dat, aes(x = durP1)) + geom_density(color="red",trim=TRUE) +xlim(c(0,3446407))+ labs(title="durP1/durP2 densities (red/blue)") + geom_density(aes(x = durP2),color="blue",trim=TRUE) -print(p1) - -p1<-ggplot(dat, aes(x = durP1)) + stat_density() +xlim(c(0,3446407))+ labs(title="durP2 density") -print(p1) - -p1<-ggplot(dat, aes(x = P25)) + stat_density() + labs(title="P25 density (log scaled)") + scale_x_log10() -print(p1) - -p1<-ggplot(dat, aes(x = P25)) + stat_density() + labs(title="P25 density") + xlim(c(2000,8000)) -print(p1) - -p1<-ggplot(dat, aes(x = P10)) + stat_density() + labs(title="P10 density") + xlim(c(8000,30000)) -print(p1) - -p1<-ggplot(dat, aes(x = P25)) + stat_density() + labs(title="P25 density/location_id") + xlim(c(2000,8000))+ facet_wrap(~location_id) -print(p1) - -p1<-ggplot(dat, aes(x = P10)) + stat_density() + labs(title="P10 density/location_id") + xlim(c(8000,30000))+ facet_wrap(~location_id) -print(p1) - -p1<-ggplot(dat, aes(x = P25)) + geom_density(aes(x = durP2),color="black",trim=TRUE) + labs(title="P25 (black), P10 (blue) densities") + xlim(c(0,50000))+ geom_density(aes(x = P10),color="blue",trim=TRUE) -print(p1) - - -p1<-ggplot(dat, aes(x = dust_density)) + geom_bar()+ labs(title="dust_density histogram") + xlim(c(-0.01,0.08)); print(p1) - -p1<-ggplot(dat, aes(x = P10)) + stat_density() + labs(title="P10 density/sensor type") + xlim(c(8000,30000))+ facet_wrap(~type) -print(p1) - - -p1 <- ggplot(filter(dat, type=="PPD42NS"), aes(P1, P2)) + geom_point() +scale_x_log10() + scale_y_log10() + facet_wrap(~location_id) -print(p1) - -p1 <- ggplot(filter(dat, type=="PPD42NS"), aes(P1, P2,color=as.double(timestamp2))) + scale_colour_continuous(high="yellow") + geom_point() +scale_x_log10() + scale_y_log10() + facet_wrap(~location_id) -print(p1) - -p1 <- ggplot(dat, aes(P25, P10)) + geom_point() +scale_x_log10() + scale_y_log10() + facet_wrap(type~location_id, drop=TRUE,shrink=TRUE) -print(p1) - -p1 <- ggplot(dat, aes(P1, P2)) + geom_point() +scale_x_log10() + scale_y_log10() + facet_wrap(type~location_id, drop=TRUE,shrink=TRUE) -print(p1) - -p1 <- ggplot(dat, aes(ratioP1, ratioP2)) + geom_point() + facet_wrap(type~location_id, drop=TRUE,shrink=TRUE) +scale_x_log10() + scale_y_log10() -print(p1) - -p1 <- ggplot(dat, aes(durP1, durP2)) + geom_point() + facet_wrap(type~location_id, drop=TRUE,shrink=TRUE) #+scale_x_log10() + scale_y_log10() -print(p1) - -p1 <- ggplot(dat, aes(vo_raw, voltage)) + geom_point() + facet_wrap(type~location_id, drop=TRUE,shrink=TRUE) #+scale_x_log10() + scale_y_log10() -print(p1) - -p1 <- ggplot(dat, aes(timestamp2, P1)) + geom_point() + facet_wrap(type~location_id, drop=TRUE,shrink=TRUE) + scale_y_log10() -print(p1) - -p1 <- ggplot(dat) + geom_line(aes(timestamp2, P1)) + geom_line(aes(timestamp2, P2, color="red")) + facet_wrap(type~location_id,ncol=1, drop=TRUE,shrink=TRUE) + scale_y_log10() -print(p1) - -# measurement times -p1 <- ggplot(dat) + geom_density(aes(x = timestamp2),color="blue",trim=TRUE,kernel="rectangular",width=0.1) + labs(title="Measurement density") -print(p1) - -p1<- ggplot(dat) + geom_point(aes(timestamp2,P2,order = sample(seq_along(timestamp2)))) -print(p1) - -# since we do have dplyr and count, plot the "table" data -# TODO: make this work -# p1<-ggplot(count(dat,yday=as.POSIXlt(dat$timestamp2)$yday,type),aes(yday,n,col=type)) + geom_point() -# print(p1) - -dev.off() # end plot to pdf - -##random sample for histogram -#rand.ppd <- sample_n(ppd, 1000) -#p2 <- ggplot(data=filter(dat, type=="PPD42NS"), aes(P2)) + geom_histogram(binwidth=1/10) - -##Daten fuer Sensoren anschauen -#head(dat) -#sample_n(filter(dat, type=="PPD42NS"), 10) -#sample_n(filter(dat, type=="GP2Y1010AU0F"), 10) - -## some statistics about measurements -# look with table -# yday = day of year -table(dat$type,as.POSIXlt(dat$timestamp2)$yday,useNA = "ifany") - -# how many NA's in P2? -table(dat$type,as.POSIXlt(dat$timestamp2)$yday,sapply(dat$P2,is.na),useNA = "no") -# how many NA's in P1? -table(dat$type,as.POSIXlt(dat$timestamp2)$yday,sapply(dat$P1,is.na),useNA = "no") - -## official data sets - -source("readdata_s_mitte.R") - -if(!("sdat" %in% ls())){ # check if we have the data - warning("data not found, check readdata_s_mitte.R to download") - }else{ # plot - pdf("s-mitte.pdf",width=20, height=8) - for (y in names(sdat)[3:length(names(sdat))]){ - p<-ggplot(sdat)+ - geom_line(aes_string("datelt",y))+ - labs(x="Zeit", - y=attr(sdat,"ylabel")[attr(sdat,"names")==y]) - print(p) - } - # can you see sylvester? PMx > 500 - # lets leave that out - y="pm25" - p<-ggplot(sdat[sdat$datelt>as.POSIXlt("2015-01-01 08:00:00"),])+ - geom_line(aes_string("datelt",y))+ - labs(title="Ohne Sylvester", - x="Zeit", - y=attr(sdat,"ylabel")[attr(sdat,"names")==y]) - - # PM10 daily means (Tagesmittelwerte), threshold is 50mug - sdat.yday<-aggregate(select(sdat,date,pm10),by=list(yday=sdat$datelt$yday),mean) - sdat.yday$datelt=as.POSIXlt(sdat.yday$date) - sdat.yday$above50<-factor(sdat.yday$pm10>50) - print(p) - - y="pm10" - p<-ggplot(sdat[sdat$datelt>as.POSIXlt("2015-01-01 08:00:00"),])+ - geom_line(aes_string("datelt",y))+ - labs(title=paste("Ohne Sylvester, Überschreitungen:",sum(sdat.yday$pm10>50,na.rm=TRUE)), - x="Zeit", - y=attr(sdat,"ylabel")[attr(sdat,"names")==y])+ - geom_point(data=sdat.yday, - aes(datelt,pm10,color=above50),size=5)+ - scale_colour_discrete(h = c(120, 340), c = 100, l = 65, h.start = 30, direction = 1, na.value = "grey50")+ - geom_hline(yintercept=50,lty=2) - - print(p) - dev.off() -} # end if sdat diff --git a/r-scripts/plot_sensordata.R b/r-scripts/plot_sensordata.R deleted file mode 100644 index eafbea85a..000000000 --- a/r-scripts/plot_sensordata.R +++ /dev/null @@ -1,332 +0,0 @@ -require("ggplot2") -require("dplyr") -require("timeSeries") -require("forecast") -require("plotly") -# require("tsoutliers") -# require("zoo") - -# TODO: use https://stat.ethz.ch/R-manual/R-devel/library/stats/html/decompose.html - -usearchive=TRUE # csv data from archive -sensorid=40 -usearchive=FALSE # timestamp needs fixing (in csv and conversion below) -usearchive=TRUE # timestamp needs fixing (in csv and conversion below) -#if(usearchive){require("RCurl");} - -# set to dir containing this script -if(("scriptdir" %in% ls())){ - setwd(scriptdir) -} - -#max values for clipping -Pclip<-list(P1=list(min=0, max=10000), - P2=list(min=0.62, max=1000)) -dateinterval<-list(min=as.POSIXct(strptime("2015-12-30", format="%Y-%m-%d")), - max=as.POSIXct(Sys.Date())) -plotdir="./output_plots" -if(!dir.exists(plotdir)){dir.create(plotdir, showWarnings = TRUE, recursive = TRUE, mode = "0755")} - -#' function to clip values above/below thresholds -clipping<-function(x,min=NULL,max=NULL){ - if(is.null(min)){ - min=min(na.omit(x)) - } - if(is.null(max)){ - max=max(na.omit(x)) - } - if(is.na(max)||is.na(min)){ - warn("NA for min/max while clipping, no clipping done") - return(x) - } - x[x>max]<-max - x[xarcdat_filename_mtime]){ - print(paste("reading ", csvfilename)) - rdat<-read.csv(csvfilename, sep=";", dec=".", header=TRUE) - adddat<-dplyr::bind_rows(adddat,rdat) - newdat=TRUE - } - if(newdat){arcdat<-dplyr::bind_rows(arcdat,adddat)} - # Detectable range of concentration 0~28,000 pcs/liter (0~8,000pcs/0.01 CF=283ml) - - arcdat$timestampct<-as.POSIXct(strptime(arcdat$timestamp,format="%Y-%m-%dT%H:%M:%OS")) - arctbl<-table(arcdat$sensor_id,as.Date(arcdat$timestamp))#$yday+1000*(as.POSIXlt(arcdat$timestamp)$year+1990)) - save(arcdat, arctbl ,file=arcdat_filename) - outfilebase="plots_sensordata_overview" - outfilepath=file.path(plotdir,"plots_sensordata_overview") - pdf(paste(outfilepath,".pdf",sep=""),width=15,height=9) - arctbl.df<-as.data.frame(arctbl) - arctbl.df$Var2<-as.Date(arctbl.df$Var2) - p<-ggplot(arctbl.df, aes(Var2,Var1,size=Freq, color=as.factor(as.POSIXlt(arctbl.df$Var2)$mon+1))) + geom_point()+ - labs(x="Date", y="sensor id")+ - theme(axis.text.x = element_text(angle=90, vjust=0.5, size=6))+ - scale_x_date(date_labels = "%b %d %Y", date_minor_breaks = "1 day", date_breaks = "1 week")+ - scale_colour_hue(name="Month") -# scale_colour_brewer(name = "Month") -# theme(legend.title=element_blank())+ - # months(arctbl.df$Var2) - print(p) - plotlyggout(p=p,dir=plotdir,filename=paste(outfilebase,".html",sep="")) - dev.off() - - # Detectable range of concentration 0~28,000 pcs/liter (0~8,000pcs/0.01 CF=283ml) - -# iterate sensors - for (sid in unique(arcdat$sensor_id)){ - print(sid) - sdat<-as.data.frame(dplyr::filter(arcdat, sensor_id==sid)) # result type is tbl_df, convert to df - if(0==sum(!is.na(sdat$P1))){print(paste0("no P1 data, skiping sensor ",sid));next;} - # check for Px sensor data - sdat<-sdat[order(sdat$timestampct),] # sort by timestampct - sdat$P2diff1=sdat$P2-sdat$P1 - sdat$durP2diff1=sdat$durP2-sdat$durP1 - - print(dim(sdat)) - # stats::filter the data - # create a gaussian smoothing - sigma=5 - ntaps=10 - gc<-gfcoeffs(sigma,ntaps) - - outfilebase=paste("plots_sensor_",sid,sep="") - pdffilename=paste(plotdir,"/",outfilebase,".pdf",sep="") -# set width according to timediff - timespan<-as.double(max(sdat$timestampct)-min(sdat$timestampct)) - print(paste("plotwidth", min(timespan/2,10))) - pdf(pdffilename, width=max(timespan/2,10), height=10) - measvalnames=c("P1", "durP1", "ratioP1", "P2", "durP2", "ratioP2", "P2diff1", "durP2diff1") - # have a timeSeries object and plot it - print(paste("tsdat plot")) - tsdat<-timeSeries(sdat[,measvalnames], sdat$timestampct) - tryCatch({plot(tsdat)}, error = function(e) e) - tdn<-as.numeric(sdat$timestampct[2:length(sdat$timestampct)]-sdat$timestampct[1:(length(sdat$timestampct)-1)]) - tdn.c<-tdn[tdn<320] - - # plot histogram of timediffs - tryCatch({hist(tdn.c,n=100, main = paste("Histogram of timediffs"))}, error = function(e) e) - - # aggregate by year, day, hour - tstamplt<-as.POSIXlt(sdat$timestampct)# [,c("year","yday")] - sdat.agg<-aggregate(sdat, by=list(year=tstamplt$year+1900,yday=tstamplt$yday,hour=tstamplt$hour),FUN=mean) - # order by ymd - sdat.agg<-sdat.agg[order(sdat.agg$year,sdat.agg$yday,sdat.agg$hour),] - - sdat.dagg<-aggregate(sdat, by=list(year=tstamplt$year+1900,yday=tstamplt$yday),FUN=mean) - sdat.dagg<-sdat.dagg[order(sdat.dagg$year,sdat.dagg$yday),] -# ggplot(sdat.dagg,aes_string("timestampct",coln)) - for (coln in measvalnames){ - print (coln) - if(length(sdat[,coln])>ntaps){ - # TODO: identify/handle outliers - # look at forecast::tsoutliers tsoutliers::tso - # outlier filter first forecast::tsclean - sdat$plotdat<-forecast::tsclean(sdat[,coln]) - sdat$plotdat<-as.vector(stats::filter(sdat$plotdat, gfcoeffs(sigma,ntaps))) - p<-ggplot(sdat.agg,aes_string("timestampct",coln))+geom_bar(stat = "identity")+labs(main="Hourly means") - print(p) - plotlyggout(p=p,dir=plotdir,filename=paste(outfilebase,"_hourly.html",sep="")) - p<-ggplot(sdat.dagg,aes_string("timestampct",coln))+ geom_bar(stat = "identity")+labs(main="Daily means") - print(p) - plotlyggout(p=p,dir=plotdir,filename=paste(outfilebase,"_daily.html",sep="")) - p<-ggplot(sdat, aes(timestampct,plotdat))+geom_line()+geom_smooth(span=0.2)+ labs(x="Time",y=coln) - print(p) - plotlyggout(p=p,dir=plotdir,filename=paste(outfilebase,"_.html",sep="")) - # TODO: gleitende 24-Stunden-Mittelwerte (24h means filtering) - # maybe possible via zoo forecast::ma its fts tseries timeSeries - # fts:moving.mean only Date as time? - # look for functions with timestamp based intervals (24h) - # z=zoo(sdat,order.by=sdat$timestampct) - # sdat.fts=as.fts(sdat[,c("timestampct","P1")]) - # idat=irts(sdat$timestampct, sdat$P1) - # plot(idat) - # measurement Dates - # mdts<-as.timeSeries(unique(as.Date(sdat$timestampct))) - # fts wants chr dates (timestamps possible?) in row names? - # rownames(sdat)<-as.character(sdat$timestampct) - } - } - dev.off() - }# sensor_id - print(paste("total size of data:", dim(arcdat) ,collapse = " ")) -}# usearchive - -## calibration function -ppdcalib<-function(x){1.1*x^3 - 3.8*x^2 + 520*x + 0.62} # calibration function: ratioPx [%] / Concentration [pcs/283ml] = [pcs/0.01cf] -cf3tom3=0.02831685 # cubic foot to cubic meter ft³=0.02831685m³, m³=ft³/35.315 -# to pcs/m3: /100 /cf3tom3 -# to µg*m^-3 -# https://github.com/intel-iot-devkit/upm/pull/409/files -# + // All particles are spherical, with a density of 1.65E12 µg/m3 -# + double density = 1.65 * pow (10, 12); -# + // The radius of a particle in the PM2.5 channel is .44 µm -# I doubt it, should be 2.5/2 µm -# + double r25 = 0.44 * pow (10, -6); -# + double vol25 = (4/3) * pi * pow (r25, 3); -# + double mass25 = density * vol25; // ug -# + double K = 3531.5; // per m^3 -# interesting, since with weather correction: -# http://www.cleanair.org/sites/default/files/Drexel%20Air%20Monitoring_-_Final_Report_-_Team_19_0.pdf - - -pdffilename=file.path(plotdir,paste("ppd_calib.pdf",sep="")) -pdf(pdffilename) -p<- ggplot(sdat,aes(ratioP1,P1))+geom_point()+ - stat_function(fun=ppdcalib)+ - labs(title="PPD calibration function")+ - coord_flip() - #coord_flip to have the same orientation as in the spec sheet curve -print(p) -p<- ggplot(sdat[sdat$ratioP1<5,],aes(ratioP1,P1))+geom_point()+ - stat_function(fun=ppdcalib)+ - labs(title="PPD calibration function < 5") -print(p) - -p<- ggplot(arcdat,aes(P2, ..count..))+ - geom_density()+xlim(0.621,3000)+ - facet_wrap(~sensor_id,scales='free_y') -print(p) -dev.off() - -stop("manual break: archive plots done") -## the following is legacy code - - # dates=seq.Date(from=as.Date(dateinterval$min),to=as.Date(dateinterval$max),by=1) - # u<-paste('http://archive.madflex.de/', - # dates, - # '/', - # dates,'_ppd42ns_sensor_', - # sensorid, - # '.csv') - # require("RCurl") - # filelist=urllist - # csvsep=";" - - -fpattern<-"sensor[0-9]+.csv" -# get filelist relative to working directory, pattern = glob2rx(fpattern) -filelist<- dir(path = ".",pattern=fpattern,recursive=FALSE,full.names=FALSE, ignore.case = TRUE) ## files in current directory - -for (csvfilename in filelist){ - # get/process the data with scripts from repo feinstaub-monitoring-client-python to sensorXX.csv - # csvfilename<-paste("sensor",sensorid,".csv",sep="") - sensorid<-regmatches(csvfilename, regexpr("[0-9]+", csvfilename)) - pdffilename<-paste("plots_sensor",sensorid,".pdf",sep="") - sendat<-read.csv(csvfilename,sep=csvsep) - - # have a proper timestamp POSIXct (never use POSIXlt) - sendat$timestampct<-as.POSIXct(strptime(sendat$timestamp,format="%Y-%m-%dT%H:%M:%OSZ")) - sendat$timestamp<-NULL - - #sendat<-sendat[sendat$timestampct>strptime("2015-10-24", format="%Y-%m-%d"),] - - # select data of latest 2 days measured values - # nval=2*60*24*2 - # nval=min(nval,dim(sendat)[1]) - # seldat<-sendat[1:nval,] - - # filter date interval - seldat<-sendat[sendat$timestampct>dateinterval$min& - sendat$timestampct% - # mutate(timestamp2 = regexpr(pattern, timestamp)) %>% - # mutate(timestamp2 = regmatches(timestamp, timestamp2)) %>% - # mutate(timestamp2=ymd_hms(timestamp2)) - airdat$timestamp2<-as.POSIXct(strptime(airdat$timestamp,format="%Y-%m-%d %H:%M:%S")) - # dat$timestamp2<-strptime(dat$timestamp,format="%d.%m.%y %H:%M:%S+%Z") - - # str(dat) - # 'data.frame': 319836 obs. of 27 variables: - # $ timestamp : Factor w/ 319831 levels "2015-04-05 23:13:10.759068+00:00",..: 319822 319805 319788 319771 319754 319737 319720 319703 319686 319669 ... - # sensor type - # $ type : Factor w/ 3 levels "dsm501a","GP2Y1010AU0F",..: 1 1 1 1 1 1 1 1 1 1 ... - # $ indoor : Factor w/ 2 levels "False","True": 2 2 2 2 2 2 2 2 2 2 ... - # $ location_id : int 4 4 4 4 4 4 4 4 4 4 ... - # $ sampling_rate : int 15000 15000 15000 15000 15000 15000 15000 15000 15000 15000 ... - # - # $ P1 : Factor w/ 61894 levels "","017.95","05.06",..: 1 1 1 1 1 1 1 1 1 1 ... - # $ P2 : num NA NA NA NA NA NA NA NA NA NA ... - # $ durP1 : num NA NA NA NA NA NA NA NA NA NA ... - # $ durP2 : int NA NA NA NA NA NA NA NA NA NA ... - # $ ratioP1 : num NA NA NA NA NA NA NA NA NA NA ... - # $ ratioP2 : num NA NA NA NA NA NA NA NA NA NA ... - # $ temperature : logi NA NA NA NA NA NA ... - # $ humidity : logi NA NA NA NA NA NA ... - # $ pressure : logi NA NA NA NA NA NA ... - # $ altitude : logi NA NA NA NA NA NA ... - # $ pressure_sealevel: logi NA NA NA NA NA NA ... - # $ brightness : logi NA NA NA NA NA NA ... - # $ dust_density : Factor w/ 77 levels "","-.00",".00",..: 1 1 1 1 1 1 1 1 1 1 ... - # $ vo_raw : num NA NA NA NA NA NA NA NA NA NA ... - # $ voltage : num NA NA NA NA NA NA NA NA NA NA ... - # $ P10 : num 16656 28523 15669 12731 14018 ... - # $ P25 : num 3514 4474 3570 3104 3552 ... - # $ durP10 : int 2906824 3794072 2812860 2503032 2644788 2711264 2342328 2416972 2560024 2548652 ... - # $ durP25 : int 972924 1198488 986724 870160 982288 969476 902680 850496 924380 968796 ... - # $ ratioP10 : num 19.4 25.3 18.8 16.7 17.6 ... - # $ ratioP25 : num 6.49 7.99 6.58 5.8 6.55 6.46 6.02 5.67 6.16 6.46 ... - # $ timestamp2 : POSIXct, format: "2015-05-05 08:15:59" "2015-05-05 08:15:44" ... - - # P1 should be numeric - # TODO: identify problematic entries - # DONE with preprocessing (sed) -# dat$P1num<-as.numeric(as.character(dat$P1)) -# ## dust_density should be numeric -# dat$dust_density_num=as.numeric(as.character(dat$dust_density)) - -if(!is.null(datafilename)){ - # save all stuff currently in workspace - save(airdat,file=datafilename) -} -return(airdat) -} diff --git a/r-scripts/readdata_s_mitte.R b/r-scripts/readdata_s_mitte.R deleted file mode 100644 index ec52333d3..000000000 --- a/r-scripts/readdata_s_mitte.R +++ /dev/null @@ -1,88 +0,0 @@ -# increase java Heap size, by using: -options(java.parameters = "-Xmx1000m") -# BEFORE loading the package/java init - - -require("xlsx") -# read in Stuttgart data (official) -# see http://www.stadtklima-stuttgart.de/index.php?luft_messdaten_station_smz - -# get the data, unzip: -# http://www.stadtklima-stuttgart.de/stadtklima_filestorage/download/luft/S-Mitte-SZ-Halbstd-Werte-2015.zip -# wget http://www.stadtklima-stuttgart.de/stadtklima_filestorage/download/luft/S-Mitte-SZ-Halbstd-Werte-2015.zip -# unzip -d data/ S-Mitte-SZ-Halbstd-Werte-2015.zip -# not used: xls2csv -g 6 -q 0 data/Halbstd-Werte-Stuttgart-Mitte-SZ_2015.xls > data/Halbstd-Werte-Stuttgart-Mitte-SZ_2015.csv # crappy, weird xls sheets - -# Messstation "Schwabenzentrum" (Amt für Umweltschutz, Abt. Stadtklimatologie) - -sdat<-NULL -sdat.xls<-"data/Halbstd-Werte-Stuttgart-Mitte-SZ_2015.xls" -sdat.datafile="readdata_s_mitte.RData" -if (file.exists(sdat.datafile)){ - message(paste("loading from",sdat.datafile)) - load(sdat.datafile) - }else{ - message(paste("creating",sdat.datafile)) - sdat.colclasses=c("Date",rep("numeric",19)) - sdat.colnames=c( - "date", # "Datum", - "hour", # "Uhrzeit", - "t", # "Temperatur...C.", - "t.max", # "Temperatur...C..1", - "t.min", # "Temperatur...C..2", - "relhum", # "Rel..Feuchte....", - "windspeed.mean", # "WG..m.s.", - "windspeed.max", # "WG..m.s..1", - "widdir", # "WR..Grad.", - "p", # "Druck..hPa.", - "precsum", # "Niederschlag..l.m..", - "rad", # "Globalstr...W.m..", - "radbalance", # "Str..Bilanz..W.m..", - "uva", # "UVA.Str...W.m..", - "uvb", # "UVB.Str...W.m..", - "no", # "NO..µg.m..", - "no2", # "NO2..µg.m..", - "o3", # "O3..µg.m..", - "pm10", # "PM10..µg.m..", - "pm25" # "PM2.5..µg.m.." - ) - # read the first sheet, should be Jan.2015 - message(paste("reading",sdat.xls,"sheet",1)) - sdat.description<-read.xlsx(sdat.xls, sheetIndex=1,as.data.frame=TRUE,startRow=6,endRow=7,colIndex=1:20,header=FALSE,colClasses="character") - sdat.description=as.data.frame(t(sdat.description)) - names(sdat.description)<-c("aggregation","measurement") - sdat.description=cbind(sdat.description,sdat.colnames) - sdat.description[] <- lapply(sdat.description, as.character) # change factor to character - sdat<-read.xlsx(sdat.xls, sheetIndex=1,as.data.frame=TRUE,startRow=7,colIndex=1:20,colClasses=sdat.colclasses) - - for (sheeti in 2:7){ # at time of development only data up to july was present - message (paste("reading",sdat.xls,"sheet",sheeti)) - sdat.tmp<-read.xlsx(sdat.xls, sheetIndex=sheeti,startRow=7,as.data.frame=TRUE,colIndex=1:20,colClasses=sdat.colclasses) - if (isTRUE(all.equal(names(sdat.tmp),names(sdat)))){ # check if we have same colnames - sdat<-rbind(sdat,sdat.tmp) - } - } - names(sdat)<-sdat.colnames - # convert date and hour to POSIXlt type - # sdat$datelt<-as.POSIXlt(sdat$date)+sdat$hour*24*60*60 - # timezone might be wrong, so use strptime and explicitly specify - # dunno about daylight-saving, needs to be looked up deeper in the documentation how this is handled (CEST is Central European Summer Time) - sdat$datelt<-as.POSIXlt(strptime(sdat$date,format="%Y-%m-%d",tz="Europe/Berlin")+sdat$hour*24*60*60) - sdat.description<-rbind(sdat.description,c(NA,"Messzeitpunkt","datelt")) - row.names(sdat.description)<-NULL - # add as attribute to sdat - attr(sdat,"ylabel")<-paste(sdat.description$measurement,sdat.description$aggregation) - print(sdat.description) - # seems to be off-by one?, wrong TZ? no, weird data: the data sets start at 0:30 and end with 0:00 - # see table(sdat$date,sdat$datelt$hour) - # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 - # 2015-01-01 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 - # [...] - # 2015-08-01 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - # clean up intermediary vars, keep .datafile .description - rm(list=ls()[grep(pattern="^sdat.[^d]",ls())]) - save(sdat,file=sdat.datafile) -} # end if (file.exists(sdat.datafile)){ - - diff --git a/r-scripts/sensorids.md b/r-scripts/sensorids.md deleted file mode 100644 index 249fa6ed2..000000000 --- a/r-scripts/sensorids.md +++ /dev/null @@ -1,26 +0,0 @@ -# sensor id list from django config page - -7 -25 -33 -39 -40 -42 -44 -45 -48 -51 -52 -66 -67 -68 -71 -80 -81 -83 -84 -87 -88 - - - grep -o 'value="[0-9]*"' ~/Downloads/sensors.html | grep -o '[0-9]*'| sort -n diff --git a/raspberry-serial/.gitignore b/raspberry-serial/.gitignore deleted file mode 100644 index 72723e50a..000000000 --- a/raspberry-serial/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*pyc diff --git a/raspberry-serial/README b/raspberry-serial/README deleted file mode 100644 index cb9321584..000000000 --- a/raspberry-serial/README +++ /dev/null @@ -1,3 +0,0 @@ -# IMPORTANT - -the code in this folder is old and unmaintained! diff --git a/raspberry-serial/config.py b/raspberry-serial/config.py deleted file mode 100644 index 2eae5b06f..000000000 --- a/raspberry-serial/config.py +++ /dev/null @@ -1,6 +0,0 @@ -# set SENSOR_UID to the UID of your sensor - -settings = {} -settings['SENSOR_UID'] = 'FIXME' -settings['SENSOR_PPD42NS_UID'] = 'TEST' -settings['SENSOR_SHT10_UID'] = 'TEST2' diff --git a/raspberry-serial/logtofile.py b/raspberry-serial/logtofile.py deleted file mode 100644 index 695db0d2c..000000000 --- a/raspberry-serial/logtofile.py +++ /dev/null @@ -1,45 +0,0 @@ -# -# Log all sensor data to file for later push to dusti.xyz api -# -# requires: -# apt-get install python-serial -# pip install pytz -# -# Python 2 code!! -# - -import os.path -import serial -import uuid - -from sensor import ( - SensorDSM501A, - SensorGP2Y10, - SensorPPD42NS, - SensorSHT10, - SensorBMP180, -) - -dirname = os.path.dirname(os.path.abspath(__file__)) -# different filename on each restart -# because you may have to change the location of the sensor -# before uploading the data -filename = os.path.join(dirname, uuid.uuid4().hex) - -import argparse -parser = argparse.ArgumentParser() -parser.add_argument("--device", help="device to read from", - default="/dev/ttyACM0") -args = parser.parse_args() - -classes = (SensorDSM501A, SensorGP2Y10, SensorPPD42NS, - SensorSHT10, SensorBMP180) - -ser = serial.Serial(args.device) -while True: - message = ser.readline() - for cls in classes: - instance = cls(filename) - data = instance.parse(message) - if data: - instance.log(data) diff --git a/raspberry-serial/push.py b/raspberry-serial/push.py deleted file mode 100644 index 2a70d806f..000000000 --- a/raspberry-serial/push.py +++ /dev/null @@ -1,13 +0,0 @@ -# -# Push data live to API using Python on a RaspberryPi -# - -import serial -from utils import parse_data, send_data - -ser = serial.Serial('/dev/ttyACM0') -while True: - message = ser.readline() - data = parse_data(message) - if data: - send_data(data) diff --git a/raspberry-serial/raspberry.md b/raspberry-serial/raspberry.md deleted file mode 100644 index 54be15194..000000000 --- a/raspberry-serial/raspberry.md +++ /dev/null @@ -1,63 +0,0 @@ -# Particulates sensor usage with RaspberryPi - - -## Usage - -Connect sensor with Arduino via usb to RaspberryPi. -The Arduino has the serial software for the sensor installed and prints the sensor results. -A python script is pushing the results to our API endpoint. - - -## Install dependencies - -for raspbian - -``` -# for push -sudo apt-get update -sudo apt-get install -y python-requests python-serial -# for logtofile -sudo apt-get install -y python-pip -sudo pip install pytz -``` - -checkout the source repository - -``` -cd /home/pi -git clone https://github.com/opendata-stuttgart/sensors-software.git -``` - - -## IMPORTANT - -set SENSOR_UID in push.py !! - -## run to log live - -``` -python push.py -``` - -## run to write to file - -``` -python logtofile.py -``` - - -## autorun logotfile.py on startup - -add this to your ``/etc/rc.local``: - -``` -/bin/sleep 15 && python /home/pi/sensors-software/raspberry-serial/logtofile.py -``` - -before the ``exit 0`` line - -## send data to server later - -``` -python send.py -``` diff --git a/raspberry-serial/send.py b/raspberry-serial/send.py deleted file mode 100644 index e807cda4e..000000000 --- a/raspberry-serial/send.py +++ /dev/null @@ -1,37 +0,0 @@ -# -# send file to API -# -# -import json -import sys - -from sensor import ( - SensorDSM501A, - SensorGP2Y10, - SensorPPD42NS, - SensorSHT10, - SensorBMP180, -) - -if len(sys.argv) != 2: - print("python send.py ") - -# get type from filename -filename = sys.argv[1] -for cls in (SensorDSM501A, SensorGP2Y10, SensorPPD42NS, - SensorSHT10, SensorBMP180): - if filename.lower().endswith(cls.sensor_type.lower()): - instance = cls() - break - -assert instance - -with open(filename, 'r') as fp: - for line in fp.readlines(): - timestamp = line.split('|')[0] - - data = json.loads(line.split('|')[1]) - data = instance.filter(data) - if data: - print(data) -# instance.send(data, timestamp) diff --git a/raspberry-serial/sensor.py b/raspberry-serial/sensor.py deleted file mode 100644 index 08d2e9163..000000000 --- a/raspberry-serial/sensor.py +++ /dev/null @@ -1,115 +0,0 @@ -from datetime import datetime -import requests -import pytz -import json -from config import settings - - -class Sensor(object): - - sensor_type = None - sampling_rate = None -# url = "http://localhost:8000/v1/push-sensor-data/" - url = "https://api.dusti.xyz/v1/push-sensor-data/" - whitelist = [] - - def __init__(self, filename=None): - if self.sensor_type: - self.sensor_uid = 'SENSOR_{}_UID'.format(self.sensor_type) - else: - self.sensor_uid = 'SENSOR_UID' - if filename: - self.filename = "{}.{}".format(filename, self.sensor_type) - - def filter(self, json_data, prefix=False): - # filter all fields not in whitelist - data = {} - for key in json_data.keys(): - if prefix: - key_prefix = key.split('_')[0] - if key_prefix.lower() != self.sensor_type.lower(): - continue - key_suffix = '_'.join(key.split('_')[1:]) - else: - key_suffix = key - if key_suffix in self.whitelist: - data[key_suffix] = json_data[key] - return data - - def check(self, message): - # some checks to elimanate some of the 400s from the API - if ':' not in message: - return False - if ';' not in message: - return False - if len(message.split(':')) != len(message.split(';')) + 1: - return False - return True - - def parse(self, message): - if not self.check(message): - return False - json_data = dict(map(lambda x: x.split(':'), - message.strip().split(';'))) - return self.filter(json_data, prefix=True) - - def send(self, data, timestamp=None): - payload = { - "sampling_rate": self.sampling_rate, - "sensordatavalues": [] - } - if timestamp: - payload['timestamp'] = timestamp - - for key, value in data.iteritems(): - d = {'value': value, 'value_type': key} - payload['sensordatavalues'].append(d) - - headers = {'SENSOR': settings.get(self.sensor_uid), - 'Content-Type': 'application/json'} - r = requests.post(self.url, data=json.dumps(payload), - headers=headers, verify=False) - print(r.status_code) - print(r.text) - - def log(self, data): - dt = str(pytz.timezone('Europe/Berlin').localize(datetime.now())) - line = "{}| {}\n".format(dt, json.dumps(data)) - with open(self.filename, "a") as fp: - print(line.strip()) - fp.write(line) - - -class SensorPPD42NS(Sensor): - - sensor_type = 'PPD42NS' - sampling_rate = '15000' - whitelist = ['P1', 'P2', 'durP1', 'durP2', 'ratioP1', 'ratioP2'] - - -class SensorSHT10(Sensor): - - sensor_type = 'SHT10' - sampling_rate = None - whitelist = ['temperature', 'humidity'] - - -class SensorGP2Y10(Sensor): - - sensor_type = 'GP2Y1010AU0F' - sampling_rate = '40' - whitelist = ['vo_raw', 'voltage', 'dust_density'] - - -class SensorDSM501A(Sensor): - - sensor_type = 'dsm501a' - sampling_rate = '15000' - whitelist = ['P10', 'P25', 'durP10', 'durP25', 'ratioP10', 'ratioP25'] - - -class SensorBMP180(Sensor): - - sensor_type = 'BMP180' - sampling_rate = None - whitelist = ['temperature', 'pressure', 'altitude', 'pressure_sealevel'] diff --git a/read_delete_file/.gitignore b/read_delete_file/.gitignore deleted file mode 100644 index 03f4a3c19..000000000 --- a/read_delete_file/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.pio diff --git a/read_delete_file/.pio/build/nodemcuv2/.sconsign36.dblite b/read_delete_file/.pio/build/nodemcuv2/.sconsign36.dblite deleted file mode 100644 index f441dfcf3..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/.sconsign36.dblite and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Crypto.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Crypto.cpp.o deleted file mode 100644 index 2fecf6a41..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Crypto.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Esp-frag.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Esp-frag.cpp.o deleted file mode 100644 index a17d7d8a3..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Esp-frag.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Esp-version.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Esp-version.cpp.o deleted file mode 100644 index 0b5a3a489..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Esp-version.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Esp.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Esp.cpp.o deleted file mode 100644 index ca9162855..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Esp.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/FS.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/FS.cpp.o deleted file mode 100644 index 21544fea3..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/FS.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/FSnoop.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/FSnoop.cpp.o deleted file mode 100644 index f1e9e68b8..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/FSnoop.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/FunctionalInterrupt.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/FunctionalInterrupt.cpp.o deleted file mode 100644 index 4fc9e3649..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/FunctionalInterrupt.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/HardwareSerial.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/HardwareSerial.cpp.o deleted file mode 100644 index 144787974..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/HardwareSerial.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/IPAddress.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/IPAddress.cpp.o deleted file mode 100644 index ecdab24fe..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/IPAddress.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/MD5Builder.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/MD5Builder.cpp.o deleted file mode 100644 index a3f9d81f4..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/MD5Builder.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Print.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Print.cpp.o deleted file mode 100644 index d3c543413..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Print.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Schedule.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Schedule.cpp.o deleted file mode 100644 index e30bea182..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Schedule.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/StackThunk.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/StackThunk.cpp.o deleted file mode 100644 index eb104597a..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/StackThunk.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Stream.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Stream.cpp.o deleted file mode 100644 index 232c45cff..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Stream.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/StreamString.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/StreamString.cpp.o deleted file mode 100644 index 699d9c807..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/StreamString.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Tone.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Tone.cpp.o deleted file mode 100644 index 61df0103a..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Tone.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/TypeConversion.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/TypeConversion.cpp.o deleted file mode 100644 index 20f87ae5c..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/TypeConversion.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Updater.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Updater.cpp.o deleted file mode 100644 index 9413284de..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/Updater.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/WMath.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/WMath.cpp.o deleted file mode 100644 index 65a5b8dc7..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/WMath.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/WString.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/WString.cpp.o deleted file mode 100644 index bfc7d07ff..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/WString.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/abi.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/abi.cpp.o deleted file mode 100644 index a92ad4908..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/abi.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/base64.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/base64.cpp.o deleted file mode 100644 index 1e2b7f79a..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/base64.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/cbuf.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/cbuf.cpp.o deleted file mode 100644 index 0bfbdf360..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/cbuf.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/cont.S.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/cont.S.o deleted file mode 100644 index ec434627b..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/cont.S.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/cont_util.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/cont_util.cpp.o deleted file mode 100644 index 9257a1b24..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/cont_util.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_app_entry_noextra4k.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_app_entry_noextra4k.cpp.o deleted file mode 100644 index 30b219438..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_app_entry_noextra4k.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_eboot_command.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_eboot_command.cpp.o deleted file mode 100644 index fba3a0a52..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_eboot_command.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_features.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_features.cpp.o deleted file mode 100644 index 6c77e2011..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_features.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_flash_quirks.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_flash_quirks.cpp.o deleted file mode 100644 index a54b5087a..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_flash_quirks.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_flash_utils.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_flash_utils.cpp.o deleted file mode 100644 index 108730aed..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_flash_utils.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_i2s.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_i2s.cpp.o deleted file mode 100644 index 8782af6bb..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_i2s.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_main.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_main.cpp.o deleted file mode 100644 index 73d60b4dc..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_main.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_noniso.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_noniso.cpp.o deleted file mode 100644 index 1e87cffd8..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_noniso.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_phy.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_phy.cpp.o deleted file mode 100644 index 7e72420e2..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_phy.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_postmortem.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_postmortem.cpp.o deleted file mode 100644 index 4821420f9..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_postmortem.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_si2c.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_si2c.cpp.o deleted file mode 100644 index c660066fe..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_si2c.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_sigma_delta.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_sigma_delta.cpp.o deleted file mode 100644 index b6c0ef473..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_sigma_delta.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_spi_utils.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_spi_utils.cpp.o deleted file mode 100644 index 7c6c41c91..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_spi_utils.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_timer.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_timer.cpp.o deleted file mode 100644 index f181c1e6b..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_timer.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_waveform.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_waveform.cpp.o deleted file mode 100644 index 9dd5fed43..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_waveform.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring.cpp.o deleted file mode 100644 index fde6fc56e..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_analog.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_analog.cpp.o deleted file mode 100644 index 91ced3034..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_analog.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_digital.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_digital.cpp.o deleted file mode 100644 index 4c34a2695..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_digital.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_pulse.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_pulse.cpp.o deleted file mode 100644 index 8ec7fbb50..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_pulse.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_pwm.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_pwm.cpp.o deleted file mode 100644 index 707213aac..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_pwm.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_shift.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_shift.cpp.o deleted file mode 100644 index 8d78105a8..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/core_esp8266_wiring_shift.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/crc32.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/crc32.cpp.o deleted file mode 100644 index 55ac8e8e0..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/crc32.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/debug.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/debug.cpp.o deleted file mode 100644 index 39c541038..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/debug.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/flash_hal.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/flash_hal.cpp.o deleted file mode 100644 index e6350dc25..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/flash_hal.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/gdb_hooks.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/gdb_hooks.cpp.o deleted file mode 100644 index d6f12e932..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/gdb_hooks.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/heap.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/heap.cpp.o deleted file mode 100644 index f1839e8fa..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/heap.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/libb64/cdecode.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/libb64/cdecode.cpp.o deleted file mode 100644 index 765b4847a..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/libb64/cdecode.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/libb64/cencode.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/libb64/cencode.cpp.o deleted file mode 100644 index f93e0cba9..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/libb64/cencode.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/libc_replacements.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/libc_replacements.cpp.o deleted file mode 100644 index d165afb7b..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/libc_replacements.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/sntp-lwip2.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/sntp-lwip2.cpp.o deleted file mode 100644 index fc14d32aa..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/sntp-lwip2.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_cache.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_cache.cpp.o deleted file mode 100644 index ba07e9eba..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_cache.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_check.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_check.cpp.o deleted file mode 100644 index d0db17d94..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_check.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_gc.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_gc.cpp.o deleted file mode 100644 index ee4628963..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_gc.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_hydrogen.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_hydrogen.cpp.o deleted file mode 100644 index 5b06d7671..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_hydrogen.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_nucleus.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_nucleus.cpp.o deleted file mode 100644 index 5e1e73c6b..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs/spiffs_nucleus.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs_api.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs_api.cpp.o deleted file mode 100644 index 9ac9e58a7..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/spiffs_api.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/sqrt32.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/sqrt32.cpp.o deleted file mode 100644 index 45ccfd518..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/sqrt32.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/time.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/time.cpp.o deleted file mode 100644 index 588471c24..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/time.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/uart.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/uart.cpp.o deleted file mode 100644 index c6fc5ac73..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/uart.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_info.c.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_info.c.o deleted file mode 100644 index 420cdb284..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_info.c.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_integrity.c.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_integrity.c.o deleted file mode 100644 index 1b576989d..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_integrity.c.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_local.c.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_local.c.o deleted file mode 100644 index 502069e71..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_local.c.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_malloc.cpp.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_malloc.cpp.o deleted file mode 100644 index 6d001eb3f..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_malloc.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_poison.c.o b/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_poison.c.o deleted file mode 100644 index 008e449a1..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/FrameworkArduino/umm_malloc/umm_poison.c.o and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/firmware.bin b/read_delete_file/.pio/build/nodemcuv2/firmware.bin deleted file mode 100644 index c39667d47..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/firmware.bin and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/firmware.elf b/read_delete_file/.pio/build/nodemcuv2/firmware.elf deleted file mode 100755 index f5a3c67f2..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/firmware.elf and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/ld/local.eagle.app.v6.common.ld b/read_delete_file/.pio/build/nodemcuv2/ld/local.eagle.app.v6.common.ld deleted file mode 100644 index 616a7d441..000000000 --- a/read_delete_file/.pio/build/nodemcuv2/ld/local.eagle.app.v6.common.ld +++ /dev/null @@ -1,265 +0,0 @@ -/* This linker script generated from xt-genldscripts.tpp for LSP . */ -/* Linker Script for ld -N */ -PHDRS -{ - dport0_0_phdr PT_LOAD; - dram0_0_phdr PT_LOAD; - dram0_0_bss_phdr PT_LOAD; - iram1_0_phdr PT_LOAD; - irom0_0_phdr PT_LOAD; -} -/* Default entry point: */ -ENTRY(app_entry) -EXTERN(_DebugExceptionVector) -EXTERN(_DoubleExceptionVector) -EXTERN(_KernelExceptionVector) -EXTERN(_NMIExceptionVector) -EXTERN(_UserExceptionVector) -EXTERN(core_version) -PROVIDE(_memmap_vecbase_reset = 0x40000000); -/* Various memory-map dependent cache attribute settings: */ -_memmap_cacheattr_wb_base = 0x00000110; -_memmap_cacheattr_wt_base = 0x00000110; -_memmap_cacheattr_bp_base = 0x00000220; -_memmap_cacheattr_unused_mask = 0xFFFFF00F; -_memmap_cacheattr_wb_trapnull = 0x2222211F; -_memmap_cacheattr_wba_trapnull = 0x2222211F; -_memmap_cacheattr_wbna_trapnull = 0x2222211F; -_memmap_cacheattr_wt_trapnull = 0x2222211F; -_memmap_cacheattr_bp_trapnull = 0x2222222F; -_memmap_cacheattr_wb_strict = 0xFFFFF11F; -_memmap_cacheattr_wt_strict = 0xFFFFF11F; -_memmap_cacheattr_bp_strict = 0xFFFFF22F; -_memmap_cacheattr_wb_allvalid = 0x22222112; -_memmap_cacheattr_wt_allvalid = 0x22222112; -_memmap_cacheattr_bp_allvalid = 0x22222222; -PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull); -SECTIONS -{ - .dport0.rodata : ALIGN(4) - { - _dport0_rodata_start = ABSOLUTE(.); - *(.dport0.rodata) - *(.dport.rodata) - _dport0_rodata_end = ABSOLUTE(.); - } >dport0_0_seg :dport0_0_phdr - .dport0.literal : ALIGN(4) - { - _dport0_literal_start = ABSOLUTE(.); - *(.dport0.literal) - *(.dport.literal) - _dport0_literal_end = ABSOLUTE(.); - } >dport0_0_seg :dport0_0_phdr - .dport0.data : ALIGN(4) - { - _dport0_data_start = ABSOLUTE(.); - *(.dport0.data) - *(.dport.data) - _dport0_data_end = ABSOLUTE(.); - } >dport0_0_seg :dport0_0_phdr - .data : ALIGN(4) - { - _data_start = ABSOLUTE(.); - *(.data) - *(.data.*) - *(.gnu.linkonce.d.*) - *(.data1) - *(.sdata) - *(.sdata.*) - *(.gnu.linkonce.s.*) - *(.sdata2) - *(.sdata2.*) - *(.gnu.linkonce.s2.*) - *(.jcr) - . = ALIGN(4); - _Pri_3_HandlerAddress = ABSOLUTE(.); - _data_end = ABSOLUTE(.); - } >dram0_0_seg :dram0_0_phdr - .noinit : ALIGN(4) - { - *(.noinit) - } >dram0_0_seg :dram0_0_phdr - /* IRAM is split into .text and .text1 to allow for moving specific */ - /* functions into IRAM that would be matched by the irom0.text matcher */ - .text : ALIGN(4) - { - _stext = .; - _text_start = ABSOLUTE(.); - *(.UserEnter.text) - . = ALIGN(16); - *(.DebugExceptionVector.text) - . = ALIGN(16); - *(.NMIExceptionVector.text) - . = ALIGN(16); - *(.KernelExceptionVector.text) - LONG(0) - LONG(0) - LONG(0) - LONG(0) - . = ALIGN(16); - *(.UserExceptionVector.text) - LONG(0) - LONG(0) - LONG(0) - LONG(0) - . = ALIGN(16); - *(.DoubleExceptionVector.text) - LONG(0) - LONG(0) - LONG(0) - LONG(0) - . = ALIGN (16); - *(.entry.text) - *(.init.literal) - *(.init) - *(.text.app_entry*) /* The main startup code */ - *(.text.gdbstub*, .text.gdb_init) /* Any GDB hooks */ - /* all functional callers are placed in IRAM (including SPI/IRQ callbacks/etc) here */ - *(.text._ZNKSt8functionIF*EE*) /* std::function::operator()() const */ - } >iram1_0_seg :iram1_0_phdr - .irom0.text : ALIGN(4) - { - _irom0_text_start = ABSOLUTE(.); - *(.ver_number) - *.c.o(.literal*, .text*) - *.cpp.o(EXCLUDE_FILE (umm_malloc.cpp.o) .literal*, EXCLUDE_FILE (umm_malloc.cpp.o) .text*) - *.cc.o(.literal*, .text*) - *(.rodata._ZTV*) /* C++ vtables */ - *libgcc.a:unwind-dw2.o(.literal .text .rodata .literal.* .text.* .rodata.*) - *libgcc.a:unwind-dw2-fde.o(.literal .text .rodata .literal.* .text.* .rodata.*) - *libc.a:(.literal .text .literal.* .text.*) - *libm.a:(.literal .text .literal.* .text.*) - *libgcc.a:_umoddi3.o(.literal .text) - *libgcc.a:_udivdi3.o(.literal .text) - *libstdc++.a:( .literal .text .literal.* .text.*) - *libstdc++-exc.a:( .literal .text .literal.* .text.*) - *libsmartconfig.a:(.literal .text .literal.* .text.*) - *liblwip_gcc.a:(.literal .text .literal.* .text.*) - *liblwip_src.a:(.literal .text .literal.* .text.*) - *liblwip2-536.a:(.literal .text .literal.* .text.*) - *liblwip2-1460.a:(.literal .text .literal.* .text.*) - *liblwip2-536-feat.a:(.literal .text .literal.* .text.*) - *liblwip2-1460-feat.a:(.literal .text .literal.* .text.*) - *liblwip6-536-feat.a:(.literal .text .literal.* .text.*) - *liblwip6-1460-feat.a:(.literal .text .literal.* .text.*) - *libbearssl.a:(.literal .text .literal.* .text.*) - *libaxtls.a:(.literal .text .literal.* .text.*) - *libat.a:(.literal.* .text.*) - *libcrypto.a:(.literal.* .text.*) - *libespnow.a:(.literal.* .text.*) - *libjson.a:(.literal.* .text.*) - *liblwip.a:(.literal.* .text.*) - *libmesh.a:(.literal.* .text.*) - *libnet80211.a:(.literal.* .text.*) - *libsmartconfig.a:(.literal.* .text.*) - *libssl.a:(.literal.* .text.*) - *libupgrade.a:(.literal.* .text.*) - *libwpa.a:(.literal.* .text.*) - *libwpa2.a:(.literal.* .text.*) - *libwps.a:(.literal.* .text.*) - *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom0.text.* .irom.text .irom.text.*) - /* Constant strings in flash (PSTRs) */ - *(.irom0.pstr.*) - /* __FUNCTION__ locals */ - *(.rodata._ZZ*__FUNCTION__) - *(.rodata._ZZ*__PRETTY_FUNCTION__) - *(.rodata._ZZ*__func__) - /* std::* exception strings, in their own section to allow string coalescing */ - *(.irom.exceptiontext) - /* c++ typeof IDs, etc. */ - *(.rodata._ZTIN* .rodata._ZTSN10* .rodata._ZTISt* .rodata._ZTSSt*) - /* Fundamental type info */ - *(.rodata._ZTIPKc .rodata._ZTIc .rodata._ZTIv .rodata._ZTSv .rodata._ZTSc .rodata._ZTSPKc .rodata._ZTSi .rodata._ZTIi) - . = ALIGN(4); - *(.gcc_except_table .gcc_except_table.*) - . = ALIGN(4); - __eh_frame = ABSOLUTE(.); - KEEP(*(.eh_frame)) - . = (. + 7) & ~ 3; /* Add a 0 entry to terminate the list */ - _irom0_text_end = ABSOLUTE(.); - _flash_code_end = ABSOLUTE(.); - } >irom0_0_seg :irom0_0_phdr - .text1 : ALIGN(4) - { - *(.literal .text .iram.literal .iram.text .iram.text.* .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) - *(.fini.literal) - *(.fini) - *(.gnu.version) - _text_end = ABSOLUTE(.); - _etext = .; - } >iram1_0_seg :iram1_0_phdr - .rodata : ALIGN(4) - { - _rodata_start = ABSOLUTE(.); - *(.sdk.version) - *(.rodata) - *(.rodata.*) - *(.gnu.linkonce.r.*) - *(.rodata1) - __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); - *(.xt_except_table) - *(.gcc_except_table) - *(.gnu.linkonce.e.*) - *(.gnu.version_r) - *(.eh_frame) - . = (. + 3) & ~ 3; - /* C++ constructor and destructor tables, properly ordered: */ - __init_array_start = ABSOLUTE(.); - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - __init_array_end = ABSOLUTE(.); - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - /* C++ exception handlers table: */ - __XT_EXCEPTION_DESCS__ = ABSOLUTE(.); - *(.xt_except_desc) - *(.gnu.linkonce.h.*) - __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); - *(.xt_except_desc_end) - *(.dynamic) - *(.gnu.version_d) - . = ALIGN(4); /* this table MUST be 4-byte aligned */ - _bss_table_start = ABSOLUTE(.); - LONG(_bss_start) - LONG(_bss_end) - _bss_table_end = ABSOLUTE(.); - _rodata_end = ABSOLUTE(.); - } >dram0_0_seg :dram0_0_phdr - .bss ALIGN(8) (NOLOAD) : ALIGN(4) - { - . = ALIGN (8); - _bss_start = ABSOLUTE(.); - *(.dynsbss) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.sb.*) - *(.scommon) - *(.sbss2) - *(.sbss2.*) - *(.gnu.linkonce.sb2.*) - *(.dynbss) - *(.bss) - *(.bss.*) - *(.gnu.linkonce.b.*) - *(COMMON) - . = ALIGN (8); - _bss_end = ABSOLUTE(.); - _heap_start = ABSOLUTE(.); -/* _stack_sentry = ALIGN(0x8); */ - } >dram0_0_seg :dram0_0_bss_phdr -/* __stack = 0x3ffc8000; */ - .lit4 : ALIGN(4) - { - _lit4_start = ABSOLUTE(.); - *(*.lit4) - *(.lit4.*) - *(.gnu.linkonce.lit4.*) - _lit4_end = ABSOLUTE(.); - } >iram1_0_seg :iram1_0_phdr -} -/* get ROM code address */ -INCLUDE "../ld/eagle.rom.addr.v6.ld" diff --git a/read_delete_file/.pio/build/nodemcuv2/libFrameworkArduino.a b/read_delete_file/.pio/build/nodemcuv2/libFrameworkArduino.a deleted file mode 100644 index 8085c273c..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/libFrameworkArduino.a and /dev/null differ diff --git a/read_delete_file/.pio/build/nodemcuv2/libFrameworkArduinoVariant.a b/read_delete_file/.pio/build/nodemcuv2/libFrameworkArduinoVariant.a deleted file mode 100644 index 8b277f0dd..000000000 --- a/read_delete_file/.pio/build/nodemcuv2/libFrameworkArduinoVariant.a +++ /dev/null @@ -1 +0,0 @@ -! diff --git a/read_delete_file/.pio/build/nodemcuv2/src/main.cpp.o b/read_delete_file/.pio/build/nodemcuv2/src/main.cpp.o deleted file mode 100644 index b8f53bf29..000000000 Binary files a/read_delete_file/.pio/build/nodemcuv2/src/main.cpp.o and /dev/null differ diff --git a/read_delete_file/.pio/build/project.checksum b/read_delete_file/.pio/build/project.checksum deleted file mode 100644 index b8676bad9..000000000 --- a/read_delete_file/.pio/build/project.checksum +++ /dev/null @@ -1 +0,0 @@ -f5c5265a818737e5fe189c29b844411f6d03628b \ No newline at end of file diff --git a/read_delete_file/include/README b/read_delete_file/include/README deleted file mode 100644 index 194dcd432..000000000 --- a/read_delete_file/include/README +++ /dev/null @@ -1,39 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the usual convention is to give header files names that end with `.h'. -It is most portable to use only letters, digits, dashes, and underscores in -header file names, and at most one dot. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/read_delete_file/lib/README b/read_delete_file/lib/README deleted file mode 100644 index 6debab1e8..000000000 --- a/read_delete_file/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into executable file. - -The source code of each library should be placed in a an own separate directory -("lib/your_library_name/[here are source files]"). - -For example, see a structure of the following two libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -and a contents of `src/main.c`: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -PlatformIO Library Dependency Finder will find automatically dependent -libraries scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/read_delete_file/platformio.ini b/read_delete_file/platformio.ini deleted file mode 100644 index 6bb127a4f..000000000 --- a/read_delete_file/platformio.ini +++ /dev/null @@ -1,14 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:nodemcuv2] -platform = espressif8266 -board = nodemcuv2 -framework = arduino diff --git a/read_delete_file/src/main.cpp b/read_delete_file/src/main.cpp deleted file mode 100644 index 908efa250..000000000 --- a/read_delete_file/src/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Blink - * - * Turns on an LED on for one second, - * then off for one second, repeatedly. - */ -#include - -static void writeDataFile(String data) { - File dataFile = SPIFFS.open(F("/data1.json"), "w"); - if (dataFile) { - dataFile.println(data); - dataFile.close(); - } - // debug_outln_info(F("Data written successfully.")); - // } else { - // debug_outln_error(F("failed to open data file for writing")); - // } -} - -void setup() -{ - // initialize LED digital pin as an output. - SPIFFS.begin(); - Serial.begin(9600); -} - -void loop() -{ - // turn the LED on (HIGH is the voltage level) - // File f = SPIFFS.open(F("/data1.json"), "w"); - - // wait for a second - delay(1000); - // String kk = "hello"; - // // f.println(kk); - // // f.close(); - // writeDataFile(String("hello")); - - File f1 = SPIFFS.open(F("/data.json"), "r"); - Serial.println(F("Reading Data from File:")); - //Data from file - int i; - char st; - Serial.println(String(f1.size())); - for(i=0;i> Creation date: Sa 20 Jun 2015 21:03:56 CEST -#Cmp ( order = Reference ) -| 1mF1 C ; ~ ; ; ; ; ; ; ; ; -| K1 DHT11 ; ; ; ; ; ; ; ; ; -| P1 5V ; ~ ; ; ; ; ; ; ; ; -| P2 3.3V ; ~ ; ; ; ; ; ; ; ; -| P3 3.3V ; ~ ; ; ; ; ; ; ; ; -| P4 CONN_5 ; ; ; ; ; ; ; ; ; -| P5 A4 ; ~ ; ; ; ; ; ; ; ; -| P6 A5 ; ~ ; ; ; ; ; ; ; ; -| P7 D2 ; ~ ; ; ; ; ; ; ; ; -| P8 A0 ; ~ ; ; ; ; ; ; ; ; -| P9 GND ; ~ ; ; ; ; ; ; ; ; -| R1 10k ; ~ ; ; ; ; ; ; ; ; -| R2 18K ; ~ ; ; ; ; ; ; ; ; -| R3 PHOTO ; ~ ; ; ; ; ; ; ; ; -#End Cmp - -#Cmp ( order = Value ) -| C 1mF1 ; ~ ; ; ; ; ; ; ; ; -| DHT11 K1 ; ; ; ; ; ; ; ; ; -| 3.3V P2 ; ~ ; ; ; ; ; ; ; ; -| 3.3V P3 ; ~ ; ; ; ; ; ; ; ; -| CONN_5 P4 ; ; ; ; ; ; ; ; ; -| 5V P1 ; ~ ; ; ; ; ; ; ; ; -| A4 P5 ; ~ ; ; ; ; ; ; ; ; -| A5 P6 ; ~ ; ; ; ; ; ; ; ; -| D2 P7 ; ~ ; ; ; ; ; ; ; ; -| A0 P8 ; ~ ; ; ; ; ; ; ; ; -| GND P9 ; ~ ; ; ; ; ; ; ; ; -| 10k R1 ; ~ ; ; ; ; ; ; ; ; -| 18K R2 ; ~ ; ; ; ; ; ; ; ; -| PHOTO R3 ; ~ ; ; ; ; ; ; ; ; -#End Cmp - -#End List diff --git a/schematics/arduino--sht11-dht11-bmp180-photoresistor/arduino--sht11-dht11-bmp180-photoresistor.net b/schematics/arduino--sht11-dht11-bmp180-photoresistor/arduino--sht11-dht11-bmp180-photoresistor.net deleted file mode 100644 index 554a19201..000000000 --- a/schematics/arduino--sht11-dht11-bmp180-photoresistor/arduino--sht11-dht11-bmp180-photoresistor.net +++ /dev/null @@ -1,172 +0,0 @@ -(export (version D) - (design - (source /home/mfa/git/sensors-software/schematics/arduino--sht11-dht11-bmp180-photoresistor/arduino--sht11-dht11-bmp180-photoresistor.sch) - (date "Sa 20 Jun 2015 21:01:27 CEST") - (tool "eeschema (2013-jul-07)-stable")) - (components - (comp (ref P8) - (value A0) - (libsource (lib device) (part CONNECTOR)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585A973)) - (comp (ref P4) - (value CONN_5) - (libsource (lib conn) (part CONN_5)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585AB0F)) - (comp (ref K1) - (value DHT11) - (libsource (lib conn) (part CONN_3)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585AB1E)) - (comp (ref R1) - (value 10k) - (libsource (lib device) (part R)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585AB3B)) - (comp (ref R2) - (value 18K) - (libsource (lib device) (part R)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585AB4A)) - (comp (ref 1mF1) - (value C) - (libsource (lib device) (part C)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585AB59)) - (comp (ref P7) - (value D2) - (libsource (lib device) (part CONNECTOR)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585AEBA)) - (comp (ref P6) - (value A5) - (libsource (lib device) (part CONNECTOR)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585AF63)) - (comp (ref P5) - (value A4) - (libsource (lib device) (part CONNECTOR)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585AF70)) - (comp (ref P3) - (value 3.3V) - (libsource (lib device) (part CONNECTOR)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585AFF6)) - (comp (ref P2) - (value 3.3V) - (libsource (lib device) (part CONNECTOR)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585B008)) - (comp (ref P1) - (value 5V) - (libsource (lib device) (part CONNECTOR)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585B00E)) - (comp (ref P9) - (value GND) - (libsource (lib device) (part CONNECTOR)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585B019)) - (comp (ref R3) - (value PHOTO) - (libsource (lib device) (part R)) - (sheetpath (names /) (tstamps /)) - (tstamp 5585B733))) - (libparts - (libpart (lib device) (part C) - (description "Condensateur non polarise") - (footprints - (fp SM*) - (fp C?) - (fp C1-1)) - (fields - (field (name Reference) C) - (field (name Value) C) - (field (name Footprint) ~) - (field (name Datasheet) ~)) - (pins - (pin (num 1) (name ~) (type passive)) - (pin (num 2) (name ~) (type passive)))) - (libpart (lib device) (part CONNECTOR) - (fields - (field (name Reference) P) - (field (name Value) CONNECTOR) - (field (name Footprint) ~) - (field (name Datasheet) ~)) - (pins - (pin (num 1) (name W) (type passive)))) - (libpart (lib device) (part R) - (description Resistance) - (footprints - (fp R?) - (fp SM0603) - (fp SM0805) - (fp R?-*) - (fp SM1206)) - (fields - (field (name Reference) R) - (field (name Value) R) - (field (name Footprint) ~) - (field (name Datasheet) ~)) - (pins - (pin (num 1) (name ~) (type passive)) - (pin (num 2) (name ~) (type passive)))) - (libpart (lib conn) (part CONN_3) - (description "Symbole general de connecteur") - (fields - (field (name Reference) K) - (field (name Value) CONN_3)) - (pins - (pin (num 1) (name P1) (type passive)) - (pin (num 2) (name PM) (type passive)) - (pin (num 3) (name P3) (type passive)))) - (libpart (lib conn) (part CONN_5) - (description "Symbole general de connecteur") - (fields - (field (name Reference) P) - (field (name Value) CONN_5)) - (pins - (pin (num 1) (name ~) (type passive)) - (pin (num 2) (name ~) (type passive)) - (pin (num 3) (name ~) (type passive)) - (pin (num 4) (name ~) (type passive)) - (pin (num 5) (name ~) (type passive))))) - (libraries - (library (logical device) - (uri /usr/share/kicad/library/device.lib)) - (library (logical conn) - (uri /usr/share/kicad/library/conn.lib))) - (nets - (net (code 1) (name "") - (node (ref P4) (pin 3)) - (node (ref P6) (pin 1))) - (net (code 2) (name "") - (node (ref P4) (pin 2)) - (node (ref P5) (pin 1))) - (net (code 3) (name "") - (node (ref P7) (pin 1)) - (node (ref R1) (pin 2)) - (node (ref K1) (pin 1))) - (net (code 4) (name GND) - (node (ref 1mF1) (pin 2)) - (node (ref K1) (pin 3)) - (node (ref P4) (pin 5)) - (node (ref P4) (pin 4)) - (node (ref R3) (pin 2)) - (node (ref P9) (pin 1))) - (net (code 5) (name +3.3V) - (node (ref P3) (pin 1)) - (node (ref P2) (pin 1)) - (node (ref P4) (pin 1))) - (net (code 6) (name +5V) - (node (ref P1) (pin 1)) - (node (ref K1) (pin 2)) - (node (ref R1) (pin 1)) - (node (ref R2) (pin 1))) - (net (code 7) (name "") - (node (ref P8) (pin 1)) - (node (ref R3) (pin 1)) - (node (ref R2) (pin 2)) - (node (ref 1mF1) (pin 1))))) \ No newline at end of file diff --git a/schematics/arduino--sht11-dht11-bmp180-photoresistor/arduino--sht11-dht11-bmp180-photoresistor.pro b/schematics/arduino--sht11-dht11-bmp180-photoresistor/arduino--sht11-dht11-bmp180-photoresistor.pro deleted file mode 100644 index 6f0964ba5..000000000 --- a/schematics/arduino--sht11-dht11-bmp180-photoresistor/arduino--sht11-dht11-bmp180-photoresistor.pro +++ /dev/null @@ -1,86 +0,0 @@ -update=Sa 20 Jun 2015 20:41:09 CEST -version=1 -last_client=pcbnew -[cvpcb] -version=1 -NetIExt=net -[cvpcb/libraries] -EquName1=devcms -[eeschema] -version=1 -LibDir= -NetFmtName= -RptD_X=0 -RptD_Y=100 -RptLab=1 -LabSize=60 -[eeschema/libraries] -LibName1=power -LibName2=device -LibName3=transistors -LibName4=conn -LibName5=linear -LibName6=regul -LibName7=74xx -LibName8=cmos4000 -LibName9=adc-dac -LibName10=memory -LibName11=xilinx -LibName12=special -LibName13=microcontrollers -LibName14=dsp -LibName15=microchip -LibName16=analog_switches -LibName17=motorola -LibName18=texas -LibName19=intel -LibName20=audio -LibName21=interface -LibName22=digital-audio -LibName23=philips -LibName24=display -LibName25=cypress -LibName26=siliconi -LibName27=opto -LibName28=atmel -LibName29=contrib -LibName30=valves -[general] -version=1 -[pcbnew] -version=1 -LastNetListRead=arduino--sht11-dht11-bmp180-photoresistor.net -UseCmpFile=0 -PadDrill=" 0,600000" -PadDrillOvalY=" 0,600000" -PadSizeH=" 1,000000" -PadSizeV=" 1,000000" -PcbTextSizeV=" 1,000000" -PcbTextSizeH=" 1,000000" -PcbTextThickness=" 0,300000" -ModuleTextSizeV=" 1,000000" -ModuleTextSizeH=" 1,000000" -ModuleTextSizeThickness=" 0,150000" -SolderMaskClearance=" 0,000000" -SolderMaskMinWidth=" 0,000000" -DrawSegmentWidth=" 0,200000" -BoardOutlineThickness=" 0,150000" -ModuleOutlineThickness=" 0,150000" -[pcbnew/libraries] -LibDir= -LibName1=sockets -LibName2=connect -LibName3=discret -LibName4=pin_array -LibName5=divers -LibName6=smd_capacitors -LibName7=smd_resistors -LibName8=smd_crystal&oscillator -LibName9=smd_dil -LibName10=smd_transistors -LibName11=libcms -LibName12=display -LibName13=led -LibName14=dip_sockets -LibName15=pga_sockets -LibName16=valves diff --git a/schematics/arduino--sht11-dht11-bmp180-photoresistor/arduino--sht11-dht11-bmp180-photoresistor.sch b/schematics/arduino--sht11-dht11-bmp180-photoresistor/arduino--sht11-dht11-bmp180-photoresistor.sch deleted file mode 100644 index e9f08e0bf..000000000 --- a/schematics/arduino--sht11-dht11-bmp180-photoresistor/arduino--sht11-dht11-bmp180-photoresistor.sch +++ /dev/null @@ -1,337 +0,0 @@ -EESchema Schematic File Version 2 -LIBS:power -LIBS:device -LIBS:transistors -LIBS:conn -LIBS:linear -LIBS:regul -LIBS:74xx -LIBS:cmos4000 -LIBS:adc-dac -LIBS:memory -LIBS:xilinx -LIBS:special -LIBS:microcontrollers -LIBS:dsp -LIBS:microchip -LIBS:analog_switches -LIBS:motorola -LIBS:texas -LIBS:intel -LIBS:audio -LIBS:interface -LIBS:digital-audio -LIBS:philips -LIBS:display -LIBS:cypress -LIBS:siliconi -LIBS:opto -LIBS:atmel -LIBS:contrib -LIBS:valves -EELAYER 27 0 -EELAYER END -$Descr A4 11693 8268 -encoding utf-8 -Sheet 1 1 -Title "" -Date "20 jun 2015" -Rev "" -Comp "" -Comment1 "" -Comment2 "" -Comment3 "" -Comment4 "" -$EndDescr -$Comp -L CONNECTOR P8 -U 1 1 5585A973 -P 5500 2050 -F 0 "P8" H 5850 2150 70 0000 C CNN -F 1 "A0" H 5850 1950 70 0000 C CNN -F 2 "~" H 5500 2050 60 0000 C CNN -F 3 "~" H 5500 2050 60 0000 C CNN - 1 5500 2050 - 1 0 0 -1 -$EndComp -$Comp -L +3.3V #PWR01 -U 1 1 5585A9C5 -P 2300 2400 -F 0 "#PWR01" H 2300 2360 30 0001 C CNN -F 1 "+3.3V" H 2300 2510 30 0000 C CNN -F 2 "" H 2300 2400 60 0000 C CNN -F 3 "" H 2300 2400 60 0000 C CNN - 1 2300 2400 - 1 0 0 -1 -$EndComp -$Comp -L +5V #PWR02 -U 1 1 5585A9D4 -P 3100 1650 -F 0 "#PWR02" H 3100 1740 20 0001 C CNN -F 1 "+5V" H 3100 1740 30 0000 C CNN -F 2 "" H 3100 1650 60 0000 C CNN -F 3 "" H 3100 1650 60 0000 C CNN - 1 3100 1650 - 1 0 0 -1 -$EndComp -$Comp -L GND #PWR03 -U 1 1 5585A9E3 -P 6050 3400 -F 0 "#PWR03" H 6050 3400 30 0001 C CNN -F 1 "GND" H 6050 3330 30 0001 C CNN -F 2 "" H 6050 3400 60 0000 C CNN -F 3 "" H 6050 3400 60 0000 C CNN - 1 6050 3400 - 1 0 0 -1 -$EndComp -$Comp -L CONN_5 P4 -U 1 1 5585AB0F -P 1900 3300 -F 0 "P4" V 1850 3300 50 0000 C CNN -F 1 "CONN_5" V 1950 3300 50 0000 C CNN -F 2 "" H 1900 3300 60 0000 C CNN -F 3 "" H 1900 3300 60 0000 C CNN - 1 1900 3300 - -1 0 0 -1 -$EndComp -$Comp -L CONN_3 K1 -U 1 1 5585AB1E -P 3950 2250 -F 0 "K1" V 3900 2250 50 0000 C CNN -F 1 "DHT11" V 4000 2250 40 0000 C CNN -F 2 "" H 3950 2250 60 0000 C CNN -F 3 "" H 3950 2250 60 0000 C CNN - 1 3950 2250 - 1 0 0 -1 -$EndComp -$Comp -L R R1 -U 1 1 5585AB3B -P 3450 1800 -F 0 "R1" V 3530 1800 40 0000 C CNN -F 1 "10k" V 3457 1801 40 0000 C CNN -F 2 "~" V 3380 1800 30 0000 C CNN -F 3 "~" H 3450 1800 30 0000 C CNN - 1 3450 1800 - 0 -1 -1 0 -$EndComp -$Comp -L R R2 -U 1 1 5585AB4A -P 4950 1800 -F 0 "R2" V 5030 1800 40 0000 C CNN -F 1 "18K" V 4957 1801 40 0000 C CNN -F 2 "~" V 4880 1800 30 0000 C CNN -F 3 "~" H 4950 1800 30 0000 C CNN - 1 4950 1800 - 1 0 0 -1 -$EndComp -$Comp -L C 1mF1 -U 1 1 5585AB59 -P 5150 2750 -F 0 "1mF1" H 5150 2850 40 0000 L CNN -F 1 "C" H 5156 2665 40 0000 L CNN -F 2 "~" H 5188 2600 30 0000 C CNN -F 3 "~" H 5150 2750 60 0000 C CNN - 1 5150 2750 - 1 0 0 -1 -$EndComp -$Comp -L CONNECTOR P7 -U 1 1 5585AEBA -P 3700 1800 -F 0 "P7" H 4050 1900 70 0000 C CNN -F 1 "D2" H 4050 1700 70 0000 C CNN -F 2 "~" H 3700 1800 60 0000 C CNN -F 3 "~" H 3700 1800 60 0000 C CNN - 1 3700 1800 - 1 0 0 -1 -$EndComp -$Comp -L CONNECTOR P6 -U 1 1 5585AF63 -P 1800 2950 -F 0 "P6" H 2150 3050 70 0000 C CNN -F 1 "A5" H 2150 2850 70 0000 C CNN -F 2 "~" H 1800 2950 60 0000 C CNN -F 3 "~" H 1800 2950 60 0000 C CNN - 1 1800 2950 - -1 0 0 -1 -$EndComp -$Comp -L CONNECTOR P5 -U 1 1 5585AF70 -P 1800 2650 -F 0 "P5" H 2150 2750 70 0000 C CNN -F 1 "A4" H 2150 2550 70 0000 C CNN -F 2 "~" H 1800 2650 60 0000 C CNN -F 3 "~" H 1800 2650 60 0000 C CNN - 1 1800 2650 - -1 0 0 -1 -$EndComp -$Comp -L CONNECTOR P3 -U 1 1 5585AFF6 -P 1750 2100 -F 0 "P3" H 2100 2200 70 0000 C CNN -F 1 "3.3V" H 2100 2000 70 0000 C CNN -F 2 "~" H 1750 2100 60 0000 C CNN -F 3 "~" H 1750 2100 60 0000 C CNN - 1 1750 2100 - -1 0 0 -1 -$EndComp -$Comp -L CONNECTOR P2 -U 1 1 5585B008 -P 1750 1850 -F 0 "P2" H 2100 1950 70 0000 C CNN -F 1 "3.3V" H 2100 1750 70 0000 C CNN -F 2 "~" H 1750 1850 60 0000 C CNN -F 3 "~" H 1750 1850 60 0000 C CNN - 1 1750 1850 - -1 0 0 -1 -$EndComp -$Comp -L CONNECTOR P1 -U 1 1 5585B00E -P 1800 1600 -F 0 "P1" H 2150 1700 70 0000 C CNN -F 1 "5V" H 2150 1500 70 0000 C CNN -F 2 "~" H 1800 1600 60 0000 C CNN -F 3 "~" H 1800 1600 60 0000 C CNN - 1 1800 1600 - -1 0 0 -1 -$EndComp -$Comp -L CONNECTOR P9 -U 1 1 5585B019 -P 6500 3400 -F 0 "P9" H 6850 3500 70 0000 C CNN -F 1 "GND" H 6850 3300 70 0000 C CNN -F 2 "~" H 6500 3400 60 0000 C CNN -F 3 "~" H 6500 3400 60 0000 C CNN - 1 6500 3400 - 1 0 0 -1 -$EndComp -$Comp -L PWR_FLAG #FLG04 -U 1 1 5585B45F -P 4650 3250 -F 0 "#FLG04" H 4650 3345 30 0001 C CNN -F 1 "PWR_FLAG" H 4650 3430 30 0000 C CNN -F 2 "" H 4650 3250 60 0000 C CNN -F 3 "" H 4650 3250 60 0000 C CNN - 1 4650 3250 - 1 0 0 -1 -$EndComp -$Comp -L PWR_FLAG #FLG05 -U 1 1 5585B4E2 -P 2550 2000 -F 0 "#FLG05" H 2550 2095 30 0001 C CNN -F 1 "PWR_FLAG" H 2550 2180 30 0000 C CNN -F 2 "" H 2550 2000 60 0000 C CNN -F 3 "" H 2550 2000 60 0000 C CNN - 1 2550 2000 - 1 0 0 -1 -$EndComp -$Comp -L PWR_FLAG #FLG06 -U 1 1 5585B50E -P 2600 2450 -F 0 "#FLG06" H 2600 2545 30 0001 C CNN -F 1 "PWR_FLAG" H 2600 2630 30 0000 C CNN -F 2 "" H 2600 2450 60 0000 C CNN -F 3 "" H 2600 2450 60 0000 C CNN - 1 2600 2450 - 1 0 0 -1 -$EndComp -$Comp -L R R3 -U 1 1 5585B733 -P 6050 1650 -F 0 "R3" V 6130 1650 40 0000 C CNN -F 1 "PHOTO" V 6057 1651 40 0000 C CNN -F 2 "~" V 5980 1650 30 0000 C CNN -F 3 "~" H 6050 1650 30 0000 C CNN - 1 6050 1650 - 1 0 0 -1 -$EndComp -Wire Wire Line - 4950 1550 3100 1550 -Wire Wire Line - 3100 1550 3100 1650 -Wire Wire Line - 5150 1400 5150 2550 -Connection ~ 5150 2050 -Wire Wire Line - 6050 3400 6050 1900 -Connection ~ 6050 3400 -Wire Wire Line - 3100 1600 3100 2250 -Wire Wire Line - 3100 2250 3600 2250 -Connection ~ 3100 1600 -Wire Wire Line - 3600 2350 3600 3500 -Wire Wire Line - 2300 3400 6500 3400 -Wire Wire Line - 3200 1800 3100 1800 -Connection ~ 3100 1800 -Wire Wire Line - 3700 1800 3700 1950 -Wire Wire Line - 3700 1950 3600 1950 -Wire Wire Line - 3600 1950 3600 2150 -Wire Wire Line - 2300 2400 2300 3100 -Connection ~ 3600 3400 -Wire Wire Line - 2400 2650 2400 3200 -Wire Wire Line - 2400 3200 2300 3200 -Wire Wire Line - 2500 2950 2500 3300 -Wire Wire Line - 2500 3300 2300 3300 -Wire Wire Line - 1800 1850 1800 2450 -Wire Wire Line - 1800 2450 2600 2450 -Connection ~ 2300 2450 -Wire Wire Line - 1800 1600 3100 1600 -Wire Wire Line - 4650 3250 4650 3400 -Connection ~ 4650 3400 -Wire Wire Line - 2550 2000 3100 2000 -Connection ~ 3100 2000 -Connection ~ 6050 2550 -Wire Wire Line - 3600 3500 2300 3500 -Wire Wire Line - 5150 2950 6050 2950 -Connection ~ 6050 2950 -Wire Wire Line - 6050 1400 5150 1400 -Wire Wire Line - 4950 2050 5500 2050 -Wire Wire Line - 1800 1850 1750 1850 -Wire Wire Line - 1750 2100 1800 2100 -Connection ~ 1800 2100 -Wire Wire Line - 2500 2950 1800 2950 -Wire Wire Line - 2400 2650 1800 2650 -$EndSCHEMATC diff --git a/schematics/readme.md b/schematics/readme.md deleted file mode 100644 index 7e25b3d60..000000000 --- a/schematics/readme.md +++ /dev/null @@ -1,7 +0,0 @@ -# Info - -Software used: Fritzing - -## Ubuntu - -```sudo apt-get install fritzing``` diff --git a/schematics/voltage-divider.fzz b/schematics/voltage-divider.fzz deleted file mode 100644 index becc1505d..000000000 Binary files a/schematics/voltage-divider.fzz and /dev/null differ diff --git a/airrohr-firmware/sps30_i2c.cpp b/sps30_i2c.cpp similarity index 100% rename from airrohr-firmware/sps30_i2c.cpp rename to sps30_i2c.cpp diff --git a/airrohr-firmware/sps30_i2c.h b/sps30_i2c.h similarity index 100% rename from airrohr-firmware/sps30_i2c.h rename to sps30_i2c.h diff --git a/airrohr-firmware/utils.cpp b/utils.cpp similarity index 100% rename from airrohr-firmware/utils.cpp rename to utils.cpp diff --git a/airrohr-firmware/utils.h b/utils.h similarity index 100% rename from airrohr-firmware/utils.h rename to utils.h diff --git a/utils/README.md b/utils/README.md deleted file mode 100644 index 3c603b8c7..000000000 --- a/utils/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Utils - -Here are some utils, which may be used to do tasks around the fine dust sensor project. - -## External utils - -[Stress Test Scripts for MQTT using Python and Ansible](https://github.com/bluewindthings/mqtt-stress) - diff --git a/utils/analysis/geodata/README.md b/utils/analysis/geodata/README.md deleted file mode 100644 index 54b1c5570..000000000 --- a/utils/analysis/geodata/README.md +++ /dev/null @@ -1,10 +0,0 @@ -This dataset is part of the Open Data Initiative datasets of LGL, - -https://www.lgl-bw.de/lgl-internet/opencms/de/07_Produkte_und_Dienstleistungen/Open_Data_Initiative/index.html - -Copyright/License: CC BY 3.0 (http://creativecommons.org/licenses/by/3.0/deed.de) -Datenquelle: LGL, www.lgl-bw.de - -[Gemeinden (ZIP-Archiv mit SHAPE-Dateien, Stand 30.06.2015) (ZIP, 7.616 KB)](https://www.lgl-bw.de/lgl-internet/web/sites/default/de/07_Produkte_und_Dienstleistungen/Open_Data_Initiative/Galerien/Dokumente/Gemeindegrenzen.zip) - - diff --git a/utils/analysis/plotmeans.R b/utils/analysis/plotmeans.R deleted file mode 100644 index 75e5d35e2..000000000 --- a/utils/analysis/plotmeans.R +++ /dev/null @@ -1,57 +0,0 @@ -# plot the meansfiles created via subsample.py -require(ggplot2) -require(reshape2) -require(plotly) -source("read_sampled.R") - -ymax=200 - -if (!"datadir"%in%ls()){datadir=""} -if (!dir.exists(datadir)){ - print ("set datadir to valid dir, using .") - datadir="." -} - -measnames=c("P1","P2","temperature","humidity","numobs") -legdata=data.frame("P1"=c("PM 10","[µm/m³]"),"P2"=c("PM 2.5","[µm/m³]"),"temperature"=c("Temperatur","[°C]"),"humidity"=c("Luftfeuchtigkeit","[%]")) - -for (meas in measnames){ - for (dh in c("daily","hourly")){ - -# csvfn<-paste("all_",dh,"_",meas,".csv", sep="") -# infilename<-file.path(datadir, csvfn) -# if (!file.exists(infilename)){next;} -# dat<-read.csv(infilename) - dat<-read_sampled(meas,dh,datadir) - - # have the time parsed - if (dh=="hourly"){ - # and add 30 minutes - dat$ts<-as.POSIXct(strptime(as.character(dat$timestamp),"%Y-%m-%d %H:%M:%S")+30*60) # 2017-02-28 00:00:00 - }else{ - dat$ts<-as.POSIXct(strptime(as.character(dat$timestamp),"%Y-%m-%d")) # 2017-02-28 - } - # deslect timestamp and - d<-subset(dat, select=-timestamp) - # melt data into long form - m<-melt(d, id.vars="ts") - # plot max value - mx<-max(m[,"value"], na.rm=TRUE) - if (mx>ymax){ - plotmax=ymax - }else{ - plotmax=mx - } - pdffilen=paste(infilename,".pdf",sep="") - pdf(pdffilen, width=40, height=10) - p<-ggplot(m,aes(ts,value,color=variable))+geom_line()+ylim(0,plotmax)+ theme(legend.position="none")+labs(title=paste("Alle Sensoren:",legdata[1,meas]),x="Zeit",y=paste(legdata[1,meas],legdata[2,meas])) - print(p) - dev.off() - - htmlfilen=paste(csvfn,".html",sep="") - oldwd=getwd() - setwd(datadir) - try(htmlwidgets::saveWidget(widget=ggplotly(p),file=htmlfilen, selfcontained = FALSE, libdir="html_libs")) - setwd(oldwd) - } -} \ No newline at end of file diff --git a/utils/analysis/subsample.py b/utils/analysis/subsample.py deleted file mode 100755 index 69998c085..000000000 --- a/utils/analysis/subsample.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env python3 - -# subsample luftdaten.info data from archive.luftdaten.info -# to hourly and daily means - -import pandas as pd -import numpy as np -import matplotlib.pyplot as plt -import argparse -import sys -import os -import csv -# import ggplot # for plots, currently install borken - -# files are given on commandline - -parser = argparse.ArgumentParser(description='Process csv from archive,dljf API') -parser.add_argument(metavar='J', type=str, nargs='+', dest='csvfilenames', - help='csv files to be processed') -parser.add_argument('-o', '--outdir', default='.', type=str, dest='outdir', - help='outdir where files (.csv) are stored') - -args = parser.parse_args() - -# result dict hourly -rdh={} -# result dict daily -rdd={} -cnt=np.size(args.csvfilenames) -for csvfilename in args.csvfilenames: - with open(csvfilename) as f: - cnt-=1; - sys.stderr.write(str(cnt)+'.') - sys.stderr.flush() - try: - dat=pd.read_csv(csvfilename, sep=";") - if dat.size < 1: - sys.stderr.write("no data in "+csvfilename) - continue - # Explicitly set utc after parsing - dat.index=pd.DatetimeIndex(dat["timestamp"]).tz_localize('utc') - # hourly - h=dat.resample('H').mean() - n=dat["timestamp"].resample('H').count() - n.name='numobs' - h=pd.concat([h,n],axis=1) - sid=np.int(h["sensor_id"][0]) - rdh[sid]=pd.concat([rdh.get(sid),h]) - # daily - d=dat.resample('D').mean() - n=dat["timestamp"].resample('D').count() - n.name='numobs' - d=pd.concat([d,n],axis=1) - rdd[sid]=pd.concat([rdd.get(sid),d]) - except Exception as e: - sys.stderr.write("error processing "+csvfilename+"\n") - # do this properly one day - sys.stderr.write(str(e.args)) - sys.stderr.flush() - continue - -if not os.path.exists(args.outdir): - os.makedirs(args.outdir) - -# sort all dfs and write out to csv files -for k in rdd.keys(): - ofilen=os.path.join(args.outdir, "sensor_hourly_"+str(k)+".csv") - with open(ofilen, 'w') as o: - rdh[k].sort_index().to_csv(o) - - ofilen=os.path.join(args.outdir, "sensor_daily_"+str(k)+".csv") - with open(ofilen, 'w') as o: - rdd[k].sort_index().to_csv(o) - -# dict of all sensors -dasd={} # daily -dash={} # hourly -dasdc={} # daily counts -dashc={} # hourly counts -measurements=['P1','P2','temperature','humidity','numobs'] -for k in rdd.keys(): - for m in measurements: - if m in rdd[k]: - s=rdd[k][m] - s.name=k - dasd[m]=pd.concat([dasd.get(m),s],axis=1) - if m in rdh[k]: - s=rdh[k][m] - s.name=k - dash[m]=pd.concat([dash.get(m),s],axis=1) - -for m in measurements: - ofilen=os.path.join(args.outdir, "all_hourly_"+str(m)+".csv") - if m not in dash.keys(): - continue - with open(ofilen, 'w') as o: - dash[m].sort_index().to_csv(o) - ofilen=os.path.join(args.outdir, "all_daily_"+str(m)+".csv") - with open(ofilen, 'w') as o: - dasd[m].sort_index().to_csv(o) - - diff --git a/utils/android/README.md b/utils/android/README.md deleted file mode 100644 index faa2e0b5f..000000000 --- a/utils/android/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# MobileFeinstaub App - -Die App MobileFeinstaub für Android erlaubt es, einen SDS011 Sensor mit einem Usb2serial Adapter per USB [OTG](https://de.wikipedia.org/wiki/Universal_Serial_Bus#USB_On-the-go)-Kabel direkt am Smartphone zu betreiben. - diff --git a/utils/downloadtools/README.md b/utils/downloadtools/README.md deleted file mode 100644 index e9870cc92..000000000 --- a/utils/downloadtools/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Data download tools - -Please see this project for advanced downloads: -https://pypi.org/project/luftdatenpumpe/ - - diff --git a/utils/flash/.gitignore b/utils/flash/.gitignore deleted file mode 100644 index f24afa42d..000000000 --- a/utils/flash/.gitignore +++ /dev/null @@ -1 +0,0 @@ -mailconfig.sh diff --git a/utils/flash/README.md b/utils/flash/README.md deleted file mode 100644 index 43227ba54..000000000 --- a/utils/flash/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# Flashing firmware for luftdaten.info airrohr sensors - -## Airrohr Firmware Flasher - - -Since 2019 there is a dedicated software for easy flashing of the firmware. -It can be run on different operating systems and provides a GUI. -On github you can find the [source code repository](https://github.com/opendata-stuttgart/airrohr-firmware-flasher) with [binary releases](https://github.com/opendata-stuttgart/airrohr-firmware-flasher/releases). -It is an alternative to the script provided here. - - -## Flash script for Linux - -[Here](https://github.com/opendata-stuttgart/sensors-software/tree/master/utils/flash) you find a tool for flashing an ESP8266 with the most recent firmware release of the fine dust measuring station. - -The script asks some more info, which is required by the admins to let the sensors data into the database. -Usally, the device should be available on `/dev/ttyUSB0` (if you have no other usb2serial attached). -The script makes use of two tools, both named esptool(.py): - -* one comes with the ESP8266 plugin for the the Android development IDE https://github.com/esp8266/arduino-esp8266fs-plugin -* the other is a python script from https://github.com/themadinventor/esptool - -The script tries to find them in standard paths. You can set variables to point to them. - -## transcript of a flash session with the script (2016-11-26) - - export gitlocation=/path/to/gitrepoparent # change path here, or just cd into the right location - cd $gitlocation/sensors-software/utils/flash - ./flashlatest.sh - - usage: [esptool=/path/to/esptool] [esptoolpy=/path/to/esptool.py] [devserial=/dev/ttyUSB0] ./flashlatest.sh - writes output to listofflashed.csv - devserial=/dev/ttyUSB0 # define to change - - ask more infos? [Y/n]Y - PM sensor revision (on back/flat side top left corner)? [default: ]V2-006 - PM sensor serial number (SN on sticker, besides fan, below barcode)? [default: ]5000-C537 - Adress? [like: 70000 Stuttgart, Staubweg 00]70000 Stuttgart, Staubweg 00 - Email? [like: unknown@example.com] - latitude? [like: 00.0000]48.000 - longitude? [like: 00.0000]9.000 - DBID esp8266-2331040 0x002391a0 5c:cf:7f:23:91:a0 V2-006:5000-C537 @ 48.000 9.000 70000 Stuttgart, Staubweg 00 SID1 SNAME1 SID2 SNAME2 - patch Freifunk to XXXXXXXX? [y/N] N - --2016-11-26 18:19:28-- https://www.madavi.de/sensor/update/data/latest.bin - Auflösen des Hostnamen »www.madavi.de (www.madavi.de)«... 2a01:238:4202:e00:342a:970a:ad33:75fd, 85.214.240.94 - Verbindungsaufbau zu www.madavi.de (www.madavi.de)|2a01:238:4202:e00:342a:970a:ad33:75fd|:443... verbunden. - HTTP-Anforderung gesendet, warte auf Antwort... 416 Requested Range Not Satisfiable - - Download der Datei schon vollständig; kein Download notwendig. - flash now? [y/N] y - esptool v0.4.9 - (c) 2014 Ch. Klippel - setting board to nodemcu - [...] - writing flash - [...] - ................................................................................ [ 90% ] - ........................................ [ 100% ] - starting app without reboot - espcomm_send_command: sending command header - espcomm_send_command: sending command payload - espcomm_send_command: receiving 2 bytes of data - closing bootloader - to erase SPIFF (config data) use arduino IDE and https://github.com/esp8266/arduino-esp8266fs-plugin - see https://github.com/esp8266/arduino-esp8266fs-plugin - - to erase SPIFF (config data) use arduino IDE and https://github.com/esp8266/arduino-esp8266fs-plugin - see https://github.com/esp8266/arduino-esp8266fs-plugin - or overwrite SPIFFS now? [y/N] N - -Now the information about your sensor is added at the end of file listofflashed.csv - diff --git a/utils/flash/empty.spiffs.bin.bz2 b/utils/flash/empty.spiffs.bin.bz2 deleted file mode 100644 index 9dc1cfba2..000000000 Binary files a/utils/flash/empty.spiffs.bin.bz2 and /dev/null differ diff --git a/utils/flash/flashlatest.sh b/utils/flash/flashlatest.sh deleted file mode 100755 index 9fedba038..000000000 --- a/utils/flash/flashlatest.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/bin/bash - -binfile="latest_de.bin" -binfile="latest_en.bin" -outappendfile=listofflashed.csv -echo "usage: [esptool=/path/to/esptool] [esptoolpy=/path/to/esptool.py] [devserial=/dev/ttyUSB0] $0" -echo "writes output to $outappendfile" - -if [ -z "$esptool" ] ; then - esptool="$(ls $HOME/.arduino*/packages/esp8266/tools/esptool/*/esptool | sort | tail -1)" - if [ -z "$esptool" ] ; then - echo esptool not found, please define esptool="/path/to/esptool" - echo "https://github.com/igrr/esptool-ck/" - exit 1 - fi -fi -if [ -z "$esptoolpy" ] ; then - esptoolpy="$(which esptool.py)" - if [ -z "$esptoolpy" ] ; then - echo esptool.py not found in PATH, please define esptoolpy="/path/to/esptool.py" - echo "https://github.com/themadinventor/esptool" - exit 1 - fi -fi - -if [ -z "$devserial" ] ; then - devserial=/dev/ttyUSB0 - echo devserial="$devserial" \# define to change -fi -if [ ! -w "$devserial" ] ; then - echo "no write access to $devserial" - if [ ! -d "/dev/serial/" ] ; then - echo "no serial devices found in /dev/serial/, exiting" - exit 1 - fi - read -p "list all serial devices? [Y/n]" ans - if [ "$ans" != "n" ] ; then - ls -l /dev/serial/by-id/ - fi - exit 1 -fi - - -if [ ! -f "$outappendfile" ] ; then - echo "nodemcuID sensorname hexchipID MAC revision:serial email lat lon locationaddress sensorID1 sensorname1 sensorID2 sensorname2" |tee -a "$outappendfile" -fi - -# get info -chipid="$($esptoolpy chip_id)" -chid=$($esptoolpy chip_id| grep -io '0x[0-9a-fA-F]*\b') -chiddec=$(python -c "print (\"%d\"%($chid))") -mac="$($esptoolpy read_mac| grep -io '[0-9a-f:]\{17\}')" -locadr="LOCADRESS" -email="@" -lat="LAT" -lon="LON" -echo "" -echo "$chipid $chid $chiddec" - -read -p "ask more infos? [y/N]" ans - -if [ "$ans" == "y" ] ; then - #examplestr="V0-000" - #read -p "PM sensor revision (on back/flat side top left corner)? [default: $examplestr]" ans - #if [ -n "$ans" ] ; then -# srevision="$ans" - #fi - #examplestr="0000-0000" - #read -p "PM sensor serial number (SN on sticker, besides fan, below barcode)? [default: $examplestr]" ans - #if [ -n "$ans" ] ; then -# sserial="$ans" - #fi - - examplestr="70000 Stuttgart, Staubweg 00" - read -p "Adress? [like: $examplestr]" ans - if [ -n "$ans" ] ; then - locadr="$ans" - fi - examplestr="unknown@example.com" - read -p "Email? [like: $examplestr]" ans - if [ -n "$ans" ] ; then - email="$ans" - fi - examplestr="00.0000" - read -p "latitude? [like: $examplestr]" ans - if [ -n "$ans" ] ; then - lat="$ans" - fi - examplestr="00.0000" - read -p "longitude? [like: $examplestr]" ans - if [ -n "$ans" ] ; then - lon="$ans" - fi -fi - -info="DBID\tesp8266-$chiddec\t$chid\t$mac\t$srevision:$sserial\t$email\t$lat\t$lon\t$locadr\tSID1\tSNAME1\tSID2\tSNAME2" -echo -e "$info" | tee -a "$outappendfile" - - -#esptool.py write_flash -vv -cb 57600 -ca 0x00000 -cp /dev/ttyUSB0 -cf latest.bin - -#read -p "patch Freifunk to XXXXXXXX? [y/N] " ans - -wget -c "https://www.madavi.de/sensor/update/data/$binfile" - -#if [ "$ans" == "y" ] -#then -# patchedbinfile="${binfile}.patched" -# hexdump -ve '1/1 "%.2X"' "$binfile" | sed "s/4672656966756E6B/5858585858585858/g" | xxd -r -p > "$patchedbinfile" -# binfile="$patchedbinfile" -#fi - -# flash -# esptool.py write_flash 0x00000 "$binfile" "$@" - - -read -p "flash now? [Y/n] " ans -if [ "$ans" == "Y" -o -z "$ans" ] -then - $esptool -vv -cd nodemcu -cb 57600 -ca 0x00000 -cp "$devserial" -cf "$binfile" -fi - - -echo "to erase SPIFF (config data) use arduino IDE and https://github.com/esp8266/arduino-esp8266fs-plugin" -echo "see https://github.com/esp8266/arduino-esp8266fs-plugin" -#[SPIFFS] data : /home/martin/hft/applications/finedust/sensors-software/esp8266-arduino/ppd42ns-wificonfig-ppd-sds-dht/data -#[SPIFFS] size : 3052 -#[SPIFFS] page : 256 -#[SPIFFS] block : 8192 -#[SPIFFS] upload : /tmp/buildae19241fabc98f54562c84b5c3712165.spiffs/ppd42ns-wificonfig-ppd-sds-dht.spiffs.bin -#[SPIFFS] address: 0x100000 -#[SPIFFS] reset : nodemcu -#[SPIFFS] port : /dev/ttyUSB0 -#[SPIFFS] speed : 115200 - -read -p "or overwrite SPIFFS now? [y/N] " ans - -if [ "$ans" == "y" ] ; then - - spiffbin=empty.spiffs.bin - if [ ! -f "$spiffbin" ] ; then - bunzip2 -k "${spiffbin}.bz2" - fi - - $esptool -vv -cd nodemcu -cb 115200 -ca 0x100000 -cp "$devserial" -cf "$spiffbin" -fi - diff --git a/utils/flash/infomail.sh b/utils/flash/infomail.sh deleted file mode 100755 index 8078d5d08..000000000 --- a/utils/flash/infomail.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/bash - - -source "$(dirname $0)/mailconfig.sh" -if [ -z "$lfile" ] ; then - lfile=listofflashed.csv -else - if [ ! -f "$lfile" ] ; then - echo "lfile=$lfile not found" - fi -fi -#testlist.csv -echo "using input file: $lfile" - -subject="[luftdaten.info] Sensor in der Datenbank, es kann losgehen" -while [ -z "$sender" ] -do - read -p "email to send from: " sender -done -while [ -z "$smtpserver" ] -do - read -p "SMTP server to send from: " smtpserver -done - -bodyfixedcontent=" -Hallo, - -hier kommen ein paar Infos zu deiner Sensorstation (Feinstaubmessstation). -* Die Station ist jetzt in unserer Datenbank eingetragen und wird daher, sobald sie online ist, Daten aufzeichnen. -* Anleitung zum Konfigurieren des eigenen WLAN: https://github.com/opendata-stuttgart/meta/wiki/Konfiguration-der-Sensoren -* Ich habe die Koordinaten nach Adresse herausgesucht, sie sind in der Datenbank (aber evtl. nicht hier in der Mail) -* Wer da Bedenken hat und das anonymisiert haben will, sage mir Bescheid. Die personenbezogenen Daten (Adresse, Email) werden nicht weitergegeben und sind nicht 'Open Data'. Koordinaten (lat/lon) werden auf 3 Stellen gerundet, das entspricht etwa Rechtecken von ca 70x110m (wen das genauer interessiert: hier ist eine Visualisierung des Punkterasters: https://github.com/Marwe/particlemap/blob/master/static/grid001.json und https://github.com/Marwe/particlemap/blob/master/static/raster_0.001_degree.png ) -* Es wäre gut, wenn ich (sofern nicht schon vorhanden) noch eine kurze Beschreibung haben könnte, wie die Sensorumgebung ist, ich habe für meinen Sensor z.B. recht ausführlich geschrieben: 'Sensor an Außenwand, Höhe über Grund: 7m, Dachüberstand in + 2m darüber. Straßenseite mit keinem Verkehr nachts, tagsüber besonders zu rush hours.' -* Die Angaben enthalten IDs, mit denen die eigenen Sensordaten identifiziert werden können: die erste Zahl (vor esp8266-xxxx) ist die Node-ID (für das Rechnermodul), hinten folgen noch einmal zwei IDs für die Sensoren, die wichtiger sind, da diese in der Karte und in den Exportdaten auftauchen, z.B. im Dateinamen und in den CSV-Dateiexporten http://archive.luftdaten.info/2017-01-10/ -* Die Karten: - * SDS011 https://www.madavi.de/sensor/feinstaub-map-sds/ - * DHT22 https://www.madavi.de/sensor/feinstaub-map-dht/ -* Für Updates zum Projekt schau bei mal wieder bei http://luftdaten.info/ vorbei - - -Hier die Infos zu deinem Sensor in einer Zeile: - -$(head -1 $lfile) - -" - - - -read -s -p "Password for smtp for $sender: " smtpw - -if [ -z "$smtpw" ] ; then - echo "pw empty, exiting" - exit 1 -fi - -maxcnt=200 -cnt=0 -tmpmail=$(mktemp -d) - -#for rec in $(grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" $lfile ) -# \t does not work properly, replace with | - -sed -e 's#\t#|#g' $lfile | while IFS="|" read nodemcuID sensorname hexchipID MAC revisionserial email lat lon locationaddress sensorID1 sensorname1 sensorID2 sensorname2 -do - cnt=$((cnt+1)) - if [ $cnt -gt $maxcnt ] ; then - echo "maxcnt=$maxcnt reached, stopping." - exit 0 - fi - # check, if there is a mail in the line - #if [ -z "$(echo "$sinfo" | grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b")" ] ; then - if [ -z "(echo $email| grep -E -o '\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b')" ] ; then - echo "no mail in line $cnt, skipping" - continue - fi - - subject="[luftdaten.info] Sensorstation $sensorname ist in der Datenbank, es kann losgehen" - bodypre="Bcc:<$sender> -Subject:${subject}" - - rec="$email" - sinfo="$nodemcuID $sensorname $hexchipID $MAC $revisionserial $email $lat $lon $locationaddress $sensorID1 $sensorname1 $sensorID2 $sensorname2" - #nodeid=$(awk -F "\t" "/$rec/{print $2}" $lfile) - #sensorid1=$(awk -F "\t" "/$rec/{print $10}" $lfile) - #sensorid2=$(awk -F "\t" "/$rec/{print $12}" $lfile) - lats=$(echo "$lat"| grep -o '[0-9-]*\.[0-9][0-9][0-9]'} - lons=$(echo "$lon"| grep -o '[0-9-]*\.[0-9][0-9][0-9]'} - - customlinks=" - -Ob der Sensor funktioniert und Daten liefert, kann auf https://www.madavi.de/sensor/graph.php eingesehen werden, wahrscheinlich sind deine Sensorseiten: -https://www.madavi.de/sensor/graph.php?sensor=${sensorname}-sds011 -https://www.madavi.de/sensor/graph.php?sensor=${sensorname}-dht - -Sollten die Daten nur unregelmäßig erscheinen, kann es am WLAN liegen, checke bitte die Signalseite: -https://www.madavi.de/sensor/signal.php?sensor=${sensorname} - -In den Karten und Exporten haben die Sensoren die Nummern: -$sensorname1 $sensorID1 -$sensorname2 $sensorID2 - -Die eingetragene Position ist: -http://www.openstreetmap.org/?mlat=$lat&mlon=$lon#map=18/$lat/$lon -herausgegeben wird nur die gerundete Position: -http://www.openstreetmap.org/?mlat=$lats&mlon=$lons#map=18/$lats/$lons - -Viel Spaß und neue Einsichten -Martin Weis -" - - body="To:<${rec}> -$bodypre -$bodyfixedcontent" - mailtextfile="$tmpmail/$rec" - echo "$body" "$sinfo" "$customlinks" | tee "$mailtextfile" - -done - -for mailtextfile in "$tmpmail"/*@* -do - - cat "$mailtextfile" - echo "$mailtextfile" - - read -p "send? [y/N]" ans - if [ "$ans" == "y" ] ; then - cat "$mailtextfile" | s-nail -v \ - -r "$sender" \ - -S smtp="$smtpserver" \ - -S smtp-use-starttls \ - -S smtp-auth=login \ - -S smtp-auth-user="$sender" \ - -S smtp-auth-password="$smtpw" \ - -S ssl-verify=ignore \ - -t # specify To: Cc: Bcc: on body - #"$sender;$rec" - # -s "$subject" \ - - success="$?" - if [ "$success" != "0" ] ; then - read -p "sending of message failed ($success), continue? [n/y]" ans - if [ "$ans" != "y" ] ; then - echo "exiting" - exit 2 - fi - fi - fi - -done - -echo tmpfiles in $tmpmail diff --git a/utils/flash/mailconfig.sh.template b/utils/flash/mailconfig.sh.template deleted file mode 100644 index 3f1928981..000000000 --- a/utils/flash/mailconfig.sh.template +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# name this file mailconfig.sh to set your parameters for infomail.sh - -export sender="" -export smtpserver="mail.example.com:587" -#export lfile="testlist.csv" - - diff --git a/utils/raspiflashstation/README.md b/utils/raspiflashstation/README.md deleted file mode 100644 index 3da501a4b..000000000 --- a/utils/raspiflashstation/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# Create Sensor Flash Station on Raspbian - - -## Install necessary software - -Install on the raspberry (raspbian here) as root: - - aptitude install python-pip - pip install -U platformio - -* create /etc/udev/rules.d/95-nodemcu.rules - - # CP210X USB UART - SUBSYSTEMS=="usb", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0666", SYMLINK+="ttyUSBnodemcu$attr{port_number}" - - -Necessary software - - if [ -z "$rsroot" ] ; then rsroot="/src/raspistation"; echo "rsroot=$rsroot" ;fi - mkdir -p "$rsroot" - if [ "$?" != "0" ] ; then echo "cannot create dir /src/raspistation, exiting"; exit 1 ; fi - pushd "$rsroot" - git clone https://github.com/paulbarber/raspi-gpio.git - git clone https://github.com/themadinventor/esptool - - # enable i2c - for modl in snd-bcm2835 i2c-dev - do - if [ -z "$(grep ^$modl /etc/modules)" ] ; then - echo "$modl" >> /etc/modules - fi - done - - - popd diff --git a/utils/raspiflashstation/vm/README.md b/utils/raspiflashstation/vm/README.md deleted file mode 100644 index f63146acb..000000000 --- a/utils/raspiflashstation/vm/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Virtual machine as flashstation and debugging tool for luftdaten.info - -Goal: create a small virtual machine with all necessary drivers and tools to flash and debug sensor stations of [luftdaten.info](https://luftdaten.info). -Many systems lack driver support or make it overly complex to install a simple usb2serial chip device (affected systems: Windows, OSX). -Idea is to start a virtual machine, hand over the USB and everyhing is fine. - - -Necessary: -* support for esp8266 nodmcu platforms -* git, esptool(s) - https://github.com/igrr/esptool-ck - -* scripts for flashing and debugging - - -git clone https://github.com/themadinventor/esptool -git clone - - -# System install - -* https://wiki.alpinelinux.org/wiki/Installation -* https://wiki.alpinelinux.org/wiki/VirtualBox_guest_additions - - - apk add git - apk add virtualbox-additions-grsec diff --git a/utils/sds011/readme.md b/utils/sds011/readme.md deleted file mode 100644 index 85376172f..000000000 --- a/utils/sds011/readme.md +++ /dev/null @@ -1,24 +0,0 @@ -# A logger script for the SDS011 - -This is a small logger script for the SDS011 particle sensor. -Connect the device via serial to your computer (e.g. via USB2serial) and run the python program. -To change the device, have the path/name as first argument, like: - - ./sds011logger.py /dev/ttyUSB0 - -To log on console and into a file just use redirection or tee: - - ./sds011logger.py /dev/ttyUSB0 | tee -a ~/sdslog_0.csv - -Three values per reading are the output, they are TAB separated. -With a header the output would be like: - - datetime[UTC] PM2.5[μg/m3] PM10[μg/m3] - 2016-08-03 22:08:28.293635 12.6 9.4 - -Time is always in time zone UTC, to avoid time zone offsets and resulting errors or misinterpretations. - -The class code was adapted from [FriskByBergen](https://github.com/FriskByBergen/RPiParticle/blob/master/lib/sds011.py). -See [spec sheet](https://github.com/opendata-stuttgart/meta/blob/master/files/SDS011-V1.3.pdf) for details. - - diff --git a/utils/sds011/sds011logger.py b/utils/sds011/sds011logger.py deleted file mode 100755 index dece115c1..000000000 --- a/utils/sds011/sds011logger.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python -import serial -import datetime, time -import sys - -# class adapted from https://github.com/FriskByBergen/RPiParticle/blob/master/lib/sds011.py - -class SDS011(object): - msg_start = 170 - msg_cmd = 192 - msg_end = 171 - sleep_time = 0.01 - device = None - - def __init__(self,serialdevice="/dev/cu.wchusbserial1420"): - self.device=serial.Serial(serialdevice, baudrate=9600, stopbits=1, parity="N", timeout=2) - - def read(self): - - # Read in loop until message start: AAC0 - while True: - s = self.device.read(1) - if ord(s) == SDS011.msg_start: - s = self.device.read(1) - if ord(s) == SDS011.msg_cmd: - break - time.sleep( SDS011.sleep_time ) - - s = self.device.read(8) - - pm25hb = ord(s[0]) - pm25lb = ord(s[1]) - pm10hb = ord(s[2]) - pm10lb = ord(s[3]) - d5 = ord(s[4]) - d6 = ord(s[5]) - - cs = ord(s[6]) - tail = ord(s[7]) - - cs_expected = (pm25hb + pm25lb + pm10hb + pm10lb + d5 + d6) % 256 - if cs != cs_expected: - raise Exception("Checksum test failed") - - if tail != SDS011.msg_end: - raise Exception("Message was not correctly terminated?") - - pm25 = float(pm25hb + pm25lb*256)/10.0 - pm10 = float(pm10hb + pm10lb*256)/10.0 - - return (pm10 , pm25) - -def main(): - serialdevice="/dev/cu.wchusbserial1420" - if len(sys.argv) > 1: - serialdevice=sys.argv[1] - sdslog=SDS011(serialdevice) - # init datetime object - dt=datetime.datetime.now() - print ("%s\tPM10\tPM2.5"%(dt.utcnow())) - while True: - try: - pm10,pm25=sdslog.read() - print ("%s\t%.1f\t%.1f"%(dt.utcnow(),pm10,pm25)) - except Exception as e: - print (e.message) -if __name__ == '__main__': - main() diff --git a/utils/serialwatch/serialwatch.sh b/utils/serialwatch/serialwatch.sh deleted file mode 100755 index 5d10392b7..000000000 --- a/utils/serialwatch/serialwatch.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# TODO -# auto discover device? -# check device? No, since it will appear suddenly - -serialdev="/dev/ttyUSB0" -if [ -n "$1" ] ; then - # it should be safe to call with any given filename - serialdev="$1" -fi - -if [ -z "$(which screen)" ] ; then - echo "screen not found, please install it" - exit 2 -fi - -while true -do - screen "$serialdev" - # little delay, so script can be stopped with ^C - sleep 0.1 -done -