wunderground esp8266 ds18b20

Odpovědět
jenicek_sut
Příspěvky: 8
Registrován: 14 říj 2018, 14:55
Reputation: 0

wunderground esp8266 ds18b20

Příspěvek od jenicek_sut » 02 lis 2019, 12:25

Ahoj.
Nevím si rady se zprovozněním esp a jednoho ds18b20 tak, aby data odesílal na wunderground. S thingspeak to není problém, ale tohle jsem nikde nenašel. Jak upravit např. tento kód, aby odesílal data na wunderground? Díky

Kód: Vybrat vše

#include <DallasTemperature.h>
#include <OneWire.h>
#include <ThingSpeak.h> 
#include <ESP8266WiFi.h>

// User changeable vaules go here.

#define ONE_WIRE_BUS D4                           // Digital pin DS18B20 is connected to.
#define TEMPERATURE_PRECISION 11                  // Set sensor precision.  Valid options 8,10,11,12 Lower is faster but less precise

unsigned long myChannelNumber = 123456;            // Thingspeak channel ID here
const char * myWriteAPIKey = "YOUR_API_WRITE_KEY";  // Write API key here
const char* ssid     = "WIRELESS_SSID";           // SSID of wireless network
const char* password = "WIRELESS_PASSWORD";       // Password for wireless network

int fieldStart = 1;                               // Field number to start populating ThingSpeak channel data, leave at 
                                                  // 1 if this is the only device reporting to that channel.  
                                                  // If more than one device this should be the FIRST FREE field.

int updatePeriod = 300;                            //delay in seconds to update to ThingSpeak.  Should be set to not less than 15.


int status = WL_IDLE_STATUS;
WiFiClient  client;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);


int numberOfDevices; // Number of temperature devices found
DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address

void setup() {
 Serial.begin(115200);
  delay(10);

  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()); 


  ThingSpeak.begin(client);
  sensors.begin();
  
  // Grab a count of devices on the wire
  numberOfDevices = sensors.getDeviceCount();
  
  // locate devices on the bus
  Serial.print("Locating devices...");
  
  Serial.print("Found ");
  Serial.print(numberOfDevices, DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");
  
  // Loop through each device, print out address
  for(int i=0;i<numberOfDevices; i++)
  {
    // Search the wire for address
    if(sensors.getAddress(tempDeviceAddress, i))
  {
    Serial.print("Found device ");
    Serial.print(i, DEC);
    Serial.print(" with address: ");
    printAddress(tempDeviceAddress);
    Serial.println();
    
    Serial.print("Setting resolution to ");
    Serial.println(TEMPERATURE_PRECISION, DEC);
    
    // set the resolution to TEMPERATURE_PRECISION bit (Each Dallas/Maxim device is capable of several different resolutions)
    sensors.setResolution(tempDeviceAddress, TEMPERATURE_PRECISION);
    
    Serial.print("Resolution actually set to: ");
    Serial.print(sensors.getResolution(tempDeviceAddress), DEC); 
    Serial.println();
  }else{
    Serial.print("Found ghost device at ");
    Serial.print(i, DEC);
    Serial.print(" but could not detect address. Check power and cabling");
  }
  }
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

void loop() {
  sensors.requestTemperatures();
  // Itterate through each sensor and send readings to ThinkSpeak.  
  for (int i=0; i<=(numberOfDevices - 1); i++){
    float temp=sensors.getTempCByIndex(i);
    ThingSpeak.setField(i+fieldStart,temp);
    Serial.println("Sensor #:");
    Serial.println(i);
    Serial.println("Temperature:");
    Serial.println(temp);
  }
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);  //Write fields to Thingspeak, comment this line out
                                                              //if you wish to test without uploading data.
    Serial.println("Data sent to ThinkSpeak");
  delay(updatePeriod * 1000);
}

Uživatelský avatar
pavel1tu
Příspěvky: 2054
Registrován: 26 říj 2017, 08:28
Reputation: 0
Bydliště: Trutnov
Kontaktovat uživatele:

Re: wunderground esp8266 ds18b20

Příspěvek od pavel1tu » 02 lis 2019, 19:17

Vzhledem k tomu že kdysi nějak zpoplatnili stahování dat nebo to nějak omezili už 2 roky to nepoužívám, ale měl jsem to takto:

Kód: Vybrat vše

server jsem měl "rtupdate.wunderground.com"
GET /weatherstation/updateweatherstation.php?ID="YourPWS_ID"&PASSWORD="YourPWS_Password"&dateutc="now"&tempf=Tempf&softwaretype=Arduino%20UNO%20version1&action=updateraw&realtime=1&rtfreq=30
ale jestli to ještě funguje ?

Vždyť ale mají v jejich helpu vše popsané, já tehdy čerpal od nich.

PS: Vzhledem k častým změnám těchto služeb a šílenému omezení já přešel na svůj WWW server na BananPi, kde provozuji Weathertemplate (český produkt, vypadá perfektně) a Grafana(na zkoušku).
UNO, NANO, Mikro, PRO mini, DUE, ESP32S2, RPi PICO
Pavel1TU
"Správně napsaný kod lze číst jako knihu"

Uživatelský avatar
dzooky
Příspěvky: 124
Registrován: 03 úno 2018, 01:09
Reputation: 0
Bydliště: Fintice
Kontaktovat uživatele:

Re: wunderground esp8266 ds18b20

Příspěvek od dzooky » 06 lis 2019, 19:08

Ak si mal free ucet mal si tolko requestov ze si vedel cca poslat kazde 3 minuty novy update. Neviem kde je teraz tato stranka.
Myslim ze to vzdy funguje mne zdochla stanica posielal som fotky z web kamery a ide to vzdy
Ja to posielam z raspberry cez curl.

Odpovědět

Kdo je online

Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 9 hostů