[SOLVED] Wemos d1 Mini + PMS7003 for Dust sensor.. Plz help


#1

Hello guys… Im trying to setup with Dust Sensor with PMS7003 and Wemos D1 Mini…
But i got a so many error and i dont know this coding is right or not... I alreday made PMS7003 sensor + crystalLCD... its Work properly…
but i try to made with wemos d1… it`s to complicated…
Somebody help me…

here is my massy coding…

include "ESP8266WiFi.h"
include "SoftwareSerial.h"
String apiKey="8BDO9VISRFNU9FJK";
const char* server="api.thingspeak.com";
const char* ssid="kwangsub_5g";
const char* password = "";
WiFiClient client;
unsigned long sleepTime= 300;
unsigned char chrRecv;
unsigned char chrData[30];
SoftwareSerial myPMS7003(1,2);
byte bytCount = 0;
void setup() {
define PM1_0_ATMOSPHERE_H   8
define PM1_0_ATMOSPHERE_L   9
define PM2_5_ATMOSPHERE_H   10
define PM2_5_ATMOSPHERE_L   11
define PM10_ATMOSPHERE_H    12
define PM10_ATMOSPHERE_L    13 
define START_1 0x42
define START_2 0x4d
  
WiFi.begin(ssid,password);
ESP.deepSleep(sleepTime * 1000000);

}

void loop() {

  if (myPMS7003.available())
  {
    chrRecv = myPMS7003.read();
    if (chrRecv == START_1 && bytCount ==0) bytCount = 1;
    if (chrRecv == START_2 && bytCount ==1) bytCount = 2;
          if (bytCount == 2)
      {
         bytCount = 0;
         
         for(int i = 0; i < 30; i++)
         {
            chrData[i] = myPMS7003.read();
         } 
         ShowPM_ATMO(chrData);        

         delay(1000); //sleep 5 seconds
      } 

      
   }

}
unsigned int GetPM_Data(unsigned char chrSrc[], byte bytHigh, byte bytLow)
{
   return (chrSrc[bytHigh] << 8) + chrSrc[bytLow];
}
    

void ShowPM_ATMO(unsigned char chrData[])
{
if(client.connect(server,80)){
  String postStr = apiKey;
  postStr +="&field1=";
  postStr +=String(GetPM_Data(chrData, PM2_5_ATMOSPHERE_H, PM2_5_ATMOSPHERE_L));
  postStr +="&field2=";
  postStr += String(GetPM_Data(chrData, PM10_ATMOSPHERE_H, PM10_ATMOSPHERE_L));
  postStr += "\r\n\r\n";
  client.print("POST /update HTTP/1.1\n");
}
client.stop();
}

#2

Greetings @ks870531, what is the purpose of your code? I see that you are trying to connect to thingspeak and to send or retrieve data from there, if that is the case the best for you is to ask directly to them how to solve the issue that you are experiencing. Also, I do not see any routine for trying to attempt a connection to Ubidots, so unfortunately I cannot help you farther than this.

If you are trying to send data to Ubidots, maybe you should reference any of our tutorials at http://help.ubidots.com for the ESP8266 and adapt them to your needs, I advise you to run the “pre-flight” routines before of making any snippet to connect to our server. Also, you can use this basic snippet to know how to send data to Ubidots.

Hope you can find the solution to your issue.

Regards