123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #include "WiFi.h"
- //https://github.com/orgua/OneWireHub or
- //https://www.pjrc.com/teensy/td_libs_OneWire.html or
- //https://github.com/RobTillaart/DS18B20_RT
- #include <OneWire.h>
- #include <DS18B20.h>
- //https://github.com/avishorp/TM1637
- #include <TM1637Display.h>
-
- char* ssid = "Antenne 5G";
- char* password = "Un Truc Moins Chiant";
- //char* ssid = "Livebox-8DA0";
- //char* password = "C3F3EE221002051A31382FFAF7";
-
- char* serverHost = "demisel.space";
- int serverPort = 10220;
- WiFiClient tcpClient;
- bool tcpClientConnected;
-
-
-
- #define CLK 18
- #define DIO 5
- #define ONE_WIRE_BUS 4
-
- OneWire oneWire(ONE_WIRE_BUS);
- DS18B20 sensor(&oneWire);
- TM1637Display display(CLK, DIO);
-
-
- void setup() {
- WiFi.begin(ssid, password);
-
- // put your setup code here, to run once:
- Serial.begin(9600);
- sensor.begin();
- display.setBrightness(0);
-
- Serial.print("Connecting");
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- Serial.println();
-
- Serial.print("Connected, IP address: ");
- Serial.println(WiFi.localIP());
- }
-
- void loop() {
- int temp = temperatureTrucs();
- //Serial.println(temp);
- display.showNumberDecEx(temp, 0x20);
-
- if( !tcpClient.connected() )
- {
- if(tcpClient.connect(serverHost,serverPort))
- {
- tcpClientConnected = true;
- }else
- {
- Serial.println("Could not connect to server");
- }
- }else
- {
- tcpClient.println(temp);
- Serial.println("Connected loop");
- }
- delay(500);
- //;
- }
-
- int temperatureTrucs()
- {
- sensor.requestTemperatures();
- while (!sensor.isConversionComplete()); // wait until sensor is ready
- return (int) (sensor.getTempC() * 10);
- }
|