Server HTTP + WebSocket + Serveur TCP pour transmettre la température du thermometre dans ma cuisine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cybergaziniere.ino 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "WiFi.h"
  2. #include <OneWire.h>
  3. #include <DS18B20.h>
  4. #include <TM1637Display.h>
  5. //const char* ssid = "Antenne 5G";
  6. //const char* password = "Un Truc Moins Chiant";
  7. const char* ssid = "Livebox-8DA0";
  8. const char* password = "C3F3EE221002051A31382FFAF7";
  9. #define CLK 18
  10. #define DIO 5
  11. #define ONE_WIRE_BUS 4
  12. OneWire oneWire(ONE_WIRE_BUS);
  13. DS18B20 sensor(&oneWire);
  14. TM1637Display display(CLK, DIO);
  15. void setup() {
  16. WiFi.begin(ssid, password);
  17. // put your setup code here, to run once:
  18. Serial.begin(9600);
  19. sensor.begin();
  20. display.setBrightness(0);
  21. Serial.print("Connecting");
  22. while (WiFi.status() != WL_CONNECTED) {
  23. delay(500);
  24. Serial.print(".");
  25. }
  26. Serial.println();
  27. Serial.print("Connected, IP address: ");
  28. Serial.println(WiFi.localIP());
  29. }
  30. void loop() {
  31. int temp = temperatureTrucs();
  32. //Serial.println(temp);
  33. display.showNumberDecEx(temp, 0x20);
  34. //;
  35. }
  36. int temperatureTrucs()
  37. {
  38. sensor.requestTemperatures();
  39. while (!sensor.isConversionComplete()); // wait until sensor is ready
  40. return (int) (sensor.getTempC() * 10);
  41. }